diff options
Diffstat (limited to 'xmerge')
240 files changed, 4867 insertions, 4867 deletions
diff --git a/xmerge/build.xml b/xmerge/build.xml index 622fb8557b4e..5878c1acf0b9 100644 --- a/xmerge/build.xml +++ b/xmerge/build.xml @@ -1,23 +1,23 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - + Copyright 2000, 2010 Oracle and/or its affiliates. - + OpenOffice.org - a multi-platform office productivity suite - + This file is part of OpenOffice.org. - + OpenOffice.org is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. - + OpenOffice.org is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details (a copy is included in the LICENSE file that accompanied this code). - + You should have received a copy of the GNU Lesser General Public License version 3 along with OpenOffice.org. If not, see <http://www.openoffice.org/license.html> @@ -32,57 +32,57 @@ <property name="solar.jar" location="${env.SOLARVER}/${solar.platform}/bin${env.UPDMINOREXT}"/> <property name="debug" value="yes"/> <property name="optimize" value="no"/> - + <target name="init"> <echoproperties prefix="solar"/> <mkdir dir="${out}"/> <mkdir dir="${out}/class"/> </target> - + <target name="xmerge" depends="init"> <ant dir="source/xmerge" target="all"/> - </target> + </target> <target name="bridge" depends="xmerge, init"> <ant dir="source/bridge" target="all"/> - </target> - + </target> + <target name="aportisdoc" depends="xmerge, init"> <ant dir="source/aportisdoc" target="all"/> - </target> + </target> <target name="pexcel" depends="xmerge, init"> <ant dir="source/pexcel" target="all"/> - </target> + </target> <target name="pocketword" depends="xmerge, init"> <ant dir="source/pocketword" target="all"/> - </target> + </target> <target name="htmlsoff" depends="init"> <ant dir="source/htmlsoff" target="all"/> - </target> - + </target> + <target name="wordsmith" depends="xmerge"> <echo>wordsmith filter is not supported</echo> <ant dir="source/wordsmith" target="all"/> - </target> + </target> <target name="minicalc" depends="xmerge"> <echo>minicalc filter is not supported</echo> <ant dir="source/minicalc" target="all"/> - </target> - + </target> + <target name="util" depends="xmerge, bridge, aportisdoc, pexcel, pocketword, htmlsoff"> <ant dir="util" target="all"/> - </target> - + </target> + <target name="all" depends="xmerge, bridge, aportisdoc, pexcel, pocketword, htmlsoff, util"> </target> - + <target name="clean"> <delete dir="${out}" /> </target> - + </project> diff --git a/xmerge/inc/pch/precompiled_xmerge.cxx b/xmerge/inc/pch/precompiled_xmerge.cxx index 8545a50a8fab..a3c5d7a24808 100644 --- a/xmerge/inc/pch/precompiled_xmerge.cxx +++ b/xmerge/inc/pch/precompiled_xmerge.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/inc/pch/precompiled_xmerge.hxx b/xmerge/inc/pch/precompiled_xmerge.hxx index ce1c7c2ac190..33202852ae8d 100644 --- a/xmerge/inc/pch/precompiled_xmerge.hxx +++ b/xmerge/inc/pch/precompiled_xmerge.hxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/activesync/XMergeFactory.cpp b/xmerge/source/activesync/XMergeFactory.cpp index f61d2401a257..1c59cd79a8a0 100644 --- a/xmerge/source/activesync/XMergeFactory.cpp +++ b/xmerge/source/activesync/XMergeFactory.cpp @@ -8,14 +8,14 @@ #include "XMergeFactory.h" ////////////////////////////////////////////////////////////////////// -// IUnknown implementation -////////////////////////////////////////////////////////////////////// -STDMETHODIMP CXMergeFactory::QueryInterface(REFIID riid, void **ppvObject) +// IUnknown implementation +////////////////////////////////////////////////////////////////////// +STDMETHODIMP CXMergeFactory::QueryInterface(REFIID riid, void **ppvObject) { if(ppvObject == NULL) return E_INVALIDARG; - if(::IsEqualIID(riid, IID_IUnknown) || ::IsEqualIID(riid, IID_IClassFactory)) + if(::IsEqualIID(riid, IID_IUnknown) || ::IsEqualIID(riid, IID_IClassFactory)) { *ppvObject = static_cast<IClassFactory*>(this); } @@ -36,7 +36,7 @@ STDMETHODIMP_(ULONG) CXMergeFactory::AddRef() } -STDMETHODIMP_(ULONG) CXMergeFactory::Release() +STDMETHODIMP_(ULONG) CXMergeFactory::Release() { if(::InterlockedDecrement(&m_cRef) == 0) { @@ -49,20 +49,20 @@ STDMETHODIMP_(ULONG) CXMergeFactory::Release() ////////////////////////////////////////////////////////////////////// -// IUnknown implementation -////////////////////////////////////////////////////////////////////// +// IUnknown implementation +////////////////////////////////////////////////////////////////////// STDMETHODIMP CXMergeFactory::CreateInstance(IUnknown *pUnkOuter, REFIID iid, void **ppvObject) { if (ppvObject == NULL) return E_INVALIDARG; - - if (pUnkOuter != NULL) // cannot aggregate + + if (pUnkOuter != NULL) // cannot aggregate { *ppvObject = NULL; return CLASS_E_NOAGGREGATION; } - if (iid == IID_ICeFileFilter) + if (iid == IID_ICeFileFilter) { CXMergeFilter *pFilter = new CXMergeFilter(); if(pFilter == NULL) diff --git a/xmerge/source/activesync/XMergeFactory.h b/xmerge/source/activesync/XMergeFactory.h index 93e2c1d0db79..bb24e8aab14e 100644 --- a/xmerge/source/activesync/XMergeFactory.h +++ b/xmerge/source/activesync/XMergeFactory.h @@ -13,22 +13,22 @@ class CXMergeFactory : public IClassFactory { private: - LONG m_cRef; + LONG m_cRef; virtual ~CXMergeFactory() {}; public: - CXMergeFactory() : m_cRef(1) {}; // Set reference count when first created - + CXMergeFactory() : m_cRef(1) {}; // Set reference count when first created + /********** IUnknown methods **********/ - STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject); - STDMETHODIMP_(ULONG) AddRef(void); - STDMETHODIMP_(ULONG) Release(); + STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject); + STDMETHODIMP_(ULONG) AddRef(void); + STDMETHODIMP_(ULONG) Release(); /********** IUnknown methods **********/ - STDMETHODIMP CreateInstance(IUnknown* pUnkOuter, REFIID riid, void **ppvObject); - STDMETHODIMP LockServer(BOOL fLock); + STDMETHODIMP CreateInstance(IUnknown* pUnkOuter, REFIID riid, void **ppvObject); + STDMETHODIMP LockServer(BOOL fLock); }; #endif // !defined(AFX_XMERGEFACTORY_H__3150043C_57FB_4BC8_9104_379506FA6B9F__INCLUDED_) diff --git a/xmerge/source/activesync/XMergeFilter.cpp b/xmerge/source/activesync/XMergeFilter.cpp index cb821fbfe98b..a02f11d03ad3 100644 --- a/xmerge/source/activesync/XMergeFilter.cpp +++ b/xmerge/source/activesync/XMergeFilter.cpp @@ -14,26 +14,26 @@ #define ERR_BADCLASSPATH 2 #define ERR_INITJAVA 3 - -const LPTSTR CXMergeFilter::m_pszPSWExportCLSID = _T("{BDD611C3-7BAB-460F-8711-5B9AC9EF6020}"); -const LPTSTR CXMergeFilter::m_pszPSWExportExt = _T("sxw"); -const LPTSTR CXMergeFilter::m_pszPSWExportDesc = _T("OpenOffice.org Writer XML Document"); -const LPTSTR CXMergeFilter::m_pszPSWExportShortDesc = _T("OpenOffice.org Writer"); -const LPTSTR CXMergeFilter::m_pszPSWImportCLSID = _T("{CB43F086-838D-4FA4-B5F6-3406B9A57439}"); -const LPTSTR CXMergeFilter::m_pszPSWImportExt = _T("psw"); -const LPTSTR CXMergeFilter::m_pszPSWImportDesc = _T("Pocket Word Document - Pocket PC"); -const LPTSTR CXMergeFilter::m_pszPSWImportShortDesc = _T("Pocket Word"); +const LPTSTR CXMergeFilter::m_pszPSWExportCLSID = _T("{BDD611C3-7BAB-460F-8711-5B9AC9EF6020}"); +const LPTSTR CXMergeFilter::m_pszPSWExportExt = _T("sxw"); +const LPTSTR CXMergeFilter::m_pszPSWExportDesc = _T("OpenOffice.org Writer XML Document"); +const LPTSTR CXMergeFilter::m_pszPSWExportShortDesc = _T("OpenOffice.org Writer"); -const LPTSTR CXMergeFilter::m_pszPXLExportCLSID = _T("{C6AB3E74-9F4F-4370-8120-A8A6FABB7A7C}"); -const LPTSTR CXMergeFilter::m_pszPXLExportExt = _T("sxc"); -const LPTSTR CXMergeFilter::m_pszPXLExportDesc = _T("OpenOffice.org Calc XML Document"); -const LPTSTR CXMergeFilter::m_pszPXLExportShortDesc = _T("OpenOffice.org Calc"); +const LPTSTR CXMergeFilter::m_pszPSWImportCLSID = _T("{CB43F086-838D-4FA4-B5F6-3406B9A57439}"); +const LPTSTR CXMergeFilter::m_pszPSWImportExt = _T("psw"); +const LPTSTR CXMergeFilter::m_pszPSWImportDesc = _T("Pocket Word Document - Pocket PC"); +const LPTSTR CXMergeFilter::m_pszPSWImportShortDesc = _T("Pocket Word"); -const LPTSTR CXMergeFilter::m_pszPXLImportCLSID = _T("{43887C67-4D5D-4127-BAAC-87A288494C7C}"); -const LPTSTR CXMergeFilter::m_pszPXLImportExt = _T("pxl"); -const LPTSTR CXMergeFilter::m_pszPXLImportDesc = _T("Pocket Excel Document - Pocket PC"); -const LPTSTR CXMergeFilter::m_pszPXLImportShortDesc = _T("Pocket Excel"); +const LPTSTR CXMergeFilter::m_pszPXLExportCLSID = _T("{C6AB3E74-9F4F-4370-8120-A8A6FABB7A7C}"); +const LPTSTR CXMergeFilter::m_pszPXLExportExt = _T("sxc"); +const LPTSTR CXMergeFilter::m_pszPXLExportDesc = _T("OpenOffice.org Calc XML Document"); +const LPTSTR CXMergeFilter::m_pszPXLExportShortDesc = _T("OpenOffice.org Calc"); + +const LPTSTR CXMergeFilter::m_pszPXLImportCLSID = _T("{43887C67-4D5D-4127-BAAC-87A288494C7C}"); +const LPTSTR CXMergeFilter::m_pszPXLImportExt = _T("pxl"); +const LPTSTR CXMergeFilter::m_pszPXLImportDesc = _T("Pocket Excel Document - Pocket PC"); +const LPTSTR CXMergeFilter::m_pszPXLImportShortDesc = _T("Pocket Excel"); ////////////////////////////////////////////////////////////////////// @@ -86,7 +86,7 @@ STDMETHODIMP CXMergeFilter::QueryInterface(REFIID riid, void **ppvObject) *ppvObject = NULL; return E_NOINTERFACE; } - + reinterpret_cast<IUnknown *>(*ppvObject)->AddRef(); return S_OK; } @@ -119,12 +119,12 @@ STDMETHODIMP CXMergeFilter::FilterOptions(HWND hwndParent) return HRESULT_FROM_WIN32(NOERROR); } -STDMETHODIMP CXMergeFilter::FormatMessage(DWORD dwFlags, DWORD dwMessageId, - DWORD dwLanguageId, LPTSTR lpBuffer, DWORD nSize, +STDMETHODIMP CXMergeFilter::FormatMessage(DWORD dwFlags, DWORD dwMessageId, + DWORD dwLanguageId, LPTSTR lpBuffer, DWORD nSize, va_list *Arguments, DWORD *pcb) { TCHAR errMsg[1024]; - + HKEY hKey = NULL; DWORD dwSize = 1024; @@ -134,12 +134,12 @@ STDMETHODIMP CXMergeFilter::FormatMessage(DWORD dwFlags, DWORD dwMessageId, // Attempt to find the messages in the registry lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Sun Microsystems\\StarOffice\\XMergeSync\\Messages\\Error"), 0, KEY_READ, &hKey); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) { // Try the user's portion of the registry lRet = ::RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Sun Microsystems\\StarOffice\\XMergeSync\\Messages\\Error"), 0, KEY_READ, &hKey); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) { hKey = NULL; } @@ -183,24 +183,24 @@ STDMETHODIMP CXMergeFilter::FormatMessage(DWORD dwFlags, DWORD dwMessageId, } -STDMETHODIMP CXMergeFilter::NextConvertFile(int nConversion, CFF_CONVERTINFO *pci, - CFF_SOURCEFILE *psf, CFF_DESTINATIONFILE *pdf, +STDMETHODIMP CXMergeFilter::NextConvertFile(int nConversion, CFF_CONVERTINFO *pci, + CFF_SOURCEFILE *psf, CFF_DESTINATIONFILE *pdf, volatile BOOL *pbCancel, CF_ERROR *perr) { std::string appArgs; - std::string appName; + std::string appName; STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory( &si, sizeof(si) ); ZeroMemory( &pi, sizeof(pi) ); - + si.cb = sizeof(si); /* - * First step: Locate Java and establish the classpath. If these can't + * First step: Locate Java and establish the classpath. If these can't * be done succesfully, then avoid all further processing. */ @@ -211,7 +211,7 @@ STDMETHODIMP CXMergeFilter::NextConvertFile(int nConversion, CFF_CONVERTINFO *pc if (m_szJavaBaseDir == NULL) { - *perr = ERR_NOJAVA; + *perr = ERR_NOJAVA; return HRESULT_FROM_WIN32(E_FAIL); } } @@ -220,7 +220,7 @@ STDMETHODIMP CXMergeFilter::NextConvertFile(int nConversion, CFF_CONVERTINFO *pc if (m_szClasspath == NULL) { m_szClasspath = GetXMergeClassPath(); - + if (m_szClasspath == NULL) { *perr = ERR_BADCLASSPATH; @@ -230,8 +230,8 @@ STDMETHODIMP CXMergeFilter::NextConvertFile(int nConversion, CFF_CONVERTINFO *pc /* - * Second step: Check the files we're going to process. If we don't have - * an XMerge plugin for the file then we can't convert. + * Second step: Check the files we're going to process. If we don't have + * an XMerge plugin for the file then we can't convert. */ if ((!lstrcmp(psf->szExtension, "sxw") || !lstrcmp(psf->szExtension, "psw")) && !m_bHaveWord) @@ -245,11 +245,11 @@ STDMETHODIMP CXMergeFilter::NextConvertFile(int nConversion, CFF_CONVERTINFO *pc *perr = ERR_BADCLASSPATH; return HRESULT_FROM_WIN32(E_FAIL); } - + /* * Third step: Locate the Java executable and build and execute the command - * line to carry out the conversion. + * line to carry out the conversion. */ // Find the Java executable and make sure it exists @@ -267,8 +267,8 @@ STDMETHODIMP CXMergeFilter::NextConvertFile(int nConversion, CFF_CONVERTINFO *pc appName.append("\""); - - // Need to build the entire command line for calling out to Java + + // Need to build the entire command line for calling out to Java appArgs = appName + " -Djava.class.path="; appArgs += m_szClasspath; appArgs += " org.openoffice.xmerge.util.ActiveSyncDriver "; @@ -304,13 +304,13 @@ STDMETHODIMP CXMergeFilter::NextConvertFile(int nConversion, CFF_CONVERTINFO *pc if(!CreateProcess(NULL, (char*)appArgs.c_str(), - NULL, // No Process Attributes - NULL, // No Thread Attributes - FALSE, // Don't want this process getting handles - CREATE_NO_WINDOW, // No console - NULL, // No special environment - NULL, // Current Working Directory is okay - &si, + NULL, // No Process Attributes + NULL, // No Thread Attributes + FALSE, // Don't want this process getting handles + CREATE_NO_WINDOW, // No console + NULL, // No special environment + NULL, // Current Working Directory is okay + &si, &pi)) { *perr = ERR_INITJAVA; @@ -336,7 +336,7 @@ TCHAR* CXMergeFilter::GetJavaBaseDir() HKEY hKey = NULL; HKEY hDataKey = NULL; - + TCHAR szClassName[_MAX_PATH] = "\0"; TCHAR szKeyName[_MAX_PATH] = "\0"; TCHAR szCurrentJava[_MAX_PATH] = "\0"; @@ -358,7 +358,7 @@ TCHAR* CXMergeFilter::GetJavaBaseDir() /* use current version */ lRet = ::RegQueryValueEx(hKey, _T("CurrentVersion"), 0, NULL, (LPBYTE)szCurrentJava, &dwSize); - + /* for (DWORD i = 0; lRet != ERROR_NO_MORE_ITEMS; i++) { @@ -369,8 +369,8 @@ TCHAR* CXMergeFilter::GetJavaBaseDir() } // Found a Java 1.4 installation. Can now read its home directory. */ - - + + lRet = ::RegOpenKeyEx(hKey, _T(szCurrentJava), 0, KEY_READ, &hDataKey); if (lRet != ERROR_SUCCESS) { @@ -394,7 +394,7 @@ TCHAR* CXMergeFilter::GetJavaBaseDir() RegCloseKey(hDataKey); RegCloseKey(hKey); - + // Check that the directory exists before returning it DWORD dwAttrs = GetFileAttributes(szJavaHome); @@ -413,7 +413,7 @@ TCHAR* CXMergeFilter::GetXMergeClassPath() { /* * The DLL will be installed by setup in the program directory of - * the installation. The XMerge Jar files, if present, will be + * the installation. The XMerge Jar files, if present, will be * located in the classes directory below program. */ @@ -448,7 +448,7 @@ TCHAR* CXMergeFilter::GetXMergeClassPath() { return NULL; } - else + else { clsPath += szTmpPath; clsPath += ";"; diff --git a/xmerge/source/activesync/XMergeFilter.h b/xmerge/source/activesync/XMergeFilter.h index 4830c577a205..54128f325125 100644 --- a/xmerge/source/activesync/XMergeFilter.h +++ b/xmerge/source/activesync/XMergeFilter.h @@ -56,16 +56,16 @@ public: /********** IUnknown methods **********/ - STDMETHODIMP QueryInterface(REFIID iid, void **ppvObject); - STDMETHODIMP_(ULONG) AddRef(); - STDMETHODIMP_(ULONG) Release(); + STDMETHODIMP QueryInterface(REFIID iid, void **ppvObject); + STDMETHODIMP_(ULONG) AddRef(); + STDMETHODIMP_(ULONG) Release(); /********** ICeFileFilter methods *********/ - STDMETHODIMP FilterOptions(HWND hwndParent); - STDMETHODIMP FormatMessage(DWORD dwFlags, DWORD dwMessageId, DWORD dwLanguageId, + STDMETHODIMP FilterOptions(HWND hwndParent); + STDMETHODIMP FormatMessage(DWORD dwFlags, DWORD dwMessageId, DWORD dwLanguageId, LPTSTR lpBuffer, DWORD nSize, va_list *Arguments, DWORD *pcb); - STDMETHODIMP NextConvertFile(int nConversion, CFF_CONVERTINFO *pci, - CFF_SOURCEFILE *psf, CFF_DESTINATIONFILE *pdf, + STDMETHODIMP NextConvertFile(int nConversion, CFF_CONVERTINFO *pci, + CFF_SOURCEFILE *psf, CFF_DESTINATIONFILE *pdf, volatile BOOL *pbCancel, CF_ERROR *perr); }; diff --git a/xmerge/source/activesync/XMergeSync.cpp b/xmerge/source/activesync/XMergeSync.cpp index ebbaacd77146..469c15b2f292 100644 --- a/xmerge/source/activesync/XMergeSync.cpp +++ b/xmerge/source/activesync/XMergeSync.cpp @@ -38,7 +38,7 @@ STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) { // Create the factory object CXMergeFactory *pFactory = new CXMergeFactory(); - if (pFactory == NULL) + if (pFactory == NULL) { *ppv = NULL; return E_OUTOFMEMORY; @@ -51,7 +51,7 @@ STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) } -STDAPI DllCanUnloadNow() +STDAPI DllCanUnloadNow() { if (_Module.GetLockCount() == 0) return S_OK; @@ -66,10 +66,10 @@ static _signalRegError(long lRet, HKEY hKey, HKEY hDataKey) if (hKey) ::RegCloseKey(hKey); - + if (hDataKey) ::RegCloseKey(hDataKey); - + return HRESULT_FROM_WIN32(lRet); } @@ -78,7 +78,7 @@ STDAPI DllRegisterServer() { HKEY hKey = NULL; HKEY hDataKey = NULL; - + long lRet = 0; TCHAR sTemp[_MAX_PATH + 1] = "\0"; @@ -86,23 +86,23 @@ STDAPI DllRegisterServer() /* * Following calls create the HKEY_CLASSES_ROOT\CLSID entry for the Writer export filter. * - * Note that import are export are relative to the WinCE device, so files are + * Note that import are export are relative to the WinCE device, so files are * exported to the desktop format. */ // Get a handle to the CLSID key lRet = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("CLSID"), 0, KEY_ALL_ACCESS, &hKey); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); // Create the CLSID key for the XMergeFilter lRet = ::RegCreateKeyEx(hKey, CXMergeFilter::m_pszPSWExportCLSID, 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hKey, NULL); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hKey, _T(""), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPSWExportShortDesc, (::_tcslen(CXMergeFilter::m_pszPSWExportShortDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); @@ -112,7 +112,7 @@ STDAPI DllRegisterServer() return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0"), - (::_tcslen(_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0")) + (::_tcslen(_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0")) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); @@ -120,101 +120,101 @@ STDAPI DllRegisterServer() // Create the InprocServer32 key lRet = ::RegCreateKeyEx(hKey, _T("InProcServer32"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, _T("ThreadingModel"), 0, REG_SZ, (LPBYTE)_T("Apartment"), 10); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - + // Create the key for the DLL file. First find the filename of the dll if (!::GetModuleFileName((HMODULE)_Module.m_hInst, sTemp, (_MAX_PATH + 1))) { lRet = ::GetLastError(); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); } - - - lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)sTemp, + + + lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)sTemp, (::_tcslen(sTemp) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hDataKey); hDataKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; // Setup the PegasusFilter key values lRet = ::RegCreateKeyEx(hKey, _T("PegasusFilter"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, _T("Description"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPSWExportDesc, (::_tcslen(CXMergeFilter::m_pszPSWExportDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, _T("Export"), 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, _T("NewExtension"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPSWExportExt, (::_tcslen(CXMergeFilter::m_pszPSWExportExt) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hKey); hKey = NULL; - ::RegCloseKey(hDataKey); hDataKey = NULL; + ::RegCloseKey(hKey); hKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; /* - * Following calls create the entries for the filter in + * Following calls create the entries for the filter in * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\Filters */ - lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), + lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), 0, KEY_ALL_ACCESS, &hKey); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); _snprintf(sTemp, _MAX_PATH + 1, "%c%s\\InstalledFilters\0", '.', CXMergeFilter::m_pszPSWImportExt); - lRet = ::RegCreateKeyEx(hKey, _T(sTemp), + lRet = ::RegCreateKeyEx(hKey, _T(sTemp), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, CXMergeFilter::m_pszPSWExportCLSID, 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hKey); hKey = NULL; - ::RegCloseKey(hDataKey); hDataKey = NULL; + ::RegCloseKey(hKey); hKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; /* * Following calls create the HKEY_CLASSES_ROOT\CLSID entry for the Writer import filter. * - * Note that import are export are relative to the WinCE device, so files are + * Note that import are export are relative to the WinCE device, so files are * exported to the desktop format. */ // Get a handle to the CLSID key lRet = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("CLSID"), 0, KEY_ALL_ACCESS, &hKey); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); // Create the CLSID key for the XMergeFilter lRet = ::RegCreateKeyEx(hKey, CXMergeFilter::m_pszPSWImportCLSID, 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hKey, NULL); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hKey, _T(""), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPSWImportShortDesc, (::_tcslen(CXMergeFilter::m_pszPSWImportShortDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); @@ -224,20 +224,20 @@ STDAPI DllRegisterServer() return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0"), - (::_tcslen(_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0")) + (::_tcslen(_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0")) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); ::RegCloseKey(hDataKey); hDataKey = NULL; - + // Create the InprocServer32 key lRet = ::RegCreateKeyEx(hKey, _T("InProcServer32"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, _T("ThreadingModel"), 0, REG_SZ, (LPBYTE)_T("Apartment"), 10); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); @@ -245,111 +245,111 @@ STDAPI DllRegisterServer() if (!::GetModuleFileName((HMODULE)_Module.m_hInst, sTemp, (_MAX_PATH + 1))) { lRet = ::GetLastError(); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); } - - - lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)sTemp, + + + lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)sTemp, (::_tcslen(sTemp) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hDataKey); hDataKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; // Setup the PegasusFilter key values lRet = ::RegCreateKeyEx(hKey, _T("PegasusFilter"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, _T("Description"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPSWImportDesc, (::_tcslen(CXMergeFilter::m_pszPSWImportDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, _T("Import"), 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, _T("NewExtension"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPSWImportExt, (::_tcslen(CXMergeFilter::m_pszPSWImportExt) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hKey); hKey = NULL; - ::RegCloseKey(hDataKey); hDataKey = NULL; + ::RegCloseKey(hKey); hKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; /* - * Following calls create the entries for the filter in + * Following calls create the entries for the filter in * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\Filters */ - lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), + lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), 0, KEY_ALL_ACCESS, &hKey); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); // Add in defaults for import and export _snprintf(sTemp, _MAX_PATH +1, "%c%s\0", '.', CXMergeFilter::m_pszPSWExportExt); lRet = ::RegCreateKeyEx(hKey, _T(sTemp), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - lRet = ::RegSetValueEx(hDataKey, _T("DefaultImport"), 0, REG_SZ, - (LPBYTE)CXMergeFilter::m_pszPSWImportCLSID, + lRet = ::RegSetValueEx(hDataKey, _T("DefaultImport"), 0, REG_SZ, + (LPBYTE)CXMergeFilter::m_pszPSWImportCLSID, (::_tcslen(CXMergeFilter::m_pszPSWImportDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, _T("DefaultExport"), 0, REG_SZ, (LPBYTE)_T("Binary Copy"), (::_tcslen(_T("Binary Copy")) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); ::RegCloseKey(hDataKey); - + // Update registered filters _snprintf(sTemp, _MAX_PATH + 1, "%c%s\\InstalledFilters\0", '.', CXMergeFilter::m_pszPSWExportExt); - lRet = ::RegCreateKeyEx(hKey, _T(sTemp), + lRet = ::RegCreateKeyEx(hKey, _T(sTemp), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - + lRet = ::RegSetValueEx(hDataKey, CXMergeFilter::m_pszPSWImportCLSID, 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hKey); hKey = NULL; - ::RegCloseKey(hDataKey); hDataKey = NULL; + ::RegCloseKey(hKey); hKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; /* * Following calls create the HKEY_CLASSES_ROOT\CLSID entry for the Calc export filter. * - * Note that import are export are relative to the WinCE device, so files are + * Note that import are export are relative to the WinCE device, so files are * exported to the desktop format. */ // Get a handle to the CLSID key lRet = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("CLSID"), 0, KEY_ALL_ACCESS, &hKey); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); // Create the CLSID key for the XMerge Filter - lRet = ::RegCreateKeyEx(hKey, CXMergeFilter::m_pszPXLExportCLSID, 0, _T(""), + lRet = ::RegCreateKeyEx(hKey, CXMergeFilter::m_pszPXLExportCLSID, 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hKey, NULL); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hKey, _T(""), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPXLExportShortDesc, (::_tcslen(CXMergeFilter::m_pszPXLExportShortDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); @@ -359,7 +359,7 @@ STDAPI DllRegisterServer() return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0"), - (::_tcslen(_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0")) + (::_tcslen(_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0")) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); @@ -368,103 +368,103 @@ STDAPI DllRegisterServer() // Create the InprocServer32 key lRet = ::RegCreateKeyEx(hKey, _T("InProcServer32"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, _T("ThreadingModel"), 0, REG_SZ, (LPBYTE)_T("Apartment"), 10); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - + // Create the key for the DLL file. First find the filename of the dll if (!::GetModuleFileName((HMODULE)_Module.m_hInst, sTemp, (_MAX_PATH + 1))) { lRet = ::GetLastError(); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); } - - - lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)sTemp, + + + lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)sTemp, (::_tcslen(sTemp) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hDataKey); hDataKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; // Setup the PegasusFilter key values lRet = ::RegCreateKeyEx(hKey, _T("PegasusFilter"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, _T("Description"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPXLExportDesc, (::_tcslen(CXMergeFilter::m_pszPXLExportDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, _T("Export"), 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, _T("NewExtension"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPXLExportExt, (::_tcslen(CXMergeFilter::m_pszPXLExportExt) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hKey); hKey = NULL; - ::RegCloseKey(hDataKey); hDataKey = NULL; + ::RegCloseKey(hKey); hKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; /* - * Following calls create the entries for the filter in + * Following calls create the entries for the filter in * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\Filters */ - lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), + lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), 0, KEY_ALL_ACCESS, &hKey); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); _snprintf(sTemp, _MAX_PATH + 1, "%c%s\\InstalledFilters\0", '.', CXMergeFilter::m_pszPXLImportExt); - lRet = ::RegCreateKeyEx(hKey, _T(sTemp), + lRet = ::RegCreateKeyEx(hKey, _T(sTemp), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, CXMergeFilter::m_pszPXLExportCLSID, 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hKey); hKey = NULL; - ::RegCloseKey(hDataKey); hDataKey = NULL; + ::RegCloseKey(hKey); hKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; /* * Following calls create the HKEY_CLASSES_ROOT\CLSID entry for the Calc import filter. * - * Note that import are export are relative to the WinCE device, so files are + * Note that import are export are relative to the WinCE device, so files are * exported to the desktop format. */ // Get a handle to the CLSID key lRet = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("CLSID"), 0, KEY_ALL_ACCESS, &hKey); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); // Create the CLSID key for the XMergeFilter lRet = ::RegCreateKeyEx(hKey, CXMergeFilter::m_pszPXLImportCLSID, 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hKey, NULL); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hKey, _T(""), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPXLImportShortDesc, (::_tcslen(CXMergeFilter::m_pszPXLImportShortDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); // Create the DefaultIcon key. For the moment, use one of the Async supplied ones @@ -473,20 +473,20 @@ STDAPI DllRegisterServer() return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0"), - (::_tcslen(_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0")) + (::_tcslen(_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0")) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); ::RegCloseKey(hDataKey); hDataKey = NULL; - + // Create the InprocServer32 key lRet = ::RegCreateKeyEx(hKey, _T("InProcServer32"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, _T("ThreadingModel"), 0, REG_SZ, (LPBYTE)_T("Apartment"), 10); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); @@ -494,89 +494,89 @@ STDAPI DllRegisterServer() if (!::GetModuleFileName((HMODULE)_Module.m_hInst, sTemp, (_MAX_PATH + 1))) { lRet = ::GetLastError(); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); } - - - lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)sTemp, + + + lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)sTemp, (::_tcslen(sTemp) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hDataKey); hDataKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; // Setup the PegasusFilter key values lRet = ::RegCreateKeyEx(hKey, _T("PegasusFilter"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, _T("Description"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPXLImportDesc, (::_tcslen(CXMergeFilter::m_pszPXLImportDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, _T("Import"), 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, _T("NewExtension"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPXLImportExt, (::_tcslen(CXMergeFilter::m_pszPXLImportExt) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hKey); hKey = NULL; - ::RegCloseKey(hDataKey); hDataKey = NULL; + ::RegCloseKey(hKey); hKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; /* - * Following calls create the entries for the filter in + * Following calls create the entries for the filter in * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\Filters */ - lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), + lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), 0, KEY_ALL_ACCESS, &hKey); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); // Add in defaults for import and export _snprintf(sTemp, _MAX_PATH +1, "%c%s\0", '.', CXMergeFilter::m_pszPXLExportExt); lRet = ::RegCreateKeyEx(hKey, _T(sTemp), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - lRet = ::RegSetValueEx(hDataKey, _T("DefaultImport"), 0, REG_SZ, - (LPBYTE)CXMergeFilter::m_pszPXLImportCLSID, + lRet = ::RegSetValueEx(hDataKey, _T("DefaultImport"), 0, REG_SZ, + (LPBYTE)CXMergeFilter::m_pszPXLImportCLSID, (::_tcslen(CXMergeFilter::m_pszPSWImportDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, _T("DefaultExport"), 0, REG_SZ, (LPBYTE)_T("Binary Copy"), (::_tcslen(_T("Binary Copy")) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); ::RegCloseKey(hDataKey); - + // Update registered filters _snprintf(sTemp, _MAX_PATH + 1, "%c%s\\InstalledFilters\0", '.', CXMergeFilter::m_pszPXLExportExt); - lRet = ::RegCreateKeyEx(hKey, _T(sTemp), + lRet = ::RegCreateKeyEx(hKey, _T(sTemp), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); lRet = ::RegSetValueEx(hDataKey, CXMergeFilter::m_pszPXLImportCLSID, 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); - if (lRet != ERROR_SUCCESS) + if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hKey); hKey = NULL; - ::RegCloseKey(hDataKey); hDataKey = NULL; + ::RegCloseKey(hKey); hKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; @@ -589,7 +589,7 @@ STDAPI DllUnregisterServer() long lRet = 0; HKEY hKey = NULL; HKEY hDataKey = NULL; - + TCHAR szClassName[_MAX_PATH] = "\0"; TCHAR szKeyName[_MAX_PATH] = "\0"; DWORD dwClassName = _MAX_PATH; @@ -707,13 +707,13 @@ STDAPI DllUnregisterServer() return _signalRegError(lRet, hKey, hDataKey); ::RegCloseKey(hKey); hKey = NULL; - + /* * Remove the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\Filters */ - lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), + lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), 0, KEY_ALL_ACCESS, &hKey); if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); @@ -728,9 +728,9 @@ STDAPI DllUnregisterServer() lRet = ::RegDeleteValue(hDataKey, CXMergeFilter::m_pszPSWExportCLSID); if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - + ::lstrcpyn(szKeyName, "\0", _MAX_PATH); - ::RegCloseKey(hDataKey); hDataKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; // Remove the Writer import filter from the Writer export file extension subkey. @@ -744,7 +744,7 @@ STDAPI DllUnregisterServer() return _signalRegError(lRet, hKey, hDataKey); ::lstrcpyn(szKeyName, "\0", _MAX_PATH); - ::RegCloseKey(hDataKey); hDataKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; // Make Binary Copy the default for Writer export file extension subkey DefaultImport @@ -759,7 +759,7 @@ STDAPI DllUnregisterServer() return _signalRegError(lRet, hKey, hDataKey); ::lstrcpyn(szKeyName, "\0", _MAX_PATH); - ::RegCloseKey(hDataKey); hDataKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; // Remove the Calc export filter from the Calc import file extension subkey. @@ -771,9 +771,9 @@ STDAPI DllUnregisterServer() lRet = ::RegDeleteValue(hDataKey, CXMergeFilter::m_pszPXLExportCLSID); if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - + ::lstrcpyn(szKeyName, "\0", _MAX_PATH); - ::RegCloseKey(hDataKey); hDataKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; // Remove the Calc import filter from the Calc export file extension subkey. _snprintf(szKeyName, _MAX_PATH, ".%s\\InstalledFilters", CXMergeFilter::m_pszPXLExportExt); @@ -784,9 +784,9 @@ STDAPI DllUnregisterServer() lRet = ::RegDeleteValue(hDataKey, CXMergeFilter::m_pszPXLImportCLSID); if (lRet != ERROR_SUCCESS) return _signalRegError(lRet, hKey, hDataKey); - + ::lstrcpyn(szKeyName, "\0", _MAX_PATH); - ::RegCloseKey(hDataKey); hDataKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; // Make Binary Copy the default for Calc export file extension subkey DefaultImport @@ -801,24 +801,24 @@ STDAPI DllUnregisterServer() return _signalRegError(lRet, hKey, hDataKey); ::lstrcpyn(szKeyName, "\0", _MAX_PATH); - ::RegCloseKey(hDataKey); hDataKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; + - - ::RegCloseKey(hKey); hKey = NULL; - + ::RegCloseKey(hKey); hKey = NULL; + return HRESULT_FROM_WIN32(lRet); -} +} ////////////////////////////////////////////////////////////////////// // CXMergeSyncModule methods ////////////////////////////////////////////////////////////////////// -CXMergeSyncModule::CXMergeSyncModule () +CXMergeSyncModule::CXMergeSyncModule () { } -CXMergeSyncModule::~CXMergeSyncModule () +CXMergeSyncModule::~CXMergeSyncModule () { } diff --git a/xmerge/source/activesync/XMergeSync.h b/xmerge/source/activesync/XMergeSync.h index a5da9bacbeee..4242b755c1fa 100644 --- a/xmerge/source/activesync/XMergeSync.h +++ b/xmerge/source/activesync/XMergeSync.h @@ -12,7 +12,7 @@ // Used to keep track of the dll -class CXMergeSyncModule +class CXMergeSyncModule { protected: long m_lLocks; diff --git a/xmerge/source/activesync/resource.h b/xmerge/source/activesync/resource.h index 67ee83448661..c670835a7455 100644 --- a/xmerge/source/activesync/resource.h +++ b/xmerge/source/activesync/resource.h @@ -6,7 +6,7 @@ #define IDS_BADCLASSPATH 2 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 101 diff --git a/xmerge/source/activesync/stdafx.cpp b/xmerge/source/activesync/stdafx.cpp index 6c4b7a566a7a..eefe5176aad4 100644 --- a/xmerge/source/activesync/stdafx.cpp +++ b/xmerge/source/activesync/stdafx.cpp @@ -1,7 +1,7 @@ // -// stdafx.cpp : source file that includes just the standard includes -// stdafx.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information +// stdafx.cpp : source file that includes just the standard includes +// stdafx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information // #include "stdafx.h" diff --git a/xmerge/source/activesync/stdafx.h b/xmerge/source/activesync/stdafx.h index b64beea9cb12..26faa277a87c 100644 --- a/xmerge/source/activesync/stdafx.h +++ b/xmerge/source/activesync/stdafx.h @@ -1,7 +1,7 @@ // -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, +// but are changed infrequently // #pragma once @@ -20,9 +20,9 @@ #include "XMergeSync.h" // -// This declares the one & only instance of the CXMergeSyncModule class. -// You can access any public members of this class through the -// global _Module. (Its definition is in XMergeSync.cpp.) +// This declares the one & only instance of the CXMergeSyncModule class. +// You can access any public members of this class through the +// global _Module. (Its definition is in XMergeSync.cpp.) // extern CXMergeSyncModule _Module; diff --git a/xmerge/source/aportisdoc/build.xml b/xmerge/source/aportisdoc/build.xml index c7997c3e395a..6e9d22b84b9a 100644 --- a/xmerge/source/aportisdoc/build.xml +++ b/xmerge/source/aportisdoc/build.xml @@ -3,23 +3,23 @@ #************************************************************************* # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - + Copyright 2000, 2010 Oracle and/or its affiliates. - + OpenOffice.org - a multi-platform office productivity suite - + This file is part of OpenOffice.org. - + OpenOffice.org is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. - + OpenOffice.org is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details (a copy is included in the LICENSE file that accompanied this code). - + You should have received a copy of the GNU Lesser General Public License version 3 along with OpenOffice.org. If not, see <http://www.openoffice.org/license.html> @@ -27,11 +27,11 @@ #************************************************************************* --> - + <project name="aportisdoc" default="all" basedir="."> <property file="../inc/antbuild.properties"/> - + <path id="classpath"> <pathelement location="${build.dir}/xmerge.jar"/> </path> @@ -51,7 +51,7 @@ <classpath refid="classpath"/> </javac> </target> - + <!-- package to jar --> <target name="jar" depends="compile"> <jar destfile="${target.jar}"> @@ -68,9 +68,9 @@ <delete dir="${class.dir}"/> <delete file="${target.jar}"/> </target> - + <target name="all" depends="jar"> </target> - + </project> diff --git a/xmerge/source/aportisdoc/converter.xml b/xmerge/source/aportisdoc/converter.xml index ce69b6da1547..3124e1e3876e 100644 --- a/xmerge/source/aportisdoc/converter.xml +++ b/xmerge/source/aportisdoc/converter.xml @@ -3,23 +3,23 @@ #************************************************************************* # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - + Copyright 2000, 2010 Oracle and/or its affiliates. - + OpenOffice.org - a multi-platform office productivity suite - + This file is part of OpenOffice.org. - + OpenOffice.org is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. - + OpenOffice.org is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details (a copy is included in the LICENSE file that accompanied this code). - + You should have received a copy of the GNU Lesser General Public License version 3 along with OpenOffice.org. If not, see <http://www.openoffice.org/license.html> diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/ConverterCapabilitiesImpl.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/ConverterCapabilitiesImpl.java index ab6e93b388a9..733450bedad8 100644 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/ConverterCapabilitiesImpl.java +++ b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/ConverterCapabilitiesImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocConstants.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocConstants.java index a74d7ab156e4..f022250bca10 100644 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocConstants.java +++ b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocConstants.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocDecoder.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocDecoder.java index 2edc16d1f136..aea2f7cd1ac4 100644 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocDecoder.java +++ b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocDecoder.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocEncoder.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocEncoder.java index 1fb81f80e970..b1cb1cbe9905 100644 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocEncoder.java +++ b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocEncoder.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentDeserializerImpl.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentDeserializerImpl.java index 757a72d4583a..2d29f8784dc5 100644 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentDeserializerImpl.java +++ b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentDeserializerImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentMergerImpl.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentMergerImpl.java index d25f011bd33b..8c8b3c9333b3 100644 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentMergerImpl.java +++ b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentMergerImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentSerializerImpl.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentSerializerImpl.java index c626f1d5f466..dc1fb4c4a1a3 100644 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentSerializerImpl.java +++ b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentSerializerImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -126,7 +126,7 @@ public final class DocumentSerializerImpl // Record records[] = encoder.getRecords(); ConvertData cd = new ConvertData(); - + PalmDocument palmDoc = new PalmDocument(docName, DocConstants.CREATOR_ID, DocConstants.TYPE_ID, 0, PalmDB.PDB_HEADER_ATTR_BACKUP, records); @@ -260,7 +260,7 @@ public final class DocumentSerializerImpl /** - * This method traverses an <code>Element</code> <code>Node</code> + * This method traverses an <code>Element</code> <code>Node</code> * within a paragraph. * * @param node <code>Element</code> <code>Node</code> within a @@ -520,7 +520,7 @@ public final class DocumentSerializerImpl /** * Logs debug messages. - * + * * @param str The debug message. */ private void log(String str) { diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/PluginFactoryImpl.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/PluginFactoryImpl.java index f14cc1de57a0..3a497cc0b5b7 100644 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/PluginFactoryImpl.java +++ b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/PluginFactoryImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -51,7 +51,7 @@ import java.io.InputStream; * {@link org.openoffice.xmerge.Document Document} * object, i.e. {@link * org.openoffice.xmerge.converter.xml.sxw.SxwDocument - * SxwDocument} that the converters in this class works with. Thus, + * SxwDocument} that the converters in this class works with. Thus, * this class only implements the methods that produces the converters, * i.e. {@link * org.openoffice.xmerge.DocumentSerializer @@ -69,7 +69,7 @@ import java.io.InputStream; * * @author Herbie Ong */ -public final class PluginFactoryImpl extends SxwPluginFactory +public final class PluginFactoryImpl extends SxwPluginFactory implements DocumentDeserializerFactory, DocumentSerializerFactory, DocumentMergerFactory { @@ -103,7 +103,7 @@ public final class PluginFactoryImpl extends SxwPluginFactory * which is an implementation of the <code>DocumentDeserializer</code> * interface. * - * @param cd <code>ConvertData</code> object for reading data + * @param cd <code>ConvertData</code> object for reading data * which will be converted back to a * <code>Document</code> object. * diff --git a/xmerge/source/bridge/build.xml b/xmerge/source/bridge/build.xml index d07e55c1d399..ad0aa33d0f0f 100644 --- a/xmerge/source/bridge/build.xml +++ b/xmerge/source/bridge/build.xml @@ -3,23 +3,23 @@ #************************************************************************* # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - + Copyright 2000, 2010 Oracle and/or its affiliates. - + OpenOffice.org - a multi-platform office productivity suite - + This file is part of OpenOffice.org. - + OpenOffice.org is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. - + OpenOffice.org is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details (a copy is included in the LICENSE file that accompanied this code). - + You should have received a copy of the GNU Lesser General Public License version 3 along with OpenOffice.org. If not, see <http://www.openoffice.org/license.html> diff --git a/xmerge/source/bridge/java/XMergeBridge.java b/xmerge/source/bridge/java/XMergeBridge.java index 4a84b3274856..38503d3b49ff 100644 --- a/xmerge/source/bridge/java/XMergeBridge.java +++ b/xmerge/source/bridge/java/XMergeBridge.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -79,8 +79,8 @@ import java.net.URI; * information about the component (__writeRegistryServiceInfo()). */ public class XMergeBridge { - - + + private static XMultiServiceFactory xMSF; private static XDocumentHandler exportDocHandler=null; private static XInputStream xInStream =null; @@ -90,7 +90,7 @@ public class XMergeBridge { private static XOutputStreamToOutputStreamAdapter adaptedStream=null; private static String offMime=null; private static String sdMime=null; - private static String sFileName=null; + private static String sFileName=null; private static String sURL=""; //private static FileOutputStream adaptedStream =null; @@ -101,17 +101,17 @@ public class XMergeBridge { */ static public class _XMergeBridge implements XImportFilter, - XExportFilter, + XExportFilter, XServiceName, XServiceInfo, - XDocumentHandler, + XDocumentHandler, XTypeProvider { - + /** The component will be registered under this name. */ static private final String __serviceName = "com.sun.star.documentconversion.XMergeBridge"; - - + + public com.sun.star.uno.Type[] getTypes() { Type[] typeReturn = {}; @@ -125,7 +125,7 @@ public class XMergeBridge { new Type( XServiceInfo.class ) }; } catch( Exception exception ) { - + } return( typeReturn ); @@ -137,11 +137,11 @@ public class XMergeBridge { if (origName !=null) { if(origName.equalsIgnoreCase("")) - name = "OutFile"; + name = "OutFile"; else { if (origName.lastIndexOf("/")>=0){ origName=origName.substring(origName.lastIndexOf("/")+1,origName.length()); - } + } if (origName.lastIndexOf(".")>=0){ name = origName.substring(0,(origName.lastIndexOf("."))); } @@ -150,20 +150,20 @@ public class XMergeBridge { } } } - else{ - name = "OutFile"; + else{ + name = "OutFile"; } return name; } - - - public boolean importer(com.sun.star.beans.PropertyValue[] aSourceData, - com.sun.star.xml.sax.XDocumentHandler xDocHandler, - java.lang.String[] msUserData) throws com.sun.star.uno.RuntimeException { - /* + + + public boolean importer(com.sun.star.beans.PropertyValue[] aSourceData, + com.sun.star.xml.sax.XDocumentHandler xDocHandler, + java.lang.String[] msUserData) throws com.sun.star.uno.RuntimeException { + /* System.out.println("\nFound the Importer!\n"); - + System.out.println("\n"+msUserData[0]); System.out.println("\n"+msUserData[1]); System.out.println("\n"+msUserData[2]); @@ -171,7 +171,7 @@ public class XMergeBridge { System.out.println("\n"+msUserData[4]); System.out.println("\n"+msUserData[5]); */ - sFileName=""; + sFileName=""; sURL=""; String sDirectory = null; String udConvertClass=msUserData[0]; @@ -180,9 +180,9 @@ public class XMergeBridge { String udExport =msUserData[3]; offMime =msUserData[4]; sdMime = msUserData[5]; - com.sun.star.io.XInputStream xis=null; + com.sun.star.io.XInputStream xis=null; com.sun.star.beans.PropertyValue[] pValue = aSourceData; - + for (int i = 0 ; i < pValue.length; i++) { @@ -196,7 +196,7 @@ public class XMergeBridge { if (pValue[i].Name.compareTo("FileName")==0){ sFileName=(String)AnyConverter.toObject(new Type(java.lang.String.class), pValue[i].Value); } - + } catch(com.sun.star.lang.IllegalArgumentException AnyExec){ System.out.println("\nIllegalArgumentException "+AnyExec); @@ -204,14 +204,14 @@ public class XMergeBridge { - } - - + } + + try{ - + Object xCfgMgrObj=xMSF.createInstance("com.sun.star.config.SpecialConfigManager"); XConfigManager xCfgMgr = (XConfigManager) UnoRuntime.queryInterface( - XConfigManager.class , xCfgMgrObj ); + XConfigManager.class , xCfgMgrObj ); String PathString=xCfgMgr.substituteVariables("$(progurl)" ); PathString= PathString.concat("/"); udJarPath= PathString.concat(udJarPath); @@ -223,7 +223,7 @@ public class XMergeBridge { XOutputStream.class , xPipeObj ); convert (xis,xOutStream,false,udJarPath,sFileName,offMime,sdMime); Object xSaxParserObj=xMSF.createInstance("com.sun.star.xml.sax.Parser"); - + XParser xParser = (XParser) UnoRuntime.queryInterface( XParser.class , xSaxParserObj ); if (xParser==null){ @@ -237,11 +237,11 @@ public class XMergeBridge { aInput.sSystemId = sFileName; aInput.aInputStream =xInStream; xParser.setDocumentHandler ( xDocHandler ); - + xParser.parseStream ( aInput ); xOutStream.closeOutput(); xInStream.closeInput(); - + } catch (IOException e){ //System.out.println("XMergeBridge IO Exception "+e.getMessage()); @@ -254,12 +254,12 @@ public class XMergeBridge { return true; } - public boolean exporter(com.sun.star.beans.PropertyValue[] aSourceData, + public boolean exporter(com.sun.star.beans.PropertyValue[] aSourceData, java.lang.String[] msUserData) throws com.sun.star.uno.RuntimeException{ - - /* + + /* System.out.println("\nFound the Exporter!\n"); - + System.out.println("\n"+msUserData[0]); System.out.println("\n"+msUserData[1]); System.out.println("\n"+msUserData[2]); @@ -267,7 +267,7 @@ public class XMergeBridge { System.out.println("\n"+msUserData[4]); System.out.println("\n"+msUserData[5]); */ - sFileName=null; + sFileName=null; sURL=null; String sDirectory = null; String title=null; @@ -277,54 +277,54 @@ public class XMergeBridge { String udExport =msUserData[3]; offMime =msUserData[4]; sdMime = msUserData[5]; - + com.sun.star.beans.PropertyValue[] pValue = aSourceData; for (int i = 0 ; i < pValue.length; i++) { - + //System.out.println("\n"+pValue[i].Name+" "+pValue[i].Value); - + try{ //System.out.println("\n"+pValue[i].Name+" "+pValue[i].Value); if (pValue[i].Name.compareTo("OutputStream")==0){ xos=(com.sun.star.io.XOutputStream)AnyConverter.toObject(new Type(com.sun.star.io.XOutputStream.class), pValue[i].Value); - // System.out.println(pValue[i].Name+" "+xos); + // System.out.println(pValue[i].Name+" "+xos); } if (pValue[i].Name.compareTo("FileName")==0){ sFileName=(String)AnyConverter.toObject(new Type(java.lang.String.class), pValue[i].Value); - //System.out.println(pValue[i].Name+" "+sFileName); + //System.out.println(pValue[i].Name+" "+sFileName); } if (pValue[i].Name.compareTo("URL")==0){ sURL=(String)AnyConverter.toObject(new Type(java.lang.String.class), pValue[i].Value); // System.out.println("\nMediaDescriptor url "+pValue[i].Name+" "+sURL); - + } if (pValue[i].Name.compareTo("Title")==0){ - + title=(String)AnyConverter.toObject(new Type(java.lang.String.class), pValue[i].Value); - //System.out.println(pValue[i].Name+" "+title); + //System.out.println(pValue[i].Name+" "+title); } - } + } catch(com.sun.star.lang.IllegalArgumentException AnyExec){ System.out.println("\nIllegalArgumentException "+AnyExec); } } - - + + if (sURL==null){ sURL=""; } - + try{ - + Object xCfgMgrObj=xMSF.createInstance("com.sun.star.config.SpecialConfigManager"); XConfigManager xCfgMgr = (XConfigManager) UnoRuntime.queryInterface( XConfigManager.class , xCfgMgrObj ); - + String PathString=xCfgMgr.substituteVariables("$(progurl)" ); PathString= PathString.concat("/"); - udJarPath= PathString.concat(udJarPath); + udJarPath= PathString.concat(udJarPath); Object xPipeObj=xMSF.createInstance("com.sun.star.io.Pipe"); xInStream = (XInputStream) UnoRuntime.queryInterface( @@ -336,12 +336,12 @@ public class XMergeBridge { System.out.println("Exception "+e); return false; } - + return true; } public String replace(String origString, String origChar, String replaceChar){ - String tmp=""; + String tmp=""; int index=origString.indexOf(origChar); if(index !=-1){ while (index !=-1){ @@ -353,43 +353,43 @@ public class XMergeBridge { if(index==-1) { tmp=tmp.concat(origString); } - + } - + } return tmp; } - + public String needsMask(String origString){ if (origString.indexOf("&")!=-1){ origString=replace(origString,"&","&"); - } + } if (origString.indexOf("\"")!=-1){ origString=replace(origString,"\"","""); - } + } if (origString.indexOf("<")!=-1){ origString=replace(origString,"<","<"); - } + } if (origString.indexOf(">")!=-1){ origString=replace(origString,">",">"); - } + } return origString; - + } - - - public void startDocument () { + + + public void startDocument () { //System.out.println("\nStart Document!"); } - + public void endDocument()throws com.sun.star.uno.RuntimeException - { - + { + try{ - xOutStream.closeOutput(); + xOutStream.closeOutput(); convert (xInStream,xos,true,udJarPath,sURL,offMime,sdMime); - + } catch (IOException e){ //System.out.println("Exception "+e); @@ -402,12 +402,12 @@ public class XMergeBridge { } } - + public void startElement (String str, com.sun.star.xml.sax.XAttributeList xattribs) { - + str="<".concat(str); if (xattribs !=null) { @@ -422,29 +422,29 @@ public class XMergeBridge { } } str=str.concat(">"); - // System.out.println(str); + // System.out.println(str); try{ xOutStream.writeBytes(str.getBytes("UTF-8")); } catch (Exception e){ System.out.println("\n"+e); } - + } public void endElement(String str){ - + str="</".concat(str); str=str.concat(">"); try{ xOutStream.writeBytes(str.getBytes("UTF-8")); - + } catch (Exception e){ System.out.println("\n"+e); } - - + + } public void characters(String str){ str=needsMask(str); @@ -454,39 +454,39 @@ public class XMergeBridge { catch (Exception e){ System.out.println("\n"+e); } - - + + } - + public void ignorableWhitespace(String str){ - - + + } public void processingInstruction(String aTarget, String aData){ - + } - + public void setDocumentLocator(com.sun.star.xml.sax.XLocator xLocator){ - + } - + public void convert (com.sun.star.io.XInputStream xml,com.sun.star.io.XOutputStream device, boolean convertFromOffice,String pluginUrl,String FileName,String offMime,String sdMime) throws com.sun.star.uno.RuntimeException, IOException { - + String jarName = pluginUrl; String name= getFileName(FileName); - + ConverterInfo converterInfo = null; Enumeration ciEnum= null; - + XInputStreamToInputStreamAdapter xis =new XInputStreamToInputStreamAdapter(xml); - - + + XOutputStreamToOutputStreamAdapter newxos =new XOutputStreamToOutputStreamAdapter(device); try{ ConverterInfoReader cir = new ConverterInfoReader(jarName,false); @@ -504,42 +504,42 @@ public class XMergeBridge { ConverterInfoMgr. removeByJar(jarName); if (convertFromOffice) { - + try { - - //Check to see if jar contains a plugin Impl - + + //Check to see if jar contains a plugin Impl + ConverterInfoMgr.addPlugIn(ciEnum); ConverterFactory cf = new ConverterFactory(); - + Convert cv = cf.getConverter(ConverterInfoMgr.findConverterInfo(sdMime,offMime),false); if (cv == null) { System.out.println("\nNo plug-in exists to convert from <staroffice/sxw> to <specified format> "); - + } else { cv.addInputStream(name,(InputStream)xis,false); ConvertData dataOut = cv.convert(); - + Enumeration docEnum = dataOut.getDocumentEnumeration(); - + if (docEnum.hasMoreElements()){ Document docOut = (Document)docEnum.nextElement(); String fileName = docOut.getFileName(); docOut.write(newxos); - + newxos.flush(); newxos.close(); - - + + int i=1; while (docEnum.hasMoreElements() && sURL.startsWith("file:")) { //URI uri=new URI(sFileName); URI uri=new URI(sURL); String newFileName= getPath(uri); - - + + //System.out.println("\nURI: "+uri.getPath()); File newFile=null; if (newFileName.lastIndexOf(".")!=-1){ @@ -548,7 +548,7 @@ public class XMergeBridge { else{ newFile =new File(newFileName.concat(String.valueOf(i))); } - + FileOutputStream fos = new FileOutputStream(newFile); docOut = (Document)docEnum.nextElement(); fileName = docOut.getFileName(); @@ -556,16 +556,16 @@ public class XMergeBridge { fos.flush(); fos.close(); i++; - + } - - } + + } } ConverterInfoMgr.removeByJar(jarName); - } + } catch (StackOverflowError sOE){ System.out.println("\nERROR : Stack OverFlow. \n Increase of the JRE by adding the following line to the end of the javarc file \n \"-Xss1m\"\n"); - + } catch (Exception e) { System.out.println("Error:"+e); @@ -573,9 +573,9 @@ public class XMergeBridge { } } else{ - + try { - //Check to see if jar contains a plugin Impl + //Check to see if jar contains a plugin Impl ConverterInfoMgr.addPlugIn(ciEnum); ConverterFactory cf = new ConverterFactory(); Convert cv = cf.getConverter(ConverterInfoMgr.findConverterInfo(sdMime,offMime),true); @@ -599,8 +599,8 @@ public class XMergeBridge { //System.out.println("\nFinished Converting"); Enumeration docEnum = dataIn.getDocumentEnumeration(); while (docEnum.hasMoreElements()) { - OfficeDocument docIn = (OfficeDocument)docEnum.nextElement(); - + OfficeDocument docIn = (OfficeDocument)docEnum.nextElement(); + docIn.write(newxos,false); } //newxos.write(-1); //EOF character @@ -608,18 +608,18 @@ public class XMergeBridge { newxos.close(); } ConverterInfoMgr.removeByJar(jarName); - } + } catch (StackOverflowError sOE){ System.out.println("\nERROR : Stack OverFlow. \n Increase of the JRE by adding the following line to the end of the javarc file \n \"-Xss1m\"\n"); } catch (Exception e) { System.out.println("Error:"+e); throw new IOException("Xmerge Exception"); - } - - } - + + + } + } private String getPath(URI uri){ @@ -631,7 +631,7 @@ public class XMergeBridge { } return path; } - + @@ -651,22 +651,22 @@ public class XMergeBridge { public String getServiceName() { return( __serviceName ); } - + // Implement methods from interface XServiceInfo public boolean supportsService(String stringServiceName) { return( stringServiceName.equals( __serviceName ) ); } - + public String getImplementationName() { return( _XMergeBridge.class.getName() ); } - + public String[] getSupportedServiceNames() { String[] stringSupportedServiceNames = { __serviceName }; return( stringSupportedServiceNames ); } } - + /** * Returns a factory for creating the service. * This method is called by the <code>JavaLoader</code> @@ -689,13 +689,13 @@ public class XMergeBridge { if (implName.equals(_XMergeBridge.class.getName()) ) { xSingleServiceFactory = FactoryHelper.getServiceFactory(_XMergeBridge.class, _XMergeBridge.__serviceName, - multiFactory, + multiFactory, regKey); } - + return xSingleServiceFactory; } - + /** * Writes the service information into the given registry key. * This method is called by the <code>JavaLoader</code> diff --git a/xmerge/source/htmlsoff/build.xml b/xmerge/source/htmlsoff/build.xml index 10969a731ebd..90cbcbb4beae 100644 --- a/xmerge/source/htmlsoff/build.xml +++ b/xmerge/source/htmlsoff/build.xml @@ -3,23 +3,23 @@ #************************************************************************* # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - + Copyright 2000, 2010 Oracle and/or its affiliates. - + OpenOffice.org - a multi-platform office productivity suite - + This file is part of OpenOffice.org. - + OpenOffice.org is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. - + OpenOffice.org is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details (a copy is included in the LICENSE file that accompanied this code). - + You should have received a copy of the GNU Lesser General Public License version 3 along with OpenOffice.org. If not, see <http://www.openoffice.org/license.html> @@ -27,11 +27,11 @@ #************************************************************************* --> - + <project name="htmlsoff" default="all" basedir="."> <property file="../inc/antbuild.properties"/> - + <path id="classpath"> <pathelement location="${build.dir}/xmerge.jar"/> </path> @@ -43,7 +43,7 @@ <!-- compile java sources in ${package} --> <target name="compile" depends="init"> </target> - + <!-- package to jar --> <target name="jar" depends="compile"> <jar destfile="${target.jar}"> @@ -59,9 +59,9 @@ <target name="clean"> <delete file="${target.jar}"/> </target> - + <target name="all" depends="jar"> </target> - + </project> diff --git a/xmerge/source/htmlsoff/converter.xml b/xmerge/source/htmlsoff/converter.xml index ce347256dd16..3038d5b70d73 100644 --- a/xmerge/source/htmlsoff/converter.xml +++ b/xmerge/source/htmlsoff/converter.xml @@ -3,23 +3,23 @@ #************************************************************************* # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - + Copyright 2000, 2010 Oracle and/or its affiliates. - + OpenOffice.org - a multi-platform office productivity suite - + This file is part of OpenOffice.org. - + OpenOffice.org is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. - + OpenOffice.org is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details (a copy is included in the LICENSE file that accompanied this code). - + You should have received a copy of the GNU Lesser General Public License version 3 along with OpenOffice.org. If not, see <http://www.openoffice.org/license.html> @@ -31,7 +31,7 @@ <converters> <converter type="staroffice/sxw" version="1.0"> <converter-display-name> - XSLT Transformation + XSLT Transformation </converter-display-name> <converter-description> Converter which performs xslt transformations diff --git a/xmerge/source/minicalc/build.xml b/xmerge/source/minicalc/build.xml index cf9d2fcba415..1332fa05cd9a 100644 --- a/xmerge/source/minicalc/build.xml +++ b/xmerge/source/minicalc/build.xml @@ -3,23 +3,23 @@ #************************************************************************* # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - + Copyright 2000, 2010 Oracle and/or its affiliates. - + OpenOffice.org - a multi-platform office productivity suite - + This file is part of OpenOffice.org. - + OpenOffice.org is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. - + OpenOffice.org is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details (a copy is included in the LICENSE file that accompanied this code). - + You should have received a copy of the GNU Lesser General Public License version 3 along with OpenOffice.org. If not, see <http://www.openoffice.org/license.html> @@ -27,11 +27,11 @@ #************************************************************************* --> - + <project name="minicalc" default="all" basedir="."> - + <property file="../inc/antbuild.properties"/> - + <path id="classpath"> <pathelement location="${build.dir}/xmerge.jar"/> </path> @@ -51,7 +51,7 @@ <classpath refid="classpath"/> </javac> </target> - + <!-- package to jar --> <target name="jar" depends="compile"> <jar destfile="${target.jar}"> @@ -68,9 +68,9 @@ <delete dir="${class.dir}"/> <delete file="${target.jar}"/> </target> - + <target name="all" depends="jar"> </target> - + </project> diff --git a/xmerge/source/minicalc/converter.xml b/xmerge/source/minicalc/converter.xml index 65de58117dea..65d1fb774423 100644 --- a/xmerge/source/minicalc/converter.xml +++ b/xmerge/source/minicalc/converter.xml @@ -3,23 +3,23 @@ #************************************************************************* # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - + Copyright 2000, 2010 Oracle and/or its affiliates. - + OpenOffice.org - a multi-platform office productivity suite - + This file is part of OpenOffice.org. - + OpenOffice.org is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. - + OpenOffice.org is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details (a copy is included in the LICENSE file that accompanied this code). - + You should have received a copy of the GNU Lesser General Public License version 3 along with OpenOffice.org. If not, see <http://www.openoffice.org/license.html> diff --git a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/ConverterCapabilitiesImpl.java b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/ConverterCapabilitiesImpl.java index d78e55db76cf..a1dc67a443e0 100644 --- a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/ConverterCapabilitiesImpl.java +++ b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/ConverterCapabilitiesImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcConstants.java b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcConstants.java index 5dadec517be9..78d48a5e4ee9 100644 --- a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcConstants.java +++ b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcConstants.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcDataString.java b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcDataString.java index 7011208be355..974e9d1b3079 100644 --- a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcDataString.java +++ b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcDataString.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -53,7 +53,7 @@ public class MinicalcDataString { /** * Checks if the MiniCalc data <code>String</code> is a <i>formula</i>. * - * @return true if the MiniCalc data <code>String</code> is a + * @return true if the MiniCalc data <code>String</code> is a * <i>formula</i>, false if the MiniCalc data <code>String</code> * is not a <i>formula</i>. */ @@ -312,8 +312,8 @@ public class MinicalcDataString { * character of the MiniCalc data <code>String</code>, the * MiniCalc data <code>String</code> is returned. * - * @return The MiniCalc data <code>String</code> minus the - * percent sign. If the MiniCalc data <code>String</code> + * @return The MiniCalc data <code>String</code> minus the + * percent sign. If the MiniCalc data <code>String</code> * does not begin with a percent sign, the MiniCalc data * <code>String</code> is returned. */ diff --git a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcDecoder.java b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcDecoder.java index d5197581ce4c..37768fa4fb02 100644 --- a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcDecoder.java +++ b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcDecoder.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -68,7 +68,7 @@ final class MinicalcDecoder extends SpreadsheetDecoder { /** The current cell - only one cell can be active at a time. */ private CellDescriptor cell = null; - + /** Format object describing the current cell. */ private Format fmt = null; @@ -93,11 +93,11 @@ final class MinicalcDecoder extends SpreadsheetDecoder { * @throws IOException If any I/O error occurs. */ MinicalcDecoder(String name, String[] worksheetNames, String password) throws IOException { - + super(name, password); - + fmt = new Format(); - + this.password = password; this.worksheetNames = worksheetNames; @@ -111,9 +111,9 @@ final class MinicalcDecoder extends SpreadsheetDecoder { Debug.log(Debug.ERROR, "MinicalcDecoder.constructor:" + e.getMessage()); throw new IOException(e.getMessage()); - // e.printStackTrace(); + // e.printStackTrace(); - } + } } @@ -135,17 +135,17 @@ final class MinicalcDecoder extends SpreadsheetDecoder { Enumeration e = cd.getDocumentEnumeration(); while(e.hasMoreElements()) { - + palmDoc = (PalmDocument) e.nextElement(); // Convert PDB to WorkBook/WorkSheet format PalmDB pdb = palmDoc.getPdb(); // This will be done at least once String sheetName = worksheetNames[j]; - + // Get number of records in the pdb int numRecords = pdb.getRecordCount(); - + // sheetName does not contain the WorkBook name, but we need the // full name. String fullSheetName = new String(wb.getWorkbookName() + "-" + sheetName); @@ -173,7 +173,7 @@ final class MinicalcDecoder extends SpreadsheetDecoder { // Add each record to the WorkSheet ws.readNextRecord(bis, bisSize); } - + // Add the WorkSheet to the WorkBook wb.addWorksheet(ws); @@ -185,7 +185,7 @@ final class MinicalcDecoder extends SpreadsheetDecoder { Debug.log(Debug.ERROR, "MinicalcDecoder.addPDB:" + e.getMessage()); throw new IOException(e.getMessage()); - } + } } @@ -237,9 +237,9 @@ final class MinicalcDecoder extends SpreadsheetDecoder { Debug.log(Debug.ERROR, "MinicalcDecoder.setWorksheet:" + e.getMessage()); throw new IOException(e.getMessage()); - // e.printStackTrace(); + // e.printStackTrace(); - } + } } @@ -277,7 +277,7 @@ final class MinicalcDecoder extends SpreadsheetDecoder { if (cell != null) { gotCell = true; } - + // As we read each cell, get its formatting info readCellFormat(); } @@ -286,9 +286,9 @@ final class MinicalcDecoder extends SpreadsheetDecoder { Debug.log(Debug.ERROR, "MinicalcDecoder.goToNextCell:" + e.getMessage()); throw new IOException(e.getMessage()); - // e.printStackTrace(); + // e.printStackTrace(); - } + } return gotCell; } @@ -330,7 +330,7 @@ final class MinicalcDecoder extends SpreadsheetDecoder { public int getNumberOfColumns() { return maxCols; } - + /** * This method returns the col number of the current cell. @@ -363,11 +363,11 @@ final class MinicalcDecoder extends SpreadsheetDecoder { if (cell != null) { contents = cell.getCellContents(); - + // Active cell, but no content if (contents == null) return new String(""); - + // Does the cell contain a formula? if (contents.startsWith("=")) { contents = parseFormula(contents); @@ -394,12 +394,12 @@ final class MinicalcDecoder extends SpreadsheetDecoder { * This method is meant to return the value of the formula cell. However * in minicalc this value is not used so hence the stubbed function * - * @return the value fo the formula cell + * @return the value fo the formula cell */ public String getCellValue() { return null; } - + /** * <p>This method takes a formula and parses it into * StarOffice XML formula format.</p> @@ -407,7 +407,7 @@ final class MinicalcDecoder extends SpreadsheetDecoder { * <p>Many spreadsheets use ',' as a separator. * StarOffice XML format uses ';' as a separator instead.</p> * - * <p>Many spreadsheets use '!' as a separator when refencing + * <p>Many spreadsheets use '!' as a separator when refencing * a cell in a different sheet.</p> * * <blockquote> @@ -652,7 +652,7 @@ final class MinicalcDecoder extends SpreadsheetDecoder { * @param contents The input <code>String</code> from which to * remove the dollar sign. * - * @return The input <code>String</code> minus the dollar sign. + * @return The input <code>String</code> minus the dollar sign. * If the input <code>String</code> did not begin or end * with a dollar sign, contents is returned. */ @@ -728,17 +728,17 @@ final class MinicalcDecoder extends SpreadsheetDecoder { return new Format(fmt); } - + /** * Create the format data for the new cell. */ private void readCellFormat() { // Make sure there are no remnants from the last time fmt.clearFormatting(); - + fmt.setCategory(getCellFormatType()); - + // TODO - Get any more formatting data here - } + } } diff --git a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcEncoder.java b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcEncoder.java index b07616867f4f..14e256918886 100644 --- a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcEncoder.java +++ b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcEncoder.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -93,7 +93,7 @@ final class MinicalcEncoder extends SpreadsheetEncoder { * @throws IOException If any I/O error occurs. */ MinicalcEncoder(String name, String password) throws IOException { - + super(name, password); try { @@ -102,12 +102,12 @@ final class MinicalcEncoder extends SpreadsheetEncoder { catch (JMCException e) { Debug.log(Debug.ERROR, "new Workbook threw exception:" + e.getMessage()); throw new IOException(e.getMessage()); - } + } } /** - * This method creates a WorkSheet belonging to the + * This method creates a WorkSheet belonging to the * WorkBook. * * @param sheetName The name of the WorkSheet. @@ -164,7 +164,7 @@ final class MinicalcEncoder extends SpreadsheetEncoder { // Get the number of records in the WorkSheet int numRecords = ws.getNumberOfRecords(); - + // Create the Record array Record[] allRecords = new Record[numRecords]; @@ -228,14 +228,14 @@ final class MinicalcEncoder extends SpreadsheetEncoder { // We are stripping out the ']' inBrace = false; break; - + case ':': - // We have a cell range reference. + // We have a cell range reference. // May need to strip out the leading '.' - if (inBrace) + if (inBrace) firstCharAfterColon = true; outFormula.append(inFormula.charAt(in)); - break; + break; case '.': if (inBrace == true) { @@ -246,7 +246,7 @@ final class MinicalcEncoder extends SpreadsheetEncoder { // and a cell reference. MiniCalc uses a ! as // this type of separator. outFormula.append('!'); - } + } else { firstCharAfterBrace = false; firstCharAfterColon = false; @@ -262,7 +262,7 @@ final class MinicalcEncoder extends SpreadsheetEncoder { } case ';': - // StarOffice XML format uses ';' as a separator. MiniCalc (and + // StarOffice XML format uses ';' as a separator. MiniCalc (and // many spreadsheets) use ',' as a separator instead. outFormula.append(','); break; @@ -292,17 +292,17 @@ final class MinicalcEncoder extends SpreadsheetEncoder { * @throws IOException If any I/O error occurs. */ public void addCell(int row, int column, Format fmt, String cellContents) throws IOException { - - CellAttributes ca = new CellAttributes(getFormat(fmt), + + CellAttributes ca = new CellAttributes(getFormat(fmt), fmt.getForeground(), fmt.getBackground()); if (cellContents.startsWith("=")) { cellContents = parseFormula(cellContents); Debug.log(Debug.INFO, "YAHOO Found Formula" + cellContents); } - + CellDescriptor cellDes = new CellDescriptor(row, column, ca, cellContents); - + try { ws.putCell(cellDes); } @@ -311,7 +311,7 @@ final class MinicalcEncoder extends SpreadsheetEncoder { throw new IOException(jmce.getMessage()); } } - + /** * Set the width of the columns in the WorkBook. @@ -322,30 +322,30 @@ final class MinicalcEncoder extends SpreadsheetEncoder { public void setColumnWidths(IntArrayList columnWidths) throws IOException { // Get the number of columns int numColumns = columnWidths.size(); - + // Return if there are no columns in the listr if (numColumns == 0) { return; } - + // Need to set the FORM_FLAGS_NONDEFAULT flag for the column widths // to be used in MiniCalc long format = JMCconstants.FORM_FLAGS_NONDEFAULT; - + CellAttributes ca = new CellAttributes(format); - + try { for (int i = 0; i < numColumns; i++) { // Get the column width in Palm pixels int width = columnWidths.get(i) * pixelsPerChar; - + // Check limits on column width if (width < minWidth) { width = minWidth; } else if (width > maxWidth) { width = maxWidth; } - + // Add the column descriptor to the WorkSheet ws.putColumn(i + 1, width, ca); } @@ -356,7 +356,7 @@ final class MinicalcEncoder extends SpreadsheetEncoder { } } - + /** * This method sets the format of a cell to <i>string</i>. * @@ -495,7 +495,7 @@ final class MinicalcEncoder extends SpreadsheetEncoder { return format; } - + /** * This method clears out the format bits associated with @@ -518,8 +518,8 @@ final class MinicalcEncoder extends SpreadsheetEncoder { return format; } - - + + /** * Set a cell's formatting options via a separately create * <code>Format</code> object. @@ -531,7 +531,7 @@ final class MinicalcEncoder extends SpreadsheetEncoder { */ public void setCellFormat(int row, int column, Format fmt) { } - + /** * Get the names of the sheets in the WorkBook. @@ -541,16 +541,16 @@ final class MinicalcEncoder extends SpreadsheetEncoder { public String getSheetName(int sheet) { return wb.getWorksheet(sheet).getName(); } - + /* * This method returns a MiniCalc style format from the * <code>Format</code> object. - */ - private long getFormat(Format fmt) + */ + private long getFormat(Format fmt) { String category = fmt.getCategory(); - + if (category.equalsIgnoreCase(OfficeConstants.CELLTYPE_BOOLEAN)) { return setFormatBoolean(0); } diff --git a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/PluginFactoryImpl.java b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/PluginFactoryImpl.java index 1c65032bfa03..037347d4c44c 100644 --- a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/PluginFactoryImpl.java +++ b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/PluginFactoryImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -101,7 +101,7 @@ public final class PluginFactoryImpl extends SxcPluginFactory * which is an implementation of <code>DocumentDeserializer</code> * interface. * - * @param cd <code>ConvertData</code> object for reading data + * @param cd <code>ConvertData</code> object for reading data * which will be converted back to a * <code>Document</code> object. * diff --git a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/SxcDocumentDeserializerImpl.java b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/SxcDocumentDeserializerImpl.java index 65cab7f085a0..61680e73f3a1 100644 --- a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/SxcDocumentDeserializerImpl.java +++ b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/SxcDocumentDeserializerImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -73,7 +73,7 @@ public final class SxcDocumentDeserializerImpl extends SxcDocumentDeserializer { return new MinicalcDecoder(workbook, worksheetNames, password); } - + /** * This method will return the name of the WorkBook from the @@ -85,9 +85,9 @@ public final class SxcDocumentDeserializerImpl extends SxcDocumentDeserializer { * * @param cd The <code>ConvertData</code>. * - * @return The name of the WorkBook. + * @return The name of the WorkBook. */ - protected String getWorkbookName(ConvertData cd) + protected String getWorkbookName(ConvertData cd) throws IOException { Enumeration e = cd.getDocumentEnumeration(); @@ -100,10 +100,10 @@ public final class SxcDocumentDeserializerImpl extends SxcDocumentDeserializer { if (end > 0) { workbookName = workbookName.substring(0, end); } - - return workbookName; + + return workbookName; } - + /** * This method will return an array of WorkSheet names from the @@ -111,9 +111,9 @@ public final class SxcDocumentDeserializerImpl extends SxcDocumentDeserializer { * * @param cd The <code>ConvertData</code>. * - * @return The name of the WorkSheet. + * @return The name of the WorkSheet. */ - protected String[] getWorksheetNames(ConvertData cd) + protected String[] getWorksheetNames(ConvertData cd) throws IOException { int numberOfPDBs = cd.getNumDocuments(); String worksheetName[] = new String[numberOfPDBs]; @@ -122,17 +122,17 @@ public final class SxcDocumentDeserializerImpl extends SxcDocumentDeserializer { while (e.hasMoreElements()) { PalmDocument palmDoc = (PalmDocument) e.nextElement(); worksheetName[i] = palmDoc.getName(); - + // Search for the "-", which seperates workbook from worksheet int start = worksheetName[i].indexOf("-"); - + if (start != -1) { worksheetName[i] = worksheetName[i].substring(start + 1); - } + } i++; } - return worksheetName; + return worksheetName; } } diff --git a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/SxcDocumentSerializerImpl.java b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/SxcDocumentSerializerImpl.java index 07b212e9a667..25ad6dda73f4 100644 --- a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/SxcDocumentSerializerImpl.java +++ b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/SxcDocumentSerializerImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -49,7 +49,7 @@ import org.openoffice.xmerge.converter.xml.sxc.Format; import org.openoffice.xmerge.converter.xml.sxc.SxcDocumentSerializer; /** - * <p>MiniCalc implementation of <code>SxcDocumentDeserializer</code> + * <p>MiniCalc implementation of <code>SxcDocumentDeserializer</code> * for the {@link * org.openoffice.xmerge.converter.xml.sxc.minicalc.PluginFactoryImpl * PluginFactoryImpl}.</p> @@ -72,7 +72,7 @@ public final class SxcDocumentSerializerImpl extends SxcDocumentSerializer { super(document); } - + public ConvertData serialize() throws ConvertException, IOException { @@ -110,8 +110,8 @@ public final class SxcDocumentSerializerImpl extends SxcDocumentSerializer { Record records[] = ((MinicalcEncoder) encoder).getRecords(i); // Get the sheet name for sheet i - String fullSheetName = new String(docName - + "-" + String fullSheetName = new String(docName + + "-" + encoder.getSheetName(i)); // Create a PalmDB object @@ -124,7 +124,7 @@ public final class SxcDocumentSerializerImpl extends SxcDocumentSerializer { } - // OutputStream os = new FileOutputStream(docName); + // OutputStream os = new FileOutputStream(docName); //pdbSet.write(os); //os.flush(); @@ -134,7 +134,7 @@ public final class SxcDocumentSerializerImpl extends SxcDocumentSerializer { return cd; } - + } diff --git a/xmerge/source/palmtests/bin/verify_sane.pl b/xmerge/source/palmtests/bin/verify_sane.pl index d6018d4b757c..dc085f3ddc44 100755 --- a/xmerge/source/palmtests/bin/verify_sane.pl +++ b/xmerge/source/palmtests/bin/verify_sane.pl @@ -4,7 +4,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -33,7 +33,7 @@ # Version : 1.0 # Project : XMerge # Author : Brian Cameron -# Date : 5th Sept. 2001 +# Date : 5th Sept. 2001 # # # Takes x and y from the command line and taps the screen there. @@ -68,7 +68,7 @@ elsif ($up_pid) waitpid($up_pid, WNOHANG); - if (kill(0, $up_pid)) + if (kill(0, $up_pid)) { print "Pose did not start successfully...\n"; kill(9, $up_pid); @@ -87,7 +87,7 @@ elsif ($up_pid) exit(0); } } -else +else { # Child process - Try to open/close the connection. This # can hang if pose did not start properly... diff --git a/xmerge/source/palmtests/qa-wrapper/bin/qa_comparator.pl b/xmerge/source/palmtests/qa-wrapper/bin/qa_comparator.pl index d467e23a3252..6cc49da3570b 100755 --- a/xmerge/source/palmtests/qa-wrapper/bin/qa_comparator.pl +++ b/xmerge/source/palmtests/qa-wrapper/bin/qa_comparator.pl @@ -4,7 +4,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -74,7 +74,7 @@ close LOGFILE; sub process_diff { -# $_[0] =~ tr/A-Z/a-z/; +# $_[0] =~ tr/A-Z/a-z/; # chdir to the output directory so the temporary files created by # the java programs are put in the right place. @@ -88,45 +88,45 @@ sub process_diff # `cp $compare_home/dtd/* $xml_new`; -# $cmd = "java -classpath $classpath_val XmlWrapper $xml_orig/$_[0].sxw $xml_new/$_[0].sxw"; +# $cmd = "java -classpath $classpath_val XmlWrapper $xml_orig/$_[0].sxw $xml_new/$_[0].sxw"; $cmd = "java -classpath $classpath_val XmlWrapper $xml_orig/$_[0] $xml_new/$_[0]"; print "Executing: $cmd\n"; $val = system($cmd)/256; if ($val == 2) { -# print LOGFILE "$_[0]|TRUE|$xml_orig/$_[0].sxw|$xml_new/$_[0].sxw\n"; +# print LOGFILE "$_[0]|TRUE|$xml_orig/$_[0].sxw|$xml_new/$_[0].sxw\n"; print LOGFILE "$_[0]|TRUE|$xml_orig/$_[0]|$xml_new/$_[0]\n"; } elsif($val == 3) { -# print LOGFILE "$_[0]|FALSE|$xml_orig/$_[0].sxw|$xml_new/$_[0].sxw\n"; +# print LOGFILE "$_[0]|FALSE|$xml_orig/$_[0].sxw|$xml_new/$_[0].sxw\n"; print LOGFILE "$_[0]|FALSE|$xml_orig/$_[0]|$xml_new/$_[0]\n"; } else { -# print LOGFILE "$_[0]|ERROR|$xml_orig/$_[0].sxw|$xml_new/$_[0].sxw\n"; +# print LOGFILE "$_[0]|ERROR|$xml_orig/$_[0].sxw|$xml_new/$_[0].sxw\n"; print LOGFILE "$_[0]|ERROR|$xml_orig/$_[0]|$xml_new/$_[0]\n"; } } elsif ($diff_type eq "pdb") { -# $cmd = "java -classpath $classpath_val SimplePdbCompare $pdb_orig/$_[0].pdb $pdb_new/$_[0].pdb\n"; +# $cmd = "java -classpath $classpath_val SimplePdbCompare $pdb_orig/$_[0].pdb $pdb_new/$_[0].pdb\n"; $cmd = "java -classpath $classpath_val SimplePdbCompare $pdb_orig/$_[0] $pdb_new/$_[0]\n"; print "Executing: $cmd\n"; $val = system($cmd)/256; if ($val == 2) { -# print LOGFILE "$_[0]|TRUE|$pdb_orig/$_[0].pdb|$pdb_new/$_[0].pdb\n"; +# print LOGFILE "$_[0]|TRUE|$pdb_orig/$_[0].pdb|$pdb_new/$_[0].pdb\n"; print LOGFILE "$_[0]|TRUE|$pdb_orig/$_[0]|$pdb_new/$_[0]\n"; } elsif($val == 3) { -# print LOGFILE "$_[0]|FALSE|$pdb_orig/$_[0].pdb|$pdb_new/$_[0].pdb\n"; +# print LOGFILE "$_[0]|FALSE|$pdb_orig/$_[0].pdb|$pdb_new/$_[0].pdb\n"; print LOGFILE "$_[0]|FALSE|$pdb_orig/$_[0]|$pdb_new/$_[0]\n"; } else { -# print LOGFILE "$_[0]|ERROR|$pdb_orig/$_[0].pdb|$pdb_new/$_[0].pdb\n"; +# print LOGFILE "$_[0]|ERROR|$pdb_orig/$_[0].pdb|$pdb_new/$_[0].pdb\n"; print LOGFILE "$_[0]|ERROR|$pdb_orig/$_[0]|$pdb_new/$_[0]\n"; } } @@ -142,7 +142,7 @@ sub process_cmdline { @arg= split('=', $i); @arg[0] =~ tr/A-Z/a-z/; - + if (@arg[0] eq "-pdb-orig") { $pdb_orig=$arg[1]; @@ -191,7 +191,7 @@ sub process_cmdline sub set_env_from_props { open(PROPSFILE, $_[0]) || die "Could not open properties file"; - + while (<PROPSFILE>) { chomp $_; @@ -219,7 +219,7 @@ sub set_env_from_props { $xml_new=$arg[1]; } - + } close PROPSFILE; } @@ -228,8 +228,8 @@ sub print_usage { print "Usage : compartor.pl - compare Office or pdb files\n"; print "\t-one=<file> :\t\t individual test case file to run\n"; - print "\t-list=<file> :\t\t list of test case files\n"; - print "\t-env=<file> :\t\t Properites like file defining env\n"; + print "\t-list=<file> :\t\t list of test case files\n"; + print "\t-env=<file> :\t\t Properites like file defining env\n"; print "\t-pdb-orig=<path> :\t directory to hold original pdb files\n"; print "\t-pdb-new=<path> :\t directory to hold new pdb files\n"; print "\t-xml-orig=<path> :\t directory to hold original office documents\n"; @@ -252,6 +252,6 @@ sub get_file_title @paths = split('\/', $_[0]); $len = @paths; return @paths[$len-1]; -# @names = split('\.', @paths[$len-1]); -# return $names[0]; +# @names = split('\.', @paths[$len-1]); +# return $names[0]; } diff --git a/xmerge/source/palmtests/qa-wrapper/bin/qa_test_driver.pl b/xmerge/source/palmtests/qa-wrapper/bin/qa_test_driver.pl index b72b5eea8854..fd57512fd171 100755 --- a/xmerge/source/palmtests/qa-wrapper/bin/qa_test_driver.pl +++ b/xmerge/source/palmtests/qa-wrapper/bin/qa_test_driver.pl @@ -4,7 +4,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -33,7 +33,7 @@ # Version : 1.0 # Project : Xmerge # Author : Brian Cameron -# Date : 5th Sept. 2001 +# Date : 5th Sept. 2001 # # # This script does the following: @@ -199,7 +199,7 @@ exit(0); # # This is the main driver function # Opens the infile, reads it in parses it, runs the appropriate conversion -# starts pose and load the file into the emulator. It launches the +# starts pose and load the file into the emulator. It launches the # appropriate editor and then runs the commands specified in the test case. # It then exports the file and saves it locally. Finally it is converted # back to the original office format. @@ -213,17 +213,17 @@ sub process_testcase # Process the inputfile # open (INFILE, $infile) || die "Failed to open test case <$infile>"; - + $running_testtype = ""; - + # Process the input file. # while ($c_inline = <INFILE>) { chomp $c_inline; @entry = split('\|', $c_inline); - - # Process TEST + + # Process TEST # if ($c_inline =~ /^ *#/ || $c_inline =~ /^[ \t]*$/) { @@ -237,9 +237,9 @@ sub process_testcase # &close_program($convert_file); $running_testtype = ""; - + $valid_test = 0; - + if ($#entry != 3) { print "\nERROR, $entry[0] invalid number of arguments\n\n"; @@ -250,12 +250,12 @@ sub process_testcase # print "\nStarting test: $entry[1]\n"; $convert_file = $entry[3]; - + if ("$entry[2]" =~ /[Qq][Uu][Ii][Cc][Kk][Ww][Oo][Rr][Dd]/) { $xml_extension = "sxw"; $convert_to = "application/x-aportisdoc"; - + # Convert XML file to pdb format. # $rc = &convert_to_pdb("$xml_orig", $convert_file, $xml_extension , @@ -271,7 +271,7 @@ sub process_testcase $rc = &start_pose("$pose_exe", "$pose_prc/Quickword.PRC,$pose_prc/DBExporter.prc,$pdb_orig/$convert_file.pdb", "Quickword", $pose_timeout); - + if ($rc == 0) { &start_quickword(); @@ -290,7 +290,7 @@ sub process_testcase { $xml_extension = "sxc"; $convert_to = "application/x-minicalc"; - + # Convert XML file to pdb format. # $rc = &convert_to_pdb("$xml_orig", $convert_file, @@ -322,7 +322,7 @@ sub process_testcase $rc = &start_pose("$pose_exe", "$pose_prc/MiniCalc.prc,$pose_prc/DBExporter.prc,$pdb_files", "MiniCalc", $pose_timeout); - + if ($rc == 0) { &start_minicalc(); @@ -343,7 +343,7 @@ sub process_testcase } } } - + # Process DB_EXPORT # elsif ("$entry[0]" eq "DB_EXPORT") @@ -390,7 +390,7 @@ sub process_testcase $entry[3], $running_testtype); } } - + # Process TAP_PEN # elsif ("$entry[0]" eq "TAP_PEN") @@ -500,13 +500,13 @@ sub process_testcase print "\nERROR, invalid line <$c_inline>\n"; } } - + &close_program($convert_file); } # close_program # convert_file - file to export -# +# # closes the program running in pose and kills pose # sub close_program @@ -526,8 +526,8 @@ sub close_program } # close_program_quickword -# convert_file - file to export -# +# convert_file - file to export +# # Closes quickword and kills pose # sub close_program_quickword @@ -562,7 +562,7 @@ sub close_program_quickword # close_program_minicalc # convert_file - file to export -# +# # Closes minicalc and kills pose # sub close_program_minicalc @@ -592,7 +592,7 @@ sub close_program_minicalc } $rc = &convert_to_xml($xml_new, $xml_orig, "$list", - "application/x-minicalc", "sxc", $convert_file, $merge_opt); + "application/x-minicalc", "sxc", $convert_file, $merge_opt); if ($rc != 0) { print "\nERROR, problem converting file(s) $list\n\n"; @@ -609,8 +609,8 @@ sub print_usage { print "Usage : test_driver.pl\n"; print "\t-test=<file> \t\t: individual test case file to run\n"; - print "\t-list=<file> \t\t: list of test case files\n"; - print "\t-env=<file> \t\t: Properites like file defining env\n"; + print "\t-list=<file> \t\t: list of test case files\n"; + print "\t-env=<file> \t\t: Properites like file defining env\n"; print "\t-pose-exe=<fullpath> \t: path to pose executable\n"; print "\t-pose-prc=<path> \t: path to directory holding prc files\n"; print "\t-pdb-orig=<path> \t: directory to hold original pdb files\n"; @@ -650,7 +650,7 @@ sub process_cmdline { my @arg= split('=', $i); @arg[0] =~ tr/A-Z/a-z/; - + if (@arg[0] eq "-pose-exe") { $pose_exe=$arg[1]; @@ -707,12 +707,12 @@ sub process_cmdline # # Read the properties file, of the form key=value # Valid key values are : -# POSE_EXE -# POSE_PRC -# PDB_ORIG -# PDB_NEW -# XML_ORIG -# XML_NEW +# POSE_EXE +# POSE_PRC +# PDB_ORIG +# PDB_NEW +# XML_ORIG +# XML_NEW # If a value is found the appropriate global variable is set. # # Sets these globals: pose_exe, pose_prc, xml_orig, xml_new_dir, @@ -723,7 +723,7 @@ sub set_env_from_props my $infile = $_[0]; open(PROPSFILE, $infile) || die "Could not open properties file <$infile>"; - + while (<PROPSFILE>) { chomp $_; @@ -761,7 +761,7 @@ sub set_env_from_props $xml_new_dir=$arg[1]; $xml_new=$arg[1]; } - + } close PROPSFILE; } @@ -782,7 +782,7 @@ sub verify_env_options { die "$pose_exe exists but is not executable."; } - + if (!-e "$pose_prc") { die "The PRC directory specified as $pose_prc does not exist."; @@ -791,7 +791,7 @@ sub verify_env_options { die "The PRC location specified as $pose_prc exists, but is not a directory."; } - + if (!-e "$pdb_orig_dir") { die "The original PDB directory specified as $pdb_orig_dir does not exist."; @@ -800,7 +800,7 @@ sub verify_env_options { die "The original PDB directory specified as $pdb_orig_dir exists but is not a directory."; } - + if (!-e "$pdb_new_dir") { die "The new PDB directory specified as $pdb_new_dir does not exist."; @@ -809,7 +809,7 @@ sub verify_env_options { die "The new PDB directory specified as $pdb_new_dir exists but is not a directory."; } - + if (!-e "$xml_orig") { die "The original Office document directory specified as $xml_orig does not exist."; @@ -818,7 +818,7 @@ sub verify_env_options { die "The original Office document location specified as $xml_orig exists but is not a directory."; } - + if (!-e "$xml_new_dir") { die "The new Office document directory specified as $xml_new_dir does not exist."; diff --git a/xmerge/source/palmtests/qa/bin/mysplit.pl b/xmerge/source/palmtests/qa/bin/mysplit.pl index 07e0760e3c75..172a53a319cc 100755 --- a/xmerge/source/palmtests/qa/bin/mysplit.pl +++ b/xmerge/source/palmtests/qa/bin/mysplit.pl @@ -4,7 +4,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -54,5 +54,5 @@ while (<TESTFILE>) print TESTCASE "TEST|@args[1]|MINICALC|@filestuff[0]\n" ; close TESTCASE; } - + } diff --git a/xmerge/source/palmtests/qa/bin/tappen.pl b/xmerge/source/palmtests/qa/bin/tappen.pl index 1216f79ff0c4..5b365448f9e8 100755 --- a/xmerge/source/palmtests/qa/bin/tappen.pl +++ b/xmerge/source/palmtests/qa/bin/tappen.pl @@ -4,7 +4,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -33,7 +33,7 @@ # Version : 1.0 # Project : XMerge # Author : Brian Cameron -# Date : 5th Sept. 2001 +# Date : 5th Sept. 2001 # # Takes x and y from the command line and taps the screen there. # Assumes pose is already running. diff --git a/xmerge/source/palmtests/qa/bin/template.pl b/xmerge/source/palmtests/qa/bin/template.pl index 713c0d7ca3ba..f5e3c0cf7668 100755 --- a/xmerge/source/palmtests/qa/bin/template.pl +++ b/xmerge/source/palmtests/qa/bin/template.pl @@ -4,7 +4,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -33,7 +33,7 @@ # Version : 1.0 # Project : XMERGE # Author : Brian Cameron -# Date : 5th Sept. 2001 +# Date : 5th Sept. 2001 # # This is just a useful script to use as a template to run # commands. Assumes that pose is already running. diff --git a/xmerge/source/palmtests/qa/bin/test_driver.pl b/xmerge/source/palmtests/qa/bin/test_driver.pl index d7b64f58f11c..55d1d44f45d9 100755 --- a/xmerge/source/palmtests/qa/bin/test_driver.pl +++ b/xmerge/source/palmtests/qa/bin/test_driver.pl @@ -4,7 +4,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -33,7 +33,7 @@ # Version : 1.0 # Project : Xmerge # Author : Brian Cameron -# Date : 5th Sept. 2001 +# Date : 5th Sept. 2001 # # This script does the following: # @@ -140,7 +140,7 @@ exit(0); # # This is the main driver function # Opens the infile, reads it in parses it, runs the appropriate conversion -# starts pose and load the file into the emulator. It launches the +# starts pose and load the file into the emulator. It launches the # appropriate editor and then runs the commands specified in the test case. # It then exports the file and saves it locally. Finally it is converted # back to the original office format. @@ -154,17 +154,17 @@ sub process_testcase # Process the inputfile # open (INFILE, $infile) || die "Failed to open test case <$infile>"; - + $running_testtype = ""; - + # Process the input file. # while ($c_inline = <INFILE>) { chomp $c_inline; @entry = split('\|', $c_inline); - - # Process TEST + + # Process TEST # if ($c_inline =~ /^ *#/ || $c_inline =~ /^[ \t]*$/) { @@ -178,9 +178,9 @@ sub process_testcase # &close_program($convert_file); $running_testtype = ""; - + $valid_test = 0; - + if ($#entry != 3) { print "\nERROR, $entry[0] invalid number of arguments\n\n"; @@ -191,12 +191,12 @@ sub process_testcase # print "\nStarting test: $entry[1]\n"; $convert_file = $entry[3]; - + if ("$entry[2]" =~ /[Qq][Uu][Ii][Cc][Kk][Ww][Oo][Rr][Dd]/) { $xml_extension = "sxw"; $convert_to = "doc"; - + # Convert XML file to pdb format. # $rc = &convert_to_pdb("$xml_orig", $convert_file, $xml_extension , @@ -212,7 +212,7 @@ sub process_testcase $rc = &start_pose("$pose_exe", "$pose_prc/Quickword.PRC,$pose_prc/DBExporter.prc,$pdb_orig/$convert_file.pdb", "Quickword", $pose_timeout); - + if ($rc == 0) { &start_quickword(); @@ -231,7 +231,7 @@ sub process_testcase { $xml_extension = "sxc"; $convert_to = "minicalc"; - + # Convert XML file to pdb format. # $rc = &convert_to_pdb("$xml_orig", $convert_file, @@ -263,7 +263,7 @@ sub process_testcase $rc = &start_pose("$pose_exe", "$pose_prc/MiniCalc.prc,$pose_prc/DBExporter.prc,$pdb_files", "MiniCalc", $pose_timeout); - + if ($rc == 0) { &start_minicalc(); @@ -284,7 +284,7 @@ sub process_testcase } } } - + # Process DB_EXPORT # elsif ("$entry[0]" eq "DB_EXPORT") @@ -331,7 +331,7 @@ sub process_testcase $entry[3], $running_testtype); } } - + # Process TAP_PEN # elsif ("$entry[0]" eq "TAP_PEN") @@ -422,13 +422,13 @@ sub process_testcase print "\nERROR, invalid line <$c_inline>\n"; } } - + &close_program($convert_file); } # close_program # convert_file - file to export -# +# # closes the program running in pose and kills pose # sub close_program @@ -448,8 +448,8 @@ sub close_program } # close_program_quickword -# convert_file - file to export -# +# convert_file - file to export +# # Closes quickword and kills pose # sub close_program_quickword @@ -484,7 +484,7 @@ sub close_program_quickword # close_program_minicalc # convert_file - file to export -# +# # Closes minicalc and kills pose # sub close_program_minicalc @@ -514,7 +514,7 @@ sub close_program_minicalc } $rc = &convert_to_xml($xml_new, $xml_orig, "$list", - "minicalc", "sxc", $convert_file, $merge_opt); + "minicalc", "sxc", $convert_file, $merge_opt); if ($rc != 0) { print "\nERROR, problem converting file(s) $list\n\n"; @@ -531,8 +531,8 @@ sub print_usage { print "Usage : test_driver.pl\n"; print "\t-test=<file> \t\t: individual test case file to run\n"; - print "\t-list=<file> \t\t: list of test case files\n"; - print "\t-env=<file> \t\t: Properites like file defining env\n"; + print "\t-list=<file> \t\t: list of test case files\n"; + print "\t-env=<file> \t\t: Properites like file defining env\n"; print "\t-pose-exe=<fullpath> \t: path to pose executable\n"; print "\t-pose-prc=<path> \t: path to directory holding prc files\n"; print "\t-pdb-orig=<path> \t: directory to hold original pdb files\n"; @@ -574,7 +574,7 @@ sub process_cmdline { my @arg= split('=', $i); @arg[0] =~ tr/A-Z/a-z/; - + if (@arg[0] eq "-pose-exe") { $pose_exe=$arg[1]; @@ -637,14 +637,14 @@ sub process_cmdline # # Read the properties file, of the form key=value # Valid key values are : -# POSE_EXE -# POSE_PRC -# POSE_PERL -# TEST_HOME -# PDB_ORIG -# PDB_NEW -# XML_ORIG -# XML_NEW +# POSE_EXE +# POSE_PRC +# POSE_PERL +# TEST_HOME +# PDB_ORIG +# PDB_NEW +# XML_ORIG +# XML_NEW # If a value is found the appropriate global variable is set. # # Sets these globals: pose_exe, pose_prc, xml_orig, xml_new_dir, @@ -656,7 +656,7 @@ sub set_env_from_props my $lu_str = &get_date_string(); open(PROPSFILE, $infile) || die "Could not open properties file <$infile>"; - + while (<PROPSFILE>) { chomp $_; @@ -700,7 +700,7 @@ sub set_env_from_props $xml_new .= "/"; $xml_new .= "$lu_str"; } - + } close PROPSFILE; } @@ -721,7 +721,7 @@ sub verify_env_options { die "$pose_exe exists but is not executable."; } - + if (!-e "$pose_prc") { die "The PRC directory specified as $pose_prc does not exist."; @@ -730,7 +730,7 @@ sub verify_env_options { die "The PRC location specified as $pose_prc exists, but is not a directory."; } - + if (!-e "$pdb_orig_dir") { die "The original PDB directory specified as $pdb_orig_dir does not exist."; @@ -739,7 +739,7 @@ sub verify_env_options { die "The original PDB directory specified as $pdb_orig_dir exists but is not a directory."; } - + if (!-e "$pdb_new_dir") { die "The new PDB directory specified as $pdb_new_dir does not exist."; @@ -748,7 +748,7 @@ sub verify_env_options { die "The new PDB directory specified as $pdb_new_dir exists but is not a directory."; } - + if (!-e "$xml_orig") { die "The original Office document directory specified as $xml_orig does not exist."; @@ -757,7 +757,7 @@ sub verify_env_options { die "The original Office document location specified as $xml_orig exists but is not a directory."; } - + if (!-e "$xml_new_dir") { die "The new Office document directory specified as $xml_new_dir does not exist."; diff --git a/xmerge/source/palmtests/qa/comparator/OfficeZip.java b/xmerge/source/palmtests/qa/comparator/OfficeZip.java index 8fbbc609e411..496949cf3d17 100644 --- a/xmerge/source/palmtests/qa/comparator/OfficeZip.java +++ b/xmerge/source/palmtests/qa/comparator/OfficeZip.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -65,7 +65,7 @@ class OfficeZip { } /** - * Constructor + * Constructor * * @param filename Full Path to Zip file to process * diff --git a/xmerge/source/palmtests/qa/comparator/PDBDecoder.java b/xmerge/source/palmtests/qa/comparator/PDBDecoder.java index 11552c4648ab..8f4dec82f4b5 100644 --- a/xmerge/source/palmtests/qa/comparator/PDBDecoder.java +++ b/xmerge/source/palmtests/qa/comparator/PDBDecoder.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/palmtests/qa/comparator/PDBHeader.java b/xmerge/source/palmtests/qa/comparator/PDBHeader.java index 272bea68e399..216fd8bd9351 100644 --- a/xmerge/source/palmtests/qa/comparator/PDBHeader.java +++ b/xmerge/source/palmtests/qa/comparator/PDBHeader.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/palmtests/qa/comparator/PDBUtil.java b/xmerge/source/palmtests/qa/comparator/PDBUtil.java index 4544a5d11d2d..bdf8a07d9360 100644 --- a/xmerge/source/palmtests/qa/comparator/PDBUtil.java +++ b/xmerge/source/palmtests/qa/comparator/PDBUtil.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/palmtests/qa/comparator/PalmDB.java b/xmerge/source/palmtests/qa/comparator/PalmDB.java index 4e4449f81be9..e15e7fefa5ff 100644 --- a/xmerge/source/palmtests/qa/comparator/PalmDB.java +++ b/xmerge/source/palmtests/qa/comparator/PalmDB.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/palmtests/qa/comparator/Record.java b/xmerge/source/palmtests/qa/comparator/Record.java index bed61a55e1e7..f506f1a2b190 100644 --- a/xmerge/source/palmtests/qa/comparator/Record.java +++ b/xmerge/source/palmtests/qa/comparator/Record.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/palmtests/qa/comparator/SimplePdbCompare.java b/xmerge/source/palmtests/qa/comparator/SimplePdbCompare.java index 19299ba52968..da01306d9545 100644 --- a/xmerge/source/palmtests/qa/comparator/SimplePdbCompare.java +++ b/xmerge/source/palmtests/qa/comparator/SimplePdbCompare.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -34,7 +34,7 @@ /** * * @author mh101528 - * @version + * @version */ public final class SimplePdbCompare { @@ -45,7 +45,7 @@ public final class SimplePdbCompare { /** * @param args the command line arguments */ - public static void main (String args[]) + public static void main (String args[]) { SimplePdbCompare comparator = new SimplePdbCompare(); if (comparator.comparePDB(args[0], args[1])) @@ -53,22 +53,22 @@ public final class SimplePdbCompare { else System.exit(3); } - + public boolean comparePDB(String pdbname1, String pdbname2) { PalmDB pdb1=null, pdb2=null; PDBDecoder decoder = new PDBDecoder(); - try + try { pdb1 = decoder.parse(pdbname1); - } - catch (Exception e) + } + catch (Exception e) { System.out.println("Could not parse PDB " + pdbname1); return false; } - try + try { pdb2 = decoder.parse(pdbname2); } @@ -78,17 +78,17 @@ public final class SimplePdbCompare { return false; } - if (pdb1.equals(pdb2)) + if (pdb1.equals(pdb2)) { //writeToLog("PDB " + pdbname1 + " and PDB " + pdbname2 + " are equal"); System.out.println("PDB " + pdbname1 + " and PDB " + pdbname2 + " are equal"); return true; - } - else + } + else { //writeToLog("PDB " + pdbname1 + " and PDB " + pdbname2 + " are not equal"); System.out.println("PDB " + pdbname1 + " and PDB " + pdbname2 + " are not equal"); return false; } - } + } } diff --git a/xmerge/source/palmtests/qa/comparator/XmlDiff.java b/xmerge/source/palmtests/qa/comparator/XmlDiff.java index 248e9124ba27..d592609d18f3 100644 --- a/xmerge/source/palmtests/qa/comparator/XmlDiff.java +++ b/xmerge/source/palmtests/qa/comparator/XmlDiff.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -123,15 +123,15 @@ public final class XmlDiff { String node2Str = ""; if (node1 != null) { - node1Str = "[Type]:" + nodeInfo(node1) + - " [Name]:" + node1.getNodeName(); + node1Str = "[Type]:" + nodeInfo(node1) + + " [Name]:" + node1.getNodeName(); if (node1.getNodeValue() != null) node1Str += " [Value]:" + node1.getNodeValue(); } if (node2 != null) { node2Str = "[Type]:" + nodeInfo(node2) + - " [Name]:" + node2.getNodeName(); + " [Name]:" + node2.getNodeName(); if (node2.getNodeValue() != null) node2Str += " [Value]:" + node2.getNodeValue(); } @@ -142,10 +142,10 @@ public final class XmlDiff { } private String nodeInfo(Node node) { - + String str = null; switch (node.getNodeType()) { - + case Node.ELEMENT_NODE: str = "ELEMENT"; break; @@ -212,12 +212,12 @@ public final class XmlDiff { equal = true; break; } else if (node1 == null || node2 == null) { - diffLog("DIFF: one of the node is null", node1, node2); + diffLog("DIFF: one of the node is null", node1, node2); break; } if (node1.getNodeType() != node2.getNodeType()) { - diffLog("DIFF: nodetype is different", node1, node2); + diffLog("DIFF: nodetype is different", node1, node2); break; } @@ -225,15 +225,15 @@ public final class XmlDiff { // empty } else if (node1.getNodeName() == null || node2.getNodeName() == null) { - diffLog("DIFF: one of the nodeName is null", node1, node2); + diffLog("DIFF: one of the nodeName is null", node1, node2); break; } else if (!node1.getNodeName().equals(node2.getNodeName())) { - diffLog("DIFF: nodeName is different", node1, node2); + diffLog("DIFF: nodeName is different", node1, node2); break; } if (ignoreTag(node1.getNodeName())) { - diffLog("DIFF: Some tag(s) is ignored", node1, node2); + diffLog("DIFF: Some tag(s) is ignored", node1, node2); equal = true; break; } @@ -242,10 +242,10 @@ public final class XmlDiff { // empty } else if (node1.getNodeValue() == null || node2.getNodeValue() == null) { - diffLog("DIFF: one of the nodevalue is null", node1, node2); + diffLog("DIFF: one of the nodevalue is null", node1, node2); break; } else if (!node1.getNodeValue().equals(node2.getNodeValue())) { - diffLog("DIFF: nodeValue is different", node1, node2); + diffLog("DIFF: nodeValue is different", node1, node2); break; } @@ -263,12 +263,12 @@ public final class XmlDiff { } if (node1Children == null || node2Children == null) { - diffLog("DIFF: one node's children is null", node1, node2); + diffLog("DIFF: one node's children is null", node1, node2); break; } if (node1Children.getLength() != node2Children.getLength()) { - diffLog("DIFF: num of children is different", node1, node2); + diffLog("DIFF: num of children is different", node1, node2); break; } @@ -354,7 +354,7 @@ public final class XmlDiff { private String [] parseTags(String tagsString) { Vector tagsVector = new Vector(); - if (tagsString.length() == 0) + if (tagsString.length() == 0) return null; int start = 0; @@ -452,7 +452,7 @@ public final class XmlDiff { same = xmldiff.diff(); } - System.out.println("Diff result: " + same); + System.out.println("Diff result: " + same); if (same) { System.out.println("XMLDIFFRESULT:PASSED"); diff --git a/xmerge/source/palmtests/qa/comparator/XmlWrapper.java b/xmerge/source/palmtests/qa/comparator/XmlWrapper.java index 3ac485600580..16dddcb0a4f3 100644 --- a/xmerge/source/palmtests/qa/comparator/XmlWrapper.java +++ b/xmerge/source/palmtests/qa/comparator/XmlWrapper.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -31,14 +31,14 @@ import java.util.zip.*; public class XmlWrapper { - public static void main(String args[]) throws IOException + public static void main(String args[]) throws IOException { System.out.println("args.length is " + args.length); if (args.length < 2) { System.out.println("Usage: java XmlWrapper [<zipfile1> <zipfile2>]."); //return; System.exit(-1); - + } XmlWrapper w = new XmlWrapper(); @@ -120,7 +120,7 @@ public class XmlWrapper same = xmldiff.diff(); } } - catch (Exception ex) + catch (Exception ex) { System.out.println("XmlDiff failed"); System.out.println("Exception: " + ex.toString()); @@ -130,7 +130,7 @@ public class XmlWrapper System.exit(-1); } - System.out.println("Diff result: " + same); + System.out.println("Diff result: " + same); if (same) { System.out.println("XMLDIFFRESULT:PASSED"); diff --git a/xmerge/source/palmtests/qa/comparator/XmlZipExtract.java b/xmerge/source/palmtests/qa/comparator/XmlZipExtract.java index 8696a4e6d75c..2e47edd65160 100644 --- a/xmerge/source/palmtests/qa/comparator/XmlZipExtract.java +++ b/xmerge/source/palmtests/qa/comparator/XmlZipExtract.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -50,7 +50,7 @@ public class XmlZipExtract /** - * Constructor + * Constructor * * @param filename Full Path to Zip file to process * @@ -99,7 +99,7 @@ public class XmlZipExtract raf.write(b); raf.close(); } - + /** * Get the specified entry in the zip file as a stream. * @@ -110,7 +110,7 @@ public class XmlZipExtract * * @throws IOException if something goes wrong */ - public byte[] getEntry(String entryName) throws IOException + public byte[] getEntry(String entryName) throws IOException { ZipFile zf = new ZipFile(filename); ZipEntry ze = zf.getEntry(entryName); @@ -127,7 +127,7 @@ public class XmlZipExtract * * @return an array of Bytes */ - private byte[] readStream(InputStream is) throws IOException + private byte[] readStream(InputStream is) throws IOException { BufferedInputStream bis = new BufferedInputStream(is); ByteArrayOutputStream baos = new ByteArrayOutputStream(); diff --git a/xmerge/source/palmtests/qa/comparator/comparator.pl b/xmerge/source/palmtests/qa/comparator/comparator.pl index e4606281cff7..5ca4f2375689 100644 --- a/xmerge/source/palmtests/qa/comparator/comparator.pl +++ b/xmerge/source/palmtests/qa/comparator/comparator.pl @@ -5,7 +5,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -134,7 +134,7 @@ sub process_cmdline { @arg= split('=', $i); @arg[0] =~ tr/A-Z/a-z/; - + if (@arg[0] eq "-pdb-orig") { $pdb_orig=$arg[1]; @@ -183,7 +183,7 @@ sub process_cmdline sub set_env_from_props { open(PROPSFILE, $_[0]) || die "Could not open properties file"; - + while (<PROPSFILE>) { chomp $_; @@ -211,7 +211,7 @@ sub set_env_from_props { $xml_new=$arg[1]; } - + } close PROPSFILE; } @@ -220,8 +220,8 @@ sub print_usage { print "Usage : compartor.pl - compare Office or pdb files\n"; print "\t-one=<file> :\t\t individual test case file to run\n"; - print "\t-list=<file> :\t\t list of test case files\n"; - print "\t-env=<file> :\t\t Properites like file defining env\n"; + print "\t-list=<file> :\t\t list of test case files\n"; + print "\t-env=<file> :\t\t Properites like file defining env\n"; print "\t-pdb-orig=<path> :\t directory to hold original pdb files\n"; print "\t-pdb-new=<path> :\t directory to hold new pdb files\n"; print "\t-xml-orig=<path> :\t directory to hold original office documents\n"; diff --git a/xmerge/source/palmtests/qa/comparator/pdbcomparison.java b/xmerge/source/palmtests/qa/comparator/pdbcomparison.java index 25191c4e79a7..785abbad0e75 100644 --- a/xmerge/source/palmtests/qa/comparator/pdbcomparison.java +++ b/xmerge/source/palmtests/qa/comparator/pdbcomparison.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -42,7 +42,7 @@ public class pdbcomparison private String pdbarr1[]; private String pdbarr2[]; - + /** * Default Constructor @@ -72,7 +72,7 @@ public class pdbcomparison str += "********************************************************\n"; System.out.println(str); - + } /** @@ -81,7 +81,7 @@ public class pdbcomparison * output file and updates the array pdbarr1 and pdbarr2 with * list of pdb's to be compared. * - * @param propFile Property filename which list the log/outputfile/list/pdb + * @param propFile Property filename which list the log/outputfile/list/pdb * names * @return * @@ -98,7 +98,7 @@ public class pdbcomparison System.out.println("Could not open Property File " + propFile); return; } - + String logFile = defaultProps.getProperty(this.LOGTAG); String outFile = defaultProps.getProperty(this.OUTTAG); @@ -114,10 +114,10 @@ public class pdbcomparison } if (logFile == null || logFile.length() == 0) - logFile = this.LOGFILE; + logFile = this.LOGFILE; if (outFile == null || outFile.length() == 0) - outFile = this.LOGFILE; + outFile = this.LOGFILE; // validate log and output files @@ -126,7 +126,7 @@ public class pdbcomparison LOGFILE = logFile; OUTFILE = outFile; - System.out.println("Output is written to log file... " + LOGFILE); + System.out.println("Output is written to log file... " + LOGFILE); if (listFile != null) { if (! checkFile(listFile)) return; @@ -144,7 +144,7 @@ public class pdbcomparison * Also validates permissions to create. * * @param filename name of file to be created - * @return true, if file could be created + * @return true, if file could be created * false, if could not. * */ @@ -171,7 +171,7 @@ public class pdbcomparison return false; } - if (newF.exists()) + if (newF.exists()) { try { newF.delete(); @@ -210,9 +210,9 @@ public class pdbcomparison } } - + return true; - + } /** @@ -246,25 +246,25 @@ public class pdbcomparison System.out.println("Cannot read file " + filename); return false; } - + return true; - + } /** - * This method populates the pdb arrays with the names of the pdbs to + * This method populates the pdb arrays with the names of the pdbs to * compare. Ths listFile lists a series of entries, wherein each * line indicates the PDB names to be compared. * <pdbname1>=<pdbname2> - * + * * @param listFile name of the listfile - * @return + * @return * */ private void populatePDBArray(String listFile) { // open ListFile and populate the PDB list to be compared - if (listFile != null) + if (listFile != null) { Properties listProps = new Properties(); try { @@ -275,7 +275,7 @@ public class pdbcomparison System.out.println("Could not open List File " + listFile); return; } - + pdbarr1 = new String[listProps.size()]; pdbarr2 = new String[listProps.size()]; Enumeration e = listProps.keys(); @@ -283,7 +283,7 @@ public class pdbcomparison while (e.hasMoreElements()) { pdbarr1[j] = (String)e.nextElement(); - pdbarr2[j] = listProps.getProperty(pdbarr1[j]); + pdbarr2[j] = listProps.getProperty(pdbarr1[j]); j++; } @@ -291,12 +291,12 @@ public class pdbcomparison } /** - * This method populates the pdb arrays with the names of the pdbs to - * compare. - * + * This method populates the pdb arrays with the names of the pdbs to + * compare. + * * @param pdbname1 Name of 2nd PDB file to be compared * @param pdbname2 Name of 2nd PDB file to be compared - * @return + * @return * */ private void populatePDBArray(String pdbname1, String pdbname2) @@ -304,7 +304,7 @@ public class pdbcomparison if (pdbname1 == null) return; if (pdbname2 == null) return; - if ((pdbname1 != null) && (pdbname2 != null)) + if ((pdbname1 != null) && (pdbname2 != null)) { pdbarr1 = new String[1]; pdbarr2 = new String[1]; @@ -315,11 +315,11 @@ public class pdbcomparison } /** - * This method populates the pdb arrays with the names of the pdbs to - * compare. - * - * @param arrayno Array number which corresponds to the pdb array - * containing list of pdbs + * This method populates the pdb arrays with the names of the pdbs to + * compare. + * + * @param arrayno Array number which corresponds to the pdb array + * containing list of pdbs * If 1 then send pdbarr1, if 2 send pdbarr2 else null * * @return PDB string array containing list of PDB's @@ -364,13 +364,13 @@ public class pdbcomparison if (pdb1.equals(pdb2)) { writeToLog("PDB " + pdbname1 + " and PDB " + pdbname2 + " are equal"); - + return true; } else { writeToLog("PDB " + pdbname1 + " and PDB " + pdbname2 + " are not equal"); return false; } - } + } @@ -378,7 +378,7 @@ public class pdbcomparison * Write message to LOGFILE * * @param msg Message to be written to log file - * @return + * @return * */ private void writeToLog(String msg) @@ -403,7 +403,7 @@ public class pdbcomparison System.out.println("ERROR: Could not write to File " + LOGFILE); return; } - } + } /** * Write status of comparison to OUTFILE @@ -412,7 +412,7 @@ public class pdbcomparison * @param pdbname1 file name of pdb which was compared. * @param pdbname2 file name of pdb which was compared. * - * @return + * @return * */ private void writeToOutputFile(String status, String pdbname1, String pdbname2) @@ -435,7 +435,7 @@ public class pdbcomparison try { long len = raf.length(); raf.seek(len); - + raf.write(msg.getBytes()); raf.write("\n".getBytes()); } catch (IOException e) { @@ -450,7 +450,7 @@ public class pdbcomparison return; } - } + } @@ -458,7 +458,7 @@ public class pdbcomparison * Main starting block of execution * * @param command line args captured in an array of Strings - * @return + * @return * */ public static void main(String args[]) @@ -469,16 +469,16 @@ public class pdbcomparison int nargs = args.length; int status=0; - if (nargs != 1) - { + if (nargs != 1) + { System.out.println("Incorrect no. of arguments passed..."); pdbcmp.usage(); System.exit(-1); - + } String propFile = args[0]; - + File f=null; try { f = new File(propFile); @@ -486,7 +486,7 @@ public class pdbcomparison System.out.println("Exception: Could not open file " + propFile); System.exit(-1); } - + if (! f.canRead()) { System.out.println("Exception: " + propFile + " is not a file "); System.exit(-1); @@ -497,16 +497,16 @@ public class pdbcomparison System.exit(-1); } - // parse Property file + // parse Property file pdbcmp.parsePropertyFile(propFile); String pdbarr1[] = pdbcmp.getPDBArray(1); String pdbarr2[] = pdbcmp.getPDBArray(2); - if ( (pdbarr1 == null) || + if ( (pdbarr1 == null) || (pdbarr2 == null) || - (pdbarr1.length == 0) || + (pdbarr1.length == 0) || (pdbarr1.length == 0)) - { + { System.out.println("pdbArray is empty. No PDBS to compare... \n"); System.exit(-1); } @@ -536,7 +536,7 @@ public class pdbcomparison pdbcmp.writeToLog("PDB Comparison: end time " + endTime); pdbcmp.writeToLog("************** End *****************n"); pdbcmp.writeToLog("\n"); - + System.exit(status); } } diff --git a/xmerge/source/palmtests/qa/lib/converterlib.pm b/xmerge/source/palmtests/qa/lib/converterlib.pm index 66d5869c42c1..d4e4eb6ea649 100644 --- a/xmerge/source/palmtests/qa/lib/converterlib.pm +++ b/xmerge/source/palmtests/qa/lib/converterlib.pm @@ -4,7 +4,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -60,7 +60,7 @@ $em_script_home = $ENV{'EM_SCRIPT_HOME'}; # # convert_to_pdb -# directory - directory containing the xml-orig and pdb-orig +# directory - directory containing the xml-orig and pdb-orig # subdirectories. # file - file to convert # extension - extension of file to convert (sxw or sxc) @@ -227,10 +227,10 @@ sub convert_to_xml &start_rd($convert_from, $extension, $pdbfile, "$xmldir/$output.$extension"); - + # No need to move the file to the $xmldir since the merge # argument specifies the output file. - + my $check_stamp_update = (stat("$xmldir/$output.$extension"))[9]; if ($check_stamp eq $check_stamp_update) { @@ -243,7 +243,7 @@ sub convert_to_xml &start_rd($convert_from, $extension, $pdbfile, ""); print "Moving $output.$extension to $xmldir\n"; - `mv $output.$extension $xmldir`; + `mv $output.$extension $xmldir`; `chmod 666 $xmldir/$output.$extension`; } } @@ -258,7 +258,7 @@ sub convert_to_xml # to - format to convert to # file - file to convert # merge - merge filename ("" indicates convert-only with no merge) -# +# # converts file from/to the specified formats. # sub start_rd @@ -333,7 +333,7 @@ sub close_connection # pose_exe - name of pose executable. # apps_load - The PRC files to load into pose, can be a comma # separated list. -# run_prog - Program to run at startup. +# run_prog - Program to run at startup. # timeout - Timeout value to use when starting pose. # # Starts the Palm OS Emulator, loads PRC files, and starts @@ -409,7 +409,7 @@ sub start_pose &open_connection(1); print "\nChecking if the appropriate window is on screen...\n"; } - + # Stop looping when the specified window has started. # for ($i=0; $i < $timeout && $stay_in_loop == 1; $i++) @@ -579,7 +579,7 @@ sub quickword_press_write_protect &print_debug(" top = $bounds{top}\n"); &print_debug(" bottom = $bounds{bottom}\n"); } - + # For some reason, the tapping of the write-protect button # doesn't work unless you tap somewhere else first. # @@ -598,14 +598,14 @@ sub quickword_press_write_protect # # Uses QuickWord's find/replace utility to replace # one string with another. -# +# sub quickword_find_replace { my $from_string = $_[0]; my $to_string = $_[1]; &enter_func("quickword_find_replace"); - + # Move cursor to beginning... # &quickword_tap_at_top(1); @@ -734,12 +734,12 @@ sub minicalc_enter_cell } # Tap pen on home button to start with row=1, col=A - # at top left. + # at top left. # pose_tap_pen(1, 1, 3); # Now the cell should be in the top-left corner, - # so click there. However we must first click + # so click there. However we must first click # in another cell or pose doesn't acknowledge the # click. # @@ -867,7 +867,7 @@ sub enter_string_at_location } } - # Just to make sure the offset isn't outside the + # Just to make sure the offset isn't outside the # proper area. # if ($x >= 100) @@ -889,10 +889,10 @@ sub enter_string_at_location # x - x-location to tap # y - y-location to tap # offset - x-offset to use for first tap. -# +# # For some reason, pose does not register a single # pen tap if the last single pen tap was also -# at the same x,y coordinate (even if the last tap +# at the same x,y coordinate (even if the last tap # was a while ago). So this function does two # slightly different pen taps to ensure then pen # tap happens. @@ -926,7 +926,7 @@ sub enter_string my $j; &enter_func("enter_string"); - + if ($global_debug) { # Display in_string so \n and \t values diff --git a/xmerge/source/pexcel/build.xml b/xmerge/source/pexcel/build.xml index a1be99f6c2ff..caaf8cefbfcd 100644 --- a/xmerge/source/pexcel/build.xml +++ b/xmerge/source/pexcel/build.xml @@ -3,23 +3,23 @@ #************************************************************************* # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - + Copyright 2000, 2010 Oracle and/or its affiliates. - + OpenOffice.org - a multi-platform office productivity suite - + This file is part of OpenOffice.org. - + OpenOffice.org is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. - + OpenOffice.org is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details (a copy is included in the LICENSE file that accompanied this code). - + You should have received a copy of the GNU Lesser General Public License version 3 along with OpenOffice.org. If not, see <http://www.openoffice.org/license.html> @@ -27,11 +27,11 @@ #************************************************************************* --> - + <project name="pexcel" default="all" basedir="."> - + <property file="../inc/antbuild.properties"/> - + <path id="classpath"> <pathelement location="${build.dir}/xmerge.jar"/> </path> @@ -51,7 +51,7 @@ <classpath refid="classpath"/> </javac> </target> - + <!-- package to jar --> <target name="jar" depends="compile"> <jar destfile="${target.jar}"> @@ -68,9 +68,9 @@ <delete dir="${class.dir}"/> <delete file="${target.jar}"/> </target> - + <target name="all" depends="jar"> </target> - + </project> diff --git a/xmerge/source/pexcel/converter.xml b/xmerge/source/pexcel/converter.xml index 0a49d5e73046..205f60ef59d5 100644 --- a/xmerge/source/pexcel/converter.xml +++ b/xmerge/source/pexcel/converter.xml @@ -3,23 +3,23 @@ #************************************************************************* # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - + Copyright 2000, 2010 Oracle and/or its affiliates. - + OpenOffice.org - a multi-platform office productivity suite - + This file is part of OpenOffice.org. - + OpenOffice.org is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. - + OpenOffice.org is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details (a copy is included in the LICENSE file that accompanied this code). - + You should have received a copy of the GNU Lesser General Public License version 3 along with OpenOffice.org. If not, see <http://www.openoffice.org/license.html> @@ -30,7 +30,7 @@ <converters> <converter type="staroffice/sxc" version="1.0"> <converter-display-name> - Pocket Excel 2.0 + Pocket Excel 2.0 </converter-display-name> <converter-description> StarCalc XML to/from Pocket Excel 2.0 conversion diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/ConverterCapabilitiesImpl.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/ConverterCapabilitiesImpl.java index 140e18d5f9ab..c39b95a173ad 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/ConverterCapabilitiesImpl.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/ConverterCapabilitiesImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PluginFactoryImpl.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PluginFactoryImpl.java index b32000e8447b..3b45b2bf680c 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PluginFactoryImpl.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PluginFactoryImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -102,7 +102,7 @@ public final class PluginFactoryImpl extends SxcPluginFactory * which is an implementation of <code>DocumentDeserializer</code> * interface. * - * @param cd <code>ConvertData</code> object for reading data + * @param cd <code>ConvertData</code> object for reading data * which will be converted back to a * <code>Document</code> object. * diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelConstants.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelConstants.java index 4223ee857082..13f73f18fdae 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelConstants.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelConstants.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -31,7 +31,7 @@ package org.openoffice.xmerge.converter.xml.sxc.pexcel; /** * Interface defining constants for Pocket Excel attributes. * - * @author Martin Maher + * @author Martin Maher */ public interface PocketExcelConstants { /** File extension for Pocket Word files. */ @@ -59,9 +59,9 @@ public interface PocketExcelConstants { public static final int DEF_COL_WIDTH = 0x55; public static final int COLINFO = 0x7D; public static final int BOUND_SHEET = 0x85; - public static final int EXTENDED_FORMAT = 0xE0; + public static final int EXTENDED_FORMAT = 0xE0; - /** Colour lookup table for mapping pexcel color values + /** Colour lookup table for mapping pexcel color values (See util/ColourConverter.java */ public short cLookup[] = { 0, 14, 15, 1, 2, 3, 4, 7, 6, 5, 8, 9, 10, 13, 12, 11 }; } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelDecoder.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelDecoder.java index 104924abfa66..dbfc43a64cd6 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelDecoder.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelDecoder.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -50,7 +50,7 @@ import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.*; * @author Paul Rank */ final class PocketExcelDecoder extends SpreadsheetDecoder { - + private Workbook wb; private Worksheet ws; private CellValue cell; @@ -63,15 +63,15 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { /** * Constructor creates a Pocket Excel WorkBook. * - * @param name The name of the WorkBook. - * @param worksheetNames set of Strings equivalent to the worksheets - * contained in the workbook - * @param password The password for the workBook. + * @param name The name of the WorkBook. + * @param worksheetNames set of Strings equivalent to the worksheets + * contained in the workbook + * @param password The password for the workBook. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ PocketExcelDecoder(String name, String[] worksheetNames, String password) throws IOException { - super(name, password); + super(name, password); fmt = new Format(); } @@ -88,7 +88,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { * @throws IOException If any I/O error occurs. */ public void addDeviceContent(ConvertData cd) throws IOException { - + Enumeration e = cd.getDocumentEnumeration(); wb = (Workbook) e.nextElement(); } @@ -119,23 +119,23 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { Vector nameDefinitionVector = new Vector(); while(e.hasMoreElements()) { DefinedName dn = (DefinedName)e.nextElement(); - NameDefinition nameDefinitionEntry = dn.getNameDefinition(); + NameDefinition nameDefinitionEntry = dn.getNameDefinition(); nameDefinitionVector.add(nameDefinitionEntry); } Debug.log(Debug.TRACE,"Getting " + nameDefinitionVector.size() + " DefinedName records"); return (nameDefinitionVector.elements()); } - + /** * This method returns an enumeration of Settings object(s), * one for each worksheet * - * @return An enumerattion of <code>Settings</code> + * @return An enumerattion of <code>Settings</code> */ public BookSettings getSettings() { return (wb.getSettings()); - } + } /** * This method returns the number of spreadsheets * stored in the WorkBook. @@ -150,7 +150,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { for(Enumeration e = ws.getColInfos();e.hasMoreElements();) { ColInfo ci = (ColInfo)e.nextElement(); int repeated = ci.getLast() - ci.getFirst() + 1; - ColumnRowInfo colInfo = new ColumnRowInfo( ci.getColWidth(), + ColumnRowInfo colInfo = new ColumnRowInfo( ci.getColWidth(), repeated, ColumnRowInfo.COLUMN); colRowVector.add(colInfo); @@ -159,18 +159,18 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { // Collect Rows from worksheet and add them to the vector for(Enumeration e = ws.getRows();e.hasMoreElements();) { Row rw = (Row)e.nextElement(); - // We will use the repeat field for number (unlike columns rows + // We will use the repeat field for number (unlike columns rows // cannot be repeated, we have unique record for each row in pxl - int repeated = rw.getRowNumber(); - ColumnRowInfo rowInfo = new ColumnRowInfo( rw.getRowHeight(), + int repeated = rw.getRowNumber(); + ColumnRowInfo rowInfo = new ColumnRowInfo( rw.getRowHeight(), repeated, ColumnRowInfo.ROW); colRowVector.add(rowInfo); - } + } Debug.log(Debug.TRACE,"Getting " + colRowVector.size() + " ColRowInfo records"); return (colRowVector.elements()); } - + /** * This method gets the requested WorkSheet from the * WorkBook and sets it as the selected WorkSheet. All @@ -201,9 +201,9 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { */ public String getSheetName() { - String wsName = wb.getSheetName(wsIndex); + String wsName = wb.getSheetName(wsIndex); Debug.log(Debug.TRACE,"The name of the current Worksheet is : " + wsName); - return wsName; + return wsName; } @@ -242,7 +242,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { * -1 if no cell is currently selected. */ public int getRowNumber() { - + int row = -1; if (cell != null) { @@ -269,7 +269,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { public int getNumberOfColumns() { return maxCols; } - + /** * This method returns the col number of the current cell. @@ -278,7 +278,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { * -1 if no cell is currently selected. */ public int getColNumber() { - + int col = -1; if (cell != null) { @@ -295,7 +295,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { * null if no cell is currently selected. */ public String getCellContents() { - + String contents = new String(""); if (cell != null) { @@ -307,7 +307,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { } catch (IOException e) { System.err.println("Could Not retrieve Cell contents"); - System.err.println("Setting contents of cell(" + cell.getRow() + System.err.println("Setting contents of cell(" + cell.getRow() + "," + cell.getCol() + ") to an empty string"); System.err.println("Error msg: " + e.getMessage()); } @@ -323,7 +323,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { * <p>Many spreadsheets use ',' as a separator. * StarOffice XML format uses ';' as a separator instead.</p> * - * <p>Many spreadsheets use '!' as a separator when refencing + * <p>Many spreadsheets use '!' as a separator when refencing * a cell in a different sheet.</p> * * <blockquote> @@ -346,7 +346,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { formula = formula.replace('!', '.'); return formula; - } + } /** * This method returns the contents of the current cell. @@ -355,7 +355,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { * null if no cell is currently selected. */ public String getCellValue() { - + String contents = new String(""); if (cell != null) { @@ -364,7 +364,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { } catch (IOException e) { System.err.println("Could Not retrieve Cell value"); - System.err.println("Setting value of cell(" + cell.getRow() + System.err.println("Setting value of cell(" + cell.getRow() + "," + cell.getCol() + ") to an empty string"); System.err.println("Error msg: " + e.getMessage()); } @@ -380,8 +380,8 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { */ public String getCellDataType() { - String type = OfficeConstants.CELLTYPE_STRING; - + String type = OfficeConstants.CELLTYPE_STRING; + if(cell instanceof FloatNumber) type = OfficeConstants.CELLTYPE_FLOAT; if(cell instanceof Formula) @@ -400,7 +400,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { return new Format(fmt); } - + /** * Create the format data for the new cell. */ @@ -421,18 +421,18 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { fmt.setBackground(xf.getBackground()); fmt.setAlign(xf.getAlign()); fmt.setVertAlign(xf.getVertAlign()); - fmt.setAttribute(Format.WORD_WRAP, xf.isWordWrap()); - - fmt.setAttribute(Format.TOP_BORDER, xf.isBorder(ExtendedFormat.TOP_BORDER)); - fmt.setAttribute(Format.BOTTOM_BORDER, xf.isBorder(ExtendedFormat.BOTTOM_BORDER)); - fmt.setAttribute(Format.RIGHT_BORDER, xf.isBorder(ExtendedFormat.RIGHT_BORDER)); - fmt.setAttribute(Format.LEFT_BORDER, xf.isBorder(ExtendedFormat.LEFT_BORDER)); + fmt.setAttribute(Format.WORD_WRAP, xf.isWordWrap()); + + fmt.setAttribute(Format.TOP_BORDER, xf.isBorder(ExtendedFormat.TOP_BORDER)); + fmt.setAttribute(Format.BOTTOM_BORDER, xf.isBorder(ExtendedFormat.BOTTOM_BORDER)); + fmt.setAttribute(Format.RIGHT_BORDER, xf.isBorder(ExtendedFormat.RIGHT_BORDER)); + fmt.setAttribute(Format.LEFT_BORDER, xf.isBorder(ExtendedFormat.LEFT_BORDER)); fmt.setFontName(fd.getFont()); fmt.setFontSize(fd.getFontSize()); - + fmt.setCategory(getCellDataType()); - } + } } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelEncoder.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelEncoder.java index dbc710d17816..52ef18d252f0 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelEncoder.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelEncoder.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -43,7 +43,7 @@ import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; * org.openoffice.xmerge.converter.xml.sxc.SxcDocumentSerializerImpl * SxcDocumentSerializerImpl} to encode the Pocket Excel format. * - * @author Martin Maher + * @author Martin Maher */ final class PocketExcelEncoder extends SpreadsheetEncoder { @@ -58,7 +58,7 @@ final class PocketExcelEncoder extends SpreadsheetEncoder { * @throws IOException If any I/O error occurs. */ PocketExcelEncoder(String name, String password) throws IOException { - + super(name, password); wb = new Workbook(name); @@ -66,7 +66,7 @@ final class PocketExcelEncoder extends SpreadsheetEncoder { /** - * This method creates a WorkSheet belonging to the + * This method creates a WorkSheet belonging to the * WorkBook. * * @param sheetName The name of the WorkSheet. @@ -92,9 +92,9 @@ final class PocketExcelEncoder extends SpreadsheetEncoder { /** - * This method returns the Workbook created. + * This method returns the Workbook created. * - * @return Returns a <code>Workbook</code> + * @return Returns a <code>Workbook</code> * * @throws IOException If any I/O error occurs. */ @@ -107,12 +107,12 @@ final class PocketExcelEncoder extends SpreadsheetEncoder { * This method converts a String containing a formula in infix notation * to a String in Reverse Polish Notation (RPN) * - * @return a parsed pexcel formula in RPN + * @return a parsed pexcel formula in RPN */ protected String parseFormula(String formula) { Debug.log(Debug.TRACE,"Strip Formula (Before) : " + formula); - + StringBuffer inFormula = new StringBuffer(formula); StringBuffer outFormula = new StringBuffer(); @@ -142,7 +142,7 @@ final class PocketExcelEncoder extends SpreadsheetEncoder { case '.': if (inBrace == true && (firstCharAfterBrace == true || firstCharAfterColon == true) ) { - + Debug.log(Debug.TRACE,"dot Found and in brace"); // Since we are in a StarOffice cell reference, // and we are the first character, we need to @@ -155,17 +155,17 @@ final class PocketExcelEncoder extends SpreadsheetEncoder { } else { outFormula.append(inFormula.charAt(in)); } - break; - + break; + case ':': - // We have a cell range reference. + // We have a cell range reference. // May need to strip out the leading '.' firstCharAfterColon = true; outFormula.append(inFormula.charAt(in)); - break; + break; case ';': - // StarOffice XML format uses ';' as a separator. MiniCalc (and + // StarOffice XML format uses ';' as a separator. MiniCalc (and // many spreadsheets) use ',' as a separator instead. outFormula.append(','); break; @@ -203,7 +203,7 @@ final class PocketExcelEncoder extends SpreadsheetEncoder { } wb.addCell(row, column, fmt, cellContents); } - + /** * Set the width of the columns in the WorkBook. @@ -228,8 +228,8 @@ final class PocketExcelEncoder extends SpreadsheetEncoder { nd.setDefinition(parseFormula(parsedName)); wb.addNameDefinition(nd); - } - + } + /** * Set the width of the columns in the WorkBook. * @@ -240,7 +240,7 @@ final class PocketExcelEncoder extends SpreadsheetEncoder { wb.addSettings(s); } - + /** * This method sets the format of a cell to <i>string</i>. * @@ -269,7 +269,7 @@ final class PocketExcelEncoder extends SpreadsheetEncoder { ",Italic : " + fmt.getAttribute(Format.ITALIC) + ",Underline : " + fmt.getAttribute(Format.UNDERLINE)); } - + /** * Get the names of the sheets in the WorkBook. @@ -280,10 +280,10 @@ final class PocketExcelEncoder extends SpreadsheetEncoder { Vector v = wb.getWorksheetNames(); String wsName = (String) (v.elementAt(sheet)); - - return wsName; + + return wsName; } - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentDeserializerImpl.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentDeserializerImpl.java index d0f3880bff2d..e95a6aa41e19 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentDeserializerImpl.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentDeserializerImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -76,7 +76,7 @@ public final class SxcDocumentDeserializerImpl extends SxcDocumentDeserializer { return new PocketExcelDecoder(workbook, worksheetNames, password); } - + /** * This method will return the name of the WorkBook from the @@ -88,18 +88,18 @@ public final class SxcDocumentDeserializerImpl extends SxcDocumentDeserializer { * * @param cd The <code>ConvertData</code>. * - * @return The name of the WorkBook. + * @return The name of the WorkBook. */ - protected String getWorkbookName(ConvertData cd) + protected String getWorkbookName(ConvertData cd) throws IOException { Enumeration e = cd.getDocumentEnumeration(); Workbook wb = (Workbook) e.nextElement(); String workbookName = wb.getName(); - return workbookName; + return workbookName; } - + /** * This method will return an array of WorkSheet names from the @@ -107,9 +107,9 @@ public final class SxcDocumentDeserializerImpl extends SxcDocumentDeserializer { * * @param cd The <code>ConvertData</code>. * - * @return The name of the WorkSheet. + * @return The name of the WorkSheet. */ - protected String[] getWorksheetNames(ConvertData cd) + protected String[] getWorksheetNames(ConvertData cd) throws IOException { Enumeration e = cd.getDocumentEnumeration(); @@ -123,7 +123,7 @@ public final class SxcDocumentDeserializerImpl extends SxcDocumentDeserializer { Debug.log(Debug.TRACE,"Worksheet Name : " + worksheetNames[i]); i++; } - return worksheetNames; + return worksheetNames; } } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentSerializerImpl.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentSerializerImpl.java index 29b76b0bb418..26d4546bd369 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentSerializerImpl.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentSerializerImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -39,7 +39,7 @@ import org.openoffice.xmerge.converter.xml.sxc.SxcDocumentSerializer; import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; /** - * <p>Pocket Excel implementation of <code>SxcDocumentDeserializer</code> + * <p>Pocket Excel implementation of <code>SxcDocumentDeserializer</code> * for the {@link * org.openoffice.xmerge.converter.xml.sxc.pexcel.PluginFactoryImpl * PluginFactoryImpl}.</p> @@ -62,7 +62,7 @@ public final class SxcDocumentSerializerImpl extends SxcDocumentSerializer { super(document); } - + public ConvertData serialize() throws ConvertException, IOException { // Get the server side document name. This value should not @@ -90,7 +90,7 @@ public final class SxcDocumentSerializerImpl extends SxcDocumentSerializer { traverseBody(node); } - // get settings for this document + // get settings for this document org.w3c.dom.Document settingsDoc = sxcDoc.getSettingsDOM(); if(settingsDoc!=null) { NodeList settingsList = settingsDoc.getElementsByTagName(TAG_OFFICE_SETTINGS); @@ -110,7 +110,7 @@ public final class SxcDocumentSerializerImpl extends SxcDocumentSerializer { return cd; } - + /** * A cell reference in a StarOffice formula looks like diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BIFFRecord.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BIFFRecord.java index 54c8f23e3737..190cb0925c21 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BIFFRecord.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BIFFRecord.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -38,24 +38,24 @@ import java.io.IOException; * designated with a byte value. See @link PocketExcelBiffConstants * for a list of the BIFF constants and what they mean. * - * @return byte The BIFF record value. + * @return byte The BIFF record value. */ public short getBiffType(); - + /** - * Read from the input stream <b>NB</b>The input stream is assumed to be in + * Read from the input stream <b>NB</b>The input stream is assumed to be in * Little Endian format. The Biff identifier is expected to be in the stream. * * @param input The InputStream to read from. * @return The number of bytes that were read in. */ public int read(InputStream input) throws IOException; - + /** * Writes the record, including the BIFF record byte to the outputstream * @param output The output stream to write to in LittleEndian format. */ public void write(OutputStream output) throws IOException; - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BeginningOfFile.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BeginningOfFile.java index a58635b9f278..df45b708d89c 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BeginningOfFile.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BeginningOfFile.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -36,21 +36,21 @@ import org.openoffice.xmerge.util.EndianConverter; import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; /** - * This class describes the beginning of file. It is the + * This class describes the beginning of file. It is the * the Biff record that marks the beginning of a a worbook * or the beginning of worksheets in the workbook * */ public class BeginningOfFile implements BIFFRecord { - + private byte[] version = new byte[2]; private byte[] subStream = new byte[2]; - + /** * Constructor that initializes the member values. * - * @param ver Version Number - * Substream type (workbook = 0x05, worksheet = 0x10) + * @param ver Version Number + * Substream type (workbook = 0x05, worksheet = 0x10) */ public BeginningOfFile(boolean global) { setVersion((short) 271); @@ -68,45 +68,45 @@ public class BeginningOfFile implements BIFFRecord { private void setVersion(short version) { this.version = EndianConverter.writeShort(version); } - + int getVersion() { return EndianConverter.readShort(version); } - + private void setSubStreamWBGlobal() { // subStream = new byte[] {0x05}; subStream = EndianConverter.writeShort((short) 0x05); } - + private void setSubStreamWorkSheet() { // subStream = new byte[] {0x10}; subStream = EndianConverter.writeShort((short) 0x10); } - + int getSubStreamType() { return EndianConverter.readShort(subStream); } - + public int read(InputStream input) throws IOException { int numBytesRead = input.read(version); numBytesRead += input.read(subStream); - Debug.log(Debug.TRACE,"\tVersion : "+ EndianConverter.readShort(version) + + Debug.log(Debug.TRACE,"\tVersion : "+ EndianConverter.readShort(version) + " Stream : " + EndianConverter.readShort(subStream)); return numBytesRead; } - + public void write(OutputStream output) throws IOException { - + output.write(getBiffType()); output.write(version); output.write(subStream); Debug.log(Debug.TRACE, "Writing BeginningOfFile record"); } - + /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>BeginningOfFile</code> */ diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BlankCell.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BlankCell.java index 767a24c0f099..da826a8d9058 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BlankCell.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BlankCell.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -26,7 +26,7 @@ ************************************************************************/ package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - + import java.io.OutputStream; import java.io.InputStream; import java.io.IOException; @@ -36,36 +36,36 @@ import org.openoffice.xmerge.util.EndianConverter; import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; /** - * Represents a BIFF Record that describes a blank cell + * Represents a BIFF Record that describes a blank cell */ public class BlankCell extends CellValue { - + /** - * Constructs a BlankCell <code>InputStream</code> + * Constructs a BlankCell <code>InputStream</code> * - * @param is InputStream containing a BlankCell. + * @param is InputStream containing a BlankCell. */ public BlankCell(InputStream is) throws IOException { - read(is); + read(is); } - + /** * Constructs a <code>BlankCell</code> using specified attributes - * + * * @param row row number - * @param col column number - * @param cellContents contents of the cell + * @param col column number + * @param cellContents contents of the cell * @param ixfe font index - */ + */ public BlankCell(int row, int column, int ixfe) throws IOException { setRow(row); setCol(column); setIxfe(ixfe); } - + /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>BlankCell</code> */ @@ -81,35 +81,35 @@ public class BlankCell extends CellValue { output.write(ixfe); Debug.log(Debug.TRACE, "Writing BlankCell record"); - + } - + /** - * Reads a BlankCell <code>InputStream</code> + * Reads a BlankCell <code>InputStream</code> * - * @param is InputStream containing a BlankCell. + * @param is InputStream containing a BlankCell. */ public int read(InputStream input) throws IOException { - int numOfBytesRead = input.read(rw); - numOfBytesRead++; - col += input.read(); - numOfBytesRead += input.read(ixfe); + int numOfBytesRead = input.read(rw); + numOfBytesRead++; + col += input.read(); + numOfBytesRead += input.read(ixfe); - Debug.log(Debug.TRACE, "\tRow : "+ EndianConverter.readShort(rw) + + Debug.log(Debug.TRACE, "\tRow : "+ EndianConverter.readShort(rw) + " Column : " + col + - " ixfe : " + EndianConverter.readShort(ixfe)); - + " ixfe : " + EndianConverter.readShort(ixfe)); + return numOfBytesRead; } - + /** - * Gets the <code>String</code> representing the cells contents + * Gets the <code>String</code> representing the cells contents * * @return the <code>String</code> representing the cells contents */ public String getString() throws IOException { return (new String("")); - } + } } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoolErrCell.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoolErrCell.java index f07212f3506e..9a370ccd8a59 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoolErrCell.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoolErrCell.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -36,21 +36,21 @@ import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; /** - * Represents a BIFF Record that describes a Boolean or Error value + * Represents a BIFF Record that describes a Boolean or Error value */ public class BoolErrCell extends CellValue { private byte bBoolErr; private byte fError; - + /** * Constructs a BoolErrCell from arguments * * @param row row number - * @param col column number + * @param col column number * @param ixfe font index - * @param bBoolErr Boolean value or error value - * @param fError Boolean error flag + * @param bBoolErr Boolean value or error value + * @param fError Boolean error flag */ public BoolErrCell(int row, int column, int ixfe, int bBoolErr, int fError) throws IOException { @@ -59,35 +59,35 @@ public class BoolErrCell extends CellValue { this.fError = (byte)fError; setRow(row); setCol(column); - } - + } + /** - * Constructs a BoolErrCell from the <code>InputStream</code> + * Constructs a BoolErrCell from the <code>InputStream</code> * - * @param is InputStream containing a BoolErrCell + * @param is InputStream containing a BoolErrCell */ public BoolErrCell(InputStream is) throws IOException { - read(is); + read(is); } /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>BoolErrCEll</code> */ public short getBiffType() { return PocketExcelConstants.BOOLERR_CELL; - } + } /** * Writes a <code>BoolErrCell</code> to the specified <code>Outputstream</code> * - * @param os the <code>OutputStream</code> to write to - */ + * @param os the <code>OutputStream</code> to write to + */ public void write(OutputStream output) throws IOException { output.write(getBiffType()); - + super.write(output); output.write(bBoolErr); @@ -95,27 +95,27 @@ public class BoolErrCell extends CellValue { Debug.log(Debug.TRACE,"Writing BoolErrCell record"); } - + /** - * Reads a BoolErrCell from the <code>InputStream</code> + * Reads a BoolErrCell from the <code>InputStream</code> * - * @param is InputStream containing a BoolErrCell + * @param is InputStream containing a BoolErrCell */ public int read(InputStream input) throws IOException { int numOfBytesRead = super.read(input); - bBoolErr = (byte) input.read(); - fError = (byte) input.read(); - numOfBytesRead += 2; + bBoolErr = (byte) input.read(); + fError = (byte) input.read(); + numOfBytesRead += 2; Debug.log(Debug.TRACE, " bBoolErr : " + bBoolErr + - " fError : " + fError); + " fError : " + fError); return numOfBytesRead; } /** - * Gets the <code>String</code> representing the cells contents + * Gets the <code>String</code> representing the cells contents * * @return the <code>String</code> representing the cells contents */ diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoundSheet.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoundSheet.java index 4056808ffc99..679224634bfa 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoundSheet.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoundSheet.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -36,21 +36,21 @@ import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; /** - * Represents a BoundSheet Record which describes the name of a worksheet + * Represents a BoundSheet Record which describes the name of a worksheet */ public class BoundSheet implements BIFFRecord { - private byte reserved; - private byte cch; - private byte[] sheetName; - + private byte reserved; + private byte cch; + private byte[] sheetName; + /** * Constructs a pocket Excel Document assigns it the document name passed in * - * @param name name of the worksheet represented + * @param name name of the worksheet represented */ public BoundSheet(String name) throws IOException { - setSheetName(name); + setSheetName(name); reserved = 0; } @@ -58,24 +58,24 @@ public class BoundSheet implements BIFFRecord { * Constructs a pocket Excel Document from the * <code>InputStream</code> and assigns it the document name passed in * - * @param is InputStream containing a Pocket Excel Data file. + * @param is InputStream containing a Pocket Excel Data file. */ public BoundSheet(InputStream is) throws IOException { - read(is); + read(is); } /** * Sets the worksheet name. The sheetname length must be doubled as the - * String is stored in unicode format. + * String is stored in unicode format. * - * @param sheetname worksheet name + * @param sheetname worksheet name */ void setSheetName(String sheetName) throws IOException { - this.cch = (byte) sheetName.length(); - this.sheetName = new byte[cch*2]; - this.sheetName = sheetName.getBytes("UTF-16LE"); + this.cch = (byte) sheetName.length(); + this.sheetName = new byte[cch*2]; + this.sheetName = sheetName.getBytes("UTF-16LE"); } - + public String getSheetName() { String name; @@ -86,21 +86,21 @@ public class BoundSheet implements BIFFRecord { } return name; } - + /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>BoundSheet</code> */ public short getBiffType() { return PocketExcelConstants.BOUND_SHEET; - } - + } + /** * Write this particular <code>BIFFRecord</code> to the <code>OutputStream</code> * * @param ouput the <code>OutputStream</code> - */ + */ public void write(OutputStream output) throws IOException { output.write(getBiffType()); @@ -110,27 +110,27 @@ public class BoundSheet implements BIFFRecord { Debug.log(Debug.TRACE,"Writing BoundSheet record"); } - + /** * Reads a BoundSheet from the <code>InputStream</code> The byte array * must be twice the size of the String as it uses unicode. * - * @param is InputStream containing the record data + * @param is InputStream containing the record data */ public int read(InputStream input) throws IOException { - - reserved = (byte) input.read(); - cch = (byte) input.read(); + + reserved = (byte) input.read(); + cch = (byte) input.read(); int numOfBytesRead = 2; int strLen = cch*2; - sheetName = new byte[strLen]; - numOfBytesRead += input.read(sheetName, 0, strLen); - - Debug.log(Debug.TRACE,"\tReserved : "+ reserved + + sheetName = new byte[strLen]; + numOfBytesRead += input.read(sheetName, 0, strLen); + + Debug.log(Debug.TRACE,"\tReserved : "+ reserved + " cch : " + cch + - " sheetName : " + new String(sheetName,"UTF-16LE")); + " sheetName : " + new String(sheetName,"UTF-16LE")); return numOfBytesRead; } - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CellValue.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CellValue.java index cdfb47e505ac..c09cde5a32c1 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CellValue.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CellValue.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -36,31 +36,31 @@ import org.openoffice.xmerge.util.EndianConverter; public abstract class CellValue implements BIFFRecord { - protected byte[] rw = new byte[2]; + protected byte[] rw = new byte[2]; protected byte col; protected byte[] ixfe = new byte[2]; - + /** - * Get the row number of this cell + * Get the row number of this cell * - * @return the row number of this cell + * @return the row number of this cell */ public int getRow() { return EndianConverter.readShort(rw) + 1; } /** - * Set the row number of this cell + * Set the row number of this cell * - * @param row sets the row number for this cell + * @param row sets the row number for this cell */ public void setRow(int row) { this.rw = EndianConverter.writeShort((short) (row - 1)); } /** - * Get the Index to the <code>ExtendedFormat</code> + * Get the Index to the <code>ExtendedFormat</code> * - * @return the index number of this cell's <code>ExtendedFormat</code> + * @return the index number of this cell's <code>ExtendedFormat</code> */ public int getIxfe() { return EndianConverter.readShort(ixfe); @@ -76,27 +76,27 @@ public abstract class CellValue implements BIFFRecord { } /** - * Get the column number of this cell + * Get the column number of this cell * - * @return the column number of this cell + * @return the column number of this cell */ public int getCol() { - return col + 1; // The cols start at 1 + return col + 1; // The cols start at 1 } /** - * Set the row number of this cell + * Set the row number of this cell * - * @param col sets the row number for this cell + * @param col sets the row number for this cell */ public void setCol(int col) { - this.col = (byte) (col - 1); // The cols start at 1 + this.col = (byte) (col - 1); // The cols start at 1 } /** * Writes basic cell value attributes to the specified <code>Outputstream</code> * - * @param os the <code>OutputStream</code> to write to + * @param os the <code>OutputStream</code> to write to */ public void write(OutputStream output) throws IOException { @@ -108,29 +108,29 @@ public abstract class CellValue implements BIFFRecord { /** * Writes a<code>LabelCell</code> to the specified <code>Outputstream</code> * - * @param os the <code>OutputStream</code> to write to + * @param os the <code>OutputStream</code> to write to */ public int read(InputStream input) throws IOException { - int numOfBytesRead = input.read(rw); - col += input.read(); + int numOfBytesRead = input.read(rw); + col += input.read(); numOfBytesRead++; - numOfBytesRead += input.read(ixfe); - - Debug.log(Debug.TRACE, "\tRow : "+ EndianConverter.readShort(rw) + + numOfBytesRead += input.read(ixfe); + + Debug.log(Debug.TRACE, "\tRow : "+ EndianConverter.readShort(rw) + " Column : " + col + - " ixfe : " + EndianConverter.readShort(ixfe)); - - return numOfBytesRead; + " ixfe : " + EndianConverter.readShort(ixfe)); + + return numOfBytesRead; } - - + + /** * Returns the contents of the cell as a String * - * @return the contents of the cell + * @return the contents of the cell */ abstract public String getString() throws IOException; - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CodePage.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CodePage.java index 6049b1de478e..91186fa27c3c 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CodePage.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CodePage.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -45,52 +45,52 @@ public class CodePage implements BIFFRecord { private byte[] unknown1 = new byte[2]; private byte[] unknown2 = new byte[2]; private byte unknown3; - + /** - * Constructs a pocket Excel Codepage + * Constructs a pocket Excel Codepage */ public CodePage() { - codepage = new byte[] {(byte)0xE4, (byte)0x04}; - unknown1 = new byte[] {(byte)0x8C, (byte)0x01}; - unknown2 = new byte[] {(byte)0x00, (byte)0x01}; - unknown3 = 0x00; + codepage = new byte[] {(byte)0xE4, (byte)0x04}; + unknown1 = new byte[] {(byte)0x8C, (byte)0x01}; + unknown2 = new byte[] {(byte)0x00, (byte)0x01}; + unknown3 = 0x00; } /** - * Constructs a pocket Excel Codepage from the<code>InputStream</code> + * Constructs a pocket Excel Codepage from the<code>InputStream</code> * - * @param is InputStream containing a Pocket Excel Data file. + * @param is InputStream containing a Pocket Excel Data file. */ public CodePage(InputStream is) throws IOException { - read(is); + read(is); } /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>BoundSheet</code> */ public short getBiffType() { return PocketExcelConstants.CODEPAGE; } - + public int read(InputStream input) throws IOException { - int numOfBytesRead = input.read(codepage); - numOfBytesRead += input.read(unknown1); - numOfBytesRead += input.read(unknown2); - // numOfBytesRead += input.read(unknown3); - unknown3 = (byte) input.read(); + int numOfBytesRead = input.read(codepage); + numOfBytesRead += input.read(unknown1); + numOfBytesRead += input.read(unknown2); + // numOfBytesRead += input.read(unknown3); + unknown3 = (byte) input.read(); numOfBytesRead++; - - Debug.log(Debug.TRACE,"\tcodepage : "+ EndianConverter.readShort(codepage) + - " unknown1 : " + EndianConverter.readShort(unknown1) + - " unknown2 : " + EndianConverter.readShort(unknown2) + - " unknown3 : " + unknown3); + + Debug.log(Debug.TRACE,"\tcodepage : "+ EndianConverter.readShort(codepage) + + " unknown1 : " + EndianConverter.readShort(unknown1) + + " unknown2 : " + EndianConverter.readShort(unknown2) + + " unknown3 : " + unknown3); return numOfBytesRead; } - + public void write(OutputStream output) throws IOException { output.write(getBiffType()); @@ -101,7 +101,7 @@ public class CodePage implements BIFFRecord { Debug.log(Debug.TRACE,"Writing CodePage record"); - + } - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ColInfo.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ColInfo.java index ea6b4721fb77..6ce59c7ca72c 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ColInfo.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ColInfo.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -36,34 +36,34 @@ import org.openoffice.xmerge.util.EndianConverter; import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; /** - * ColInfo describes the formatting for a column + * ColInfo describes the formatting for a column * */ public class ColInfo implements BIFFRecord { - private byte[] colFirst = new byte[2]; // first column this formatting applies to - private byte[] colLast = new byte[2]; // last column this formatting applies to - private byte[] colDX = new byte[2]; // column width - private byte[] ixfe = new byte[2]; // index for formatting - private byte grbit; // options flags - private float scale = (float) 2.5; // 1.798; - + private byte[] colFirst = new byte[2]; // first column this formatting applies to + private byte[] colLast = new byte[2]; // last column this formatting applies to + private byte[] colDX = new byte[2]; // column width + private byte[] ixfe = new byte[2]; // index for formatting + private byte grbit; // options flags + private float scale = (float) 2.5; // 1.798; + /** * Constructs a pocket Excel Document from the * <code>InputStream</code> and assigns it the document name passed in * - * @param colFirst the first column this formatting applies to - * @param colLast last column this formatting applies to - * @param coldx column width - * @param grbit options flags + * @param colFirst the first column this formatting applies to + * @param colLast last column this formatting applies to + * @param coldx column width + * @param grbit options flags */ public ColInfo(int colFirst, int colLast, int colDX, int ixfe) { - this.colFirst = EndianConverter.writeShort((short)colFirst); - this.colLast = EndianConverter.writeShort((short)colLast); + this.colFirst = EndianConverter.writeShort((short)colFirst); + this.colLast = EndianConverter.writeShort((short)colLast); colDX *= scale; - this.colDX = EndianConverter.writeShort((short)colDX); - this.ixfe = EndianConverter.writeShort((short)ixfe); - this.grbit = 0x00; + this.colDX = EndianConverter.writeShort((short)colDX); + this.ixfe = EndianConverter.writeShort((short)ixfe); + this.grbit = 0x00; } /** @@ -78,59 +78,59 @@ public class ColInfo implements BIFFRecord { /** * Reads ColInfo record from the InputStream * - * @param input the InputStream to read from + * @param input the InputStream to read from * @return the number of bytes read */ public int read(InputStream input) throws IOException { - int numOfBytesRead = input.read(colFirst); - numOfBytesRead += input.read(colLast); - numOfBytesRead += input.read(colDX); + int numOfBytesRead = input.read(colFirst); + numOfBytesRead += input.read(colLast); + numOfBytesRead += input.read(colDX); short scaledDX = (short) (EndianConverter.readShort(colDX) / scale); colDX = EndianConverter.writeShort(scaledDX); - numOfBytesRead += input.read(ixfe); - grbit = (byte) input.read(); - numOfBytesRead ++; - - Debug.log(Debug.TRACE,"\tcolFirst : "+ EndianConverter.readShort(colFirst) + + numOfBytesRead += input.read(ixfe); + grbit = (byte) input.read(); + numOfBytesRead ++; + + Debug.log(Debug.TRACE,"\tcolFirst : "+ EndianConverter.readShort(colFirst) + " colLast : " + EndianConverter.readShort(colLast) + " colDX : " + EndianConverter.readShort(colDX) + " ixfe : " + EndianConverter.readShort(ixfe) + " grbit : " + grbit); - + return numOfBytesRead; } - + /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * - * @return the hex code for <code>ColInfo</code> + * @return the hex code for <code>ColInfo</code> */ public short getBiffType() { return PocketExcelConstants.COLINFO; } /** - * Get the width of this column + * Get the width of this column * - * @return the width of this column + * @return the width of this column */ public short getColWidth() { return EndianConverter.readShort(colDX); - } - + } + /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * - * @return the hex code for <code>ColInfo</code> + * @return the hex code for <code>ColInfo</code> */ public short getFirst() { return EndianConverter.readShort(colFirst); } - + /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * - * @return the hex code for <code>ColInfo</code> + * @return the hex code for <code>ColInfo</code> */ public short getLast() { return EndianConverter.readShort(colLast); @@ -139,10 +139,10 @@ public class ColInfo implements BIFFRecord { /** * Writes a ColInfo to the specified <code>Outputstream</code> * - * @param os the <code>OutputStream</code> to write to + * @param os the <code>OutputStream</code> to write to */ public void write(OutputStream output) throws IOException { - + output.write(getBiffType()); output.write(colFirst); output.write(colLast); @@ -153,5 +153,5 @@ public class ColInfo implements BIFFRecord { Debug.log(Debug.TRACE,"Writing ColInfo record"); } - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefColWidth.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefColWidth.java index 24acb376e606..b3e3a8e6b0e3 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefColWidth.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefColWidth.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -36,24 +36,24 @@ import org.openoffice.xmerge.util.EndianConverter; import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; /** - * Represents a BIFF record defiuning the defualt column width + * Represents a BIFF record defiuning the defualt column width */ public class DefColWidth implements BIFFRecord { private byte[] grbit = new byte[2]; private byte[] coldx = new byte[2]; private byte[] ixfe = new byte[2]; - + /** * Constructs a pocket Excel Document from the * <code>InputStream</code> and assigns it the document name passed in * - * @param is InputStream containing a Pocket Excel Data file. + * @param is InputStream containing a Pocket Excel Data file. */ public DefColWidth() { - grbit = new byte[] {0x00, 0x00}; - coldx = new byte[] {0x00, 0x09}; - ixfe = new byte[] {0x00, 0x00}; + grbit = new byte[] {0x00, 0x00}; + coldx = new byte[] {0x00, 0x09}; + ixfe = new byte[] {0x00, 0x00}; } public DefColWidth(InputStream is) throws IOException { @@ -61,14 +61,14 @@ public class DefColWidth implements BIFFRecord { } /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>DefColWidth</code> */ public short getBiffType() { return PocketExcelConstants.DEF_COL_WIDTH; } - + public void write(OutputStream output) throws IOException { output.write(getBiffType()); @@ -76,19 +76,19 @@ public class DefColWidth implements BIFFRecord { output.write(coldx); output.write(ixfe); - Debug.log(Debug.TRACE, "Writing DefColWidth record"); + Debug.log(Debug.TRACE, "Writing DefColWidth record"); } - + public int read(InputStream input) throws IOException { - int numOfBytesRead = input.read(grbit); - numOfBytesRead += input.read(coldx); - numOfBytesRead += input.read(ixfe); - - Debug.log(Debug.TRACE,"\tgrbit : "+ EndianConverter.readShort(grbit) + + int numOfBytesRead = input.read(grbit); + numOfBytesRead += input.read(coldx); + numOfBytesRead += input.read(ixfe); + + Debug.log(Debug.TRACE,"\tgrbit : "+ EndianConverter.readShort(grbit) + " coldx : " + EndianConverter.readShort(coldx) + " ixfe : " + EndianConverter.readShort(ixfe)); return 0; } - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefRowHeight.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefRowHeight.java index a4cfb8476b53..454a5ed87520 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefRowHeight.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefRowHeight.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -36,18 +36,18 @@ import org.openoffice.xmerge.util.EndianConverter; import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; /** - * Represents a BIFF record defiuning the default row height + * Represents a BIFF record defiuning the default row height */ public class DefRowHeight implements BIFFRecord { private byte[] unknown1 = new byte[2]; private byte[] unknown2 = new byte[2]; - + /** * Constructs a pocket Excel Document from the * <code>InputStream</code> and assigns it the document name passed in * - * @param is InputStream containing a Pocket Excel Data file. + * @param is InputStream containing a Pocket Excel Data file. */ public DefRowHeight() { unknown1 = new byte[] {(byte)0x00, (byte)0x00}; @@ -55,33 +55,33 @@ public class DefRowHeight implements BIFFRecord { } /** - * Constructs a DefRowHeight from the <code>InputStream</code> + * Constructs a DefRowHeight from the <code>InputStream</code> * - * @param is InputStream containing a Pocket Excel Data file. + * @param is InputStream containing a Pocket Excel Data file. */ public DefRowHeight(InputStream is) throws IOException { read(is); } /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>DefRowHeight</code> */ public short getBiffType() { return PocketExcelConstants.DEFAULT_ROW_HEIGHT; } - + public int read(InputStream input) throws IOException { int numOfBytesRead = input.read(unknown1); - numOfBytesRead += input.read(unknown2); + numOfBytesRead += input.read(unknown2); - Debug.log(Debug.TRACE,"\tunknown1 : "+ EndianConverter.readShort(unknown1) + - " unknown2 : " + EndianConverter.readShort(unknown2)); + Debug.log(Debug.TRACE,"\tunknown1 : "+ EndianConverter.readShort(unknown1) + + " unknown2 : " + EndianConverter.readShort(unknown2)); return numOfBytesRead; } - + public void write(OutputStream output) throws IOException { output.write(getBiffType()); @@ -90,7 +90,7 @@ public class DefRowHeight implements BIFFRecord { Debug.log(Debug.TRACE,"Writing DefRowHeight record"); - + } - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefinedName.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefinedName.java index 8613771355ce..0f8c535a9b92 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefinedName.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefinedName.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -44,29 +44,29 @@ import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; */ public class DefinedName implements BIFFRecord { - private byte[] grbit = new byte[2]; + private byte[] grbit = new byte[2]; private byte cch; - private byte[] cce = new byte[2]; - private byte[] ixals = new byte[2]; + private byte[] cce = new byte[2]; + private byte[] ixals = new byte[2]; private byte[] rgch; private byte[] rgce; - private FormulaHelper fh = new FormulaHelper(); + private FormulaHelper fh = new FormulaHelper(); private String definition = new String(""); private Workbook wb; /** - * Constructs a Defined Name from the <code>InputStream</code> + * Constructs a Defined Name from the <code>InputStream</code> * - * @param is InputStream containing the record data + * @param is InputStream containing the record data */ public DefinedName(NameDefinition nd, Workbook wb) throws IOException { - + fh.setWorkbook(wb); this.wb = wb; String name = nd.getName(); - + // we have to insert an = to stop the formulaParser throwing an exception - definition = "=" + nd.getDefinition(); + definition = "=" + nd.getDefinition(); cch = (byte)name.length(); rgch = new byte[cch*2]; @@ -75,9 +75,9 @@ public class DefinedName implements BIFFRecord { ixals[0] = (byte)0xFF;ixals[1] = (byte)0xFF; } /** - * Constructs a Defined Name from the <code>InputStream</code> + * Constructs a Defined Name from the <code>InputStream</code> * - * @param is InputStream containing the record data + * @param is InputStream containing the record data */ public DefinedName(InputStream is, Workbook wb) throws IOException { @@ -87,51 +87,51 @@ public class DefinedName implements BIFFRecord { } /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>DefinedName</code> */ public short getBiffType() { return PocketExcelConstants.DEFINED_NAME; } - + /** * Reads a Defined Name from the <code>InputStream</code> The byte array * must be twice the size of the String as it uses unicode. * - * @param is InputStream containing the record data + * @param is InputStream containing the record data */ public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(grbit); - cch = (byte) input.read(); + + int numOfBytesRead = input.read(grbit); + cch = (byte) input.read(); numOfBytesRead++; - numOfBytesRead += input.read(cce); - numOfBytesRead += input.read(ixals); - + numOfBytesRead += input.read(cce); + numOfBytesRead += input.read(ixals); + rgch = new byte[cch*2]; - input.read(rgch, 0, cch*2); - + input.read(rgch, 0, cch*2); + rgce = new byte[EndianConverter.readShort(cce)]; - input.read(rgce, 0, EndianConverter.readShort(cce)); - + input.read(rgce, 0, EndianConverter.readShort(cce)); - Debug.log(Debug.TRACE, "\tgrbit : "+ EndianConverter.readShort(grbit) + + + Debug.log(Debug.TRACE, "\tgrbit : "+ EndianConverter.readShort(grbit) + " cch : " + cch + " cce : " + EndianConverter.readShort(cce) + " ixals : " + EndianConverter.readShort(ixals) + - "\n\trgch : " + rgch + + "\n\trgch : " + rgch + " rgce : " + rgce); - + return numOfBytesRead; } - + /** * Write this particular <code>BIFFRecord</code> to the <code>OutputStream</code> * * @param ouput the <code>OutputStream</code> - */ + */ public void write(OutputStream output) throws IOException { try { @@ -142,7 +142,7 @@ public class DefinedName implements BIFFRecord { Debug.log(Debug.TRACE,"Error in Parsing Name Definition"); cce = EndianConverter.writeShort((short) 0); } - + output.write(getBiffType()); output.write(grbit); @@ -171,56 +171,56 @@ public class DefinedName implements BIFFRecord { } catch (UnsupportedEncodingException e){ name = "unknown"; } - return name; + return name; } /** * Returns a definition table which can be used by the pocket excel * decoder to build a complete definitions table for writing to the sxc - * document + * document */ public NameDefinition getNameDefinition() { - + String baseCellAddress; - getDefinition(); // This must be called first so we know the type + getDefinition(); // This must be called first so we know the type baseCellAddress = "$" + wb.getSheetName(0) + ".A1"; - + NameDefinition nd = new NameDefinition(getName(),definition, baseCellAddress, isRangeType(), isExpressionType()); return nd; } - + /** - * Returns the definition + * Returns the definition * - * @return the <code>String</code> containing the definition + * @return the <code>String</code> containing the definition */ private String getDefinition() { // pexcel sometimes creates Name definition with no defintion, bug?? - if(EndianConverter.readShort(cce)!=0) { - definition = fh.convertPXLToCalc(rgce); - definition = definition.substring(1); // remove the '=' + if(EndianConverter.readShort(cce)!=0) { + definition = fh.convertPXLToCalc(rgce); + definition = definition.substring(1); // remove the '=' definition = definition.replace(',', ';'); - } - return definition; + } + return definition; } - + /** - * Returns the defintion + * Returns the defintion * - * @return the <code>String</code> containing the definition + * @return the <code>String</code> containing the definition */ private boolean isRangeType() { - - return fh.isRangeType(); + + return fh.isRangeType(); } /** - * Returns the defintion + * Returns the defintion * - * @return the <code>String</code> containing the definition + * @return the <code>String</code> containing the definition */ private boolean isExpressionType() { - return fh.isExpressionType(); + return fh.isExpressionType(); } } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Eof.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Eof.java index 685abecfd804..d0a2fec3e90e 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Eof.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Eof.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -46,25 +46,25 @@ public class Eof implements BIFFRecord { } /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>BeginningOfFile</code> */ public short getBiffType() { return PocketExcelConstants.EOF_MARKER; } - + public int read(InputStream input) throws IOException { return 0; } - + public void write(OutputStream output) throws IOException { output.write(getBiffType()); Debug.log(Debug.TRACE,"Writing Eof record"); - + } - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ExtendedFormat.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ExtendedFormat.java index 30fdfb03555a..5165efd84460 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ExtendedFormat.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ExtendedFormat.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -39,49 +39,49 @@ import org.openoffice.xmerge.converter.xml.sxc.Format; import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; /** - * Represents a BIFF Record descibing extended formatting information + * Represents a BIFF Record descibing extended formatting information * */ public class ExtendedFormat implements BIFFRecord, org.openoffice.xmerge.converter.xml.OfficeConstants { - private byte[] ixfnt = new byte[2]; // Index to Font Record - private byte[] ixnf = new byte[2]; - private byte[] fattributes = new byte[4]; - private byte[] fBaseAttr = new byte[2]; // base attribute flags - private byte[] fTextAttr = new byte[2]; // text attribute flags - private byte[] icvFore = new byte[2]; // Background colour of the cell - private byte[] icvFill = new byte[2]; - private byte bRight; // Right border Style - private byte bTop; // Top border style - private byte bLeft; // Left border style - private byte bBottom; // Bottom border style + private byte[] ixfnt = new byte[2]; // Index to Font Record + private byte[] ixnf = new byte[2]; + private byte[] fattributes = new byte[4]; + private byte[] fBaseAttr = new byte[2]; // base attribute flags + private byte[] fTextAttr = new byte[2]; // text attribute flags + private byte[] icvFore = new byte[2]; // Background colour of the cell + private byte[] icvFill = new byte[2]; + private byte bRight; // Right border Style + private byte bTop; // Top border style + private byte bLeft; // Left border style + private byte bBottom; // Bottom border style private byte backstyle; private byte borderstyle; - - public static final int TOP_BORDER = 0x01; - public static final int LEFT_BORDER = 0x02; - public static final int BOTTOM_BORDER = 0x04; - public static final int RIGHT_BORDER = 0x08; + + public static final int TOP_BORDER = 0x01; + public static final int LEFT_BORDER = 0x02; + public static final int BOTTOM_BORDER = 0x04; + public static final int RIGHT_BORDER = 0x08; // Horizontal Alignment Styles - public static final int NORMAL_ALIGN = 0x00; - public static final int LEFT_ALIGN = 0x01; - public static final int CENTER_ALIGN = 0x02; - public static final int RIGHT_ALIGN = 0x03; - + public static final int NORMAL_ALIGN = 0x00; + public static final int LEFT_ALIGN = 0x01; + public static final int CENTER_ALIGN = 0x02; + public static final int RIGHT_ALIGN = 0x03; + // Vertical Alignment Styles - public static final int TOP_ALIGN = 0x10; - public static final int MIDDLE_ALIGN = 0x20; - public static final int BOTTOM_ALIGN = 0x30; - - public static final int WORD_WRAP = 0x08; + public static final int TOP_ALIGN = 0x10; + public static final int MIDDLE_ALIGN = 0x20; + public static final int BOTTOM_ALIGN = 0x30; + + public static final int WORD_WRAP = 0x08; /** * Constructs an <code>ExtendedFormat</code> from the - * <code>InputStream</code> + * <code>InputStream</code> * - * @param is <code>InputStream</code> to read from + * @param is <code>InputStream</code> to read from */ public ExtendedFormat(InputStream is) throws IOException { read(is); @@ -89,30 +89,30 @@ org.openoffice.xmerge.converter.xml.OfficeConstants { /** * Constructs a pocket Excel Document using defualt values and sets the - * font index using the specified attribute + * font index using the specified attribute * - * @param ixfnt index of the font this format should use + * @param ixfnt index of the font this format should use */ public ExtendedFormat(int ixfnt, Format fmt) { - this.ixfnt = EndianConverter.writeShort((short)ixfnt); + this.ixfnt = EndianConverter.writeShort((short)ixfnt); String category = fmt.getCategory(); if(category.equalsIgnoreCase(CELLTYPE_CURRENCY)) { - this.ixnf = EndianConverter.writeShort((short) 0); + this.ixnf = EndianConverter.writeShort((short) 0); } else if(category.equalsIgnoreCase(CELLTYPE_DATE)) { - this.ixnf = EndianConverter.writeShort((short) 0x12); + this.ixnf = EndianConverter.writeShort((short) 0x12); } else if(category.equalsIgnoreCase(CELLTYPE_TIME)) { - this.ixnf = EndianConverter.writeShort((short) 0x1E); + this.ixnf = EndianConverter.writeShort((short) 0x1E); } else { - this.ixnf = EndianConverter.writeShort((short) 0); + this.ixnf = EndianConverter.writeShort((short) 0); } - this.fattributes = new byte[] {(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF}; - this.fBaseAttr = new byte[] {(byte)0x02,(byte)0x00}; + this.fattributes = new byte[] {(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF}; + this.fBaseAttr = new byte[] {(byte)0x02,(byte)0x00}; - this.fTextAttr = new byte[] {(byte)0x00, (byte)0x00}; + this.fTextAttr = new byte[] {(byte)0x00, (byte)0x00}; int align = fmt.getAlign(); - + // Horizontal alignment if(align==Format.CENTER_ALIGN) { fTextAttr[0] |= CENTER_ALIGN; @@ -123,7 +123,7 @@ org.openoffice.xmerge.converter.xml.OfficeConstants { } else { fTextAttr[0] |= NORMAL_ALIGN; } - + int vertAlign = fmt.getVertAlign(); // Vertical alignment @@ -135,8 +135,8 @@ org.openoffice.xmerge.converter.xml.OfficeConstants { fTextAttr[0] |= MIDDLE_ALIGN; } else { fTextAttr[0] |= BOTTOM_ALIGN; - } - + } + if(fmt.getAttribute(Format.WORD_WRAP)) { fTextAttr[0] |= WORD_WRAP; } @@ -153,55 +153,55 @@ org.openoffice.xmerge.converter.xml.OfficeConstants { if(fmt.getAttribute(Format.BOTTOM_BORDER)) { fTextAttr[1] |= BOTTOM_BORDER; } - + Color background = fmt.getBackground(); if( background != null ) { ColourConverter cc = new ColourConverter(PocketExcelConstants.cLookup); icvFill = EndianConverter.writeShort(cc.convertFromRGB(background)); } else { - icvFill = new byte[] {(byte)0xFF,(byte)0x00}; + icvFill = new byte[] {(byte)0xFF,(byte)0x00}; } - - icvFore = new byte[] {(byte)0xFF,(byte)0x00}; - bRight = (byte) 0xFF; - bTop = (byte) 0xFF; - bLeft = (byte) 0xFF; - bBottom = (byte) 0xFF; - backstyle = (byte) 0x00; - borderstyle = (byte) 0x00; + icvFore = new byte[] {(byte)0xFF,(byte)0x00}; + + bRight = (byte) 0xFF; + bTop = (byte) 0xFF; + bLeft = (byte) 0xFF; + bBottom = (byte) 0xFF; + backstyle = (byte) 0x00; + borderstyle = (byte) 0x00; } /** - * Get the font index this format uses + * Get the font index this format uses * - * @return the font index + * @return the font index */ public int getFontIndex() { return EndianConverter.readShort(ixfnt); } - + /** - * Get the font index this format uses + * Get the font index this format uses * - * @return the font index + * @return the font index */ public int getFormatIndex() { return EndianConverter.readShort(ixnf); } - + /** - * Get the font index this format uses + * Get the font index this format uses * - * @return the font index + * @return the font index */ public int getTextAttr() { return EndianConverter.readShort(fTextAttr); } - + /** - * Get the background color this format uses + * Get the background color this format uses * * @return the background color */ @@ -211,7 +211,7 @@ org.openoffice.xmerge.converter.xml.OfficeConstants { if(rgb!=0xFF) { ColourConverter cc = new ColourConverter(PocketExcelConstants.cLookup); c = cc.convertToRGB(rgb); - } + } return c; } @@ -221,7 +221,7 @@ org.openoffice.xmerge.converter.xml.OfficeConstants { * @return the alignment */ public int getVertAlign() { - + int mask = MIDDLE_ALIGN | BOTTOM_ALIGN | TOP_ALIGN; int masked = fTextAttr[0] & mask; @@ -243,7 +243,7 @@ org.openoffice.xmerge.converter.xml.OfficeConstants { * @return the alignment */ public int getAlign() { - + int mask = LEFT_ALIGN | CENTER_ALIGN | RIGHT_ALIGN; int masked = fTextAttr[0] & mask; @@ -258,9 +258,9 @@ org.openoffice.xmerge.converter.xml.OfficeConstants { return Format.LEFT_ALIGN; } - + /** - * Is the word wrap set + * Is the word wrap set * * @return true if it is selected */ @@ -278,87 +278,87 @@ org.openoffice.xmerge.converter.xml.OfficeConstants { } /** - * Compare two ExtendedFormat to see if the font index is the same + * Compare two ExtendedFormat to see if the font index is the same * * @param the ExtendedFormat to be used in the comaprison * @return boolean if the two are the same otherwise false - */ + */ public boolean compareTo(ExtendedFormat rhs) { if(EndianConverter.readShort(icvFill) != - EndianConverter.readShort(rhs.icvFill)) + EndianConverter.readShort(rhs.icvFill)) return false; - - if(this.getTextAttr() != rhs.getTextAttr()) + + if(this.getTextAttr() != rhs.getTextAttr()) return false; - - if(this.getVertAlign() != rhs.getVertAlign()) + + if(this.getVertAlign() != rhs.getVertAlign()) return false; - - if(this.getAlign() != rhs.getAlign()) + + if(this.getAlign() != rhs.getAlign()) return false; - + if (this.getFontIndex() != rhs.getFontIndex()) return false; if (this.getFormatIndex() != rhs.getFormatIndex()) return false; - + return true; } - + /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>ExtendedFormat</code> - */ + */ public short getBiffType() { return PocketExcelConstants.EXTENDED_FORMAT; } - + /** - * Reads the extended format from the <code>Inputstream</code> + * Reads the extended format from the <code>Inputstream</code> * - * @param input the <code>Inputstream</code>to read - * @return toal number of bytes read + * @param input the <code>Inputstream</code>to read + * @return toal number of bytes read */ public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(ixfnt); - numOfBytesRead += input.read(ixnf); - numOfBytesRead += input.read(fattributes); - numOfBytesRead += input.read(fBaseAttr); - numOfBytesRead += input.read(fTextAttr); - numOfBytesRead += input.read(icvFore); - numOfBytesRead += input.read(icvFill); - bRight = (byte) input.read(); - bTop = (byte) input.read(); - bLeft = (byte) input.read(); - bBottom = (byte) input.read(); - backstyle = (byte) input.read(); - borderstyle = (byte) input.read(); + + int numOfBytesRead = input.read(ixfnt); + numOfBytesRead += input.read(ixnf); + numOfBytesRead += input.read(fattributes); + numOfBytesRead += input.read(fBaseAttr); + numOfBytesRead += input.read(fTextAttr); + numOfBytesRead += input.read(icvFore); + numOfBytesRead += input.read(icvFill); + bRight = (byte) input.read(); + bTop = (byte) input.read(); + bLeft = (byte) input.read(); + bBottom = (byte) input.read(); + backstyle = (byte) input.read(); + borderstyle = (byte) input.read(); numOfBytesRead += 6; - - Debug.log(Debug.TRACE,"\tixfnt : "+ EndianConverter.readShort(ixfnt) + + + Debug.log(Debug.TRACE,"\tixfnt : "+ EndianConverter.readShort(ixfnt) + " ixnf : " + EndianConverter.readShort(ixnf) + " fattributes : " + EndianConverter.readInt(fattributes) + " fBaseAttr : " + EndianConverter.readShort(fBaseAttr) + - "\n\tfTextAttr : " + EndianConverter.readShort(fTextAttr) + + "\n\tfTextAttr : " + EndianConverter.readShort(fTextAttr) + " icvFore : " + EndianConverter.readShort(icvFore) + " icvFill : " + EndianConverter.readShort(icvFill) + " bRight : " + bRight + - "\n\tbTop : " + bTop + + "\n\tbTop : " + bTop + " bLeft : " + bLeft + " bBottom : " + bBottom + " backstyle : " + backstyle + " borderstyle : " + borderstyle); return numOfBytesRead; } - + /** - * Writes the ExtendedFormat to the <code>Outputstream<code> + * Writes the ExtendedFormat to the <code>Outputstream<code> * - * @param output the <code>Outputstream</code>to write to + * @param output the <code>Outputstream</code>to write to */ public void write(OutputStream output) throws IOException { @@ -378,7 +378,7 @@ org.openoffice.xmerge.converter.xml.OfficeConstants { output.write(borderstyle); Debug.log(Debug.TRACE,"Writing ExtendedFormat record"); - + } - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FloatNumber.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FloatNumber.java index 902feef2bbc2..8d702640a500 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FloatNumber.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FloatNumber.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -41,23 +41,23 @@ import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; public class FloatNumber extends CellValue { protected byte[] num = new byte[8]; - + /** * Constructs a pocket Excel Document from the * <code>InputStream</code> and assigns it the document name passed in * - * @param is InputStream containing a Pocket Excel Data file. + * @param is InputStream containing a Pocket Excel Data file. */ public FloatNumber(InputStream is) throws IOException { read(is); } /** - * Constructs a <code>FloatNumber</code> using specified attributes + * Constructs a <code>FloatNumber</code> using specified attributes * * @param row row number - * @param col column number - * @param cellContents contents of the cell + * @param col column number + * @param cellContents contents of the cell * @param ixfe font index */ public FloatNumber(int row, int column, String cellContents, int ixfe) throws IOException { @@ -66,11 +66,11 @@ public class FloatNumber extends CellValue { setRow(row); setCol(column); double cellLong = (double) Double.parseDouble(cellContents); - num = EndianConverter.writeDouble(cellLong); + num = EndianConverter.writeDouble(cellLong); } /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>FloatNumber</code> */ @@ -81,40 +81,40 @@ public class FloatNumber extends CellValue { /** * Reads a<code>FloatNumber</code> from the specified <code>InputStream</code> * - * @param input the <code>InputStram</code> to read from - */ + * @param input the <code>InputStram</code> to read from + */ public int read(InputStream input) throws IOException { - + int numOfBytesRead = super.read(input); - numOfBytesRead += input.read(num); - + numOfBytesRead += input.read(num); + Debug.log(Debug.TRACE," num : " + getString()); return numOfBytesRead; } - + public void write(OutputStream output) throws IOException { output.write(getBiffType()); - + super.write(output); output.write(num); Debug.log(Debug.TRACE,"Writing FloatNumber record"); } - + /** - * Gets the numerical value the cell represents + * Gets the numerical value the cell represents * - * @return the <code>String</code> representing a double value + * @return the <code>String</code> representing a double value */ public String getString() throws IOException { double value = EndianConverter.readDouble(num); Double myDo = new Double(value); - return myDo.toString(); + return myDo.toString(); } } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FontDescription.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FontDescription.java index d555c063dc90..61d9746c80d3 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FontDescription.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FontDescription.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -41,15 +41,15 @@ import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; /** - * Represents a BIFF Record descibing a font used + * Represents a BIFF Record descibing a font used */ public class FontDescription implements BIFFRecord { - private byte[] dwHeight = new byte[2]; - private byte[] grbit = new byte[2]; - private byte[] icvFore = new byte[2]; - private byte[] bls = new byte[2]; - private byte[] Reserved2 = new byte[2]; + private byte[] dwHeight = new byte[2]; + private byte[] grbit = new byte[2]; + private byte[] icvFore = new byte[2]; + private byte[] bls = new byte[2]; + private byte[] Reserved2 = new byte[2]; private byte uls; private byte bFamily; private byte bCharSet; @@ -57,42 +57,42 @@ public class FontDescription implements BIFFRecord { private byte cch; private byte[] rgch; - public static final int UNDERLINE = 0x01; - public static final int ITALIC = 0x02; + public static final int UNDERLINE = 0x01; + public static final int ITALIC = 0x02; /** - * Constructs a FontDescription from the bold italic and undelrine attributes + * Constructs a FontDescription from the bold italic and undelrine attributes * - * @param italic Italic attribute - * @param bold Bold attribute - * @param underline Underline attribute + * @param italic Italic attribute + * @param bold Bold attribute + * @param underline Underline attribute */ public FontDescription(Format fmt) throws IOException { Debug.log(Debug.TRACE,"Building FontDescriptor based on Format : " + fmt); - this.dwHeight = EndianConverter.writeShort((short) (fmt.getFontSize()*20)); - + this.dwHeight = EndianConverter.writeShort((short) (fmt.getFontSize()*20)); + grbit = new byte[] {(byte)0x00, (byte)0x00}; bls = EndianConverter.writeShort((short) 400); uls = 0; - + if (fmt.getAttribute(Format.ITALIC)) grbit[0] |= ITALIC; if (fmt.getAttribute(Format.BOLD)) - bls = EndianConverter.writeShort((short) 700); + bls = EndianConverter.writeShort((short) 700); if (fmt.getAttribute(Format.UNDERLINE)) - uls |= UNDERLINE; + uls |= UNDERLINE; - bFamily = 0; - bCharSet = 0; + bFamily = 0; + bCharSet = 0; String fontName = fmt.getFontName(); - if( !fontName.equals("Tahoma") && - !fontName.equals("Courier New")) { + if( !fontName.equals("Tahoma") && + !fontName.equals("Courier New")) { // We will set our default font to be Tahoma fontName = new String("Tahoma"); } @@ -105,11 +105,11 @@ public class FontDescription implements BIFFRecord { ColourConverter cc = new ColourConverter(PocketExcelConstants.cLookup); icvFore = EndianConverter.writeShort(cc.convertFromRGB(foreground)); } else { - icvFore = new byte[] {(byte)0xFF,(byte)0x00}; + icvFore = new byte[] {(byte)0xFF,(byte)0x00}; } - Reserved2 = EndianConverter.writeShort((short) 0); - Reserved3 = 0; + Reserved2 = EndianConverter.writeShort((short) 0); + Reserved3 = 0; } @@ -119,12 +119,12 @@ public class FontDescription implements BIFFRecord { * @return true if italic otherwise false */ public boolean isItalic() { - + return (EndianConverter.readShort(grbit) == 2); } /** - * Tests if this font descriptor defines underline + * Tests if this font descriptor defines underline * * @return true if underline otherwise false */ @@ -134,7 +134,7 @@ public class FontDescription implements BIFFRecord { } /** - * Tests if this font descriptor defines bold + * Tests if this font descriptor defines bold * * @return true if bold otherwise false */ @@ -144,7 +144,7 @@ public class FontDescription implements BIFFRecord { } /** - * Get the background color this format uses + * Get the background color this format uses * * @return the background color */ @@ -154,21 +154,21 @@ public class FontDescription implements BIFFRecord { if(rgb!=0xFF) { ColourConverter cc = new ColourConverter(PocketExcelConstants.cLookup); c = cc.convertToRGB(rgb); - } + } return c; } - + /** * Compares current font descriptor against one passed in * - * @return true if attrbitues are the same + * @return true if attrbitues are the same */ public boolean compareTo(FontDescription rhs) { if(EndianConverter.readShort(icvFore) != - EndianConverter.readShort(rhs.icvFore)) + EndianConverter.readShort(rhs.icvFore)) return false; - + if (EndianConverter.readShort(dwHeight) != EndianConverter.readShort(dwHeight)) return false; @@ -187,26 +187,26 @@ public class FontDescription implements BIFFRecord { return true; } - + /** - * Constructs a Font Description from the <code>InputStream</code> + * Constructs a Font Description from the <code>InputStream</code> * - * @param is InputStream containing a <code>FontDescription</code> + * @param is InputStream containing a <code>FontDescription</code> */ public FontDescription(InputStream is) throws IOException { read(is); } /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>FontDescription</code> */ public short getBiffType() { return PocketExcelConstants.FONT_DESCRIPTION; } - + /** * Get the Font size * @@ -220,7 +220,7 @@ public class FontDescription implements BIFFRecord { * */ public String getFont() { - + String name; try { @@ -230,43 +230,43 @@ public class FontDescription implements BIFFRecord { } return name; } - + /** - * Constructs a Font Description from the <code>InputStream</code> + * Constructs a Font Description from the <code>InputStream</code> * - * @param is InputStream containing a <code>FontDescription</code> + * @param is InputStream containing a <code>FontDescription</code> */ public int read(InputStream input) throws IOException { - int numOfBytesRead = input.read(dwHeight); - numOfBytesRead += input.read(grbit); - numOfBytesRead += input.read(icvFore); - numOfBytesRead += input.read(bls); - numOfBytesRead += input.read(Reserved2); - uls = (byte) input.read(); - bFamily = (byte) input.read(); - bCharSet = (byte) input.read(); - Reserved3 = (byte) input.read(); - cch = (byte) input.read(); + int numOfBytesRead = input.read(dwHeight); + numOfBytesRead += input.read(grbit); + numOfBytesRead += input.read(icvFore); + numOfBytesRead += input.read(bls); + numOfBytesRead += input.read(Reserved2); + uls = (byte) input.read(); + bFamily = (byte) input.read(); + bCharSet = (byte) input.read(); + Reserved3 = (byte) input.read(); + cch = (byte) input.read(); numOfBytesRead += 5; - + rgch = new byte[cch*2]; - input.read(rgch, 0, cch*2); - - Debug.log(Debug.TRACE,"\tdwHeight : "+ EndianConverter.readShort(dwHeight) + + input.read(rgch, 0, cch*2); + + Debug.log(Debug.TRACE,"\tdwHeight : "+ EndianConverter.readShort(dwHeight) + " grbit : " + EndianConverter.readShort(grbit) + " bls : " + EndianConverter.readShort(bls) + " uls : " + uls + - "\n\tFamily : " + bFamily + + "\n\tFamily : " + bFamily + " bCharSet : " + bCharSet + " cch : " + cch + " rgch : " + new String(rgch,"UTF-16LE")); - + return numOfBytesRead; } - + public void write(OutputStream output) throws IOException { - + output.write(getBiffType()); output.write(dwHeight); output.write(grbit); @@ -282,5 +282,5 @@ public class FontDescription implements BIFFRecord { Debug.log(Debug.TRACE,"Writing FontDescription record"); } - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Formula.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Formula.java index e78645ab7644..a073883b2e8e 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Formula.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Formula.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -41,22 +41,22 @@ import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; /** - * Represents a BIFF Record describing a formula + * Represents a BIFF Record describing a formula */ public class Formula extends CellValue implements OfficeConstants { - private byte[] num = new byte[8]; + private byte[] num = new byte[8]; private byte grbit; - private byte[] cce = new byte[2]; + private byte[] cce = new byte[2]; private byte[] rgce; private FormulaHelper fh = new FormulaHelper(); - + /** * Constructs a <code>Formula</code> using specified attributes - * + * * @param row row number - * @param col column number - * @param cellContents contents of the cell + * @param col column number + * @param cellContents contents of the cell * @param ixfe font index * @param value the value of the cell */ @@ -69,10 +69,10 @@ public class Formula extends CellValue implements OfficeConstants { setCol(column); setIxfe(ixfe); setFormula(cellContents); - + String category = fmt.getCategory(); String value = fmt.getValue(); - + if(category.equalsIgnoreCase(CELLTYPE_BOOLEAN)) { num[0]=(byte)0x01; num[1]=(byte)0x00; @@ -111,24 +111,24 @@ public class Formula extends CellValue implements OfficeConstants { num = EndianConverter.writeDouble(cellLong); } } - + /** * Translates a <code>String</code> written in infix which represents a * formula into a byte[] what can be written to pocket excel file. * - * @param formula string + * @param formula string */ public void setFormula(String inFormula) throws Exception { rgce = fh.convertCalcToPXL(inFormula); cce = EndianConverter.writeShort((short) rgce.length); } - + /** * Constructs a pocket Excel formula from the - * <code>InputStream</code> + * <code>InputStream</code> * - * @param is InputStream containing a Pocket Excel Data file. + * @param is InputStream containing a Pocket Excel Data file. */ public Formula(InputStream is, Workbook wb) throws IOException { read(is); @@ -136,51 +136,51 @@ public class Formula extends CellValue implements OfficeConstants { } /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>Formula</code> */ public short getBiffType() { return PocketExcelConstants.FORMULA_CELL; } - + /** * Reads the formula data members from the stream. Byte arrays for Strings * are doubled as they are stored as unicode * - * @return total number of bytes read + * @return total number of bytes read */ public int read(InputStream input) throws IOException { int numOfBytesRead = super.read(input); numOfBytesRead += input.read(num); - grbit = (byte) input.read(); - numOfBytesRead ++; - numOfBytesRead += input.read(cce); - + grbit = (byte) input.read(); + numOfBytesRead ++; + numOfBytesRead += input.read(cce); + int strLen = EndianConverter.readShort(cce); rgce = new byte[strLen]; - input.read(rgce, 0, strLen); - + input.read(rgce, 0, strLen); + Debug.log(Debug.TRACE, " num : " + num + - "\n\tgrbit : " + grbit + + "\n\tgrbit : " + grbit + " cce : " + EndianConverter.readShort(cce) + - " rgce : " + new String(rgce,"UTF-16LE") + + " rgce : " + new String(rgce,"UTF-16LE") + "\n" + numOfBytesRead + " Bytes Read"); - + return numOfBytesRead; } /** - * Writes the Formula record to the <code>OutputStream</code> + * Writes the Formula record to the <code>OutputStream</code> * - * @param the <code>OutputStream</code> being written to - */ + * @param the <code>OutputStream</code> being written to + */ public void write(OutputStream output) throws IOException { output.write(getBiffType()); - + super.write(output); output.write(num); @@ -204,7 +204,7 @@ public class Formula extends CellValue implements OfficeConstants { } /** - * Gets the <code>String</code> representing the cells contents + * Gets the <code>String</code> representing the cells contents * * @return the <code>String</code> representing the cells contents */ @@ -212,13 +212,13 @@ public class Formula extends CellValue implements OfficeConstants { return fh.convertPXLToCalc(rgce); } - + /** * Excel dates are the number of days since 1/1/1900. This method converts * to this date. * - * @param s String representing a date in the form YYYY-MM-DD - * @return The excel serial date + * @param s String representing a date in the form YYYY-MM-DD + * @return The excel serial date */ public long toExcelSerialDate(String s) throws IOException { @@ -226,20 +226,20 @@ public class Formula extends CellValue implements OfficeConstants { int month = Integer.parseInt(s.substring(5,7)); int day = Integer.parseInt(s.substring(8,10)); - long serialDate = (1461 * (year + 4800 + (month - 14) / 12)) / 4 + + long serialDate = (1461 * (year + 4800 + (month - 14) / 12)) / 4 + (367 * (month - 2 - 12 * ((month - 14) / 12))) / 12 - (3 * ((year + 4900 + (month - 14) / 12)) / 100) / 4 + - day - 2415019 - 32075; + day - 2415019 - 32075; return serialDate; } - + /** * Excel times are a fraction of a 24 hour day expressed in seconds. This method converts * to this time. * - * @param s String representing a time in the form ??HH?MM?SS? - * @return The excel serial time + * @param s String representing a time in the form ??HH?MM?SS? + * @return The excel serial time */ public double toExcelSerialTime(String s) throws IOException { @@ -249,7 +249,7 @@ public class Formula extends CellValue implements OfficeConstants { int timeSecs = (hours*3600) + (mins*60) + (secs); - double d = (double) timeSecs / (24 * 3600); + double d = (double) timeSecs / (24 * 3600); return d; } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/LabelCell.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/LabelCell.java index 879c187b4b26..d4ad28cc7e2b 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/LabelCell.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/LabelCell.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -41,21 +41,21 @@ import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; */ public class LabelCell extends CellValue { - private byte[] cch = new byte[2]; + private byte[] cch = new byte[2]; private byte[] rgch; - + /** * Constructs a <code>LabelCell</code> using specified attributes - * + * * @param row row number - * @param col column number - * @param cellContents contents of the cell + * @param col column number + * @param cellContents contents of the cell * @param ixfe font index */ public LabelCell(int row, int column, String cellContents, int ixfe) throws IOException { - setLabel(cellContents); + setLabel(cellContents); setRow(row); setCol(column); setIxfe(ixfe); @@ -67,18 +67,18 @@ public class LabelCell extends CellValue { * @param is the <code>Inputstream</code> to read from */ public LabelCell(InputStream is) throws IOException { - read(is); + read(is); } /** * Writes a <code>LabelCell</code> to the specified <code>Outputstream</code> * - * @param os the <code>OutputStream</code> to write to + * @param os the <code>OutputStream</code> to write to */ public void write(OutputStream output) throws IOException { output.write(getBiffType()); - + super.write(output); output.write(cch); @@ -86,40 +86,40 @@ public class LabelCell extends CellValue { Debug.log(Debug.TRACE,"Writing Label record"); } - + /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>LabelCell</code> */ public short getBiffType() { return PocketExcelConstants.LABEL_CELL; } - + /** * Reads a<code>LabelCell</code> from the specified <code>InputStream</code> * - * @param input the <code>InputStram</code> to read from + * @param input the <code>InputStram</code> to read from */ public int read(InputStream input) throws IOException { int numOfBytesRead = super.read(input); numOfBytesRead += input.read(cch); - + int strLen = EndianConverter.readShort(cch)*2; rgch = new byte[strLen]; - input.read(rgch, 0, strLen); - + input.read(rgch, 0, strLen); + Debug.log(Debug.TRACE, " cch : " + EndianConverter.readShort(cch) + - " rgch : " + new String(rgch, "UTF-16LE")); - - return numOfBytesRead; + " rgch : " + new String(rgch, "UTF-16LE")); + + return numOfBytesRead; } /** - * Gets the <code>String</code> representing the cells contents + * Gets the <code>String</code> representing the cells contents * * @return the <code>String</code> representing the cells contents */ @@ -128,7 +128,7 @@ public class LabelCell extends CellValue { } /** - * Sets the <code>String</code> representing the cells contents + * Sets the <code>String</code> representing the cells contents * * @return the <code>String</code> representing the cells contents */ diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/NumberFormat.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/NumberFormat.java index a3ea0f3d338d..342d9b676bcd 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/NumberFormat.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/NumberFormat.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -36,58 +36,58 @@ import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; /** - * Represents a BIFF Record describing a number format + * Represents a BIFF Record describing a number format */ public class NumberFormat implements BIFFRecord { private byte cce; private byte[] rgch; - + /** - * Constructs a NumberFormat Record from the <code>InputStream</code> + * Constructs a NumberFormat Record from the <code>InputStream</code> * - * @param is InputStream containing the record data + * @param is InputStream containing the record data */ public NumberFormat(InputStream is) throws IOException { read(is); } /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>NumberFormat</code> */ public short getBiffType() { return PocketExcelConstants.NUMBER_FORMAT; } - + /** * Reads the NumberFormat from the <code>InputStream</code> Byte array * containg strings are doubled in length becuse they use unicode * - * @return the total number of bytes read + * @return the total number of bytes read */ public int read(InputStream input) throws IOException { cce = (byte) input.read(); int numOfBytesRead = 1; - + rgch = new byte[cce*2]; - numOfBytesRead += input.read(rgch, 0, cce*2); - - Debug.log(Debug.TRACE, "\tcce : "+ cce + + numOfBytesRead += input.read(rgch, 0, cce*2); + + Debug.log(Debug.TRACE, "\tcce : "+ cce + " rgch : " + new String(rgch,"UTF-16LE")); - + return numOfBytesRead; } - + public void write(OutputStream output) throws IOException { output.write(getBiffType()); output.write(cce); output.write(rgch); - Debug.log(Debug.TRACE,"Writing NumberFormat record"); + Debug.log(Debug.TRACE,"Writing NumberFormat record"); } - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Pane.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Pane.java index b57135a450e3..b65d1027f969 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Pane.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Pane.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -43,37 +43,37 @@ import org.openoffice.xmerge.converter.xml.sxc.SheetSettings; */ public class Pane implements BIFFRecord { - private byte[] x = new byte[2]; - private byte[] y = new byte[2]; - private byte[] rwTop = new byte[2]; - private byte[] colLeft = new byte[2]; + private byte[] x = new byte[2]; + private byte[] y = new byte[2]; + private byte[] rwTop = new byte[2]; + private byte[] colLeft = new byte[2]; private byte pnnAcct; - + /** - * Default Constructor + * Default Constructor */ public Pane() { - pnnAcct = (byte) 0x02; // Default setting + pnnAcct = (byte) 0x02; // Default setting } - + /** * Constructs a Pane Record from the <code>InputStream</code> * - * @param is InputStream containing a Pane record + * @param is InputStream containing a Pane record */ public Pane(InputStream is) throws IOException { - read(is); + read(is); } /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>Pane</code> */ public short getBiffType() { return PocketExcelConstants.PANE_INFO; } - + /** * Gets the split point for this pane, in the case of splits this will be * in twips. @@ -98,7 +98,7 @@ public class Pane implements BIFFRecord { return (new Point(EndianConverter.readShort(x), EndianConverter.readShort(y))); } - + /** * Sets the split point for this pane, coordinates are in column row units * if the split type is freeze or twips if split type is split. @@ -107,8 +107,8 @@ public class Pane implements BIFFRecord { * @param p the split point */ public void setSplitPoint(Point splitType, Point p) { - - if(splitType.getX()==SheetSettings.SPLIT + + if(splitType.getX()==SheetSettings.SPLIT || splitType.getY()==SheetSettings.SPLIT) { int yTwips = (int) p.getY(); short yPxl = (short) (yTwips * 15); @@ -121,19 +121,19 @@ public class Pane implements BIFFRecord { x = EndianConverter.writeShort((short) p.getX()); } - } - + } + /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>Pane</code> */ public void setPaneNumber(int paneNumber) { pnnAcct = (byte) paneNumber; } - + /** - * Get the pane number of the active pane + * Get the pane number of the active pane * 0 - bottom right, 1 - top right * 2 - bottom left, 3 - top left * @@ -141,69 +141,69 @@ public class Pane implements BIFFRecord { */ public int getPaneNumber() { return pnnAcct; - } + } /** - * Set the top row visible in the lower pane + * Set the top row visible in the lower pane * * @param top 0-based inex of the top row */ public void setTop(int top) { rwTop = EndianConverter.writeShort((short)top); } - + /** - * Set leftmost column visible in the right pane + * Set leftmost column visible in the right pane * * @param left 0-based index of the leftmost column */ public void setLeft(int left) { colLeft = EndianConverter.writeShort((short)left); } - + /** - * Get the top row visible in the lower pane + * Get the top row visible in the lower pane * * @return the hex code for <code>Pane</code> */ public int getTop() { return EndianConverter.readShort(rwTop); } - + /** - * Get leftmost column visible in the right pane + * Get leftmost column visible in the right pane * - * @return 0-based index of the column + * @return 0-based index of the column */ public int getLeft() { return EndianConverter.readShort(colLeft); } - /** + /** * Reads a <code>Pane</code> record from the <code>InputStream</code> * - * @param input <code>InputStream</code> to read from + * @param input <code>InputStream</code> to read from * @return the total number of bytes read */ public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(x); - numOfBytesRead += input.read(y); - numOfBytesRead += input.read(rwTop); - numOfBytesRead += input.read(colLeft); - pnnAcct = (byte) input.read(); + + int numOfBytesRead = input.read(x); + numOfBytesRead += input.read(y); + numOfBytesRead += input.read(rwTop); + numOfBytesRead += input.read(colLeft); + pnnAcct = (byte) input.read(); numOfBytesRead++; - - Debug.log(Debug.TRACE, "\tx : "+ EndianConverter.readShort(x) + + + Debug.log(Debug.TRACE, "\tx : "+ EndianConverter.readShort(x) + " y : " + EndianConverter.readShort(y) + " rwTop : " + EndianConverter.readShort(rwTop) + " colLeft : " + EndianConverter.readShort(colLeft) + " pnnAcct : " + pnnAcct); - - return numOfBytesRead; + + return numOfBytesRead; } - + public void write(OutputStream output) throws IOException { output.write(getBiffType()); diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Row.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Row.java index e0e00f63c9c9..8e3067d26c6b 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Row.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Row.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -26,7 +26,7 @@ ************************************************************************/ package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - + import java.io.OutputStream; import java.io.InputStream; import java.io.IOException; @@ -41,88 +41,88 @@ import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; */ public class Row implements BIFFRecord { - private byte[] rw = new byte[2]; - private byte[] miyRw = new byte[2]; - private byte[] grbit = new byte[2]; - private byte[] ixfe = new byte[2]; + private byte[] rw = new byte[2]; + private byte[] miyRw = new byte[2]; + private byte[] grbit = new byte[2]; + private byte[] ixfe = new byte[2]; private float scale = (float) 1; - + /** * Constructs a pocket Excel Document from the * <code>InputStream</code> and assigns it the document name passed in * - * @param rw Zero based row number - * @param miyRw row height + * @param rw Zero based row number + * @param miyRw row height */ public Row(int rw, int miyRw, boolean userDefined) { - this.rw = EndianConverter.writeShort((short) rw); + this.rw = EndianConverter.writeShort((short) rw); miyRw *= scale; - this.miyRw = EndianConverter.writeShort((short) miyRw); + this.miyRw = EndianConverter.writeShort((short) miyRw); if(userDefined) { - grbit = EndianConverter.writeShort((short) 2); + grbit = EndianConverter.writeShort((short) 2); } else { - grbit = EndianConverter.writeShort((short) 0); + grbit = EndianConverter.writeShort((short) 0); } - ixfe = EndianConverter.writeShort((short) 0); + ixfe = EndianConverter.writeShort((short) 0); } /** - * Constructs a Row fro man <code>InputStream</code> + * Constructs a Row fro man <code>InputStream</code> * - * @param is InputStream containing a Pane Record + * @param is InputStream containing a Pane Record */ public Row(InputStream is) throws IOException { - read(is); + read(is); } /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>Row</code> */ public short getBiffType() { return PocketExcelConstants.ROW_DESCRIPTION; } - + /** - * Get the height of this row + * Get the height of this row * - * @return the height of this row + * @return the height of this row */ public short getRowHeight() { return EndianConverter.readShort(miyRw); } - + /** - * Get the rown number for this style + * Get the rown number for this style * - * @return the row this style applies to + * @return the row this style applies to */ public short getRowNumber() { return EndianConverter.readShort(rw); - } + } /** - * Reads a Row from an <code>InputStream</code> + * Reads a Row from an <code>InputStream</code> * - * @param is InputStream containing a Pane Record + * @param is InputStream containing a Pane Record */ public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(rw); - numOfBytesRead += input.read(miyRw); + + int numOfBytesRead = input.read(rw); + numOfBytesRead += input.read(miyRw); short scaledHeight = (short) (EndianConverter.readShort(miyRw) / scale); - miyRw = EndianConverter.writeShort(scaledHeight); - numOfBytesRead += input.read(grbit); - numOfBytesRead += input.read(ixfe); - - Debug.log(Debug.TRACE,"\trw : "+ EndianConverter.readShort(rw) + + miyRw = EndianConverter.writeShort(scaledHeight); + numOfBytesRead += input.read(grbit); + numOfBytesRead += input.read(ixfe); + + Debug.log(Debug.TRACE,"\trw : "+ EndianConverter.readShort(rw) + " miyRw : " + EndianConverter.readShort(miyRw) + " grbit : " + EndianConverter.readShort(grbit) + - " ixfe : " + EndianConverter.readShort(ixfe)); + " ixfe : " + EndianConverter.readShort(ixfe)); return numOfBytesRead; } - + public void write(OutputStream output) throws IOException { output.write(getBiffType()); @@ -134,5 +134,5 @@ public class Row implements BIFFRecord { Debug.log(Debug.TRACE,"Writing Row record"); } - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Selection.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Selection.java index effa109ef2f5..308eae29227e 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Selection.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Selection.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -42,56 +42,56 @@ import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; */ public class Selection implements BIFFRecord { - private byte[] rwTop = new byte[2]; + private byte[] rwTop = new byte[2]; private byte colLeft; - private byte[] rwBottom = new byte[2]; + private byte[] rwBottom = new byte[2]; private byte colRight; - private byte[] rwActive = new byte[2]; + private byte[] rwActive = new byte[2]; private byte colActive; - + /** * Default Constructor */ public Selection() { - this.rwTop = EndianConverter.writeShort((short) 0); - this.colLeft = 0; - this.rwBottom = EndianConverter.writeShort((short) 0); - this.colRight = 0; - this.rwActive = EndianConverter.writeShort((short) 0); - this.colActive = 0; - + this.rwTop = EndianConverter.writeShort((short) 0); + this.colLeft = 0; + this.rwBottom = EndianConverter.writeShort((short) 0); + this.colRight = 0; + this.rwActive = EndianConverter.writeShort((short) 0); + this.colActive = 0; + } /** - * Constructs a Selection Record from the <code>InputStream</code> + * Constructs a Selection Record from the <code>InputStream</code> * - * @param is InputStream containing a Pocket Excel Data file. + * @param is InputStream containing a Pocket Excel Data file. */ public Selection(InputStream is) throws IOException { - read(is); + read(is); } /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>Selection</code> */ public short getBiffType() { return PocketExcelConstants.CURRENT_SELECTION; } - + /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>Selection</code> */ public Point getActiveCell() { Point p = new Point(colActive, EndianConverter.readShort(rwActive)); return p; - } - + } + /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>Selection</code> */ @@ -100,32 +100,32 @@ public class Selection implements BIFFRecord { colActive = (byte) p.getX(); rwActive = EndianConverter.writeShort((short) p.getY()); } - + /** - * Reads a Selection Record from the <code>InputStream</code> + * Reads a Selection Record from the <code>InputStream</code> * - * @param is InputStream containing a Pocket Excel Data file. + * @param is InputStream containing a Pocket Excel Data file. */ public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(rwTop); - colLeft += (byte) input.read(); - numOfBytesRead += input.read(rwBottom); - colRight += (byte) input.read(); - numOfBytesRead += input.read(rwActive); - colActive += (byte) input.read(); + + int numOfBytesRead = input.read(rwTop); + colLeft += (byte) input.read(); + numOfBytesRead += input.read(rwBottom); + colRight += (byte) input.read(); + numOfBytesRead += input.read(rwActive); + colActive += (byte) input.read(); numOfBytesRead += 3; - - Debug.log(Debug.TRACE,"\trwTop : "+ EndianConverter.readShort(rwTop) + + + Debug.log(Debug.TRACE,"\trwTop : "+ EndianConverter.readShort(rwTop) + " colLeft : " + colLeft + " rwBottom : " + EndianConverter.readShort(rwBottom) + - " colRight : "+ colRight + + " colRight : "+ colRight + " rwActive : " + EndianConverter.readShort(rwActive) + " colActive : " + colActive); - - return numOfBytesRead; + + return numOfBytesRead; } - + public void write(OutputStream output) throws IOException { output.write(getBiffType()); @@ -138,5 +138,5 @@ public class Selection implements BIFFRecord { Debug.log(Debug.TRACE,"Writing Selection record"); } - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/StringValue.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/StringValue.java index f2fa16334182..c516eca69b1b 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/StringValue.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/StringValue.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -43,59 +43,59 @@ import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; */ public class StringValue implements BIFFRecord { - private byte[] cch = new byte[2]; + private byte[] cch = new byte[2]; private byte[] rgch; /** - * Constructs a StringValue Record from an <code>InputStream</code> + * Constructs a StringValue Record from an <code>InputStream</code> * - * @param is InputStream containing a StringValue Record + * @param is InputStream containing a StringValue Record */ public StringValue(String str) throws IOException { cch = EndianConverter.writeShort((short) str.length()); rgch = new byte[str.length()]; rgch = str.getBytes("UTF-16LE"); } - + /** - * Constructs a StringValue Record from an <code>InputStream</code> + * Constructs a StringValue Record from an <code>InputStream</code> * - * @param is InputStream containing a StringValue Record + * @param is InputStream containing a StringValue Record */ public StringValue(InputStream is) throws IOException { read(is); } /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>StringValue</code> */ public short getBiffType() { return PocketExcelConstants.FORMULA_STRING; } - + /** - * Reads a StringVlaue Record from an <code>InputStream</code> + * Reads a StringVlaue Record from an <code>InputStream</code> * - * @param is InputStream containing a StringValue Record + * @param is InputStream containing a StringValue Record */ public int read(InputStream input) throws IOException { - + cch[0] = (byte) input.read(); cch[1] = (byte) input.read(); int numOfBytesRead = 1; - + int strlen = EndianConverter.readShort(cch)*2; rgch = new byte[strlen]; - numOfBytesRead += input.read(rgch, 0, strlen); - - Debug.log(Debug.TRACE,"\tcch : "+ cch + + numOfBytesRead += input.read(rgch, 0, strlen); + + Debug.log(Debug.TRACE,"\tcch : "+ cch + " rgch : " + rgch); - + return numOfBytesRead; } - + public void write(OutputStream output) throws IOException { output.write(getBiffType()); @@ -106,7 +106,7 @@ public class StringValue implements BIFFRecord { } /** - * Gets the <code>String</code> representing the cells contents + * Gets the <code>String</code> representing the cells contents * * @return the <code>String</code> representing the cells contents */ diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/UnsupportedFormulaException.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/UnsupportedFormulaException.java index 4e021226998f..e6f941d46556 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/UnsupportedFormulaException.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/UnsupportedFormulaException.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window1.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window1.java index 428de2a75388..c060db90d60d 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window1.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window1.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -37,73 +37,73 @@ import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; /** - * Represents a BIFF REcord that describes workbook window attributes + * Represents a BIFF REcord that describes workbook window attributes */ public class Window1 implements BIFFRecord { - private byte[] grbit = new byte[2]; - private byte[] itabCur = new byte[2]; // index of selected worksheet - + private byte[] grbit = new byte[2]; + private byte[] itabCur = new byte[2]; // index of selected worksheet + /** * Constructor */ public Window1() { - grbit = EndianConverter.writeShort((short) 0); - itabCur = EndianConverter.writeShort((short) 0); + grbit = EndianConverter.writeShort((short) 0); + itabCur = EndianConverter.writeShort((short) 0); } /** - * Constructs a Window1 Record from an <code>InputStream</code> + * Constructs a Window1 Record from an <code>InputStream</code> * - * @param is InputStream containing a Window1 Record + * @param is InputStream containing a Window1 Record */ public Window1(InputStream is) throws IOException{ - read(is); + read(is); } - + /** * Set the number of the active sheet * - * @param activeSheet number of the active sheet + * @param activeSheet number of the active sheet */ public void setActiveSheet(int activeSheet) { itabCur = EndianConverter.writeShort((short) activeSheet); } - + /** - * Get the number of the active sheet + * Get the number of the active sheet * - * @return number of the active sheet + * @return number of the active sheet */ public int getActiveSheet() { return EndianConverter.readShort(itabCur); - } + } /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>Window1</code> */ public short getBiffType() { return PocketExcelConstants.WINDOW_INFO; } - + /** - * Reads a Window1 Record from an <code>InputStream</code> + * Reads a Window1 Record from an <code>InputStream</code> * - * @param is InputStream containing a Window1 Record + * @param is InputStream containing a Window1 Record */ public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(grbit); - numOfBytesRead += input.read(itabCur); - - Debug.log(Debug.TRACE,"\tgrbit : "+ EndianConverter.readShort(grbit) + + + int numOfBytesRead = input.read(grbit); + numOfBytesRead += input.read(itabCur); + + Debug.log(Debug.TRACE,"\tgrbit : "+ EndianConverter.readShort(grbit) + " itabCur : " + EndianConverter.readShort(itabCur)); - - return numOfBytesRead; + + return numOfBytesRead; } - + public void write(OutputStream output) throws IOException { output.write(getBiffType()); diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window2.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window2.java index 8557b9c4bed5..4c49a941219c 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window2.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window2.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -43,33 +43,33 @@ import org.openoffice.xmerge.converter.xml.sxc.SheetSettings; */ public class Window2 implements BIFFRecord { - private final static int FROZEN = 0x08; - private final static int NOSPLIT = 0x01; + private final static int FROZEN = 0x08; + private final static int NOSPLIT = 0x01; - private byte[] rwTop = new byte[2]; + private byte[] rwTop = new byte[2]; private byte colLeft; - private byte[] grbit = new byte[2]; - + private byte[] grbit = new byte[2]; + /** - * Constructor + * Constructor */ public Window2() { - this.rwTop = EndianConverter.writeShort((short) 0); - this.colLeft = 0; - this.grbit = EndianConverter.writeShort((short) 0); + this.rwTop = EndianConverter.writeShort((short) 0); + this.colLeft = 0; + this.grbit = EndianConverter.writeShort((short) 0); } - + /** - * Constructs a Window2 Record from an <code>InputStream</code> + * Constructs a Window2 Record from an <code>InputStream</code> * - * @param is InputStream containing a Window2 Record + * @param is InputStream containing a Window2 Record */ public Window2(InputStream is) throws IOException { - read(is); + read(is); } /** - * Get the hex code for this particular <code>BIFFRecord</code> + * Get the hex code for this particular <code>BIFFRecord</code> * * @return the hex code for <code>Window2</code> */ @@ -94,8 +94,8 @@ public class Window2 implements BIFFRecord { } } - /** - * This method tests if this object describes a freeze + /** + * This method tests if this object describes a freeze * * @return true if freeze otherwise false */ @@ -109,7 +109,7 @@ public class Window2 implements BIFFRecord { return true; } - /** + /** * This method tests if this object describes a split * * @return true if split otherwise false @@ -123,25 +123,25 @@ public class Window2 implements BIFFRecord { return true; } - + /** - * Reads a Window2 Record from an <code>InputStream</code> + * Reads a Window2 Record from an <code>InputStream</code> * - * @param is InputStream containing a Window2 Record + * @param is InputStream containing a Window2 Record */ public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(rwTop); - colLeft = (byte) input.read(); + + int numOfBytesRead = input.read(rwTop); + colLeft = (byte) input.read(); numOfBytesRead++; - numOfBytesRead += input.read(grbit); - - Debug.log(Debug.TRACE,"\trwTop : "+ EndianConverter.readShort(rwTop) + + numOfBytesRead += input.read(grbit); + + Debug.log(Debug.TRACE,"\trwTop : "+ EndianConverter.readShort(rwTop) + " colLeft : " + colLeft + " grbit : " + EndianConverter.readShort(grbit)); - return numOfBytesRead; + return numOfBytesRead; } - + public void write(OutputStream output) throws IOException { output.write(getBiffType()); diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook.java index b6c7e786f449..5a9f329e4667 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -44,18 +44,18 @@ import org.openoffice.xmerge.converter.xml.sxc.ColumnRowInfo; /** * This class is used by <code> PxlDocument</code> to maintain pexcel - * workbooks. + * workbooks. * - * @author Martin Maher + * @author Martin Maher */ public class Workbook implements org.openoffice.xmerge.Document, OfficeConstants { - private Vector fonts = new Vector(); - private Vector extendedFormats = new Vector(); - private Vector worksheets = new Vector(); - private Vector boundsheets = new Vector(); - private Vector definedNames = new Vector(); + private Vector fonts = new Vector(); + private Vector extendedFormats = new Vector(); + private Vector worksheets = new Vector(); + private Vector boundsheets = new Vector(); + private Vector definedNames = new Vector(); private static final CodePage cp; private static final Window1 win1; private static final BeginningOfFile bof;; @@ -63,10 +63,10 @@ OfficeConstants { private String fileName; static { - cp = new CodePage(); - win1 = new Window1(); - bof = new BeginningOfFile(true); - eof = new Eof(); + cp = new CodePage(); + win1 = new Window1(); + bof = new BeginningOfFile(true); + eof = new Eof(); } @@ -75,8 +75,8 @@ OfficeConstants { * as an argument. Also fills out a basic header block containing the * minimum number of objects that can be created at this time. * - * @param name Name of the Pocket Excel Data file. (excluding the file - * extension) + * @param name Name of the Pocket Excel Data file. (excluding the file + * extension) */ public Workbook(String name) throws IOException { fileName = name + PocketExcelConstants.FILE_EXTENSION; @@ -91,7 +91,7 @@ OfficeConstants { * Constructs a pocket Excel Workbook from the * <code>InputStream</code> and assigns it the document name passed in * - * @param is InputStream containing a Pocket Excel Data file. + * @param is InputStream containing a Pocket Excel Data file. */ public Workbook(String name, InputStream is) throws IOException { read(is); @@ -99,9 +99,9 @@ OfficeConstants { } /** - * Writes the current workbook to the <code>Outputstream</code> - * - * @param os The destination outputstream + * Writes the current workbook to the <code>Outputstream</code> + * + * @param os The destination outputstream */ public void write(OutputStream os) throws IOException { bof.write(os); @@ -132,10 +132,10 @@ OfficeConstants { } /** - * Reads a workbook from the <code>InputStream</code> and contructs a - * workbook object from it + * Reads a workbook from the <code>InputStream</code> and contructs a + * workbook object from it * - * @param is InputStream containing a Pocket Excel Data file. + * @param is InputStream containing a Pocket Excel Data file. */ public void read(InputStream is) throws IOException { @@ -150,7 +150,7 @@ OfficeConstants { Debug.log(Debug.TRACE,"End of file reached"); break; } - + switch (b) { case PocketExcelConstants.DEFINED_NAME: @@ -158,12 +158,12 @@ OfficeConstants { DefinedName dn = new DefinedName(is, this); definedNames.add(dn); break; - + case PocketExcelConstants.BOF_RECORD: Debug.log(Debug.TRACE,"BOF Record"); bof.read(is); break; - + case PocketExcelConstants.EOF_MARKER: Debug.log(Debug.TRACE,"EOF Marker"); eof.read(is); @@ -173,7 +173,7 @@ OfficeConstants { ws = new Worksheet(this); } break; - + case PocketExcelConstants.FONT_DESCRIPTION: Debug.log(Debug.TRACE,"FONT: Font Description (31h)"); FontDescription fd = new FontDescription(is); @@ -184,7 +184,7 @@ OfficeConstants { Debug.log(Debug.TRACE,"WINDOW1: Window Information (3Dh) [PXL 2.0]"); win1.read(is); break; - + case PocketExcelConstants.CODEPAGE: Debug.log(Debug.TRACE,"CODEPAGE : Codepage and unknown fields (42h)"); cp.read(is); @@ -195,32 +195,32 @@ OfficeConstants { BoundSheet bs = new BoundSheet(is); boundsheets.add(bs); break; - + case PocketExcelConstants.EXTENDED_FORMAT: Debug.log(Debug.TRACE,"XF: Extended Format (E0h) [PXL 2.0]"); ExtendedFormat xf = new ExtendedFormat(is); extendedFormats.add(xf); break; - + default: b = is.read(); break; } - + } is.close(); } - + /** - * Adds a font recrod to the workbook + * Adds a font recrod to the workbook * - * @param f the font record to add - */ + * @param f the font record to add + */ public int addFont(FontDescription f) { boolean alreadyExists = false; int i = 0; - + for(Enumeration e = fonts.elements();e.hasMoreElements();) { FontDescription fd = (FontDescription) e.nextElement(); if(fd.compareTo(f)) { @@ -230,18 +230,18 @@ OfficeConstants { i++; } } - - if(!alreadyExists) + + if(!alreadyExists) fonts.add(f); - return i; + return i; } /** - * Adds a ExtendedFormat record to the workbook + * Adds a ExtendedFormat record to the workbook * - * @param f the font recrod to add - */ + * @param f the font recrod to add + */ public int addExtendedFormat(Format fmt) throws IOException { FontDescription fd = new FontDescription(fmt); @@ -250,7 +250,7 @@ OfficeConstants { boolean alreadyExists = false; int i = 0; - + for(Enumeration e = extendedFormats.elements();e.hasMoreElements();) { ExtendedFormat currentXF = (ExtendedFormat) e.nextElement(); if(xf.compareTo(currentXF)) { @@ -263,30 +263,30 @@ OfficeConstants { if(!alreadyExists) extendedFormats.add(xf); - - return i; + + return i; } - + /** - * Gets a worksheet at a particular index from mthe current workbook. + * Gets a worksheet at a particular index from mthe current workbook. * - * @param index the index of the worksheet to retrieve + * @param index the index of the worksheet to retrieve */ public Worksheet getWorksheet(int index) { return ((Worksheet) worksheets.elementAt(index)); } - + /** * Returns a FontDescription indictated by the * index parameter passed in to the method * * @param ixfnt index to the FontDescriptions, this is a 0 based index - * @return FontDescription indexed by ixfe + * @return FontDescription indexed by ixfe */ public FontDescription getFontDescription(int ixfnt) { - return (FontDescription) fonts.elementAt(ixfnt); + return (FontDescription) fonts.elementAt(ixfnt); } /** @@ -294,15 +294,15 @@ OfficeConstants { * index parameter passed in to the method * * @param ixfe index to the FontDescriptions, this is a 0 based index - * @return FontDescription indexed by ixfe + * @return FontDescription indexed by ixfe */ public ExtendedFormat getExtendedFormat(int ixfe) { - return (ExtendedFormat) extendedFormats.elementAt(ixfe); - } + return (ExtendedFormat) extendedFormats.elementAt(ixfe); + } /** - * Returns an enumeration of DefinedNames for this workbook + * Returns an enumeration of DefinedNames for this workbook * * @return Enumeration for the DefinedNames */ @@ -310,9 +310,9 @@ OfficeConstants { return definedNames.elements(); } - + /** - * Returns an enumeration of <code>Settings</code> for this workbook + * Returns an enumeration of <code>Settings</code> for this workbook * * @return Enumeration of <code>Settings</code> */ @@ -333,39 +333,39 @@ OfficeConstants { } /** - * Returns a <code>Vector</code> containing all the worksheet Names + * Returns a <code>Vector</code> containing all the worksheet Names * - * @return a <code>Vector</code> containing all the worksheet Names - */ + * @return a <code>Vector</code> containing all the worksheet Names + */ public Vector getWorksheetNames() { Vector wsNames = new Vector(); for(int i = 0;i < boundsheets.size();i++) { wsNames.add(getSheetName(i)); - } + } return wsNames; } /** - * Returns the name of the worksheet at the specified index + * Returns the name of the worksheet at the specified index * - * @return a <code>String</code> containing the name of the worksheet - */ + * @return a <code>String</code> containing the name of the worksheet + */ public String getSheetName(int index) { - BoundSheet bs = (BoundSheet) boundsheets.elementAt(index); + BoundSheet bs = (BoundSheet) boundsheets.elementAt(index); return bs.getSheetName(); } /** - * Adds a <code>Worksheet</code> to the workbook. + * Adds a <code>Worksheet</code> to the workbook. * - * @return name the name of the <code>Worksheet</code> to be added - */ + * @return name the name of the <code>Worksheet</code> to be added + */ public void addWorksheet(String name) throws IOException { - + BoundSheet bs = new BoundSheet(name); boundsheets.add(bs); @@ -374,13 +374,13 @@ OfficeConstants { } /** - * Adds a cell to the current worksheet. + * Adds a cell to the current worksheet. * - * @return the name of the <code>Worksheet</code> to be added + * @return the name of the <code>Worksheet</code> to be added */ public void addCell(int row,int col, Format fmt, String cellContents) throws IOException { - + Worksheet currentWS = (Worksheet) worksheets.elementAt(worksheets.size()-1); int ixfe = addExtendedFormat(fmt); @@ -395,7 +395,7 @@ OfficeConstants { Formula f = new Formula(row, col, cellContents, ixfe, fmt, this); currentWS.addCell(f); if(category.equalsIgnoreCase(CELLTYPE_STRING)) { - StringValue sv = new StringValue(fmt.getValue()); + StringValue sv = new StringValue(fmt.getValue()); currentWS.addCell(sv); } } catch(Exception e) { @@ -410,31 +410,31 @@ OfficeConstants { } catch(Exception e) { Debug.log(Debug.TRACE,"Error could not parse Float " + cellContents); LabelCell lc = new LabelCell(row, col, cellContents, ixfe); - currentWS.addCell(lc); + currentWS.addCell(lc); } } else { if(cellContents.length()==0) { Debug.log(Debug.TRACE, "Blank Cell"); BlankCell b = new BlankCell(row, col, ixfe); - currentWS.addCell(b); + currentWS.addCell(b); } else { Debug.log(Debug.TRACE, "Label Cell : " + cellContents); LabelCell lc = new LabelCell(row, col, cellContents, ixfe); - currentWS.addCell(lc); // three because we assume the last three - // Records in any worksheet is the selection, - // window2 and eof Records + currentWS.addCell(lc); // three because we assume the last three + // Records in any worksheet is the selection, + // window2 and eof Records } } } /** * Will create a number of ColInfo records based on the column widths - * based in. + * based in. * - * @param columnRows <code>Vector</code> of <code>ColumnRowInfo</code> + * @param columnRows <code>Vector</code> of <code>ColumnRowInfo</code> */ public void addColInfo(Vector columnRows) throws IOException { - + Worksheet currentWS = (Worksheet) worksheets.elementAt(worksheets.size()-1); int nCols = 0; @@ -448,15 +448,15 @@ OfficeConstants { int repeated = cri.getRepeated(); if(cri.isColumn()) { Debug.log(Debug.TRACE,"Workbook: adding ColInfo width = " + size); - ColInfo newColInfo = new ColInfo( nCols, - nCols+repeated-1, + ColInfo newColInfo = new ColInfo( nCols, + nCols+repeated-1, size, ixfe); currentWS.addCol(newColInfo); nCols += repeated; } else if(cri.isRow()) { - + Debug.log(Debug.TRACE,"Workbook: adding Row Height = " + size); - if(!cri.isDefaultSize()) { + if(!cri.isDefaultSize()) { for(int i=0;i<repeated;i++) { Row newRow = new Row(nRows++, size, cri.isUserDefined()); currentWS.addRow(newRow); @@ -465,26 +465,26 @@ OfficeConstants { // If it is the Default Row we don't need to add it nRows += repeated; } - - } + + } } } /** * Will create a number of ColInfo recrods based on the column widths - * based in. + * based in. * - * @param an integer list representing the column widths + * @param an integer list representing the column widths */ public void addNameDefinition(NameDefinition nameDefinition) throws IOException { DefinedName dn = new DefinedName(nameDefinition, this); definedNames.add(dn); } - + /** * Adds the <code>BookSettings</code> for this workbook. - * + * * @param book the <code>BookSettings</code> to add */ public void addSettings(BookSettings book) throws IOException { @@ -492,7 +492,7 @@ OfficeConstants { int index = 0; Vector sheetSettings = book.getSheetSettings(); String activeSheetName = book.getActiveSheet(); - + for(Enumeration e = worksheets.elements();e.hasMoreElements();) { Worksheet ws = (Worksheet) e.nextElement(); String name = getSheetName(index++); @@ -507,33 +507,33 @@ OfficeConstants { } } } - + /** - * Return the filename of the pxl document without the file extension + * Return the filename of the pxl document without the file extension * - * @return filename without the file extension + * @return filename without the file extension */ public String getName() { // We have to strip off the file extension int end = fileName.lastIndexOf("."); String name; - if( end >= 0) // check in case the filename is already stripped + if( end >= 0) // check in case the filename is already stripped name = fileName.substring(0, end); else name = fileName; return name; } - + /** - * Returns the filename of the pxl document with the file extension + * Returns the filename of the pxl document with the file extension * - * @return filename with the file extension + * @return filename with the file extension */ public String getFileName() { return fileName; } - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet.java index 7b681af7b273..6ab57189f39f 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -41,50 +41,50 @@ import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; /** * This class is used by <code>PxlDocument</code> to maintain pexcel - * worksheets. + * worksheets. * - * @author Martin Maher + * @author Martin Maher */ public class Worksheet { private String name; private Workbook wb; - private Vector rows = new Vector(); - private Vector colInfo = new Vector(); - private Vector cells = new Vector(); - private DefColWidth dcw = new DefColWidth(); - private DefRowHeight drh = new DefRowHeight(); - private Window2 win2 = new Window2(); - private Selection sel = new Selection(); - private Pane p = new Pane(); + private Vector rows = new Vector(); + private Vector colInfo = new Vector(); + private Vector cells = new Vector(); + private DefColWidth dcw = new DefColWidth(); + private DefRowHeight drh = new DefRowHeight(); + private Window2 win2 = new Window2(); + private Selection sel = new Selection(); + private Pane p = new Pane(); private BeginningOfFile bof; private Eof eof; - + /** - * Writes the current workbook to the <code>Outputstream</code> - * - * @param os The destination outputstream + * Writes the current workbook to the <code>Outputstream</code> + * + * @param os The destination outputstream */ public Worksheet(Workbook wb) { this.wb = wb; } - + /** - * Default Contructor - * - * @param os The destination outputstream + * Default Contructor + * + * @param os The destination outputstream */ public Worksheet() { - } + } /** - * Writes the current workbook to the <code>Outputstream</code> - * - * @param os The destination outputstream + * Writes the current workbook to the <code>Outputstream</code> + * + * @param os The destination outputstream */ public void write(OutputStream os) throws IOException { - - bof = new BeginningOfFile(false); + + bof = new BeginningOfFile(false); bof.write(os); dcw.write(os); for(Enumeration e = colInfo.elements();e.hasMoreElements();) { @@ -103,15 +103,15 @@ public class Worksheet { win2.write(os); p.write(os); sel.write(os); - eof = new Eof(); + eof = new Eof(); eof.write(os); } /** - * Reads a worksheet from the <code>InputStream</code> and contructs a - * workbook object from it + * Reads a worksheet from the <code>InputStream</code> and contructs a + * workbook object from it * - * @param is InputStream containing a Pocket Excel Data file. + * @param is InputStream containing a Pocket Excel Data file. */ public boolean read(InputStream is) throws IOException { @@ -128,13 +128,13 @@ public class Worksheet { BlankCell bc = new BlankCell(is); cells.add(bc); break; - + case PocketExcelConstants.NUMBER_CELL: Debug.log(Debug.TRACE,"NUMBER: Cell Value, Floating-Point Number (03h)"); - FloatNumber fn = new FloatNumber(is); + FloatNumber fn = new FloatNumber(is); cells.add(fn); break; - + case PocketExcelConstants.LABEL_CELL: Debug.log(Debug.TRACE,"LABEL: Cell Value, String Constant (04h)"); LabelCell lc = new LabelCell(is); @@ -149,14 +149,14 @@ public class Worksheet { case PocketExcelConstants.FORMULA_CELL: Debug.log(Debug.TRACE,"FORMULA: Cell Formula (06h)"); Formula f = new Formula(is, wb); - cells.add(f); + cells.add(f); break; - + case PocketExcelConstants.FORMULA_STRING: Debug.log(Debug.TRACE,"String Value of a Formula (07h)"); StringValue sv = new StringValue(is); break; - + case PocketExcelConstants.ROW_DESCRIPTION: Debug.log(Debug.TRACE,"ROW: Describes a Row (08h)"); Row rw = new Row(is); @@ -167,7 +167,7 @@ public class Worksheet { Debug.log(Debug.TRACE,"BOF Record"); bof = new BeginningOfFile(is); break; - + case PocketExcelConstants.EOF_MARKER: Debug.log(Debug.TRACE,"EOF Marker"); eof = new Eof(); @@ -177,7 +177,7 @@ public class Worksheet { Debug.log(Debug.TRACE,"SELECTION: Current Selection (1Dh)"); sel = new Selection(is); break; - + case PocketExcelConstants.NUMBER_FORMAT: Debug.log(Debug.TRACE,"FORMAT: Number Format (1Eh)"); NumberFormat nf = new NumberFormat(is); @@ -187,22 +187,22 @@ public class Worksheet { Debug.log(Debug.TRACE,"DEFAULTROWHEIGHT: Default Row Height (25h)"); drh = new DefRowHeight(is); break; - + case PocketExcelConstants.SHEET_WINDOW_INFO: Debug.log(Debug.TRACE,"WINDOW2: Sheet Window Information (3Eh) [PXL 2.0]"); win2 = new Window2(is); break; - + case PocketExcelConstants.PANE_INFO: Debug.log(Debug.TRACE,"PANE: Number of Panes and their Position (41h) [PXL 2.0]"); p = new Pane(is); break; - + case PocketExcelConstants.DEF_COL_WIDTH: Debug.log(Debug.TRACE,"DEFCOLWIDTH: Default Column Width (55h) [PXL 2.0]"); dcw = new DefColWidth(is); break; - + case PocketExcelConstants.COLINFO: Debug.log(Debug.TRACE,"COLINFO: Column Formatting Information (7Dh) [PXL 2.0]"); ColInfo ci = new ColInfo(is); @@ -213,7 +213,7 @@ public class Worksheet { break; } b = is.read(); - + } Debug.log(Debug.TRACE,"Leaving Worksheet:"); @@ -221,9 +221,9 @@ public class Worksheet { } /** - * Returns an enumerator which will be used to access individual cells + * Returns an enumerator which will be used to access individual cells * - * @return an enumerator to the worksheet cells + * @return an enumerator to the worksheet cells */ public Enumeration getCellEnumerator() throws IOException { return (cells.elements()); @@ -233,7 +233,7 @@ public class Worksheet { * Adds a cell to this worksheet. Current valdid celltypes are * <code>FloatNumber</code>, <code>LabelCell</code> or <code>Formula</code> * - * @param f the font recrod to add + * @param f the font recrod to add */ public void addCell(BIFFRecord br) { cells.add(br); @@ -243,7 +243,7 @@ public class Worksheet { * Adds a number of ColInfo Records to the worksheet base on a list of * clumnwidths passed in * - * @param list of column widths + * @param list of column widths */ public void addRow(Row r) { rows.add(r); @@ -253,7 +253,7 @@ public class Worksheet { * Adds a number of ColInfo Records to the worksheet base on a list of * clumnwidths passed in * - * @param list of column widths + * @param list of column widths */ public void addCol(ColInfo c) { colInfo.add(c); @@ -261,7 +261,7 @@ public class Worksheet { /** * Returns an <code>Enumeration</code> to the ColInfo's for this worksheet * - * @return an <code>Enumeration</code> to the ColInfo's + * @return an <code>Enumeration</code> to the ColInfo's */ public void addSettings(SheetSettings s) { @@ -275,17 +275,17 @@ public class Worksheet { win2.setSplitType(s.getSplitType()); } } - + /** * Returns an <code>Enumeration</code> to the ColInfo's for this worksheet * - * @return an <code>Enumeration</code> to the ColInfo's + * @return an <code>Enumeration</code> to the ColInfo's */ public Enumeration getColInfos() { return (colInfo.elements()); } - + /** * Returns a <code>SheetSettings</code> object containing a collection of data * contained in <code>Pane</code>, <code>Window2</code> and @@ -305,15 +305,15 @@ public class Worksheet { s.setPaneNumber(p.getPaneNumber()); s.setTopLeft(p.getTop(), p.getLeft()); return s; - } + } /** * Returns an <code>Enumeration</code> to the Rows for this worksheet * - * @return an <code>Enumeration</code> to the Rows + * @return an <code>Enumeration</code> to the Rows */ public Enumeration getRows() { return (rows.elements()); } - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaCompiler.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaCompiler.java index 61f5c8ab9c6d..2e060ca0a148 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaCompiler.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaCompiler.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -31,78 +31,78 @@ import java.util.*; import org.openoffice.xmerge.util.Debug; /** - * FormulaCompiler converts Calc formula string into PocketXL bytes + * FormulaCompiler converts Calc formula string into PocketXL bytes * and PocketXL formula bytes into Calc Formula strings - * + * * For converting from infix to Reverse Polish (or Postfix) notation the string is * converted into a vector of Tokens and then re-ordered based on a modified version * of the standard Infix to RPN conversion algorithms. * <pre> - * Infix2Rpn(tokens) - * while have more tokens - * if token is operand - * push to stack - * else if token is function, argument separater, or open bracket - * push token - * extract tokens to matching close bracket into param - * Infix2Rpn(param) - * else if token is close bracket - * pop from stack into result until close bracket or function - * else - * while stack.top.priority >= token.priority - * add stack.pop to result - * push token onto stack + * Infix2Rpn(tokens) + * while have more tokens + * if token is operand + * push to stack + * else if token is function, argument separater, or open bracket + * push token + * extract tokens to matching close bracket into param + * Infix2Rpn(param) + * else if token is close bracket + * pop from stack into result until close bracket or function + * else + * while stack.top.priority >= token.priority + * add stack.pop to result + * push token onto stack * </pre> * For converting from RPN to Infix the following algorithm is applied: * <pre> - * while have more tokens - * if token is operand - * push token to stack - * else if token is function or operator - * pop from stack number of args required by token - * apply token to params to make expr - * push expr to stack - * return stack.pop + * while have more tokens + * if token is operand + * push token to stack + * else if token is function or operator + * pop from stack number of args required by token + * apply token to params to make expr + * push expr to stack + * return stack.pop * </pre> */ public class FormulaCompiler { /** - * Constructs a FormulaCompiler object + * Constructs a FormulaCompiler object */ public FormulaCompiler() { } - + private boolean isPercent(Token pt) { return pt.getTokenID() == TokenConstants.TPERCENT; } - + private boolean isOpenBrace(Token pt) { return pt.getTokenID() == TokenConstants.TPAREN; } - + private boolean isCloseBrace(Token pt) { return pt.getValue().compareTo(")") == 0; } - + private boolean isParamDelimiter(Token pt) { return pt.getTokenID() == TokenConstants.TARGSEP; - } + } private boolean isBinaryOperator(Token pt) { return false; } - + /** * Re-order into Infix format - * @param tokens The tokens in RPN form - * @return The vector of tokens re-ordered in Infix notation + * @param tokens The tokens in RPN form + * @return The vector of tokens re-ordered in Infix notation */ public Vector RPN2Infix(Vector tokens) { Vector infixExpr = new Vector(15); ListIterator iter = tokens.listIterator(); Stack evalStack = new Stack(); Stack args = new Stack(); - + while (iter.hasNext()) { Token pt = (Token)iter.next(); if (pt.isOperand()) { @@ -119,15 +119,15 @@ public class FormulaCompiler { } return (Vector)evalStack.elementAt(0); } - + /** * Convert the infix expression to RPN. Note that open brackets are saved onto the stack to preserve the users bracketing. * <p>Also note that the open bracket following functions is not pushed onto the stack - it is always implied when * writing out results * - * @param tokens The vector of tokens in Infix form + * @param tokens The vector of tokens in Infix form * - * @return A vector of tokens for the expression in Reverse Polish Notation order + * @return A vector of tokens for the expression in Reverse Polish Notation order */ public Vector infix2RPN(Vector tokens) { Vector rpnExpr = new Vector(15); @@ -135,7 +135,7 @@ public class FormulaCompiler { ListIterator iter = tokens.listIterator(); while (iter.hasNext()) { Token pt = (Token)iter.next(); - + if (pt.isOperand()) { //Operands are output immediately rpnExpr.add(pt); } else if (pt.isFunction() || isParamDelimiter(pt) || isOpenBrace(pt)) { //Extract parameters after afunction or comma @@ -144,7 +144,7 @@ public class FormulaCompiler { iter.next(); } Vector param = extractParameter(iter); - Debug.log(Debug.TRACE, "Extracted parameter " + param); + Debug.log(Debug.TRACE, "Extracted parameter " + param); rpnExpr.addAll(infix2RPN(param)); } else if (isCloseBrace(pt)) { //Pop off stack till you meet a function or an open bracket Token tmpTok = null; @@ -159,13 +159,13 @@ public class FormulaCompiler { rpnExpr.add(tmpTok); } if (tmpTok.isFunction() || isOpenBrace(tmpTok)) { - bPop = false; + bPop = false; } } } } else { if (!evalStack.isEmpty()) { - while (!evalStack.isEmpty() && + while (!evalStack.isEmpty() && (((Token)evalStack.peek()).getTokenPriority() >=pt.getTokenPriority())) { Token topTok = (Token)evalStack.peek(); if (topTok.isFunction() || isOpenBrace(topTok)) { @@ -174,10 +174,10 @@ public class FormulaCompiler { rpnExpr.add(evalStack.pop()); } } - evalStack.push(pt); + evalStack.push(pt); } } - + while (!evalStack.isEmpty()) { Token topTok = (Token)evalStack.peek(); if (!(isOpenBrace(topTok) || isParamDelimiter(topTok))) { //Don't output brackets and commas @@ -190,7 +190,7 @@ public class FormulaCompiler { } return rpnExpr; } - + /** * Extract a parameter or bracketed sub-expression * @param iter an iterator into the list @@ -199,10 +199,10 @@ public class FormulaCompiler { protected Vector extractParameter(ListIterator iter) { Vector param = new Vector(5); int subExprCount = 0; - + while (iter.hasNext()) { Token pt = (Token)iter.next(); - Debug.log(Debug.TRACE, "Token is " + pt + " and subExprCount is " + subExprCount); + Debug.log(Debug.TRACE, "Token is " + pt + " and subExprCount is " + subExprCount); if (isOpenBrace(pt)) { subExprCount++; param.add(pt); @@ -223,12 +223,12 @@ public class FormulaCompiler { } return param; } - + /** * Given the operator and it's operators - * @param pt The operator token - * @param args The arguments for this operator - * @return A correctly ordered expression + * @param pt The operator token + * @param args The arguments for this operator + * @return A correctly ordered expression */ protected Vector makeExpression(Token pt, Stack args) { Vector tmp = new Vector(5); diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaHelper.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaHelper.java index aa14a3c7e953..208feb030f36 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaHelper.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaHelper.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -47,12 +47,12 @@ public class FormulaHelper { private static TokenDecoder decoder; private boolean rangeType = false; private boolean expressionType = false; - + static { parser = new FormulaParser(); compiler = new FormulaCompiler(); encoder = new TokenEncoder(); - decoder = new TokenDecoder(); + decoder = new TokenDecoder(); } /** @@ -63,54 +63,54 @@ public class FormulaHelper { */ public void setWorkbook(Workbook wb) { - encoder.setWorkbook(wb); + encoder.setWorkbook(wb); decoder.setWorkbook(wb); parser.setWorkbook(wb); } /** * Convertes a string representation of a calc formula into an array of PocketXL bytes - * @param formula The Formula String (e.g. 1+SUM(A1,B1)) + * @param formula The Formula String (e.g. 1+SUM(A1,B1)) * - * @throws UnsupportedFunctionException Thrown if a function in the formula is nto supported by Pocket Excel - * @throws FormulaParsingException Thrown when the formula is not well formed + * @throws UnsupportedFunctionException Thrown if a function in the formula is nto supported by Pocket Excel + * @throws FormulaParsingException Thrown when the formula is not well formed * */ public byte[] convertCalcToPXL(String formula) throws UnsupportedFunctionException, FormulaParsingException { - + Vector parseTokens = parser.parse(formula); Vector rpnTokens = compiler.infix2RPN(parseTokens); - + ByteArrayOutputStream bytes = null; try { - bytes = new ByteArrayOutputStream(); + bytes = new ByteArrayOutputStream(); for (Enumeration e = rpnTokens.elements(); e.hasMoreElements();) { Token t = (Token)e.nextElement(); bytes.write(encoder.getByte(t)); } } catch (IOException e) { } - + return bytes.toByteArray(); } - + /** * Converts a PocketXL byte array into a Calc function string - * @param formula A byte array that contains the PocketXL bytes for a formula + * @param formula A byte array that contains the PocketXL bytes for a formula * */ public String convertPXLToCalc(byte[] formula) { Vector parseTokens = decoder.getTokenVector(formula); Vector infixTokens = compiler.RPN2Infix(parseTokens); - + StringBuffer buff = new StringBuffer(); for (Enumeration e = infixTokens.elements();e.hasMoreElements();) { Token t = (Token)e.nextElement(); buff.append(t.toString()); // If we are parsing a Name definition we need to know if it is of // type range or expression - if(!t.isOperand()) { + if(!t.isOperand()) { expressionType = true; } } @@ -127,26 +127,26 @@ public class FormulaHelper { * types differs. This is only of interest when dealing with * <code>DefinedNames</code> and not <code>Formula</code> * - * @return a boolean true if of type range otherwise false + * @return a boolean true if of type range otherwise false * */ public boolean isRangeType() { - - return rangeType; + + return rangeType; } /** * Returns a boolean indicating whether or not the byte[] parsed is of * type expression. This means it contains operators. This is necessry - * because the syntax for range and expression types differs. This is - * only of interest when dealing with <code>DefinedNames</code> and not - * <code>Formula</code> + * because the syntax for range and expression types differs. This is + * only of interest when dealing with <code>DefinedNames</code> and not + * <code>Formula</code> * - * @return a boolean true if of type expression otherwise false + * @return a boolean true if of type expression otherwise false * */ public boolean isExpressionType() { - - return expressionType; + + return expressionType; } } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParser.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParser.java index 003f61207b73..0ab40ec53fd2 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParser.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParser.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -27,25 +27,25 @@ package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; - + import java.util.Vector; import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; import org.openoffice.xmerge.util.Debug; /** - * This is the Formula Parser based on an article written by Jack Crenshaw. It is a + * This is the Formula Parser based on an article written by Jack Crenshaw. It is a * top down parser with some basic error handling. It handles - * +,-,*,/,>,<,>=,<=,=,<>, unary + and - as well as functions. + * +,-,*,/,>,<,>=,<=,=,<>, unary + and - as well as functions. * The BNF notation for this parser is * <pre> - * <expression> ::= <unary op> <term> [<addop>|<logop> <term>] - * <term> ::= <factor> [<mulop> <factor>] - * <factor> ::= <number>[%] | <CellRef> | <QuoteString> | <expression> + * <expression> ::= <unary op> <term> [<addop>|<logop> <term>] + * <term> ::= <factor> [<mulop> <factor>] + * <factor> ::= <number>[%] | <CellRef> | <QuoteString> | <expression> * </pre> */ public class FormulaParser { - + private char look; private String formulaStr; private int index = 1; @@ -62,7 +62,7 @@ public class FormulaParser { tokenFactory = new TokenFactory(); tokenVector = new Vector(); } - + /** * */ @@ -70,7 +70,7 @@ public class FormulaParser { this.wb = wb; } - + /** * Parse method for parsing from a String to a byte[] * @@ -79,7 +79,7 @@ public class FormulaParser { * @return A <code>Vector</code> containing the parsed <code>Token</code>s */ public Vector parse(String formula) throws FormulaParsingException { - + index = 1; look = ' '; tokenVector.clear(); @@ -90,38 +90,38 @@ public class FormulaParser { expression(); } else { throw new FormulaParsingException("No equals found!" + makeErrorString()); - } + } return tokenVector; } - + /** * Identify + and - operators - * + * * @param c The character which is to be identified - * @return A boolean returning the result of the comparison + * @return A boolean returning the result of the comparison */ private boolean isAddOp(char c) { return (c == '-') || (c == '+'); } - + /** * Determine if the current character is a multiop * - * @return A boolean returning the result of the comparison + * @return A boolean returning the result of the comparison */ private boolean isMultiOp() { return look=='*' || look =='/' || look == '^' || look == '&'; } - + /** * Identify <, >, <=, >=, =, <> using the index to find the current character(s) - * - * @return A boolean returning the result of the comparison + * + * @return A boolean returning the result of the comparison */ private boolean isLogicalOp() { if (!isLogicalOpChar(look)) { return false; - } else if ((index+1) >= formulaStr.length()) {//logical operators in their own right : if at end then return true + } else if ((index+1) >= formulaStr.length()) {//logical operators in their own right : if at end then return true return true; } else if (!isLogicalOpChar(formulaStr.charAt(index))) { // we have >, < or = on their own return true; @@ -130,7 +130,7 @@ public class FormulaParser { } else if ((look == '>') && (formulaStr.charAt(index) == '=')) { // >= return true; } - + return false; } @@ -138,10 +138,10 @@ public class FormulaParser { * Identify <, >, <=, >=, =, <> * * @param The <code>String</code> which is to be identified - * @return A boolean returning the result of the comparison + * @return A boolean returning the result of the comparison */ private boolean isLogicalOp(String op) { - return ((op.compareTo(">") == 0) || + return ((op.compareTo(">") == 0) || (op.compareTo("<") == 0) || (op.compareTo(">=") == 0) || (op.compareTo("<=") == 0) || @@ -149,42 +149,42 @@ public class FormulaParser { (op.compareTo("<>") == 0)); } - + /** * Identify characters that MAY be logical operator characters - * + * * @param c The character which is to be identified - * @return A boolean returning the result of the comparison + * @return A boolean returning the result of the comparison */ private boolean isLogicalOpChar(char c) { return (c == '>') || (c == '<') || (c == '='); } - + /** * Identify special Cell Reference charaters - * + * * @param c The character which is to be identified - * @return A boolean returning the result of the comparison + * @return A boolean returning the result of the comparison */ private boolean isCellRefSpecialChar(char c) { return (c == ':') || (c == '$') || (c == '.'); } - + /** * Identify letters - * + * * @param c The character which is to be identified - * @return A boolean returning the result of the comparison + * @return A boolean returning the result of the comparison */ private boolean isAlpha(char c) { return(Character.isLetter(c)); } - + /** * Identify numbers - * + * * @param c The character which is to be identified - * @return A boolean returning the result of the comparison + * @return A boolean returning the result of the comparison */ private boolean isDigit(char c) { return(Character.isDigit(c)); @@ -192,19 +192,19 @@ public class FormulaParser { /** * Identify numbers - * + * * @param c The character which is to be identified - * @return A boolean returning the result of the comparison + * @return A boolean returning the result of the comparison */ private boolean isPercent(char c) { return (c == '%'); } - + /** * Identify letters or numbers - * + * * @param c The character which is to be identified - * @return A boolean returning the result of the comparison + * @return A boolean returning the result of the comparison */ private boolean isAlphaNum(char c) { return(isAlpha(c) || isDigit(c)); @@ -212,9 +212,9 @@ public class FormulaParser { /** * Identify valid Characters for cell references - * + * * @param c The character which is to be identified - * @return A boolean returning the result of the comparison + * @return A boolean returning the result of the comparison */ private boolean isCellRefChar(char c) { return(isAlpha(c) || isDigit(c) || isCellRefSpecialChar(c)); @@ -226,23 +226,23 @@ public class FormulaParser { * @param c The character which is to be matched */ private void match(char c) throws FormulaParsingException { - + if(look==c) { - Debug.log(Debug.TRACE,"Operator Found : " + look); + Debug.log(Debug.TRACE,"Operator Found : " + look); getChar(); skipWhite(); } else throw new FormulaParsingException("Unexpected character '" + c + "'" + makeErrorString()); - } - + } + /** * Test if current character is a match and move to next character * - * @param symbol The <code>String</code> to be matched. + * @param symbol The <code>String</code> to be matched. */ private void match(String symbol) throws FormulaParsingException { - + int numChars = symbol.length(); boolean bContinue = true; for (int i=0;i<numChars && bContinue; i++) { @@ -254,28 +254,28 @@ public class FormulaParser { } } } - + /** * Skip over whitespaces (ie. spaces and tabs) */ private void skipWhite() throws FormulaParsingException { - + boolean success = true; - + while(Character.isWhitespace(look) && success) { success = getChar(); } } - + /** * This is a factor for multiplication and division operators */ private void factor() throws FormulaParsingException { - if(isAddOp(look)) { // handle unary addop + if(isAddOp(look)) { // handle unary addop Character ch = new Character(look); match(look); tokenVector.add(tokenFactory.getOperatorToken(ch.toString(), 1)); - } + } if(look=='(') { match('('); tokenVector.add(tokenFactory.getOperatorToken("(", 1)); @@ -288,17 +288,17 @@ public class FormulaParser { ident(); } } - + /** * Pulls the next character from the <code>String</code> - * - * @return boolean false if the end if the statement - * is reached otherwise true + * + * @return boolean false if the end if the statement + * is reached otherwise true */ private boolean getChar() throws FormulaParsingException { - + boolean success = true; - + if(index<formulaStr.length()) { look = formulaStr.charAt(index); index++; @@ -308,22 +308,22 @@ public class FormulaParser { success = false; } return success; - } - + } + /** * Parses the number of arguments in a function - * + * * @return The number of arguments */ private int arguments() throws FormulaParsingException { int numArgs; - + skipWhite(); if(look==')') numArgs = 0; else numArgs = 1; - + while(look!=')') { expression(); if(look==',') { @@ -338,7 +338,7 @@ public class FormulaParser { /** * Test to see if we have come across a cell reference or a Name * Definition. - */ + */ private boolean isCellRef(String s) { char c; boolean result = false; @@ -353,30 +353,30 @@ public class FormulaParser { // if it is a simple cell reference then there will not be a cell // reference 'special char' so we should also look for a digit - if(!result) { + if(!result) { if(isDigit(s.charAt(1)) || isDigit(s.charAt(2))) { result = true; } } return result; } - + /** * Test to see if we have come across a cell reference or a function and * add the resulting toek nto the tokenVector. */ private void ident() throws FormulaParsingException { - + String cell = getTokenString(); if(look=='(') { Debug.log(Debug.TRACE,"Found Function : " + cell); - + int index = tokenVector.size(); match('('); tokenVector.add(tokenFactory.getOperatorToken("(", 1)); int numArgs = arguments(); match(')'); - tokenVector.add(tokenFactory.getOperatorToken(")", 1)); + tokenVector.add(tokenFactory.getOperatorToken(")", 1)); tokenVector.insertElementAt(tokenFactory.getFunctionToken(cell, numArgs), index); } else { @@ -396,17 +396,17 @@ public class FormulaParser { } } } - + /** * Will keep pulling valid logical operators from the formula and return * the resultant <code>String</code>. - * + * * @return a <code>String<code> representing a logical operator */ private String getLogicalOperator() throws FormulaParsingException { String op = new String(); boolean status; - + do { op += look; status = getChar(); @@ -414,15 +414,15 @@ public class FormulaParser { skipWhite(); return op; } - + /** - * Keeps pulling characters from the statement until we get an + * Keeps pulling characters from the statement until we get an * operator and returns the resulting string. * * @return A <code>String</code>representing the next token */ private String getTokenString() throws FormulaParsingException { - + if(!isAlpha(look) && look!='$') throw new FormulaParsingException("Expected Cell Reference" + makeErrorString()); else { @@ -436,20 +436,20 @@ public class FormulaParser { return cell; } } - + /** * Keeps pulling numbers from the statement and add the resulting integer * token to the tokenVector. - */ + */ private void getNum() throws FormulaParsingException { - - Debug.log(Debug.TRACE,"getNum : "); + + Debug.log(Debug.TRACE,"getNum : "); if(!isDigit(look)) throw new FormulaParsingException("Expected Integer" + makeErrorString()); else { String num = new String(); boolean status; - + do { num += look; status = getChar(); @@ -459,13 +459,13 @@ public class FormulaParser { if(isPercent(look)) { match(look); tokenVector.add(tokenFactory.getOperatorToken("%", 1)); - Debug.log(Debug.TRACE,"Added Percent token to Vector: "); + Debug.log(Debug.TRACE,"Added Percent token to Vector: "); } - Debug.log(Debug.TRACE,"Number parsed : " + num); + Debug.log(Debug.TRACE,"Number parsed : " + num); } } - - + + /** * Term will parse multiplication/division expressions */ @@ -473,15 +473,15 @@ public class FormulaParser { factor(); while(isMultiOp()) { multiOp(Character.toString(look)); - } + } } - + /** * Expression is the entry point for the parser. It is the code * that parses addition/subtraction expressions. */ private void expression() throws FormulaParsingException { - + if (look == '"') { //Extract a quoted string... StringBuffer buff = new StringBuffer(); boolean success = true; @@ -490,12 +490,12 @@ public class FormulaParser { buff.append(look); success = getChar(); } - + if (look != '"') { //We've reached the end of the string without getting a closing quote throw new FormulaParsingException("Expected closing quote." + makeErrorString()); } else { tokenVector.add(tokenFactory.getOperandToken(buff.toString(), "STRING")); - getChar(); //Move on to the next character + getChar(); //Move on to the next character } } else { term(); @@ -504,10 +504,10 @@ public class FormulaParser { if (isAddOp(look)) { addOp(Character.toString(look)); } else if (isLogicalOp()) { - logicalOp(); + logicalOp(); } - } - } + } + } /** * Test to see if the next token (represented as a <code>String</code>) is @@ -520,10 +520,10 @@ public class FormulaParser { private void addOp(String op) throws FormulaParsingException { match(op); tokenVector.add(tokenFactory.getOperatorToken(op, 2)); - term(); + term(); } - - /** + + /** * Test to see if the next token (represented as a <code>String</code>) is * the same as the String passed in. Move the index along to the end of * that String and add that <code>Token</code> to the tokenVector. Then @@ -536,7 +536,7 @@ public class FormulaParser { tokenVector.add(tokenFactory.getOperatorToken(op, 2)); factor(); } - + /** * Pull a logical operator starting at the current index, add a token for * that operator to the tokenVector and call <code>term<code> to parse the @@ -553,7 +553,7 @@ public class FormulaParser { for (int i=0; i<index-1; i++) { buff.append(' '); } - + buff.append('^'); return "\n\t" + formulaStr + "\n\t" + buff.toString(); } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParsingException.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParsingException.java index a74723702bd8..e8465391e6ff 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParsingException.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParsingException.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -32,9 +32,9 @@ package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; * * Martin Maher */ - + public class FormulaParsingException extends Exception { - + public FormulaParsingException(String message) { super(message); } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java index 30896812b096..42c06d88754a 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -51,50 +51,50 @@ public class FunctionLookup extends SymbolLookup { idToString = new HashMap(); stringToArgs = new HashMap(); - // Functions with Variable number of Arguments + // Functions with Variable number of Arguments // Math and Trig addEntry("SUM", TokenConstants.TSUM, -1); addEntry("MIN", TokenConstants.TMIN, -1); - addEntry("PRODUCT", TokenConstants.TPRODUCT, -1); - addEntry("LOG", TokenConstants.TLOG, -1); + addEntry("PRODUCT", TokenConstants.TPRODUCT, -1); + addEntry("LOG", TokenConstants.TLOG, -1); addEntry("SUMIF", TokenConstants.TSUMIF, -1); - addEntry("TRUNC", TokenConstants.TRUNC, -1); + addEntry("TRUNC", TokenConstants.TRUNC, -1); // Financial - addEntry("DDB", TokenConstants.TDDB, -1); - addEntry("FV", TokenConstants.TFV, -1); - addEntry("IRR", TokenConstants.TIRR, -1); - addEntry("NPER", TokenConstants.TNPER, -1); - addEntry("NPV", TokenConstants.TNPV, -1); - addEntry("PMT", TokenConstants.TPMT, -1); - addEntry("PV", TokenConstants.TPV, -1); + addEntry("DDB", TokenConstants.TDDB, -1); + addEntry("FV", TokenConstants.TFV, -1); + addEntry("IRR", TokenConstants.TIRR, -1); + addEntry("NPER", TokenConstants.TNPER, -1); + addEntry("NPV", TokenConstants.TNPV, -1); + addEntry("PMT", TokenConstants.TPMT, -1); + addEntry("PV", TokenConstants.TPV, -1); addEntry("RATE", TokenConstants.TRATE, -1); // Statistical - addEntry("AVERAGE", TokenConstants.TAVERAGE, -1); + addEntry("AVERAGE", TokenConstants.TAVERAGE, -1); addEntry("COUNT", TokenConstants.TCOUNT, -1); addEntry("COUNTA", TokenConstants.TCOUNTA, -1); - addEntry("MAX", TokenConstants.TMAX, -1 ); - addEntry("MIN", TokenConstants.TMIN, -1); - addEntry("STDEV", TokenConstants.TSTDEV, -1 ); - addEntry("STDEVP", TokenConstants.TSTDEVP, -1 ); - addEntry("VAR", TokenConstants.TVAR, -1); - addEntry("VARP", TokenConstants.TVARP, -1); + addEntry("MAX", TokenConstants.TMAX, -1 ); + addEntry("MIN", TokenConstants.TMIN, -1); + addEntry("STDEV", TokenConstants.TSTDEV, -1 ); + addEntry("STDEVP", TokenConstants.TSTDEVP, -1 ); + addEntry("VAR", TokenConstants.TVAR, -1); + addEntry("VARP", TokenConstants.TVARP, -1); // Lookup - addEntry("CHOOSE", TokenConstants.TCHOOSE, -1); - addEntry("HLOOKUP", TokenConstants.THLOOKUP, -1); - addEntry("INDEX", TokenConstants.TINDEX, -1); - addEntry("MATCH", TokenConstants.TMATCH, -1) ; - addEntry("VLOOKUP", TokenConstants.TVLOOKUP, -1); + addEntry("CHOOSE", TokenConstants.TCHOOSE, -1); + addEntry("HLOOKUP", TokenConstants.THLOOKUP, -1); + addEntry("INDEX", TokenConstants.TINDEX, -1); + addEntry("MATCH", TokenConstants.TMATCH, -1) ; + addEntry("VLOOKUP", TokenConstants.TVLOOKUP, -1); // Text - addEntry("RIGHT", TokenConstants.TRIGHT, -1); - addEntry("SUBSTITUTE", TokenConstants.TSUBSTITUTE, -1); - addEntry("FIND", TokenConstants.TFIND, -1); - addEntry("LEFT", TokenConstants.TLEFT, -1); + addEntry("RIGHT", TokenConstants.TRIGHT, -1); + addEntry("SUBSTITUTE", TokenConstants.TSUBSTITUTE, -1); + addEntry("FIND", TokenConstants.TFIND, -1); + addEntry("LEFT", TokenConstants.TLEFT, -1); // Logical - addEntry("AND", TokenConstants.TAND, -1 ); - addEntry("IF", TokenConstants.TIF, -1) ; - addEntry("OR", TokenConstants.TOR, -1); + addEntry("AND", TokenConstants.TAND, -1 ); + addEntry("IF", TokenConstants.TIF, -1) ; + addEntry("OR", TokenConstants.TOR, -1); - // Functions with Fixed number of Arguments + // Functions with Fixed number of Arguments // Math and Trig addEntry("ABS", TokenConstants.TABS, 1); addEntry("ACOS", TokenConstants.TACOS, 1); @@ -110,94 +110,94 @@ public class FunctionLookup extends SymbolLookup { addEntry("LN", TokenConstants.TLN, 1); addEntry("LOG10", TokenConstants.TLOG10, 1); addEntry("MOD", TokenConstants.TMOD, 1); - addEntry("PI", TokenConstants.TPI, 0); + addEntry("PI", TokenConstants.TPI, 0); addEntry("POWER", TokenConstants.TPOWERF, 2); addEntry("RADIANS", TokenConstants.TRADIANS, 1); addEntry("RAND", TokenConstants.TRAND, 1); addEntry("ROUND", TokenConstants.TROUND, 1); addEntry("SQRT", TokenConstants.TSQRT, 1); - addEntry("TAN", TokenConstants.TTAN, 1); - addEntry("SIN", TokenConstants.TSIN, 1); + addEntry("TAN", TokenConstants.TTAN, 1); + addEntry("SIN", TokenConstants.TSIN, 1); // Financial - addEntry("SLN", TokenConstants.TSLN, 3); - addEntry("SYD", TokenConstants.TSYD, 4); + addEntry("SLN", TokenConstants.TSLN, 3); + addEntry("SYD", TokenConstants.TSYD, 4); // Date and Time - addEntry("DATE", TokenConstants.TDATE, 3); - addEntry("DATEVALUE", TokenConstants.TDATEVALUE, 1); + addEntry("DATE", TokenConstants.TDATE, 3); + addEntry("DATEVALUE", TokenConstants.TDATEVALUE, 1); addEntry("DAY", TokenConstants.TDAY, 1); - addEntry("HOUR", TokenConstants.THOUR, 1); - addEntry("MINUTE", TokenConstants.TMINUTE, 1 ); - addEntry("MONTH", TokenConstants.TMONTH, 1); - addEntry("NOW", TokenConstants.TNOW, 0); - addEntry("SECOND", TokenConstants.TSECOND, 1); - addEntry("TIME", TokenConstants.TTIME, 3); + addEntry("HOUR", TokenConstants.THOUR, 1); + addEntry("MINUTE", TokenConstants.TMINUTE, 1 ); + addEntry("MONTH", TokenConstants.TMONTH, 1); + addEntry("NOW", TokenConstants.TNOW, 0); + addEntry("SECOND", TokenConstants.TSECOND, 1); + addEntry("TIME", TokenConstants.TTIME, 3); addEntry("TIMEVALUE", TokenConstants.TTIMEVALUE, 1); - addEntry("YEAR", TokenConstants.TYEAR, 1); + addEntry("YEAR", TokenConstants.TYEAR, 1); // Statistical - addEntry("COUNTBLANK", TokenConstants.TCOUNTBLANK, 1); + addEntry("COUNTBLANK", TokenConstants.TCOUNTBLANK, 1); // lookup - addEntry("COLUMNS", TokenConstants.TCOLUMNS, 1); - addEntry("ROWS", TokenConstants.TROWS, 1); + addEntry("COLUMNS", TokenConstants.TCOLUMNS, 1); + addEntry("ROWS", TokenConstants.TROWS, 1); // Database - addEntry("DAVERAGE", TokenConstants.TDAVAERAGE, 3); - addEntry("DCOUNT", TokenConstants.TDCOUNT, 3); - addEntry("DCOUNTA", TokenConstants.TDCOUNTA, 2); - addEntry("DGET", TokenConstants.TDGET, 3); - addEntry("DMAX", TokenConstants.TDMAX, 3); + addEntry("DAVERAGE", TokenConstants.TDAVAERAGE, 3); + addEntry("DCOUNT", TokenConstants.TDCOUNT, 3); + addEntry("DCOUNTA", TokenConstants.TDCOUNTA, 2); + addEntry("DGET", TokenConstants.TDGET, 3); + addEntry("DMAX", TokenConstants.TDMAX, 3); addEntry("DMIN", TokenConstants.TDMIN, 3); - addEntry("DPRODUCT", TokenConstants.TDPRODUCT, 3); - addEntry("DSTDEV", TokenConstants.TDSTDEV, 3); + addEntry("DPRODUCT", TokenConstants.TDPRODUCT, 3); + addEntry("DSTDEV", TokenConstants.TDSTDEV, 3); addEntry("DSTDEVP", TokenConstants.TDSTDEVP, 3) ; - addEntry("DSUM", TokenConstants.TDSUM, 3); - addEntry("DVAR", TokenConstants.TDVAR, 3); - addEntry("DVARP", TokenConstants.TDVARP, 3); + addEntry("DSUM", TokenConstants.TDSUM, 3); + addEntry("DVAR", TokenConstants.TDVAR, 3); + addEntry("DVARP", TokenConstants.TDVARP, 3); // Text - addEntry("EXACT", TokenConstants.TEXACT, 2); - addEntry("LEN", TokenConstants.TLEN, 1); - addEntry("LOWER", TokenConstants.TLOWER, 1); + addEntry("EXACT", TokenConstants.TEXACT, 2); + addEntry("LEN", TokenConstants.TLEN, 1); + addEntry("LOWER", TokenConstants.TLOWER, 1); addEntry("MID", TokenConstants.TMID, 3); // ?????? - addEntry("PROPER", TokenConstants.TPROPER, 1); - addEntry("REPLACE", TokenConstants.TREPLACE, 4); - addEntry("REPT", TokenConstants.TREPT, 2); - addEntry("T", TokenConstants.TT, 1); - addEntry("TRIM", TokenConstants.TRIM, 1); - addEntry("UPPER", TokenConstants.TUPPER, 1); - addEntry("VALUE", TokenConstants.TVALUE, 1); + addEntry("PROPER", TokenConstants.TPROPER, 1); + addEntry("REPLACE", TokenConstants.TREPLACE, 4); + addEntry("REPT", TokenConstants.TREPT, 2); + addEntry("T", TokenConstants.TT, 1); + addEntry("TRIM", TokenConstants.TRIM, 1); + addEntry("UPPER", TokenConstants.TUPPER, 1); + addEntry("VALUE", TokenConstants.TVALUE, 1); // Logical - addEntry("FALSE", TokenConstants.TFALSE, 0); - addEntry("NOT", TokenConstants.TNOT, 1); - addEntry("TRUE", TokenConstants.TTRUE, 0); + addEntry("FALSE", TokenConstants.TFALSE, 0); + addEntry("NOT", TokenConstants.TNOT, 1); + addEntry("TRUE", TokenConstants.TTRUE, 0); // Informational - addEntry("ERRORTYPE", TokenConstants.TERRORTYPE, 1); + addEntry("ERRORTYPE", TokenConstants.TERRORTYPE, 1); addEntry("ISBLANK", TokenConstants.TISBLANK, 1); - addEntry("ISERR", TokenConstants.TISERR, 1); - addEntry("ISERROR", TokenConstants.TISERROR, 1); - addEntry("ISLOGICAL", TokenConstants.TISLOGICAL, 1); - addEntry("ISNA", TokenConstants.TISNA, 1); - addEntry("ISNONTEXT", TokenConstants.TISNONTEXT, 1); - addEntry("ISNUMBER", TokenConstants.TISNUMBER, 1); - addEntry("ISTEXT", TokenConstants.TISTEXT, 1); - addEntry("N", TokenConstants.TN, 1); - addEntry("NA", TokenConstants.TNA, 0); - + addEntry("ISERR", TokenConstants.TISERR, 1); + addEntry("ISERROR", TokenConstants.TISERROR, 1); + addEntry("ISLOGICAL", TokenConstants.TISLOGICAL, 1); + addEntry("ISNA", TokenConstants.TISNA, 1); + addEntry("ISNONTEXT", TokenConstants.TISNONTEXT, 1); + addEntry("ISNUMBER", TokenConstants.TISNUMBER, 1); + addEntry("ISTEXT", TokenConstants.TISTEXT, 1); + addEntry("N", TokenConstants.TN, 1); + addEntry("NA", TokenConstants.TNA, 0); + } - + /** * Associate a function with an identifier and specifiy the number of arguments for that function - * @param symbol The function string that will act as the key in the lookup table - * @param id The identifier for the function - * @param args The number of arguments this function requires + * @param symbol The function string that will act as the key in the lookup table + * @param id The identifier for the function + * @param args The number of arguments this function requires */ public void addEntry(String symbol, int id, int args) { addEntry(symbol, id); stringToArgs.put(symbol, new Integer(args)); } - + /** * Retrieve the number of arguments for this function - * @param symbol The function name - * @return The number of arguments required by this function - */ + * @param symbol The function name + * @return The number of arguments required by this function + */ public int getArgCountFromString(String symbol) { return ((Integer)stringToArgs.get(symbol)).intValue(); } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperandLookup.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperandLookup.java index 28f1cc98e12a..6ad1876e5358 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperandLookup.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperandLookup.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -58,5 +58,5 @@ public class OperandLookup extends SymbolLookup { addEntry("3D_CELL_REFERENCE", TokenConstants.TREF3D); addEntry("3D_CELL_AREA_REFERENCE", TokenConstants.TAREA3D); } - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperatorLookup.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperatorLookup.java index 681a60f18b95..de9ed23d8a24 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperatorLookup.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperatorLookup.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -69,5 +69,5 @@ public class OperatorLookup extends SymbolLookup { addEntry("=", TokenConstants.TEQUALS); addEntry("<>", TokenConstants.TNEQUALS); } - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/ParseToken.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/ParseToken.java index 4c7a7bc3de49..053266c8008b 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/ParseToken.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/ParseToken.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -32,11 +32,11 @@ public interface ParseToken public boolean isOperand(); public boolean isOperator(); public int getTokenType(); - + //GENERIC TOKENS (MOSTLY UNUSED public static final int TOKEN_OPERATOR = 1; public static final int TOKEN_OPERAND = 2; public static final int TOKEN_FUNCTION_FIXED = 3; public static final int TOKEN_FUNCTION_VARIABLE = 4; - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/PrecedenceTable.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/PrecedenceTable.java index 1a1b6da932b0..551b77cf6e7f 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/PrecedenceTable.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/PrecedenceTable.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -31,26 +31,26 @@ import java.util.HashMap; /** * This class defines the precedence applied to each operator when performing a conversion - * {@link org.openoffice.xmerge.converter.xml.sxc.pexcel.Records.formula.FormulaCompiler.infix2 from infix to RPN.}. + * {@link org.openoffice.xmerge.converter.xml.sxc.pexcel.Records.formula.FormulaCompiler.infix2 from infix to RPN.}. */ public class PrecedenceTable { public static final int DEFAULT_PRECEDENCE = 0; public static final int EQNEQ_PRECEDENCE = 1; // =, <> - public static final int GTLTEQ_PRECEDENCE = 1; // >=, <= - public static final int GTLT_PRECEDENCE = 2; // >, < + public static final int GTLTEQ_PRECEDENCE = 1; // >=, <= + public static final int GTLT_PRECEDENCE = 2; // >, < public static final int ADDOP_PRECEDENCE = 4; // +, - public static final int MULTOP_PRECEDENCE = 5; // *, / - public static final int FACTOR_PRECEDENCE = 6; // ^ - public static final int CONCAT_PRECEDENCE = 6; // & + public static final int FACTOR_PRECEDENCE = 6; // ^ + public static final int CONCAT_PRECEDENCE = 6; // & public static final int UNARY_PRECEDENCE = 7; // !, Unary +, Unary - public static final int PAREN_PRECEDENCE = 8; // (, ) public static final int FUNCTION_PRECEDENCE = 8; public static final int COMMA_PRECEDENCE = 8; - + private static HashMap map; static { map = new HashMap(); - + map.put("%", new Integer(UNARY_PRECEDENCE)); map.put("+", new Integer(ADDOP_PRECEDENCE)); map.put("-", new Integer(ADDOP_PRECEDENCE)); @@ -71,14 +71,14 @@ public class PrecedenceTable { } /** - * Retrieve the precedence value for a given operator. - * @param op Look up the precedence for this operator - * @return an integer representing the integer value of the operator + * Retrieve the precedence value for a given operator. + * @param op Look up the precedence for this operator + * @return an integer representing the integer value of the operator */ public static int getPrecedence(String op) { Object obj = map.get(op); if (obj == null) { - return DEFAULT_PRECEDENCE; + return DEFAULT_PRECEDENCE; } return ((Integer)obj).intValue(); } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/SymbolLookup.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/SymbolLookup.java index ac4ec2731b80..bf7722b973e4 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/SymbolLookup.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/SymbolLookup.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -44,38 +44,38 @@ public abstract class SymbolLookup { * across all instances of the lookup table. */ abstract public void initialize(); - + /** * Associate a symbol with a numeric value in the lookup table - * @param symbol The symbol that will act as the key in the lookup table - * @param value The value to be associated with a given symbol + * @param symbol The symbol that will act as the key in the lookup table + * @param value The value to be associated with a given symbol */ public void addEntry(String symbol, int id) { Integer iObj = new Integer(id); stringToID.put(symbol, iObj); idToString.put(iObj, symbol); } - + /** * Retrieve the symbol associated with a given identifier - * @param id The identfier for which we need to retieve the symbol string - * @return The string associated with this identifier in the lookup table. + * @param id The identfier for which we need to retieve the symbol string + * @return The string associated with this identifier in the lookup table. */ public String getStringFromID(int id) { return (String)idToString.get(new Integer(id)); } - + /** * Retrieve the identifier associated with a given symbol - * @param symbol The symbol for which we need to retieve the identifier + * @param symbol The symbol for which we need to retieve the identifier * @throws UnsupportedFunctionException Thown when the symbol is not found in the lookup table - * @return The identifier associated with this string in the lookup table. + * @return The identifier associated with this string in the lookup table. */ public int getIDFromString(String symbol) throws UnsupportedFunctionException { Integer i = (Integer)stringToID.get(symbol); if (i == null) throw new UnsupportedFunctionException("Token '" + symbol + "' not supported by Pocket Excel"); - + return ((Integer)stringToID.get(symbol)).intValue(); } } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/Token.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/Token.java index 267b86eb8c27..48d35dcef5d1 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/Token.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/Token.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -29,25 +29,25 @@ package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; /** - * A Token is the basic building block of any formula. + * A Token is the basic building block of any formula. * A Token can be of four types (Operator, Operand, Function with fixed * arguments and function with a variable number of arguments. Each type can - * have numerous id's. Thetypes are define in <code>ParseToken</code> and the - * id's are defined in <code>TokenConstants</code>. The other member variables - * are priority which is returned from the <code>PrecedenceTable</code>, the + * have numerous id's. Thetypes are define in <code>ParseToken</code> and the + * id's are defined in <code>TokenConstants</code>. The other member variables + * are priority which is returned from the <code>PrecedenceTable</code>, the * value which is the String equivalent of the token (eg. "+", "$A$12", "SUM") * and the number of arguments which is only valid for operators and functions. * Tokens should never be created directly and instead are created by the - * <code>TokenFactory</code> + * <code>TokenFactory</code> */ public class Token implements ParseToken { - + private String value; private int type; // operator, operand, function fixed, function variable private int id; // cell reference, SUM, integer private int priority; private int numArgs=-1; - + public Token(String op, int type, int id, int args) { this.value = op; this.type = type; @@ -60,90 +60,90 @@ public class Token implements ParseToken { } else { priority = PrecedenceTable.getPrecedence("DEFAULT"); } - } - + } + /** * Checks if the current token is an operator - * + * * @return A <code>boolean</code> result of the comaparison */ public boolean isOperator() { return type == ParseToken.TOKEN_OPERATOR; } - + /** * Checks if the current token is an operand - * + * * @return A <code>boolean</code> result of the comaparison */ public boolean isOperand() { return type == ParseToken.TOKEN_OPERAND; } - + /** * Checks if the current token is a function - * + * * @return A <code>boolean</code> result of the comaparison */ public boolean isFunction() { return (type==ParseToken.TOKEN_FUNCTION_FIXED) || (type==ParseToken.TOKEN_FUNCTION_VARIABLE); } - + /** * Returns the token type. This can be one of four values (TOKEN_OPERATOR, * TOKEN_OPERAND, TOKEN_FUNCTION_FIXED, TOKEN_FUNCTION_VARIABLE) defined in - * <code>ParseToken</code> - * + * <code>ParseToken</code> + * * @return A <code>boolean</code> result of the comparison */ public int getTokenType() { - + return type; - } - + } + /** * Returns the ID of this token. This ID is equivalent to the pexcel hex - * value and is defined in <code>ParseToken</code> - * + * value and is defined in <code>ParseToken</code> + * * @return Returns the id of this token */ public int getTokenID() { - + return id; - } - + } + /** - * Returns the <code>String</code> equivalent of this token - * - * @return The <code>String</code> representing this Token + * Returns the <code>String</code> equivalent of this token + * + * @return The <code>String</code> representing this Token */ public String getValue() { return value; - } + } /** * Returns the number of arguments if this token represents an operator or * function. Otherwise returns -1. - * + * * @return The number of arguments */ public int getNumArgs() { return numArgs; } - + /** * Checks if the current token is an operator - * + * * @return A <code>boolean</code> result of the comparison */ public int getTokenPriority() { return priority; } - + /** - * Returns the <code>String</code> equivalent of this token - * - * @return The <code>String</code> representing this Token + * Returns the <code>String</code> equivalent of this token + * + * @return The <code>String</code> representing this Token */ public String toString() { return getValue(); diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenConstants.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenConstants.java index 2c72b3503a7b..1a636f9ae1f1 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenConstants.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenConstants.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -28,84 +28,84 @@ package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; public interface TokenConstants { - + // Unary Operator Tokens - public static final int TUPLUS = 0x12; + public static final int TUPLUS = 0x12; public static final int TUMINUS = 0x13; public static final int TPERCENT = 0x14; public static final int TPAREN = 0x15; // Binary Operator Tokens - public static final int TADD = 0x03; + public static final int TADD = 0x03; public static final int TSUB = 0x04; public static final int TMUL = 0x05; public static final int TDIV = 0x06; public static final int TPOWER = 0x07; public static final int TCONCAT = 0x08; - + //Logical operators - public static final int TLESS = 0x09; - public static final int TLESSEQUALS = 0x0A; - public static final int TEQUALS = 0x0B; - public static final int TGTEQUALS = 0x0C; - public static final int TGREATER = 0x0D; - public static final int TNEQUALS = 0x0E; - + public static final int TLESS = 0x09; + public static final int TLESSEQUALS = 0x0A; + public static final int TEQUALS = 0x0B; + public static final int TGTEQUALS = 0x0C; + public static final int TGREATER = 0x0D; + public static final int TNEQUALS = 0x0E; + // Function Operator Tokens public static final int TFUNC = 0x41; - public static final int TFUNCVAR = 0x42; - + public static final int TFUNCVAR = 0x42; + // Constant Operand Tokens - public static final int TSTRING = 0x17; + public static final int TSTRING = 0x17; public static final int TINT = 0x1E; public static final int TNUM = 0x1F; - // Operand Tokens + // Operand Tokens public static final int TREF = 0x44; public static final int TAREA = 0x25; public static final int TNAME = 0x23; - public static final int TREF3D = 0x3A; - public static final int TAREA3D = 0x3B; + public static final int TREF3D = 0x3A; + public static final int TAREA3D = 0x3B; // public static final int TARGSEP = 0x1001; - public static final int TCLOSEPAREN = 0x1002; + public static final int TCLOSEPAREN = 0x1002; // Variable argument Functions // Math and Trig - public static final int TSUM = 0x04; + public static final int TSUM = 0x04; public static final int TPRODUCT = 0xB7; - public static final int TSUMIF = 0x0159; - public static final int TLOG = 0x6D; - public static final int TRUNC = 0xC5; + public static final int TSUMIF = 0x0159; + public static final int TLOG = 0x6D; + public static final int TRUNC = 0xC5; // Financial - public static final int TDDB = 0x90; - public static final int TFV = 0x39; - public static final int TIRR = 0x3E; - public static final int TNPER = 0x3A; - public static final int TNPV = 0x0B; - public static final int TPMT = 0x3B; - public static final int TPV = 0x38; + public static final int TDDB = 0x90; + public static final int TFV = 0x39; + public static final int TIRR = 0x3E; + public static final int TNPER = 0x3A; + public static final int TNPV = 0x0B; + public static final int TPMT = 0x3B; + public static final int TPV = 0x38; public static final int TRATE = 0x3C; // Statistical - public static final int TAVERAGE = 0x05; + public static final int TAVERAGE = 0x05; public static final int TCOUNT = 0x00; public static final int TCOUNTA = 0xA9; - public static final int TMAX = 0x07; - public static final int TMIN = 0x06; - public static final int TSTDEV = 0x0C; - public static final int TSTDEVP = 0xC1; - public static final int TVAR = 0x2E; - public static final int TVARP = 0xC2; + public static final int TMAX = 0x07; + public static final int TMIN = 0x06; + public static final int TSTDEV = 0x0C; + public static final int TSTDEVP = 0xC1; + public static final int TVAR = 0x2E; + public static final int TVARP = 0xC2; // Lookup - public static final int TCHOOSE = 0x64; - public static final int THLOOKUP = 0x65; - public static final int TINDEX = 0x1D; - public static final int TMATCH = 0x40; - public static final int TVLOOKUP = 0x66; + public static final int TCHOOSE = 0x64; + public static final int THLOOKUP = 0x65; + public static final int TINDEX = 0x1D; + public static final int TMATCH = 0x40; + public static final int TVLOOKUP = 0x66; // Text - public static final int TRIGHT = 0x74; - public static final int TSUBSTITUTE = 0x78; - public static final int TFIND = 0x7c; - public static final int TLEFT = 0x73; + public static final int TRIGHT = 0x74; + public static final int TSUBSTITUTE = 0x78; + public static final int TFIND = 0x7c; + public static final int TLEFT = 0x73; // Logical public static final int TAND = 0x24; // 42 public static final int TIF = 0x01; // 42 @@ -120,84 +120,84 @@ public interface TokenConstants { public static final int TATAN2 = 0x61; public static final int TCOS = 0x10; public static final int TSIN = 0x0F; - + public static final int TCOUNTIF = 0x015A; public static final int TDEGREES = 0x0157; public static final int TEXP = 0x15; public static final int TFACT = 0xB8; public static final int TINTE = 0x19; public static final int TLN = 0x16; - + public static final int TLOG10 = 0x17; public static final int TMOD = 0x27; public static final int TPI = 0x13; - + public static final int TPOWERF = 0x0151; public static final int TRADIANS = 0x0156; public static final int TRAND = 0x3F; public static final int TROUND = 0x1B; - public static final int TSQRT = 0x14; - public static final int TTAN = 0x11; - - public static final int TSLN = 0x8E; - public static final int TSYD = 0x8F; - + public static final int TSQRT = 0x14; + public static final int TTAN = 0x11; + + public static final int TSLN = 0x8E; + public static final int TSYD = 0x8F; + // Date and Time - public static final int TDATE = 0x41; - public static final int TDATEVALUE = 0x8C; + public static final int TDATE = 0x41; + public static final int TDATEVALUE = 0x8C; public static final int TDAY = 0x43; - public static final int THOUR = 0x47; - public static final int TMINUTE = 0x48; - public static final int TMONTH = 0x44; - public static final int TNOW = 0x4A; - public static final int TSECOND = 0x49; - public static final int TTIME = 0x42; + public static final int THOUR = 0x47; + public static final int TMINUTE = 0x48; + public static final int TMONTH = 0x44; + public static final int TNOW = 0x4A; + public static final int TSECOND = 0x49; + public static final int TTIME = 0x42; public static final int TTIMEVALUE = 0x8D; - public static final int TYEAR = 0x45; + public static final int TYEAR = 0x45; // Statistical - public static final int TCOUNTBLANK = 0x015B ; + public static final int TCOUNTBLANK = 0x015B ; // lookup - public static final int TCOLUMNS = 0x4D; - public static final int TROWS = 0x4C; + public static final int TCOLUMNS = 0x4D; + public static final int TROWS = 0x4C; // Database - public static final int TDAVAERAGE = 0x2A; - public static final int TDCOUNT = 0x28; - public static final int TDCOUNTA = 0xC7; - public static final int TDGET = 0xEB; - public static final int TDMAX = 0x2C; + public static final int TDAVAERAGE = 0x2A; + public static final int TDCOUNT = 0x28; + public static final int TDCOUNTA = 0xC7; + public static final int TDGET = 0xEB; + public static final int TDMAX = 0x2C; public static final int TDMIN = 0x2B; - public static final int TDPRODUCT = 0xBD; - public static final int TDSTDEV = 0x2D; + public static final int TDPRODUCT = 0xBD; + public static final int TDSTDEV = 0x2D; public static final int TDSTDEVP = 0xC3; - public static final int TDSUM = 0x29; - public static final int TDVAR = 0x2F; - public static final int TDVARP = 0xC4; + public static final int TDSUM = 0x29; + public static final int TDVAR = 0x2F; + public static final int TDVARP = 0xC4; // Text - public static final int TEXACT = 0x75; - public static final int TLEN = 0x20; - public static final int TLOWER = 0x70; + public static final int TEXACT = 0x75; + public static final int TLEN = 0x20; + public static final int TLOWER = 0x70; public static final int TMID = 0x1F; // ?????? - public static final int TPROPER = 0x72; - public static final int TREPLACE = 0x77; - public static final int TREPT = 0x1E; - public static final int TT = 0x82; - public static final int TRIM = 0x76; - public static final int TUPPER = 0x71; - public static final int TVALUE = 0x21; + public static final int TPROPER = 0x72; + public static final int TREPLACE = 0x77; + public static final int TREPT = 0x1E; + public static final int TT = 0x82; + public static final int TRIM = 0x76; + public static final int TUPPER = 0x71; + public static final int TVALUE = 0x21; // Logical - public static final int TFALSE = 0x23; - public static final int TNOT = 0x26; - public static final int TTRUE = 0x22; + public static final int TFALSE = 0x23; + public static final int TNOT = 0x26; + public static final int TTRUE = 0x22; // Informational - public static final int TERRORTYPE = 0x05; + public static final int TERRORTYPE = 0x05; public static final int TISBLANK = 0x81; - public static final int TISERR = 0x7E; - public static final int TISERROR = 0x03; - public static final int TISLOGICAL = 0xC6; - public static final int TISNA = 0x02; - public static final int TISNONTEXT = 0xBE; - public static final int TISNUMBER = 0x80; - public static final int TISTEXT = 0x7F; - public static final int TN = 0x83; - public static final int TNA = 0x0A; + public static final int TISERR = 0x7E; + public static final int TISERROR = 0x03; + public static final int TISLOGICAL = 0xC6; + public static final int TISNA = 0x02; + public static final int TISNONTEXT = 0xBE; + public static final int TISNUMBER = 0x80; + public static final int TISTEXT = 0x7F; + public static final int TN = 0x83; + public static final int TNA = 0x0A; } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenDecoder.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenDecoder.java index 16b4ed2450a9..e18c1d10cc04 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenDecoder.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenDecoder.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -40,15 +40,15 @@ import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; * The TokenDecoder decodes a byte[] to an equivalent <code>String</code>. The only * public method apart from the default constructor is the getTokenVector method. * This method takes an entire formula as a pexcel byte[] and decodes it into - * a series of <code>Token</code>s. It adds these to a <code>Vector</code> which - * is returned once all the tokens have been decoded. The Decoder supports + * a series of <code>Token</code>s. It adds these to a <code>Vector</code> which + * is returned once all the tokens have been decoded. The Decoder supports * the following tokens.<br><br> - * - * Operands Floating point's, Cell references (absolute and relative), - * cell ranges<br> - * Operators +,-,*,/,<,>.<=,>=,<><br> - * Functions All pexcel fixed and varaible argument functions - * + * + * Operands Floating point's, Cell references (absolute and relative), + * cell ranges<br> + * Operators +,-,*,/,<,>.<=,>=,<><br> + * Functions All pexcel fixed and varaible argument functions + * */ public class TokenDecoder { @@ -57,10 +57,10 @@ public class TokenDecoder { private OperatorLookup operatorLookup; private OperandLookup operandLookup; private Workbook wb; - + /** - * Default Constructor initializes the <code>TokenFactory</code> for generating - * <code>Token</code> and the <code>SymbolLookup</code> for generating + * Default Constructor initializes the <code>TokenFactory</code> for generating + * <code>Token</code> and the <code>SymbolLookup</code> for generating * Strings from hex values. */ public TokenDecoder() { @@ -69,82 +69,82 @@ public class TokenDecoder { operatorLookup = new OperatorLookup(); operandLookup = new OperandLookup(); } - + /** * Sets global workbook data needed for defined names */ public void setWorkbook(Workbook wb) { - - Debug.log(Debug.TRACE, "TokenDecoder : setWorkbook"); + + Debug.log(Debug.TRACE, "TokenDecoder : setWorkbook"); this.wb = wb; } - + /** * Returns a <code>Vector</code> of <code>Token</code> decoded from a * byte[]. The byte[] is first converted to a * <code>ByteArrayInputStream</code> as this is the easiest way of reading * bytes. - * + * * @param formula A Pocket Excel Formula byte[] * @return A <code>Vector</code> of deoded <code>Token</code> */ public Vector getTokenVector(byte[] formula) { - + Vector v = new Vector(); - + ByteArrayInputStream bis = new ByteArrayInputStream(formula); int b = 0 ; Token t; - + while ((b = bis.read())!=-1) { - - + + switch (b) { - - case TokenConstants.TAREA3D: - Debug.log(Debug.TRACE, "Decoded 3D Area Cell Reference: "); + + case TokenConstants.TAREA3D: + Debug.log(Debug.TRACE, "Decoded 3D Area Cell Reference: "); v.add(read3DCellAreaRefToken(bis)); - Debug.log(Debug.TRACE, "Decoded 3D Area Cell Reference: " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded 3D Area Cell Reference: " + v.lastElement()); break; - case TokenConstants.TREF3D: - Debug.log(Debug.TRACE, "Decoded 3D Cell Reference: "); + case TokenConstants.TREF3D: + Debug.log(Debug.TRACE, "Decoded 3D Cell Reference: "); v.add(read3DCellRefToken(bis)); - Debug.log(Debug.TRACE, "Decoded 3D Cell Reference: " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded 3D Cell Reference: " + v.lastElement()); break; - case TokenConstants.TREF : + case TokenConstants.TREF : v.add(readCellRefToken(bis)); - Debug.log(Debug.TRACE, "Decoded Cell Reference: " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded Cell Reference: " + v.lastElement()); break; - case TokenConstants.TAREA : + case TokenConstants.TAREA : v.add(readCellAreaRefToken(bis)); - Debug.log(Debug.TRACE, "Decoded Cell Area Reference: " + v.lastElement()); - break; + Debug.log(Debug.TRACE, "Decoded Cell Area Reference: " + v.lastElement()); + break; case TokenConstants.TNUM : v.add(readNumToken(bis)); - Debug.log(Debug.TRACE, "Decoded number : " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded number : " + v.lastElement()); break; case TokenConstants.TFUNCVAR : - v.add(readFunctionVarToken(bis)); - Debug.log(Debug.TRACE, "Decoded variable argument function: " + v.lastElement()); + v.add(readFunctionVarToken(bis)); + Debug.log(Debug.TRACE, "Decoded variable argument function: " + v.lastElement()); break; case TokenConstants.TFUNC : - v.add(readFunctionToken(bis)); - Debug.log(Debug.TRACE, "Decoded function: " + v.lastElement()); + v.add(readFunctionToken(bis)); + Debug.log(Debug.TRACE, "Decoded function: " + v.lastElement()); break; case TokenConstants.TSTRING : v.add(readStringToken(bis)); - Debug.log(Debug.TRACE, "Decoded string: " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded string: " + v.lastElement()); break; case TokenConstants.TNAME : v.add(readNameToken(bis)); - Debug.log(Debug.TRACE, "Decoded defined name: " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded defined name: " + v.lastElement()); break; case TokenConstants.TUPLUS: case TokenConstants.TUMINUS: case TokenConstants.TPERCENT: v.add(readOperatorToken(b, 1)); - Debug.log(Debug.TRACE, "Decoded Unary operator : " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded Unary operator : " + v.lastElement()); break; case TokenConstants.TADD : case TokenConstants.TSUB : @@ -157,33 +157,33 @@ public class TokenDecoder { case TokenConstants.TGREATER : case TokenConstants.TNEQUALS : v.add(readOperatorToken(b, 2)); - Debug.log(Debug.TRACE, "Decoded Binary operator : " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded Binary operator : " + v.lastElement()); break; - + default : - Debug.log(Debug.TRACE, "Unrecognized byte : " + b); + Debug.log(Debug.TRACE, "Unrecognized byte : " + b); } } return v; } - + /** * Converts a zero based integer to a char (eg. a=0, b=1). * It assumes the integer is less than 26. * * @param i A 0 based index - * @return The equivalent character + * @return The equivalent character */ private char int2Char(int i) { return (char) ('A' + i); } - + /** * Reads a Cell Reference token from the <code>ByteArrayInputStream</code> * * @param bis The <code>ByteArrayInputStream</code> from which we read the * bytes. - * @return The decoded String <code>Token</code> + * @return The decoded String <code>Token</code> */ private Token readStringToken(ByteArrayInputStream bis) { @@ -196,7 +196,7 @@ public class TokenDecoder { Debug.log(Debug.TRACE,"Expected " + len + " bytes. Could only read " + numRead + " bytes."); //throw new IOException("Expected " + len + " bytes. Could only read " + numRead + " bytes."); } - StringBuffer outputString = new StringBuffer(); + StringBuffer outputString = new StringBuffer(); outputString.append('"'); try { Debug.log(Debug.TRACE,"Using LE encoding"); @@ -205,23 +205,23 @@ public class TokenDecoder { outputString.append(new String(stringBytes)); //fall back to default encoding } outputString.append('"'); - + return (tf.getOperandToken(outputString.toString(), "STRING")); } - + /** * Reads a Defined Name token from the <code>ByteArrayInputStream</code> * * @param bis The <code>ByteArrayInputStream</code> from which we read the * bytes. - * @return The decoded Name <code>Token</code> + * @return The decoded Name <code>Token</code> */ private Token readNameToken(ByteArrayInputStream bis) { byte buffer[] = new byte[2]; buffer[0] = (byte) bis.read(); buffer[1] = (byte) bis.read(); int nameIndex = EndianConverter.readShort(buffer); - bis.skip(12); // the next 12 bytes are unused + bis.skip(12); // the next 12 bytes are unused Enumeration e = wb.getDefinedNames(); int i = 1; while(i<nameIndex) { @@ -232,29 +232,29 @@ public class TokenDecoder { DefinedName dn = (DefinedName)e.nextElement(); Debug.log(Debug.TRACE,"DefinedName is " + dn.getName()); return (tf.getOperandToken(dn.getName(), "NAME")); - } - + } + /** * Reads a Cell Reference token from the <code>ByteArrayInputStream</code> * * @param bis The <code>ByteArrayInputStream</code> from which we read the * bytes. - * @return The decoded Cell Reference <code>Token</code> + * @return The decoded Cell Reference <code>Token</code> */ private Token readCellRefToken(ByteArrayInputStream bis) { - + byte buffer[] = new byte[2]; String outputString = new String(); - + buffer[0] = (byte) bis.read(); buffer[1] = (byte) bis.read(); int formulaRow = EndianConverter.readShort(buffer); int relativeFlags = (formulaRow & 0xC000)>>14; formulaRow &= 0x3FFF; int formulaCol = (byte) bis.read(); - + outputString = int2CellStr(formulaRow, formulaCol, relativeFlags); - + return (tf.getOperandToken(outputString,"CELL_REFERENCE")); } @@ -263,15 +263,15 @@ public class TokenDecoder { * * @param bis The <code>ByteArrayInputStream</code> from which we read the * bytes. - * @return The decoded Cell Reference <code>Token</code> + * @return The decoded Cell Reference <code>Token</code> */ private Token read3DCellRefToken(ByteArrayInputStream bis) { - + byte buffer[] = new byte[2]; - String outputString = new String(); + String outputString = new String(); bis.skip(10); - + buffer[0] = (byte) bis.read(); buffer[1] = (byte) bis.read(); int Sheet1 = EndianConverter.readShort(buffer); @@ -290,25 +290,25 @@ public class TokenDecoder { outputString = "$" + wb.getSheetName(Sheet1) + cellRef; } else { outputString = "$" + wb.getSheetName(Sheet1) + cellRef + ":$" + wb.getSheetName(Sheet2) + cellRef; - } - + } + return (tf.getOperandToken(outputString,"3D_CELL_REFERENCE")); } - + /** * Reads a Cell Reference token from the <code>ByteArrayInputStream</code> * * @param bis The <code>ByteArrayInputStream</code> from which we read the * bytes. - * @return The decoded Cell Reference <code>Token</code> + * @return The decoded Cell Reference <code>Token</code> */ private Token read3DCellAreaRefToken(ByteArrayInputStream bis) { - + byte buffer[] = new byte[2]; - String outputString = new String(); + String outputString = new String(); bis.skip(10); - + buffer[0] = (byte) bis.read(); buffer[1] = (byte) bis.read(); int Sheet1 = EndianConverter.readShort(buffer); @@ -321,7 +321,7 @@ public class TokenDecoder { int formulaRow1 = EndianConverter.readShort(buffer); int relativeFlags1 = (formulaRow1 & 0xC000)>>14; formulaRow1 &= 0x3FFF; - + buffer[0] = (byte) bis.read(); buffer[1] = (byte) bis.read(); int formulaRow2 = EndianConverter.readShort(buffer); @@ -330,22 +330,22 @@ public class TokenDecoder { int formulaCol1 = (byte) bis.read(); int formulaCol2 = (byte) bis.read(); - + String cellRef1 = "." + int2CellStr(formulaRow1, formulaCol1, relativeFlags1); String cellRef2 = int2CellStr(formulaRow2, formulaCol2, relativeFlags2); - + if(Sheet1 == Sheet2) { outputString = "$" + wb.getSheetName(Sheet1) + cellRef1 + ":" + cellRef2; } else { outputString = "$" + wb.getSheetName(Sheet1) + cellRef1 + ":$" + wb.getSheetName(Sheet2) + "." + cellRef2; - } - + } + return (tf.getOperandToken(outputString,"3D_CELL_AREA_REFERENCE")); } /** - * Converts a row and col 0 based index to a spreadsheet cell reference. - * It also has a relativeFlags which indicates whether or not the + * Converts a row and col 0 based index to a spreadsheet cell reference. + * It also has a relativeFlags which indicates whether or not the * Cell Reference is relative or absolute (Absolute is denoted with '$') * * 00 = absolute row, absolute col @@ -355,7 +355,7 @@ public class TokenDecoder { * * @param row The cell reference 0 based index to the row * @param col The cell reference 0 based index to the row - * @param relativeFlags Flags indicating addressing of row and column + * @param relativeFlags Flags indicating addressing of row and column * @return A <code>String</code> representing a cell reference */ private String int2CellStr(int row, int col, int relativeFlags) { @@ -365,72 +365,72 @@ public class TokenDecoder { if((relativeFlags & 1) == 0) { outputString += "$"; } - + if(firstChar>0) { - int secondChar = (col + 1) % 26; + int secondChar = (col + 1) % 26; outputString += Character.toString(int2Char(firstChar - 1)) + Character.toString(int2Char(secondChar - 1)); } else { outputString += Character.toString(int2Char(col)); - } + } if((relativeFlags & 2) == 0) { outputString += "$"; - } + } outputString += Integer.toString(row+1); return outputString; } - + /** - * Reads a Cell Area Reference (cell range) <code>Token</code> from + * Reads a Cell Area Reference (cell range) <code>Token</code> from * the <code>ByteArrayInputStream</code> * * @param bis The <code>ByteArrayInputStream</code> from which we read the * bytes. * @return The equivalent Cell Area Reference (cell range) - * <code>Token</code> + * <code>Token</code> */ private Token readCellAreaRefToken(ByteArrayInputStream bis) { byte buffer[] = new byte[2]; int formulaRow1, formulaRow2; int formulaCol1, formulaCol2; - + String outputString = new String(); - + buffer[0] = (byte) bis.read(); buffer[1] = (byte) bis.read(); formulaRow1 = EndianConverter.readShort(buffer); - int relativeFlags1 = (formulaRow1 & 0xC000)>>14; + int relativeFlags1 = (formulaRow1 & 0xC000)>>14; formulaRow1 &= 0x3FFF; buffer[0] = (byte) bis.read(); buffer[1] = (byte) bis.read(); formulaRow2 = EndianConverter.readShort(buffer); int relativeFlags2 = (formulaRow2 & 0xC000)>>14; formulaRow2 &= 0x3FFF; - + formulaCol1 = (byte) bis.read(); formulaCol2 = (byte) bis.read(); outputString = int2CellStr(formulaRow1, formulaCol1, relativeFlags1); outputString += (":" + int2CellStr(formulaRow2, formulaCol2, relativeFlags2)); - + return (tf.getOperandToken(outputString,"CELL_AREA_REFERENCE")); } - - + + /** * Reads a Number (floating point) token from the <code>ByteArrayInputStream</code> * * @param bis The <code>ByteArrayInputStream</code> from which we read the * bytes. - * @return The decoded Integer <code>Token</code> + * @return The decoded Integer <code>Token</code> */ private Token readNumToken(ByteArrayInputStream bis) { - + byte numBuffer[] = new byte[8]; - + for(int j=0;j<8;j++) { numBuffer[j]=(byte) bis.read(); } - + return (tf.getOperandToken(Double.toString(EndianConverter.readDouble(numBuffer)),"NUMBER")); } @@ -439,15 +439,15 @@ public class TokenDecoder { * * @param b A Pocket Excel number representing an operator. * @param args The number of arguments this operator takes. - * @return The decoded Operator <code>Token</code> + * @return The decoded Operator <code>Token</code> */ private Token readOperatorToken(int b, int args) { Token t; - + if(b==TokenConstants.TUPLUS) { t = tf.getOperatorToken("+", args); - } else if(b==TokenConstants.TUMINUS) { + } else if(b==TokenConstants.TUMINUS) { t = tf.getOperatorToken("-", args); } else { t = tf.getOperatorToken(operatorLookup.getStringFromID(b), args); @@ -462,22 +462,22 @@ public class TokenDecoder { * * @param bis The <code>ByteArrayInputStream</code> from which we read the * bytes. - * @return The decoded variable argument Function <code>Token</code> + * @return The decoded variable argument Function <code>Token</code> */ private Token readFunctionVarToken(ByteArrayInputStream bis) { - + int numArgs = 0; numArgs = bis.read(); byte buffer[] = new byte[2]; buffer[0] = (byte) bis.read(); buffer[1] = (byte) bis.read(); - int functionID = EndianConverter.readShort(buffer); + int functionID = EndianConverter.readShort(buffer); return (tf.getFunctionToken(fl.getStringFromID(functionID),numArgs)); } - + /** * Read a Function token from the <code>ByteArrayInputStream</code> - * This function has a fixed number of arguments which it will get + * This function has a fixed number of arguments which it will get * from <code>FunctionLookup</code>. * * @param bis The <code>ByteArrayInputStream</code> from which we read the @@ -485,7 +485,7 @@ public class TokenDecoder { * @return The decoded fixed argument Function <code>Token</code> */ private Token readFunctionToken(ByteArrayInputStream bis) { - + byte buffer[] = new byte[2]; buffer[0] = (byte) bis.read(); buffer[1] = (byte) bis.read(); @@ -493,5 +493,5 @@ public class TokenDecoder { String functionName = fl.getStringFromID(functionID); return (tf.getFunctionToken(functionName,fl.getArgCountFromString(functionName))); } - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenEncoder.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenEncoder.java index 4ac9ac9aceaa..249e14ac620f 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenEncoder.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenEncoder.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -41,19 +41,19 @@ import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.DefinedName; * public method apart from the default constructor is the getByte method. * This method picks an encoder based onthe Token's type or id field and uses * that encoder to return a byte[] which it returns. This Encoder supports - * Operands Floating point's, Cell references (absolute and relative), - * cell ranges - * Operators +,-,*,/,<,>.<=,>=,<> - * Functions All pexcel fixed and varaible argument functions - * + * Operands Floating point's, Cell references (absolute and relative), + * cell ranges + * Operators +,-,*,/,<,>.<=,>=,<> + * Functions All pexcel fixed and varaible argument functions + * */ public class TokenEncoder { - + private FunctionLookup fl; private String parseString; private int index; private Workbook wb; - + /** * Default Constructor */ @@ -62,20 +62,20 @@ public class TokenEncoder { parseString = new String(); fl = new FunctionLookup(); } - + /** * Sets global workbook data needed for defined names */ public void setWorkbook(Workbook wb) { - + this.wb = wb; } - - + + /** * Return the byte[] equivalent of a <code>Token</code>. The various - * encoders return <code>Vector</code> of <code>Byte</code> instead - * of byte[] because the number of bytes returned varies with each + * encoders return <code>Vector</code> of <code>Byte</code> instead + * of byte[] because the number of bytes returned varies with each * <code>Token</code> encoded. After the encoding is finished the Vector * in converted to a byte[]. * @@ -83,30 +83,30 @@ public class TokenEncoder { * @return An equivalent Pocket Excel byte[] */ public byte[] getByte(Token t) throws IOException { - - Vector tmpByteArray = null; // we use this cause we don't know till after + + Vector tmpByteArray = null; // we use this cause we don't know till after // the encoding takes place how big the byte [] will be - //index=0; // This class is declared static in + //index=0; // This class is declared static in // FormulaHelper so better make sure our index is 0 if(t.getTokenType()==ParseToken.TOKEN_OPERATOR) { tmpByteArray = operatorEncoder(t); } else if (t.getTokenType()==ParseToken.TOKEN_FUNCTION_VARIABLE || t.getTokenType()==ParseToken.TOKEN_FUNCTION_FIXED){ tmpByteArray = functionEncoder(t); - } else { // Operands and functions + } else { // Operands and functions switch(t.getTokenID()) { - case TokenConstants.TNAME : + case TokenConstants.TNAME : tmpByteArray = nameDefinitionEncoder(t); break; - case TokenConstants.TREF3D : + case TokenConstants.TREF3D : tmpByteArray = threeDCellRefEncoder(t); break; - case TokenConstants.TAREA3D: + case TokenConstants.TAREA3D: tmpByteArray = threeDAreaRefEncoder(t); break; - case TokenConstants.TREF : + case TokenConstants.TREF : tmpByteArray = cellRefEncoder(t); break; - case TokenConstants.TAREA : + case TokenConstants.TAREA : tmpByteArray = areaRefEncoder(t); break; case TokenConstants.TNUM : @@ -116,7 +116,7 @@ public class TokenEncoder { tmpByteArray = stringEncoder(t); break; default : - Debug.log(Debug.ERROR, "Encoder found unrecognized Token"); + Debug.log(Debug.ERROR, "Encoder found unrecognized Token"); } } @@ -130,12 +130,12 @@ public class TokenEncoder { i++; } Debug.log(Debug.TRACE, "Encoding Token " + t.getValue() + " as [" + s + "]"); - return cellRefArray; + return cellRefArray; } - - /** - * An Operator Encoder. - * + + /** + * An Operator Encoder. + * * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ @@ -147,9 +147,9 @@ public class TokenEncoder { } - /** - * A String Encoder. - * + /** + * A String Encoder. + * * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ @@ -167,16 +167,16 @@ public class TokenEncoder { } - /** - * An Integer Encoder. - * + /** + * An Integer Encoder. + * * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ private Vector numEncoder(Token t) { Vector tmpByteArray = new Vector(); - + double cellLong = (double) Double.parseDouble(t.getValue()); tmpByteArray.add(new Byte((byte)t.getTokenID())); byte[] tempByte = EndianConverter.writeDouble(cellLong); @@ -185,37 +185,37 @@ public class TokenEncoder { } return tmpByteArray; } - - /** + + /** * Converts a char to an int. It is zero based * so a=0, b=1 etc. - * + * * @param ch the character to be converted * @return -1 if not a character otherwise a 0 based index */ private int char2int(char ch) { - if(!Character.isLetter(ch)) + if(!Character.isLetter(ch)) return -1; - + ch = Character.toUpperCase(ch); return ch-'A'; } - + /** * Identify letters - * + * * @param c The character which is to be identified - * @return A boolean returning the result of the comparison - */ + * @return A boolean returning the result of the comparison + */ private boolean isAlpha(char c) { return(Character.isLetter(c)); } - + /** * Identify numbers - * + * * @param c The character which is to be identified - * @return A boolean returning the result of the comparison + * @return A boolean returning the result of the comparison */ private boolean isDigit(char c) { return(Character.isDigit(c)); @@ -223,31 +223,31 @@ public class TokenEncoder { /** * Identify letters or numbers - * + * * @param c The character which is to be identified - * @return A boolean returning the result of the comparison - */ + * @return A boolean returning the result of the comparison + */ private boolean isAlphaNum(char c) { return(isAlpha(c) || isDigit(c)); } - + /** * Parses a column reference and returns it's integer equivalent. (eg. * A=0, D=3, BA=27) - * + * * @return an 0 based index to a column */ private int column() { char ch = parseString.charAt(index); String columnStr = new String(); int col = 0; - + while(isAlpha(ch)) { columnStr += ch; index++; ch = parseString.charAt(index); } - + if(columnStr.length()==1) { col = char2int(columnStr.charAt(0)); } else if (columnStr.length()==2) { @@ -256,7 +256,7 @@ public class TokenEncoder { } else { Debug.log(Debug.ERROR, "Invalid Column Reference " + columnStr ); } - + return col; } @@ -264,15 +264,15 @@ public class TokenEncoder { /** * Parses a column reference and returns it's integer equivalent. (eg. * A=0, D=3, BA=27) - * + * * @return an 0 based index to a column - */ + */ private int row() { char ch = parseString.charAt(index); String rowStr = new String(); int row = 0; boolean status = true; - + do { rowStr += ch; index++; @@ -285,14 +285,14 @@ public class TokenEncoder { return Integer.parseInt(rowStr)-1; // Pexcel uses a 0 based index } - /** + /** * A Cell Reference Encoder (It supports absolute and relative addressing) - * + * * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ private byte[] encodeCellCoordinates(String cellCoordinates) { - int col = 0, row = 0; + int col = 0, row = 0; int addressing = 0xC000; index = 0; @@ -302,38 +302,38 @@ public class TokenEncoder { addressing &= 0x8000; index++; } - col = column(); + col = column(); if(cellCoordinates.charAt(index)=='$') { addressing &= 0x4000; index++; - } + } row = row(); // Pexcel uses a 0 based index row |= addressing; - byte tokenBytes[] = new byte[3]; + byte tokenBytes[] = new byte[3]; tokenBytes[0] = (byte)row; tokenBytes[1] = (byte)(row>>8); tokenBytes[2] = (byte)col; return tokenBytes; } - - /** - * A name definition Encoder - * + + /** + * A name definition Encoder + * * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ private Vector nameDefinitionEncoder(Token t) { - + Vector tmpByteArray = new Vector(); - + String nameString = t.getValue(); Debug.log(Debug.TRACE,"NameDefinitionEncoder : " + nameString); - tmpByteArray.add(new Byte((byte)t.getTokenID())); + tmpByteArray.add(new Byte((byte)t.getTokenID())); Enumeration e = wb.getDefinedNames(); DefinedName dn; String name; int definedNameIndex = 0; - do { + do { dn = (DefinedName)e.nextElement(); name = dn.getName(); Debug.log(Debug.TRACE,"Name pulled from DefinedName : " + name); @@ -342,25 +342,25 @@ public class TokenEncoder { tmpByteArray.add(new Byte((byte)definedNameIndex)); tmpByteArray.add(new Byte((byte)0x00)); - + for(int i = 0;i < 12;i++) { tmpByteArray.add(new Byte((byte)0x00)); } return tmpByteArray; - } - /** + } + /** * A Cell Reference Encoder. It supports absolute and relative addressing * but not sheetnames. - * + * * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ private Vector cellRefEncoder(Token t) { - + Vector tmpByteArray = new Vector(); - - tmpByteArray.add(new Byte((byte)t.getTokenID())); + + tmpByteArray.add(new Byte((byte)t.getTokenID())); byte cellRefBytes[] = encodeCellCoordinates(t.getValue()); for(int i = 0;i < cellRefBytes.length;i++) { tmpByteArray.add(new Byte(cellRefBytes[i])); @@ -368,21 +368,21 @@ public class TokenEncoder { return tmpByteArray; } - /** - * This function will find the sheetname index for a given String - * + /** + * This function will find the sheetname index for a given String + * * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ private short findSheetIndex(String s) { - + short sheetIndex = 0; String savedName; - String sheetName; + String sheetName; if (s.startsWith("$")) { - sheetName = s.substring(1,s.length()); // Remove $ + sheetName = s.substring(1,s.length()); // Remove $ } else { - sheetName = s.substring(0,s.length()); + sheetName = s.substring(0,s.length()); } Debug.log(Debug.TRACE,"Searching for Worksheet : " + sheetName); Vector names = wb.getWorksheetNames(); @@ -391,29 +391,29 @@ public class TokenEncoder { savedName = (String) e.nextElement(); sheetIndex++; } while(!savedName.equalsIgnoreCase(sheetName) && e.hasMoreElements()); - + Debug.log(Debug.TRACE,"Setting sheetindex to " + sheetIndex); return (short)(sheetIndex-1); } - /** - * A 3D Cell reference encoder - * + /** + * A 3D Cell reference encoder + * * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ private Vector threeDCellRefEncoder(Token t) { - + Vector tmpByteArray = new Vector(); parseString = t.getValue(); Debug.log(Debug.TRACE,"Encoding 3D Cell reference " + t); - tmpByteArray.add(new Byte((byte)t.getTokenID())); + tmpByteArray.add(new Byte((byte)t.getTokenID())); tmpByteArray.add(new Byte((byte)0xFF)); tmpByteArray.add(new Byte((byte)0xFF)); for(int i = 0;i < 8;i++) { tmpByteArray.add(new Byte((byte)0x00)); } - + String sheetRef = parseString.substring(0, parseString.indexOf('.') + 1); if (sheetRef.indexOf(':')!=-1) { sheetRef = parseString.substring(0, parseString.indexOf(':')); @@ -439,25 +439,25 @@ public class TokenEncoder { tmpByteArray.add(new Byte(cellRefBytes[i])); } return tmpByteArray; - } - /** - * A 3D Area Reference Encoder. - * + } + /** + * A 3D Area Reference Encoder. + * * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ private Vector threeDAreaRefEncoder(Token t) { - + Vector tmpByteArray = new Vector(); parseString = t.getValue(); Debug.log(Debug.TRACE,"Encoding 3D Area reference " + t); - tmpByteArray.add(new Byte((byte)t.getTokenID())); + tmpByteArray.add(new Byte((byte)t.getTokenID())); tmpByteArray.add(new Byte((byte)0xFF)); tmpByteArray.add(new Byte((byte)0xFF)); for(int i = 0;i < 8;i++) { tmpByteArray.add(new Byte((byte)0x00)); } - + String param1= parseString.substring(0, parseString.indexOf(':')); String cellRef1 = param1.substring(parseString.indexOf('.') + 1, param1.length()); String sheetRef1 = param1.substring(0, param1.indexOf('.')); @@ -474,86 +474,86 @@ public class TokenEncoder { tmpByteArray.add(new Byte((byte)sheetNum1)); tmpByteArray.add(new Byte((byte)0x00)); } else { - String sheetRef2 = param2.substring(0, param2.indexOf('.')); + String sheetRef2 = param2.substring(0, param2.indexOf('.')); short sheetNum2 = findSheetIndex(sheetRef2); tmpByteArray.add(new Byte((byte)sheetNum1)); tmpByteArray.add(new Byte((byte)0x00)); tmpByteArray.add(new Byte((byte)sheetNum2)); tmpByteArray.add(new Byte((byte)0x00)); } - + byte cellRefBytes1[] = encodeCellCoordinates(cellRef1); byte cellRefBytes2[] = encodeCellCoordinates(cellRef2); - + tmpByteArray.add(new Byte(cellRefBytes1[0])); tmpByteArray.add(new Byte(cellRefBytes1[1])); - + tmpByteArray.add(new Byte(cellRefBytes2[0])); tmpByteArray.add(new Byte(cellRefBytes2[1])); - + tmpByteArray.add(new Byte(cellRefBytes1[2])); tmpByteArray.add(new Byte(cellRefBytes2[2])); return tmpByteArray; - } - - /** - * A Cell Range Encoder. - * + } + + /** + * A Cell Range Encoder. + * * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> - */ + */ private Vector areaRefEncoder(Token t) { Vector tmpByteArray = new Vector(); - - tmpByteArray.add(new Byte((byte)t.getTokenID())); + + tmpByteArray.add(new Byte((byte)t.getTokenID())); String param = t.getValue(); String cellRef1 = new String(); String cellRef2 = new String(); if(param.indexOf(':')==-1) { - Debug.log(Debug.ERROR, "Invalid Cell Range, could not find :"); + Debug.log(Debug.ERROR, "Invalid Cell Range, could not find :"); } else { cellRef1 = param.substring(0, param.indexOf(':')); cellRef2 = param.substring(param.indexOf(':') + 1, param.length()); } byte cellRefBytes1[] = encodeCellCoordinates(cellRef1); byte cellRefBytes2[] = encodeCellCoordinates(cellRef2); - + tmpByteArray.add(new Byte(cellRefBytes1[0])); tmpByteArray.add(new Byte(cellRefBytes1[1])); - + tmpByteArray.add(new Byte(cellRefBytes2[0])); tmpByteArray.add(new Byte(cellRefBytes2[1])); - + tmpByteArray.add(new Byte(cellRefBytes1[2])); tmpByteArray.add(new Byte(cellRefBytes2[2])); return tmpByteArray; } - - /** - * A Function Encoder. - * + + /** + * A Function Encoder. + * * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> - */ + */ private Vector functionEncoder(Token t) { Vector tmpByteArray = new Vector(); - + int id = t.getTokenID(); if(t.getTokenType()==ParseToken.TOKEN_FUNCTION_VARIABLE) { - tmpByteArray.add(new Byte((byte)TokenConstants.TFUNCVAR)); - tmpByteArray.add(new Byte((byte)t.getNumArgs())); + tmpByteArray.add(new Byte((byte)TokenConstants.TFUNCVAR)); + tmpByteArray.add(new Byte((byte)t.getNumArgs())); } else { - tmpByteArray.add(new Byte((byte)TokenConstants.TFUNC)); + tmpByteArray.add(new Byte((byte)TokenConstants.TFUNC)); } - - tmpByteArray.add(new Byte((byte)id)); - tmpByteArray.add(new Byte((byte)(id>>8))); + + tmpByteArray.add(new Byte((byte)id)); + tmpByteArray.add(new Byte((byte)(id>>8))); return tmpByteArray; } - + } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenFactory.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenFactory.java index 7a3e6e68a875..e745c7c0f970 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenFactory.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenFactory.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -30,18 +30,18 @@ package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; import org.openoffice.xmerge.util.Debug; /** - * This is the Factory class responsible for creating a <code>Token</code>. + * This is the Factory class responsible for creating a <code>Token</code>. * It has three methods for returning three different types of Tokens - * (Operator, Operand and Function). + * (Operator, Operand and Function). * This utility class is used by either the <code>FormulaParser</code> or the - * <code>FormulaDecoder</code>. + * <code>FormulaDecoder</code>. */ public class TokenFactory { - + private OperatorLookup operatorLookup; private OperandLookup operandLookup; private FunctionLookup fl; - + /** * Default Constructor */ @@ -53,7 +53,7 @@ public class TokenFactory { /** * The Factory method for creating function Tokens - * + * * @return The created <code>Token</code> */ public Token getFunctionToken(String s, int args) { @@ -64,21 +64,21 @@ public class TokenFactory { try { t = new Token(s, ParseToken.TOKEN_FUNCTION_VARIABLE, fl.getIDFromString(s), args); } catch (UnsupportedFunctionException eFn) { - + Debug.log(Debug.ERROR, eFn.getMessage()); } return t; } - + /** * The Factory method for creating operator Tokens * * @return The created <code>Token</code> */ public Token getOperatorToken(String s, int args) { - + Token t = null; - + Debug.log(Debug.TRACE,"TokenFactory creating operator Token : " + s); try { if(args==1) { @@ -94,7 +94,7 @@ public class TokenFactory { } } catch (UnsupportedFunctionException eFn) { Debug.log(Debug.ERROR, eFn.getMessage()); - } + } return t; } @@ -105,13 +105,13 @@ public class TokenFactory { */ public Token getOperandToken(String s, String type) { Token t = null; - + Debug.log(Debug.TRACE,"TokenFactory creating operand (" + type + ") Token : " + s); try { t = new Token(s, ParseToken.TOKEN_OPERAND, operandLookup.getIDFromString(type), 0); } catch (UnsupportedFunctionException eFn) { Debug.log(Debug.ERROR, eFn.getMessage()); - } + } return t; } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/UnsupportedFunctionException.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/UnsupportedFunctionException.java index d9808e526816..ca2794d3f73d 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/UnsupportedFunctionException.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/UnsupportedFunctionException.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/pocketword/build.xml b/xmerge/source/pocketword/build.xml index 16b1d23b6fff..51b198c329af 100644 --- a/xmerge/source/pocketword/build.xml +++ b/xmerge/source/pocketword/build.xml @@ -3,23 +3,23 @@ #************************************************************************* # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - + Copyright 2000, 2010 Oracle and/or its affiliates. - + OpenOffice.org - a multi-platform office productivity suite - + This file is part of OpenOffice.org. - + OpenOffice.org is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. - + OpenOffice.org is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details (a copy is included in the LICENSE file that accompanied this code). - + You should have received a copy of the GNU Lesser General Public License version 3 along with OpenOffice.org. If not, see <http://www.openoffice.org/license.html> @@ -27,11 +27,11 @@ #************************************************************************* --> - + <project name="pocketword" default="all" basedir="."> <property file="../inc/antbuild.properties"/> - + <path id="classpath"> <pathelement location="${build.dir}/xmerge.jar"/> </path> @@ -51,7 +51,7 @@ <classpath refid="classpath"/> </javac> </target> - + <!-- package to jar --> <target name="jar" depends="compile"> <jar destfile="${target.jar}"> @@ -68,9 +68,9 @@ <delete dir="${class.dir}"/> <delete file="${target.jar}"/> </target> - + <target name="all" depends="jar"> </target> - + </project> diff --git a/xmerge/source/pocketword/converter.xml b/xmerge/source/pocketword/converter.xml index d7cd7663070e..56fcebfba6b1 100644 --- a/xmerge/source/pocketword/converter.xml +++ b/xmerge/source/pocketword/converter.xml @@ -4,23 +4,23 @@ #************************************************************************* # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - + Copyright 2000, 2010 Oracle and/or its affiliates. - + OpenOffice.org - a multi-platform office productivity suite - + This file is part of OpenOffice.org. - + OpenOffice.org is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. - + OpenOffice.org is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details (a copy is included in the LICENSE file that accompanied this code). - + You should have received a copy of the GNU Lesser General Public License version 3 along with OpenOffice.org. If not, see <http://www.openoffice.org/license.html> diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/ConverterCapabilitiesImpl.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/ConverterCapabilitiesImpl.java index 67e674cbfdc2..13437cc7bb7c 100644 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/ConverterCapabilitiesImpl.java +++ b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/ConverterCapabilitiesImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDescriptor.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDescriptor.java index f54e5a6fcf5e..5e2f8a06e3a0 100644 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDescriptor.java +++ b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDescriptor.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -37,8 +37,8 @@ import java.util.Vector; /** - * This class to represent the data structure stored by a Pocket Word file that - * describes that file. + * This class to represent the data structure stored by a Pocket Word file that + * describes that file. * * The data structure is of variable length, beginning at the end of the * font declarations and ending 10 bytes before the first instance of 0xFF 0xFF @@ -49,23 +49,23 @@ import java.util.Vector; * of the Document Descriptor. * * @author Mark Murnane - * @version 1.1 + * @version 1.1 */ class DocumentDescriptor { private short numParagraphs = 0; private short length = 0; private short numLines = 0; - - private Vector paragraphDesc = null; - + + private Vector paragraphDesc = null; + DocumentDescriptor() { paragraphDesc = new Vector(0, 1); } - - - + + + /** - * Updates the <code>DocumentDescriptor</code> to include details of another + * Updates the <code>DocumentDescriptor</code> to include details of another * paragraph in the document. * * @param len The number of characters in the paragraph. @@ -73,54 +73,54 @@ class DocumentDescriptor { */ public void addParagraph(short len, short lines) { ParagraphDescriptor pd = new ParagraphDescriptor(len, lines); - + paragraphDesc.add(pd); numParagraphs++; numLines += lines; length += pd.length; } - - + + /** - * Retrieve the <code>DocumentDescriptor's</code> data. Due to the variable - * length nature of the descriptor, certain fields can only be + * Retrieve the <code>DocumentDescriptor's</code> data. Due to the variable + * length nature of the descriptor, certain fields can only be * calculated/written after the addition of all paragraphs. * - * @return Byte array containing the Pocket Word representation of this + * @return Byte array containing the Pocket Word representation of this * <code>DocumentDescriptor</code>. */ - public byte[] getDescriptor () { + public byte[] getDescriptor () { ByteArrayOutputStream descStream = new ByteArrayOutputStream(); - + writeHeader(descStream); - - /* + + /* * This value seems to increment by 0x02 for each paragraph. - * For a single paragraph doc, the value is 0x08, 0x0A for two, + * For a single paragraph doc, the value is 0x08, 0x0A for two, * 0x0C for three ... */ try { - descStream.write(EndianConverter.writeShort((short)(6 + + descStream.write(EndianConverter.writeShort((short)(6 + (numParagraphs * 2)))); - + descStream.write(EndianConverter.writeShort(numParagraphs)); descStream.write(EndianConverter.writeShort((short)0)); descStream.write(EndianConverter.writeShort(numParagraphs)); - + descStream.write(EndianConverter.writeShort((short)0)); descStream.write(EndianConverter.writeShort((short)length)); descStream.write(EndianConverter.writeShort((short)0)); - + descStream.write(EndianConverter.writeShort(numLines)); - descStream.write(new byte[] { 0x00, 0x00, 0x00, 0x00, + descStream.write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } ); - + for (int i = 0; i < paragraphDesc.size(); i++) { ParagraphDescriptor pd = (ParagraphDescriptor)paragraphDesc.elementAt(i); - + descStream.write(pd.getDescriptor()); } - + // Byte sequence marking the end of this DocumentDescriptor descStream.write(EndianConverter.writeShort((short)0)); descStream.write(EndianConverter.writeShort((short)0x41)); @@ -128,54 +128,54 @@ class DocumentDescriptor { catch (IOException ioe) { // Should never happen as this is a memory based stream. } - + return descStream.toByteArray(); } - + /* * This method loads the intial fixed portion of the descriptor and the * mid-section. The mid-section is variable but Pocket Word doesn't seem * to mind default values. - */ + */ private void writeHeader(OutputStream descStream) { - + try { - descStream.write(new byte[] { 0x00, 0x00, 0x00, 0x00, + descStream.write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x06, 0x00, - 0x15, 0x00, 0x10, 0x00, + 0x15, 0x00, 0x10, 0x00, 0x01, 0x00, (byte)0xD0, 0x2F, - 0x00, 0x00, (byte)0xE0, 0x3D, + 0x00, 0x00, (byte)0xE0, 0x3D, 0x00, 0x00, (byte)0xF0, 0x00, - 0x00, 0x00, (byte)0xA0, 0x05, 0x00, 0x00, (byte)0xA0, 0x05, - 0x00, 0x00, (byte)0xA0, 0x05, 0x00, 0x00, (byte)0xA0, 0x05, - 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, (byte)0xA0, 0x05, + 0x00, 0x00, (byte)0xA0, 0x05, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0A, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0A, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, - 0x07, 0x00, 0x10, 0x00, + 0x07, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x12, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x04, 0x00, 0x00 } ); - - /* + + /* * The next four bytes are variable, but a pattern hasn't yet been * established. Pocket Word seems to accept this constant value. * @@ -183,12 +183,12 @@ class DocumentDescriptor { * not seem to change from one file to the next. */ descStream.write(new byte[] { (byte)0xE2, 0x02, 0x00, 0x00 } ); - descStream.write(new byte[] { 0x00, 0x00, 0x00, 0x00, + descStream.write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3D, 0x04, 0x00, 0x00 } ); descStream.write(new byte[] { (byte)0xE2, 0x02, 0x00, 0x00 } ); - - descStream.write(new byte[] { 0x00, 0x00, 0x00, 0x00, + + descStream.write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x08, 0x00 } ); @@ -197,10 +197,10 @@ class DocumentDescriptor { /* Shouldn't happen with a ByteArrayOutputStream */ } } - - + + /** - * <code>ParagraphDescriptor</code> represents the data structure used to + * <code>ParagraphDescriptor</code> represents the data structure used to * describe individual paragraphs within a <code>DocumentDescriptor.</code> * * It is used solely by the <code>DocumentDescriptor<code> class. @@ -210,16 +210,16 @@ class DocumentDescriptor { private short lines = 0; private short length = 0; private short unknown = 0x23; - + public ParagraphDescriptor(short len, short numLines) { lines = numLines; length = (short)(len + 1); } - + public byte[] getDescriptor() { ByteArrayOutputStream desc = new ByteArrayOutputStream(); - - try { + + try { desc.write(EndianConverter.writeShort(filler)); desc.write(EndianConverter.writeShort(lines)); desc.write(EndianConverter.writeShort(length)); @@ -228,7 +228,7 @@ class DocumentDescriptor { catch (IOException ioe) { /* Should never happen */ } - + return desc.toByteArray(); } } diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDeserializerImpl.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDeserializerImpl.java index c3f63e73fba6..6d7873cca96b 100644 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDeserializerImpl.java +++ b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDeserializerImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -62,22 +62,22 @@ import org.w3c.dom.Element; * @author Mark Murnane * @version 1.1 */ -public final class DocumentDeserializerImpl +public final class DocumentDeserializerImpl implements DocumentDeserializer, OfficeConstants { - + private PocketWordDocument pswDoc = null; private SxwDocument sxwDoc = null; private String docName; - + private StyleCatalog styleCat = null; - - + + /** - * Initialises a new <code>DocumentDeserializerImpl</code> using the + * Initialises a new <code>DocumentDeserializerImpl</code> using the * supplied <code>ConvertData</code>.</p> * * <p>The <code>Document</code> objects in the <code>ConvertData</code> - * should be {@link + * should be {@link * org.openoffice.xmerge.converter.xml.sxw.pocketword.PocketWordDocument * PocketWordDocument} objects.</p> * @@ -85,17 +85,17 @@ public final class DocumentDeserializerImpl * for conversion. */ public DocumentDeserializerImpl(ConvertData cd) { - Enumeration e = cd.getDocumentEnumeration(); - + Enumeration e = cd.getDocumentEnumeration(); + // A Pocket Word file is composed of one binary file while (e.hasMoreElements()) { pswDoc = (PocketWordDocument)e.nextElement(); } - + docName = pswDoc.getName(); } - - + + /** * <p>Convert the data passed into the <code>DocumentDeserializer</code> * constructor into the OpenOffice Writer <code>Document</code> @@ -110,31 +110,31 @@ public final class DocumentDeserializerImpl * @throws ConvertException If any Convert error occurs. * @throws IOException If any I/O error occurs. */ - public Document deserialize() throws IOException, ConvertException { + public Document deserialize() throws IOException, ConvertException { Enumeration pe = pswDoc.getParagraphEnumeration(); - + sxwDoc = new SxwDocument (docName); sxwDoc.initContentDOM(); - - // Default to an initial 5 entries in the catalog. + + // Default to an initial 5 entries in the catalog. styleCat = new StyleCatalog(5); try { - buildDocument(pe); + buildDocument(pe); } catch (Exception e) { e.printStackTrace(); throw new ConvertException("Error building OpenOffice Writer DOM: " + e.toString()); - + } - + return sxwDoc; } - - + + /** - * This method actually takes care of the conversion. + * This method actually takes care of the conversion. * * @param data An Enumeration of all Paragraphs in the Pocket Word doc. * @@ -143,15 +143,15 @@ public final class DocumentDeserializerImpl * @throws IOException If any I/O errors occur. */ private void buildDocument(Enumeration data) throws IOException { - + org.w3c.dom.Document doc = sxwDoc.getContentDOM(); - + /* - * There should be only one each of office:body and + * There should be only one each of office:body and * office:automatic-styles in each document. */ Node bodyNode = doc.getElementsByTagName(TAG_OFFICE_BODY).item(0); - + // Not every document has an automatic style tag Node autoStylesNode = doc.getElementsByTagName( TAG_OFFICE_AUTOMATIC_STYLES).item(0); @@ -164,20 +164,20 @@ public final class DocumentDeserializerImpl // Needed for naming new styles int paraStyles = 1; int textStyles = 1; - + // Pocket Word has no concept of a list. Element listNode = null; - + // Down to business ... while (data.hasMoreElements()) { Paragraph p = (Paragraph)data.nextElement(); Element paraNode = doc.createElement(TAG_PARAGRAPH); - + // Set paragraph style information here ParaStyle pStyle = p.makeStyle(); if (pStyle == null) { - paraNode.setAttribute(ATTRIBUTE_TEXT_STYLE_NAME, + paraNode.setAttribute(ATTRIBUTE_TEXT_STYLE_NAME, PocketWordConstants.DEFAULT_STYLE); } else { @@ -186,59 +186,59 @@ public final class DocumentDeserializerImpl paraNode.setAttribute(ATTRIBUTE_TEXT_STYLE_NAME, pStyle.getName()); styleCat.add(pStyle); } - - + + /* * For each of the paragraphs, process each segment. * There will always be at least one. */ Enumeration paraData = p.getSegmentsEnumerator(); Vector textSpans = new Vector(0, 1); - + do { ParagraphTextSegment pts = (ParagraphTextSegment)paraData.nextElement(); Element span = doc.createElement(OfficeConstants.TAG_SPAN); - + TextStyle ts = pts.getStyle(); - + if (ts != null) { ts.setName(new String("TS" + textStyles++)); span.setAttribute(ATTRIBUTE_TEXT_STYLE_NAME, ts.getName()); styleCat.add(ts); } else { - span.setAttribute(ATTRIBUTE_TEXT_STYLE_NAME, + span.setAttribute(ATTRIBUTE_TEXT_STYLE_NAME, PocketWordConstants.DEFAULT_STYLE); } - + // If this isn't a blank paragraph if (pts.getText() != null && !pts.getText().equals("")) { Node[] children = OfficeUtil.parseText(pts.getText(), doc); - + for (int j = 0; j < children.length; j++) { span.appendChild(children[j]); } } textSpans.add(span); - + } while (paraData.hasMoreElements()); - - + + /* * Special case for the first span. If it has no style, then * it shouldn't be a span, so just add its children with style * set as standard. - */ + */ Element firstSpan = (Element)textSpans.elementAt(0); String styleName = firstSpan.getAttribute(ATTRIBUTE_TEXT_STYLE_NAME); if (styleName.equals(PocketWordConstants.DEFAULT_STYLE)) { NodeList nl = firstSpan.getChildNodes(); int len = nl.getLength(); - + for (int i = 0; i < len; i++) { /* - * Always take item 0 as the DOM tree event model will + * Always take item 0 as the DOM tree event model will * cause the NodeList to shrink as each Node is reparented. * * By taking the first item from the list, we essentially @@ -255,13 +255,13 @@ public final class DocumentDeserializerImpl for (int i = 1; i < textSpans.size(); i++) { paraNode.appendChild((Node)textSpans.elementAt(i)); } - - + + /* * Pocket Word doesn't support lists, but it does have bulleted - * paragraphs that are essentially the same thing. + * paragraphs that are essentially the same thing. * - * Unlike OpenOffice Writer, a blank paragraph can be bulleted + * Unlike OpenOffice Writer, a blank paragraph can be bulleted * as well. This will be handled by inserting a blank paragraph * into the unordered list, but OpenOffice Writer will not display * an item at that point in the list. @@ -274,7 +274,7 @@ public final class DocumentDeserializerImpl listItem.appendChild(paraNode); listNode.appendChild(listItem); } - else { + else { if (listNode != null) { bodyNode.appendChild(listNode); listNode = null; @@ -282,8 +282,8 @@ public final class DocumentDeserializerImpl bodyNode.appendChild(paraNode); } } // End processing paragraphs - - + + // Now write the style catalog to the document NodeList nl = styleCat.writeNode(doc, "dummy").getChildNodes(); int nlLen = nl.getLength(); // nl.item reduces the length diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentMergerImpl.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentMergerImpl.java index 83d24c1b6993..e3d09b5c2bcc 100644 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentMergerImpl.java +++ b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentMergerImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentSerializerImpl.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentSerializerImpl.java index aaa226b87823..08424a073803 100644 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentSerializerImpl.java +++ b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentSerializerImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -47,7 +47,7 @@ import java.io.IOException; /** - * <p>Pocket Word implementation of <code>DocumentDeserializer</code> + * <p>Pocket Word implementation of <code>DocumentDeserializer</code> * for use by {@link * org.openoffice.xmerge.converter.xml.sxw.pocketword.PluginFactoryImpl * PluginFactoryImpl}.</p> @@ -57,17 +57,17 @@ import java.io.IOException; * @author Mark Murnane * @version 1.1 */ -public final class DocumentSerializerImpl +public final class DocumentSerializerImpl implements DocumentSerializer, OfficeConstants { - + private PocketWordDocument pswDoc; private SxwDocument sxwDoc; - + private StyleCatalog styleCat = null; - + private boolean inList = false; - - + + /** * <p>Initialises a new <code>DocumentSerializerImpl</code> using the.<br> * supplied <code>Document</code></p> @@ -76,14 +76,14 @@ public final class DocumentSerializerImpl * org.openoffice.xmerge.converter.xml.sxw.SxwDocument SxwDocument} * object.</p> * - * @param document The <code>Document</code> to convert. + * @param document The <code>Document</code> to convert. */ public DocumentSerializerImpl(Document doc) { sxwDoc = (SxwDocument)doc; pswDoc = new PocketWordDocument(sxwDoc.getName()); } - - + + /** * <p>Convert the data passed into the <code>DocumentSerializerImpl</code> * constructor into Pocket Word format.</p> @@ -98,28 +98,28 @@ public final class DocumentSerializerImpl * @throws ConvertException If any conversion error occurs. * @throws IOException If any I/O error occurs. */ - public ConvertData serialize() throws IOException, ConvertException { + public ConvertData serialize() throws IOException, ConvertException { ConvertData cd = new ConvertData(); - + org.w3c.dom.Document doc = sxwDoc.getContentDOM(); - + // Load any style info before traversing the document content tree loadStyles(); - + NodeList list = doc.getElementsByTagName(TAG_OFFICE_BODY); - + int len = list.getLength(); if (len > 0) { Node node = list.item(0); traverseBody(node); } - + cd.addDocument(pswDoc); - + return cd; } - - + + /* * Handles the loading of defined styles from the style.xml file as well * as automatic styles from the content.xml file. @@ -132,19 +132,19 @@ public final class DocumentSerializerImpl org.w3c.dom.Document styleDom = sxwDoc.getStyleDOM(); styleCat = new StyleCatalog(25); - + NodeList nl = null; - String families[] = new String[] { PocketWordConstants.TEXT_STYLE_FAMILY, - PocketWordConstants.PARAGRAPH_STYLE_FAMILY, + String families[] = new String[] { PocketWordConstants.TEXT_STYLE_FAMILY, + PocketWordConstants.PARAGRAPH_STYLE_FAMILY, PocketWordConstants.PARAGRAPH_STYLE_FAMILY }; - Class classes[] = new Class[] { TextStyle.class, - ParaStyle.class, + Class classes[] = new Class[] { TextStyle.class, + ParaStyle.class, TextStyle.class }; - + String[] styleTypes = new String[] { TAG_OFFICE_STYLES, TAG_OFFICE_AUTOMATIC_STYLES, TAG_OFFICE_MASTER_STYLES }; - + /* * Documents converted from PSW -> SXW will not have a style.xml when * being converted back to PSW. This would occur if a document was @@ -154,49 +154,49 @@ public final class DocumentSerializerImpl * portions of a complete Writer SXW file. */ if (styleDom != null) { - // Process the Style XML tree - for (int i = 0; i < styleTypes.length; i++ ) { + // Process the Style XML tree + for (int i = 0; i < styleTypes.length; i++ ) { nl = styleDom.getElementsByTagName(styleTypes[i]); if (nl.getLength() != 0) { styleCat.add(nl.item(0), families, classes, null, false); } } } - + /* - * Process the content XML for any other style info. + * Process the content XML for any other style info. * Should only be automatic types here. */ - for (int i = 0; i < styleTypes.length; i++ ) { + for (int i = 0; i < styleTypes.length; i++ ) { nl = contentDom.getElementsByTagName(styleTypes[i]); if (nl.getLength() != 0) { styleCat.add(nl.item(0), families, classes, null, false); } } } - - + + /* - * Process the office:body tag. + * Process the office:body tag. */ private void traverseBody(Node node) throws IOException, ConvertException { - + if (node.hasChildNodes()) { NodeList nList = node.getChildNodes(); int len = nList.getLength(); - + for (int i = 0; i < len; i++) { Node child = nList.item(i); - + if (child.getNodeType() == Node.ELEMENT_NODE) { String nodeName = child.getNodeName(); - - if (nodeName.equals(TAG_PARAGRAPH) + + if (nodeName.equals(TAG_PARAGRAPH) || nodeName.equals(TAG_HEADING)) { traverseParagraph(child); } - - if (nodeName.equals(TAG_UNORDERED_LIST) || + + if (nodeName.equals(TAG_UNORDERED_LIST) || nodeName.equals(TAG_ORDERED_LIST)) { traverseList(child); } @@ -204,67 +204,67 @@ public final class DocumentSerializerImpl } } } - - + + /* * Process a text:p tag */ private void traverseParagraph(Node node) throws IOException, ConvertException { String styleName = getAttribute(node, ATTRIBUTE_TEXT_STYLE_NAME); - - ParaStyle pstyle = (ParaStyle)styleCat.lookup(styleName, - PocketWordConstants.PARAGRAPH_STYLE_FAMILY, null, + + ParaStyle pstyle = (ParaStyle)styleCat.lookup(styleName, + PocketWordConstants.PARAGRAPH_STYLE_FAMILY, null, ParaStyle.class); if (pstyle != null) { pstyle = (ParaStyle)pstyle.getResolved(); } - - TextStyle tstyle = (TextStyle)styleCat.lookup(styleName, - PocketWordConstants.PARAGRAPH_STYLE_FAMILY, null, + + TextStyle tstyle = (TextStyle)styleCat.lookup(styleName, + PocketWordConstants.PARAGRAPH_STYLE_FAMILY, null, TextStyle.class); if (pstyle != null) { tstyle = (TextStyle)tstyle.getResolved(); } - + try { pswDoc.addParagraph(pstyle, inList); - } + } catch (Exception e) { throw new ConvertException( "Error adding paragraph to PocketWordDocument.\n" + e.toString()); } - + traverseParagraphContents(node, tstyle); } - - + + /* * Process the contents of a paragraph. This method handles situations - * where the paragraph contains multiple children, each representing a + * where the paragraph contains multiple children, each representing a * differently formatted piece of text. */ - private void traverseParagraphContents (Node node, TextStyle defTextStyle) + private void traverseParagraphContents (Node node, TextStyle defTextStyle) throws IOException, ConvertException { // First up, get the style of this little bit String styleName = getAttribute(node, ATTRIBUTE_TEXT_STYLE_NAME); - TextStyle tStyle = (TextStyle)styleCat.lookup(styleName, - PocketWordConstants.TEXT_STYLE_FAMILY, null, + TextStyle tStyle = (TextStyle)styleCat.lookup(styleName, + PocketWordConstants.TEXT_STYLE_FAMILY, null, TextStyle.class); - + if (tStyle == null) { tStyle = defTextStyle; } - + if (node.hasChildNodes()) { NodeList nList = node.getChildNodes(); int len = nList.getLength(); - + for (int i = 0; i < len; i++) { - + Node child = nList.item(i); short nodeType = child.getNodeType(); - + switch (nodeType) { case Node.TEXT_NODE: String s = child.getNodeValue(); @@ -274,31 +274,31 @@ public final class DocumentSerializerImpl } catch (Exception e) { throw new ConvertException( - "Error adding data to paragraph in " + + "Error adding data to paragraph in " + "PocketWordDocument.\n" + e.toString()); - + } } break; - + case Node.ELEMENT_NODE: if (child.getNodeName().equals(TAG_SPACE)) { StringBuffer sb = new StringBuffer(""); int count = 1; - + NamedNodeMap map = child.getAttributes(); - + if (map.getLength() > 0) { Node attr = map.getNamedItem(ATTRIBUTE_SPACE_COUNT); count = Integer.parseInt(attr.getNodeValue().trim()); } - + for ( ; count > 0; count--) { sb.append(" "); } - + /* - * May want to look at style info for spaces. Could + * May want to look at style info for spaces. Could * be important when calculating font metrics. */ try { @@ -306,9 +306,9 @@ public final class DocumentSerializerImpl } catch (Exception e) { throw new ConvertException( - "Error adding data to paragraph in " + + "Error adding data to paragraph in " + "PocketWordDocument.\n" + e.toString()); - + } } else if (child.getNodeName().equals(TAG_TAB_STOP)) { @@ -317,9 +317,9 @@ public final class DocumentSerializerImpl } catch (Exception e) { throw new ConvertException( - "Error adding data to paragraph in " + + "Error adding data to paragraph in " + "PocketWordDocument.\n" + e.toString()); - + } } else if (child.getNodeName().equals(TAG_LINE_BREAK)) { @@ -355,41 +355,41 @@ public final class DocumentSerializerImpl pswDoc.addParagraphData("", tStyle); } } - - + + /* * Process a text:ordered-list or text:unordered-list tag. Pocket Word has - * no concept of a list so there is no need to differentiate between the + * no concept of a list so there is no need to differentiate between the * two. * * Each item on the list contains a text:p node. */ private void traverseList (Node node) throws IOException, ConvertException { inList = true; - + if (node.hasChildNodes()) { NodeList nList = node.getChildNodes(); int len = nList.getLength(); - + for (int i = 0; i < len; i++) { Node child = nList.item(i); - + if (child.getNodeType() == Node.ELEMENT_NODE) { String nodeName = child.getNodeName(); - + if (nodeName.equals(TAG_LIST_ITEM)) { traverseListItem(child); } } } } - + inList = false; } - - + + /* - * Process a text:list-item node. They usually contain have a single + * Process a text:list-item node. They usually contain have a single * text:p child but can also have sections or other lists. * * For this case, only paragraphs are supported. @@ -398,13 +398,13 @@ public final class DocumentSerializerImpl if (node.hasChildNodes()) { NodeList nList = node.getChildNodes(); int len = nList.getLength(); - + for (int i = 0; i < len; i++) { Node child = nList.item(i); - + if (child.getNodeType() == Node.ELEMENT_NODE) { String nodeName = child.getNodeName(); - + if (nodeName.equals(TAG_PARAGRAPH)) { traverseParagraph(child); } @@ -413,21 +413,21 @@ public final class DocumentSerializerImpl } } - - + + /* * Utility method to retrieve a Node attribute. */ private String getAttribute (Node node, String attribute) { NamedNodeMap attrNodes = node.getAttributes(); - + if (attrNodes != null) { Node attr = attrNodes.getNamedItem(attribute); if (attr != null) { return attr.getNodeValue(); } } - + return null; } } diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/Paragraph.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/Paragraph.java index e30ecab21aee..0302a5d6efba 100644 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/Paragraph.java +++ b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/Paragraph.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -43,7 +43,7 @@ import org.openoffice.xmerge.converter.xml.TextStyle; /** * Represents a paragraph data structure within a Pocket Word document. - * + * * @author Mark Murnane * @version 1.1 */ @@ -59,38 +59,38 @@ class Paragraph implements PocketWordConstants { private short textLength = 0; private short lengthWithFormatting = 0; private short lines = 0; - + private static final short marker = (short)0xFFFF; private static int unknown2 = 0x22; // May be two short values - + private short specialIndentation = 0; private short leftIndentation = 0; private short rightIndentation = 0; - + private byte bullets = 0; private byte alignment = 0; - + private static int unknown3 = 0; - + // Will always have at least these formatting settings in each paragraph private short defaultFont = 2; // Courier New for the time being private short defaultSize = 10; - - + + /* - * Remaining elements assist in calculating correct values for the paragraph + * Remaining elements assist in calculating correct values for the paragraph * representation. */ - + private Vector textSegments = null; - + private Vector lineDescriptors = null; - + private ParaStyle pStyle = null; - + private boolean isLastParagraph = false; - - + + /* * Private class constructor used by all constructors. Ensures the proper * initialisation of the Vector storing the paragraph's text. @@ -98,25 +98,25 @@ class Paragraph implements PocketWordConstants { private Paragraph () { textSegments = new Vector(0, 1); } - - + + /** - * <p>Constructor for use when converting from SXW format to Pocket Word + * <p>Constructor for use when converting from SXW format to Pocket Word * format.</p> - * + * * @param style Paragraph style object describing the formatting style * of this paragraph. */ public Paragraph (ParaStyle style) { this(); - + lineDescriptors = new Vector(0, 1); pStyle = style; } - - + + /** - * <p>Constructor for use when converting from Pocket Word format to SXW + * <p>Constructor for use when converting from Pocket Word format to SXW * format.</p> * * @param data Byte array containing byte data describing this paragraph @@ -124,7 +124,7 @@ class Paragraph implements PocketWordConstants { */ public Paragraph (byte[] data) { this(); - + /* * Read in all fixed data from the array * @@ -135,22 +135,22 @@ class Paragraph implements PocketWordConstants { lengthWithFormatting = EndianConverter.readShort( new byte[] { data[6], data[7] } ); lines = EndianConverter.readShort(new byte[] { data[8], data [9] } ); - + /* * The marker appears at data[10] and data[11]. * * The value of unknown2 is at data[12], data[13], data[14] and data[15]. */ - + specialIndentation = EndianConverter.readShort(new byte[] { data[16], data[17] } ); leftIndentation = EndianConverter.readShort(new byte[] { data[18], data [19] } ); rightIndentation = EndianConverter.readShort(new byte[] { data[20], data [21] } ); - + bullets = data[22]; alignment = data[23]; - + // The value of unknown3 is at data[24], data[25], data[26] and data[27]. - + /* * The actual paragraph data is in the remainder of the byte sequence. * @@ -161,58 +161,58 @@ class Paragraph implements PocketWordConstants { bos.write(data, 28, lengthWithFormatting); parseText(bos.toByteArray()); } - - + + /* * Processes the text portion of the raw paragraph data from the Pocket Word * file. This data also includes formatting settings for the text in the * paragraph. * * Formatting changes appear like XML/HTML tags. Formatted blocks are - * preceded by a sequence of bytes switching on a formatting change and + * preceded by a sequence of bytes switching on a formatting change and * followed by a sequence switching off that formatting change. */ private void parseText (byte[] data) { - + int totalLength = data.length; - + StringBuffer sb = new StringBuffer(""); - + // Setup text style information - int mask = TextStyle.BOLD | TextStyle.ITALIC | TextStyle.UNDERLINE + int mask = TextStyle.BOLD | TextStyle.ITALIC | TextStyle.UNDERLINE | TextStyle.STRIKETHRU; - - + + String fontName = null; int fontSize = 0; Color textColour = null; Color backColour = null; int modifiers = 0; - + TextStyle ts = null; - + int attrsSet = 0; // If this is 0, we have no extra style boolean inSequence = false; boolean sawText = false; - + String s = new String(); // For debugging - + // Start from the very beginning - for (int i = 0; i < totalLength; i++) { + for (int i = 0; i < totalLength; i++) { // Will encounter at least two codes first - if ((byte)(data[i] & 0xF0) == FORMATTING_TAG) { + if ((byte)(data[i] & 0xF0) == FORMATTING_TAG) { if (sawText) { // Style change so dump previous segment and style info addTextSegment(sb.toString(), ts); sb = new StringBuffer(""); sawText = false; } - + switch (data[i]) { case FONT_TAG: int index = EndianConverter.readShort( new byte[] { data[i + 1], data[i + 2] } ); - + /* * Standard font. * @@ -241,19 +241,19 @@ class Paragraph implements PocketWordConstants { } i += 2; break; - - + + case FONT_SIZE_TAG: int size = EndianConverter.readShort( new byte[] { data[i + 1], data[i + 2] } ); - + if (size == 0) { // Flags the end of the last paragraph isLastParagraph = true; i += 2; break; } - + // Standard size if (fontSize == 0 || fontSize == 10) { if (size != 10) { @@ -273,15 +273,15 @@ class Paragraph implements PocketWordConstants { } i += 2; break; - - + + case COLOUR_TAG: if (data[i + 1] != 0) { ColourConverter cc = new ColourConverter(); textColour = cc.convertToRGB( - EndianConverter.readShort(new byte[] { data[i + 1], - data[i + 2] } )); - attrsSet++; + EndianConverter.readShort(new byte[] { data[i + 1], + data[i + 2] } )); + attrsSet++; } else { textColour = null; @@ -289,10 +289,10 @@ class Paragraph implements PocketWordConstants { } i += 2; break; - - + + case FONT_WEIGHT_TAG: - if (data[i + 1] == FONT_WEIGHT_BOLD + if (data[i + 1] == FONT_WEIGHT_BOLD || data[i + 1] == FONT_WEIGHT_THICK) { modifiers |= TextStyle.BOLD; attrsSet++; @@ -304,8 +304,8 @@ class Paragraph implements PocketWordConstants { } i += 2; break; - - + + case ITALIC_TAG: if (data[i + 1] == (byte)0x01) { modifiers |= TextStyle.ITALIC; @@ -317,8 +317,8 @@ class Paragraph implements PocketWordConstants { } i++; break; - - + + case UNDERLINE_TAG: if (data[i + 1] == (byte)0x01) { modifiers |= TextStyle.UNDERLINE; @@ -330,8 +330,8 @@ class Paragraph implements PocketWordConstants { } i++; break; - - + + case STRIKETHROUGH_TAG: if (data[i + 1] == (byte)0x01) { modifiers |= TextStyle.STRIKETHRU; @@ -343,10 +343,10 @@ class Paragraph implements PocketWordConstants { } i++; break; - + case HIGHLIGHT_TAG: /* - * Highlighting is treated by OpenOffice as a + * Highlighting is treated by OpenOffice as a * background colour. */ if (data[i + 1] == (byte)0x01) { @@ -360,17 +360,17 @@ class Paragraph implements PocketWordConstants { i++; break; } - + inSequence = true; continue; } - - if (inSequence) { + + if (inSequence) { // Style information has been changed. Create new style here - + inSequence = false; if (attrsSet > 0) { - ts = new TextStyle(null, TEXT_STYLE_FAMILY, DEFAULT_STYLE, + ts = new TextStyle(null, TEXT_STYLE_FAMILY, DEFAULT_STYLE, mask, modifiers, fontSize, fontName, null); ts.setColors(textColour, backColour); } @@ -378,7 +378,7 @@ class Paragraph implements PocketWordConstants { ts = null; } } - + /* * C4 xx seems to indicate a control code. C4 00 indicates the end * of a paragraph; C4 04 indicates a tab space. Only these two @@ -388,11 +388,11 @@ class Paragraph implements PocketWordConstants { /* * Redundant nodes are sometimes added to the last paragraph * because a new sequence is being processed when the flag is - * set. + * set. * * To avoid this, do nothing with the last paragraph unless no * text has been added for it already. In that case, add the - * empty text segment being process to ensure that all + * empty text segment being process to ensure that all * paragraphs have at least one text segment. */ if (data[i + 1] == (byte)0x00) { @@ -407,14 +407,14 @@ class Paragraph implements PocketWordConstants { i++; continue; } - + sb.append((char)data[i]); sawText = true; s = sb.toString(); } } - + /** * <p>Adds details of a new text block to the <code>Paragraph</code> object. * </p> @@ -427,27 +427,27 @@ class Paragraph implements PocketWordConstants { textLength += text.length(); textSegments.add(new ParagraphTextSegment(text, style)); } - - + + /** - * <p>This method alters the state of the <code>Paragraph</code> object to + * <p>This method alters the state of the <code>Paragraph</code> object to * indicate whether or not it is the final paragraph in the document.</p> * - * <p>It is used during conversion from SXW format to Pocket Word format. + * <p>It is used during conversion from SXW format to Pocket Word format. * In Pocket Word files, the last paragraph finishes with a different byte * sequence to other paragraphs.</p> * - * @param isLast true if the Paragraph is the last in the document, + * @param isLast true if the Paragraph is the last in the document, * false otherwise. */ public void setLastParagraph(boolean isLast) { isLastParagraph = isLast; } - - + + /** - * <p>Complementary method to {@link #setLastParagraph(boolean) - * setLastParagraph}. Returns the terminal status of this + * <p>Complementary method to {@link #setLastParagraph(boolean) + * setLastParagraph}. Returns the terminal status of this * <code>Paragraph</code> within the Pocket Word document.</p> * * @return true if the Paragraph is the last in the document; false otherwise. @@ -455,28 +455,28 @@ class Paragraph implements PocketWordConstants { public boolean getLastParagraph () { return isLastParagraph; } - - + + /** - * <p>This method returns the Pocket Word representation of this + * <p>This method returns the Pocket Word representation of this * <code>Paragraph</code> in Little Endian byte order.</p> * * <p>Used when converting from SXW format to Pocket Word format.</p> * - * @return <code>byte</code> array containing the formatted representation + * @return <code>byte</code> array containing the formatted representation * of this Paragraph. */ public byte[] getParagraphData() { ByteArrayOutputStream bos = new ByteArrayOutputStream(); - + postProcessText(); - - /* + + /* * Need information about the paragraph segments in two places - * so calculate them first. + * so calculate them first. * * The stream contains the text wrapped in any formatting sequences that - * are necessary. + * are necessary. */ ByteArrayOutputStream segs = new ByteArrayOutputStream(); @@ -489,7 +489,7 @@ class Paragraph implements PocketWordConstants { catch (IOException ioe) { // Should never happen in a memory based stream } - + /* * Number of data words for this paragraph descriptor: * @@ -504,21 +504,21 @@ class Paragraph implements PocketWordConstants { dataWords += (4 - (dataWords % 4)); } dataWords /= 4; - + /* * The 8 bytes are made up of E6 ?0 00 and E5 ?0 00 at the start of the - * text along with the C4 00 that terminates it. + * text along with the C4 00 that terminates it. * - * In the event that the paragraph is the last one E6 00 00 is also + * In the event that the paragraph is the last one E6 00 00 is also * present at the end of the text. Also, as we currently use a font * other than the first in the index (Tahoma) E5 01 00 is also present. * * Make sure this is accurate when font specifications change */ lengthWithFormatting = (short)(segs.size() + (isLastParagraph ? 14 : 8)); - + try { - bos.write(EndianConverter.writeShort(unknown1)); + bos.write(EndianConverter.writeShort(unknown1)); bos.write(EndianConverter.writeShort(dataWords)); bos.write(EndianConverter.writeShort((short)(textLength + 1))); bos.write(EndianConverter.writeShort(lengthWithFormatting)); @@ -526,36 +526,36 @@ class Paragraph implements PocketWordConstants { bos.write(EndianConverter.writeShort(marker)); bos.write(EndianConverter.writeInt(unknown2)); - + bos.write(EndianConverter.writeShort(specialIndentation)); bos.write(EndianConverter.writeShort(leftIndentation)); bos.write(EndianConverter.writeShort(rightIndentation)); - + bos.write(bullets); - + if (pStyle != null && pStyle.isAttributeSet(ParaStyle.TEXT_ALIGN)) { switch (pStyle.getAttribute(ParaStyle.TEXT_ALIGN)) { - + case ParaStyle.ALIGN_RIGHT: bos.write(0x01); break; - + case ParaStyle.ALIGN_CENTER: bos.write(0x02); break; - + default: bos.write(0x00); // Left align in all other circumstances break; - } + } } else { bos.write(0x00); } - + bos.write(EndianConverter.writeInt(unknown3)); - - + + /* * Write out font and size. * @@ -566,13 +566,13 @@ class Paragraph implements PocketWordConstants { bos.write(EndianConverter.writeShort(defaultFont)); bos.write(FONT_SIZE_TAG); bos.write(EndianConverter.writeShort(defaultSize)); - + // Write out the text segments - bos.write(segs.toByteArray()); - + bos.write(segs.toByteArray()); + /* - * If this is the last paragraph in the document then we need to make - * sure that the paragraph text is terminated correctly with an E6 00 00 + * If this is the last paragraph in the document then we need to make + * sure that the paragraph text is terminated correctly with an E6 00 00 * before the C4 00 00. */ if (isLastParagraph) { @@ -584,9 +584,9 @@ class Paragraph implements PocketWordConstants { bos.write(FONT_SIZE_TAG); bos.write(EndianConverter.writeShort((short)0x00)); } - + bos.write(new byte[] { (byte)0xC4, 0x00, 0x00 } ); - + int padding = 0; if (bos.size() % 4 != 0) { padding = 4 - (bos.size() % 4); @@ -594,10 +594,10 @@ class Paragraph implements PocketWordConstants { for (int i = 0; i < padding; i++) { bos.write(0x00); } - - // Third byte should match first byte after 0xFF 0xFF + + // Third byte should match first byte after 0xFF 0xFF bos.write(new byte[] { 0x42, 0x00, 0x22, 0x00} ); - + /* * Meaning of last two bytes seems to be the number of words describing * lines. This is calculated at 10 bytes per descriptor. @@ -610,16 +610,16 @@ class Paragraph implements PocketWordConstants { wordsRemaining++; } bos.write(EndianConverter.writeShort((short)wordsRemaining)); - - + + // Now write out the line descriptors for (int i = 0; i < lineDescriptors.size(); i++) { LineDescriptor ld = (LineDescriptor)lineDescriptors.elementAt(i); - + bos.write(ld.getDescriptorInfo()); - } - - + } + + if (!isLastParagraph) { /* * There may be a need to pad this. Will be writing at @@ -634,17 +634,17 @@ class Paragraph implements PocketWordConstants { catch (IOException ioe) { // Should never occur for a memory based stream } - + return bos.toByteArray(); } - - + + /* * This method handles the calculation of correct values for line lengths * in each individual descriptor and the number of lines in the document. * * TODO: Update to take account of different font metrics. - */ + */ private void postProcessText() { /* * The post-processing ... @@ -655,30 +655,30 @@ class Paragraph implements PocketWordConstants { * To do this, make sure that no sequence goes over the given screen * width unless the last char is a whitespace character. */ - + // In courier, can have no more than 29 chars per line - - int chunkStart = 0; + + int chunkStart = 0; StringBuffer sb = new StringBuffer(""); - + // Line Descriptor info should be eliminated each time lineDescriptors = new Vector(1, 1); lines = 0; - + for (int i = 0; i < textSegments.size(); i++) { ParagraphTextSegment pts = (ParagraphTextSegment)textSegments.elementAt(i); sb.append(pts.getText()); } - + if (sb.length() == 0) { lines = 1; lineDescriptors.add(new LineDescriptor((short)1, (short)0)); return; } - + while (chunkStart < sb.length()) { String text = ""; - + try { text = sb.substring(chunkStart, chunkStart + 30); } @@ -690,16 +690,16 @@ class Paragraph implements PocketWordConstants { lines++; continue; } - + int lastWhitespace = -1; - + for (int i = 29; i >= 0; i--) { if (Character.isWhitespace(text.charAt(i))) { lastWhitespace = i; break; } - } - + } + if (lastWhitespace != -1) { // The line can be split lineDescriptors.add(new LineDescriptor((short)(lastWhitespace + 1), (short)(lastWhitespace * 36))); @@ -714,8 +714,8 @@ class Paragraph implements PocketWordConstants { } } } - - + + /** * <p>Returns the number of lines in the <code>Paragraph</code>.</p> * @@ -723,13 +723,13 @@ class Paragraph implements PocketWordConstants { */ public short getLines() { postProcessText(); - + return lines; } - - + + /** - * <p>Toggles the flag indicating that the <code>Paragraph</code> is a + * <p>Toggles the flag indicating that the <code>Paragraph</code> is a * bulleted paragraph.</p> * * @param isBulleted true to enable bulleting for this paragraph, false @@ -741,7 +741,7 @@ class Paragraph implements PocketWordConstants { } else { bullets = 0; - } + } } /** @@ -755,10 +755,10 @@ class Paragraph implements PocketWordConstants { } return false; } - - + + /** - * <p>Returns the number of text characters in the <code>Paragraph</code>, + * <p>Returns the number of text characters in the <code>Paragraph</code>, * excluding formatting.</p> * * @return The length of the paragraph. @@ -766,10 +766,10 @@ class Paragraph implements PocketWordConstants { public int getTextLength () { return textLength; } - - + + /** - * <p>Returns an <code>Enumeration</code> over the individual text segments + * <p>Returns an <code>Enumeration</code> over the individual text segments * of the <code>Paragraph</code>.</p> * * @return An <code>Enumeration</code> of the text segments. @@ -777,47 +777,47 @@ class Paragraph implements PocketWordConstants { public Enumeration getSegmentsEnumerator () { return textSegments.elements(); } - - + + /** - * <p>Returns a paragraph style object that describes any of the paragraph + * <p>Returns a paragraph style object that describes any of the paragraph * level formatting used by this <code>Paragraph</code>.</p> * * @return Paragraph style object describing the <code>Paragraph</code>. */ public ParaStyle makeStyle() { - int attrs[] = new int[] { ParaStyle.MARGIN_LEFT, ParaStyle.MARGIN_RIGHT, + int attrs[] = new int[] { ParaStyle.MARGIN_LEFT, ParaStyle.MARGIN_RIGHT, ParaStyle.TEXT_ALIGN }; String values[] = new String[attrs.length]; - - /* + + /* * Not interested in left or right indents just yet. Don't know * how to calculate them. */ - + switch (alignment) { case 2: values[2] = "center"; break; - + case 1: values[2] = "right"; break; - + case 0: default: values[2] = "left"; return null; // Not interested if its the default. } - - return new ParaStyle(null, PARAGRAPH_STYLE_FAMILY, null, attrs, + + return new ParaStyle(null, PARAGRAPH_STYLE_FAMILY, null, attrs, values, null); } - - + + /* * Class describing the data structures which appear following the text - * of a Paragraph. For each line on screen that the Paragraph uses, a + * of a Paragraph. For each line on screen that the Paragraph uses, a * LineDescriptor details how many characters are on the line and how much * screen space they occupy. * @@ -831,17 +831,17 @@ class Paragraph implements PocketWordConstants { private int filler = 0; private short screen_space = 0; private short marker = 0; - + private LineDescriptor(short chars, short space) { characters = chars; screen_space = space; marker = (short)0x040C; // Not a constant. Depends on font used. } - - + + private byte[] getDescriptorInfo(){ ByteArrayOutputStream bos = new ByteArrayOutputStream(); - + try { bos.write(EndianConverter.writeShort(characters)); bos.write(EndianConverter.writeInt(filler)); @@ -851,7 +851,7 @@ class Paragraph implements PocketWordConstants { catch (IOException ioe) { // Should never happen in a memory based stream. } - + return bos.toByteArray(); } } diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/ParagraphTextSegment.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/ParagraphTextSegment.java index 7fd816cd0371..e17617f467c7 100644 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/ParagraphTextSegment.java +++ b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/ParagraphTextSegment.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -45,11 +45,11 @@ import java.io.IOException; * @version 1.1 */ class ParagraphTextSegment implements PocketWordConstants { - + private String pText; private TextStyle pStyle; - - + + /** * <p>Initialise a new <code>ParagraphTextSegment</p>. * <p>Both parameters may be <code>null</code>.</p> @@ -61,7 +61,7 @@ class ParagraphTextSegment implements PocketWordConstants { pText = data; pStyle = style; } - + /** * <p>Sets the text for this segment.</p> * @@ -75,12 +75,12 @@ class ParagraphTextSegment implements PocketWordConstants { * <p>Gets the text for this segment.</p> * * @return The text of this segment. - */ + */ public String getText () { return pText; } - - + + /** * <p>Sets the style for this segment.</p> * @@ -89,8 +89,8 @@ class ParagraphTextSegment implements PocketWordConstants { public void setStyle (TextStyle style) { pStyle = style; } - - + + /** * <p>Gets the style for this segment.</p> * @@ -99,25 +99,25 @@ class ParagraphTextSegment implements PocketWordConstants { public TextStyle getStyle () { return pStyle; } - - + + /** - * <p>Returns the string data for this text segment wrapped with the + * <p>Returns the string data for this text segment wrapped with the * appropriate byte codes for the formatting settings used.</p> * - * @return <code>byte</code> array containing formatted text in Pocket Word + * @return <code>byte</code> array containing formatted text in Pocket Word * format. */ public byte[] getData () { ByteArrayOutputStream data = new ByteArrayOutputStream(); - + boolean colourSet = false; boolean boldSet = false; boolean italicSet = false; boolean underlineSet = false; boolean strikeSet = false; boolean highlightSet = false; - + // TODO: Font changes need to be worked out here try { @@ -125,7 +125,7 @@ class ParagraphTextSegment implements PocketWordConstants { if (pStyle.getFontColor() != null) { ColourConverter cc = new ColourConverter(); short colourCode = cc.convertFromRGB(pStyle.getFontColor()); - if (colourCode != 0) { // not black + if (colourCode != 0) { // not black data.write(COLOUR_TAG); data.write(EndianConverter.writeShort(colourCode)); colourSet = true; @@ -134,7 +134,7 @@ class ParagraphTextSegment implements PocketWordConstants { if (pStyle.isSet(TextStyle.BOLD) && pStyle.getAttribute(TextStyle.BOLD)) { data.write(new byte[] { FONT_WEIGHT_TAG, FONT_WEIGHT_BOLD, 0x00 } ); boldSet = true; - } + } if (pStyle.isSet(TextStyle.ITALIC) && pStyle.getAttribute(TextStyle.ITALIC)) { data.write(new byte[] { ITALIC_TAG, 0x01 } ); italicSet = true; @@ -146,14 +146,14 @@ class ParagraphTextSegment implements PocketWordConstants { if (pStyle.isSet(TextStyle.STRIKETHRU) && pStyle.getAttribute(TextStyle.STRIKETHRU)) { data.write(new byte[] { STRIKETHROUGH_TAG, 0x01 } ); strikeSet = true; - } + } if (pStyle.getBackgroundColor() != null) { data.write(new byte[] { HIGHLIGHT_TAG, 0x01 } ); highlightSet = true; } } - - + + // Now write out the data if (!pText.equals("\t")) { data.write(pText.getBytes()); @@ -165,8 +165,8 @@ class ParagraphTextSegment implements PocketWordConstants { */ data.write(new byte[] { (byte)0xC4, 0x04 } ); } - - + + // Now close out any of the settings changes if (colourSet) { /* @@ -196,7 +196,7 @@ class ParagraphTextSegment implements PocketWordConstants { catch (IOException ioe) { // Should never occur in a memory based stream } - + return data.toByteArray(); } } diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PluginFactoryImpl.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PluginFactoryImpl.java index e9c99a221bbd..963e7f489726 100644 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PluginFactoryImpl.java +++ b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PluginFactoryImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -52,9 +52,9 @@ import org.openoffice.xmerge.converter.xml.sxw.SxwPluginFactory; * @author Mark Murnane * @version 1.1 */ -public final class PluginFactoryImpl extends SxwPluginFactory +public final class PluginFactoryImpl extends SxwPluginFactory implements DocumentDeserializerFactory, DocumentSerializerFactory, - DocumentMergerFactory{ + DocumentMergerFactory{ /** * <p>Constructor that caches the <code>ConvertInfo</code> that @@ -65,15 +65,15 @@ public final class PluginFactoryImpl extends SxwPluginFactory public PluginFactoryImpl (ConverterInfo ci) { super(ci); } - + /** ConverterCapabilities object for this type of conversion. */ private final static ConverterCapabilities converterCap = new ConverterCapabilitiesImpl(); - + /** - * <p>The <code>DocumentSerializer</code> is used to convert - * from the OpenOffice Writer <code>Document</code> format + * <p>The <code>DocumentSerializer</code> is used to convert + * from the OpenOffice Writer <code>Document</code> format * to the Pocket Word <code>Document</code> format.</p> * * <p>The <code>ConvertData</code> object is passed along to the @@ -87,11 +87,11 @@ public final class PluginFactoryImpl extends SxwPluginFactory * as input. * * @return A <code>DocumentSerializer</code> object. - */ + */ public DocumentSerializer createDocumentSerializer(Document doc) { return new DocumentSerializerImpl(doc); } - + /** * The <code>DocumentDeserializer</code> is used to convert @@ -114,12 +114,12 @@ public final class PluginFactoryImpl extends SxwPluginFactory public DocumentDeserializer createDocumentDeserializer(ConvertData cd) { return new DocumentDeserializerImpl(cd); } - - + + /** * <p>Create a <code>Document</code> object that corresponds to * the Pocket Word data passed in via the <code>InputStream</code> - * object. + * object. * * <p>This method will read from the given <code>InputStream</code> * object. The returned <code>Document</code> object will contain @@ -129,7 +129,7 @@ public final class PluginFactoryImpl extends SxwPluginFactory * <code>DocumentMerger</code> object.</p> * * @param name The <code>Document</code> name. - * @param is <code>InputStream</code> object corresponding + * @param is <code>InputStream</code> object corresponding * to the <code>Document</code>. * * @return A <code>Document</code> object representing the @@ -138,12 +138,12 @@ public final class PluginFactoryImpl extends SxwPluginFactory * @throws IOException If any I/O error occurs. */ - public Document createDeviceDocument(String name, InputStream is) + public Document createDeviceDocument(String name, InputStream is) throws IOException { PocketWordDocument pwd = new PocketWordDocument(name); pwd.read(is); return pwd; - } + } /** * Returns an instance of <code>DocumentMergerImpl</code>, @@ -154,7 +154,7 @@ public final class PluginFactoryImpl extends SxwPluginFactory * * @return A DocumentMergerImpl object. */ - public DocumentMerger createDocumentMerger(Document doc) { + public DocumentMerger createDocumentMerger(Document doc) { ConverterCapabilities cc = converterCap; DocumentMergerImpl merger = new DocumentMergerImpl(doc, cc); return merger; diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordConstants.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordConstants.java index edc45f93e750..207627398ca1 100644 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordConstants.java +++ b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordConstants.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -37,58 +37,58 @@ package org.openoffice.xmerge.converter.xml.sxw.pocketword; public interface PocketWordConstants { /** File extension for Pocket Word files. */ public static final String FILE_EXTENSION = ".psw"; - + /** Name of the default style. */ public static final String DEFAULT_STYLE = "Standard"; - + /** Family name for Paragraph styles. */ public static final String PARAGRAPH_STYLE_FAMILY = "paragraph"; - + /** Family name for Text styles. */ public static final String TEXT_STYLE_FAMILY = "text"; - - - /** - * Generic Pocket Word formatting code. + + + /** + * Generic Pocket Word formatting code. * * Formatting codes are 0xEz, where z indicates the specific format code. */ public static final byte FORMATTING_TAG = (byte)0xE0; - + /** Font specification tag. The two bytes following inidicate which font. */ public static final byte FONT_TAG = (byte)0xE5; - + /** Font size tag. The two bytes following specify font size in points. */ public static final byte FONT_SIZE_TAG = (byte)0xE6; - + /** Colour tag. Two bytes following index a 4-bit colour table. */ public static final byte COLOUR_TAG = (byte)0xE7; - + /** Font weight tag. Two bytes following indicate weighting of font. */ public static final byte FONT_WEIGHT_TAG = (byte)0xE8; - + /** Normal font weight value. */ public static final byte FONT_WEIGHT_NORMAL = (byte)0x04; - + /** Fine font weight value. */ public static final byte FONT_WEIGHT_FINE = (byte)0x01; - + /** Bold font weight value. */ public static final byte FONT_WEIGHT_BOLD = (byte)0x07; - + /** Thick font weight value. */ public static final byte FONT_WEIGHT_THICK = (byte)0x09; /** Italic tag. Single byte following indicates whether italic is on. */ public static final byte ITALIC_TAG = (byte)0xE9; - + /** Underline tag. Single byte following indicates whether underline is on. */ public static final byte UNDERLINE_TAG = (byte)0xEA; - + /** Strikethrough tag. Single byte following indicates whether strikethrough is on. */ public static final byte STRIKETHROUGH_TAG = (byte)0XEB; - + /** Highlighting tag. Single byte following indicates whether highlighting is on. */ public static final byte HIGHLIGHT_TAG = (byte)0xEC; - + } diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordDocument.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordDocument.java index ee2dc901d249..bc77e0fa6988 100644 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordDocument.java +++ b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordDocument.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -45,7 +45,7 @@ import java.util.Vector; * <p>Class representing a Pocket Word Document.</p> * * <p><code>PocketWordDocument</code> is used to create new Pocket Word documents - * and to read existing data to allow for conversion to OpenOffice Writer + * and to read existing data to allow for conversion to OpenOffice Writer * format.</p> * * @author Mark Murnane @@ -53,15 +53,15 @@ import java.util.Vector; */ public class PocketWordDocument implements Document, PocketWordConstants { private String docName; - + private byte[] preamble; private Vector fonts; private DocumentDescriptor descriptor; private Vector paragraphs; - + private ParaStyle pStyle; private Paragraph currentPara; - + /* * The trailer currently appears to be constant, but if its found to * have a variable component, then this initialisation should be moved @@ -70,70 +70,70 @@ public class PocketWordDocument implements Document, PocketWordConstants { * Padding is sometimes needed before the trailer to ensure the file * ends on a 4-byte boundary, but this is handled in write(). */ - private static final byte[] trailer = new byte[] { (byte)0x82, 0x00, - 0x09, 0x00, - 0x03, 0x00, - (byte)0x82, 0x00, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, + private static final byte[] trailer = new byte[] { (byte)0x82, 0x00, + 0x09, 0x00, + 0x03, 0x00, + (byte)0x82, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - + /** * <p>Constructs a new Pocket Word Document.</p> * - * <p>This new document does notcontain any information. Document data must - * either be added using appropriate methods, or an existing file can be + * <p>This new document does notcontain any information. Document data must + * either be added using appropriate methods, or an existing file can be * {@link #read(InputStream) read} from an <code>InputStream</code>.</p> * * @param name The name of the <code>PocketWordDocument</code>. */ public PocketWordDocument(String name) { - + docName = trimDocumentName(name); - + preamble = new byte[52]; fonts = new Vector(0, 1); descriptor = new DocumentDescriptor(); paragraphs = new Vector(0, 1); } - - + + /** - * <p>This method reads <code>byte</code> data from the InputStream and + * <p>This method reads <code>byte</code> data from the InputStream and * extracts font and paragraph data from the file.</p> - * + * * @param is InputStream containing a Pocket Word data file. * * @throws IOException In case of any I/O errors. */ public void read(InputStream docData) throws IOException { - + if (docData == null) { throw new IOException ("No input stream to convert"); } - + // The preamble may become important for font declarations. int readValue = docData.read(preamble); - // #i33702# check for an empty InputStream. + // #i33702# check for an empty InputStream. if(readValue == -1) { System.err.println("Error:invalid input stream"); return; } - + byte[] font = new byte[80]; int numfonts = 0; do { - docData.read(font); - + docData.read(font); + String name = new String(font, 0, 64, "UTF-16LE"); fonts.add(name.trim()); - - } while (!(font[76] == 5 && font[77] == 0 - && font[78] == 1 && font[79] == 0)); - + + } while (!(font[76] == 5 && font[77] == 0 + && font[78] == 1 && font[79] == 0)); + /* * TODO: The document descriptor data that follows the fonts ends with * a variable section containing data for each of the paragraphs. @@ -141,27 +141,27 @@ public class PocketWordDocument implements Document, PocketWordConstants { * positions for each paragraph rather than iterating through the * entire byte stream. */ - + int value; ByteArrayOutputStream bos = new ByteArrayOutputStream(); while ((value = docData.read()) != -1) { bos.write(value); } - + byte[] contentData = bos.toByteArray(); int start = 0, end = 0; boolean sawMarker = false; - + for (int i = 0; i < contentData.length; i += 4) { - if (contentData[i + 2] == (byte)0xFF + if (contentData[i + 2] == (byte)0xFF && contentData[i + 3] == (byte)0xFF && !sawMarker) { start = i - 8; sawMarker = true; continue; } - - if (contentData[i + 2] == (byte)0xFF + + if (contentData[i + 2] == (byte)0xFF && contentData[i + 3] == (byte)0xFF && sawMarker) { end = i - 8; ByteArrayOutputStream paragraph = new ByteArrayOutputStream(); @@ -172,9 +172,9 @@ public class PocketWordDocument implements Document, PocketWordConstants { sawMarker = false; i -= 4; // Skip back } - + } - + /* * Special case, the last paragraph * If we got here, and the marker is set then we saw the start of the @@ -189,15 +189,15 @@ public class PocketWordDocument implements Document, PocketWordConstants { } paragraphs.add(new Paragraph(paragraph.toByteArray())); } - - + + /* * Utility method to make sure the document name is stripped of any file * extensions before use. */ private String trimDocumentName(String name) { String temp = name.toLowerCase(); - + if (temp.endsWith(FILE_EXTENSION)) { // strip the extension int nlen = name.length(); @@ -207,10 +207,10 @@ public class PocketWordDocument implements Document, PocketWordConstants { return name; } - - + + /** - * <p>Method to provide access to all of the <code>Paragraph</code> objects + * <p>Method to provide access to all of the <code>Paragraph</code> objects * in the <code>Document</code>.</p> * * @return <code>Enumeration</code> over the paragraphs in the document. @@ -218,8 +218,8 @@ public class PocketWordDocument implements Document, PocketWordConstants { public Enumeration getParagraphEnumeration() { return paragraphs.elements(); } - - + + /** * <p>Returns the <code>Document</code> name with no file extension.</p> * @@ -228,8 +228,8 @@ public class PocketWordDocument implements Document, PocketWordConstants { public String getName() { return docName; } - - + + /** * <p>Returns the <code>Document</code> name with file extension.</p> * @@ -238,8 +238,8 @@ public class PocketWordDocument implements Document, PocketWordConstants { public String getFileName() { return new String(docName + FILE_EXTENSION); } - - + + /** * <p>Writes out the <code>Document</code> content to the specified * <code>OutputStream</code>.</p> @@ -256,54 +256,54 @@ public class PocketWordDocument implements Document, PocketWordConstants { */ public void write(OutputStream os) throws IOException { DataOutputStream dos = new DataOutputStream(os); - + initPreamble(); dos.write(preamble); - + loadFonts(); for (int i = 0; i < fonts.size(); i++ ) { ByteArrayOutputStream fontData = (ByteArrayOutputStream)fonts.elementAt(i); dos.write(fontData.toByteArray()); } - - + + for (int i = 0; i < paragraphs.size(); i++) { Paragraph para = (Paragraph)paragraphs.elementAt(i); descriptor.addParagraph((short)para.getTextLength(), para.getLines()); } dos.write(descriptor.getDescriptor()); - + for (int i = 0; i < paragraphs.size(); i++ ) { Paragraph para = (Paragraph)paragraphs.elementAt(i); - + // Last paragraph has some extra data if (i + 1 == paragraphs.size()) { para.setLastParagraph(true); } dos.write(para.getParagraphData()); } - - + + /* - * Before we write out the trailer, we need to make sure that it will + * Before we write out the trailer, we need to make sure that it will * lead to the file ending on a 4 byte boundary. */ if (dos.size() % 4 == 0) { dos.write((byte)0x00); dos.write((byte)0x00); } - + dos.write(trailer); - + dos.flush(); dos.close(); } - - + + /** - * <p>This method adds a new paragraph element to the document. No string + * <p>This method adds a new paragraph element to the document. No string * data is added to the paragraph.</p> - * + * * <p><b>N.B.</b> The newly added paragraph becomes the current paragraph and * is used as the target for all subsequent calls to addParagraphData().</p> * @@ -313,25 +313,25 @@ public class PocketWordDocument implements Document, PocketWordConstants { * false otherwise. */ public void addParagraph(ParaStyle style, boolean listElement) { - /* For the moment, only support basic text entry in a single paragraph */ + /* For the moment, only support basic text entry in a single paragraph */ Paragraph para = new Paragraph(style); - + paragraphs.add(para); - + pStyle = style; currentPara = para; - + if (listElement) { para.setBullets(true); } } - - + + /** * <p>This method adds text to the current paragraph.</p> - * + * * <p>If no paragraphs exist within the document, it creates one.</p> - * + * * @param data The string data for this segment. * @param style Text Style object describing the formatting of this * segment. Can be null. @@ -342,10 +342,10 @@ public class PocketWordDocument implements Document, PocketWordConstants { } currentPara.addTextSegment(data, style); } - - - /* - * Preamble is the portion before font specification which never + + + /* + * Preamble is the portion before font specification which never * seems to change from one file, or one saved version, to the next. * * Bytes 18h and 19h seem to contain the number of fonts and should @@ -361,11 +361,11 @@ public class PocketWordDocument implements Document, PocketWordConstants { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; } - - + + /* * This method writes the minimum font data that is used by the converter. - * Currently, all documents convert to 10 point Courier New. Tahoma is + * Currently, all documents convert to 10 point Courier New. Tahoma is * always mentioned in Pocket Word files, however, even if it is not used. * * TODO: Rewrite to allow for multiple fonts once font support issues @@ -373,7 +373,7 @@ public class PocketWordDocument implements Document, PocketWordConstants { */ private void loadFonts() { ByteArrayOutputStream fontData = new ByteArrayOutputStream(); - + try { fontData.write(new String("Tahoma").getBytes("UTF-16LE")); fontData.write(new byte[52]); // Rest of font name? @@ -381,24 +381,24 @@ public class PocketWordDocument implements Document, PocketWordConstants { fontData.write(new byte[] { 0x00, 0x00, 0x01, 0x00 } ); fontData.write(new byte[] { 0x00, 0x00, 0x00, 0x00 } ); fontData.write(new byte[] { 0x00, 0x00, 0x00, 0x00 } ); - + fonts.add(fontData); - + fontData = new ByteArrayOutputStream(); - + fontData.write(new String("Courier New").getBytes("UTF-16LE")); fontData.write(new byte[42]); fontData.write(new byte[] { 0x14, 0x00, 0x04, 0x00 } ); fontData.write(new byte[] { 0x01, 0x00, 0x00, 0x00 } ); fontData.write(new byte[] { 0x00, 0x00, 0x15, 0x00 } ); - + // Next part indicates that this is the last font fontData.write(new byte[] { 0x05, 0x00, 0x01, 0x00 } ); - + fonts.add(fontData); } catch (IOException ioe) { - // Shouldn't happen as this is a memory based stream + // Shouldn't happen as this is a memory based stream } } } diff --git a/xmerge/source/regutil/regutil.cpp b/xmerge/source/regutil/regutil.cpp index 188454df7568..3703192d79b5 100644 --- a/xmerge/source/regutil/regutil.cpp +++ b/xmerge/source/regutil/regutil.cpp @@ -23,12 +23,12 @@ int main(int argc, char* argv[]) return -1; } - + if (argc == 3) { if (strcmp("/u", argv[1])) { - printf("\nUnrecognised option: %s\n", argv[1]); + printf("\nUnrecognised option: %s\n", argv[1]); return -1; } @@ -36,34 +36,34 @@ int main(int argc, char* argv[]) nPathIndex = 2; } - + // Dynamically load the library HMODULE hmXMDll = LoadLibrary(argv[nPathIndex]); - if (hmXMDll == NULL) + if (hmXMDll == NULL) { printf("\nUnable to load the library %s\n", argv[nPathIndex]); return -1; } - + // Get an offset to the either the DllRegisterServer or DllUnregisterServer functions - if (!bUninstall) + if (!bUninstall) { printf("\nRegistering %s ... ", argv[nPathIndex]); DLLREGISTERSERVER DllRegisterServer = (DLLREGISTERSERVER)GetProcAddress(hmXMDll, "DllRegisterServer"); - + if (DllRegisterServer == NULL) { printf("failed.\n\nDllRegisterServer is not present in library.\n"); return -1; - } + } // Now call the procedure ... HRESULT regResult = DllRegisterServer() ; - if (regResult != S_OK) + if (regResult != S_OK) { printf("failed.\n"); return -1; @@ -79,12 +79,12 @@ int main(int argc, char* argv[]) { printf("failed.\n\nDllUnregisterServer is not present in library.\n"); return -1; - } + } // Now call the procedure ... HRESULT regResult = DllUnregisterServer() ; - if (regResult != S_OK) + if (regResult != S_OK) { printf("failed.\n"); return -1; @@ -97,6 +97,6 @@ int main(int argc, char* argv[]) // Clean up FreeLibrary(hmXMDll); - + return 0; }
\ No newline at end of file diff --git a/xmerge/source/wordsmith/build.xml b/xmerge/source/wordsmith/build.xml index 197f569699e6..9a0c1aef7563 100644 --- a/xmerge/source/wordsmith/build.xml +++ b/xmerge/source/wordsmith/build.xml @@ -3,23 +3,23 @@ #************************************************************************* # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - + Copyright 2000, 2010 Oracle and/or its affiliates. - + OpenOffice.org - a multi-platform office productivity suite - + This file is part of OpenOffice.org. - + OpenOffice.org is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. - + OpenOffice.org is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details (a copy is included in the LICENSE file that accompanied this code). - + You should have received a copy of the GNU Lesser General Public License version 3 along with OpenOffice.org. If not, see <http://www.openoffice.org/license.html> @@ -27,11 +27,11 @@ #************************************************************************* --> - + <project name="wordsmith" default="all" basedir="."> <property file="../inc/antbuild.properties"/> - + <path id="classpath"> <pathelement location="${build.dir}/xmerge.jar"/> </path> @@ -51,7 +51,7 @@ <classpath refid="classpath"/> </javac> </target> - + <!-- package to jar --> <target name="jar" depends="compile"> <jar destfile="${target.jar}"> @@ -68,9 +68,9 @@ <delete dir="${class.dir}"/> <delete file="${target.jar}"/> </target> - + <target name="all" depends="jar"> </target> - + </project> diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/ConverterCapabilitiesImpl.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/ConverterCapabilitiesImpl.java index 05d680e3086e..11e264a07cfb 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/ConverterCapabilitiesImpl.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/ConverterCapabilitiesImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DOCConstants.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DOCConstants.java index b571d5e75e8b..415392933c2c 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DOCConstants.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DOCConstants.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentDeserializerImpl.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentDeserializerImpl.java index 0442a4844285..29098b72cc17 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentDeserializerImpl.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentDeserializerImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentMergerImpl.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentMergerImpl.java index f0fb3b92687e..b338c9adb6ff 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentMergerImpl.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentMergerImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentSerializerImpl.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentSerializerImpl.java index 6adbfd7280ab..bca91fa53415 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentSerializerImpl.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentSerializerImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -112,7 +112,7 @@ implements OfficeConstants, DocumentSerializer { * @param doc Input should be an XML <code>Document</code> * object * @param os Output of <code>PalmDB</code> object - * + * * @throws ConvertException If any conversion error occurs. * @throws IOException If any I/O error occurs. */ diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/PluginFactoryImpl.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/PluginFactoryImpl.java index aeb1f8d97806..d7e84d69f34c 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/PluginFactoryImpl.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/PluginFactoryImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -71,7 +71,7 @@ import java.io.IOException; * * @author Herbie Ong, Dave Proulx */ -public final class PluginFactoryImpl extends SxwPluginFactory +public final class PluginFactoryImpl extends SxwPluginFactory implements DocumentDeserializerFactory, DocumentSerializerFactory, DocumentMergerFactory { @@ -103,7 +103,7 @@ public final class PluginFactoryImpl extends SxwPluginFactory * which is an implementation of <code>DocumentDeserializer</code> * interface. * - * @param cd <code>ConvertData</code> object for reading data + * @param cd <code>ConvertData</code> object for reading data * which will be converted back to a * <code>Document</code> object. * @@ -131,14 +131,14 @@ public final class PluginFactoryImpl extends SxwPluginFactory } /** - * Returns an instance of the DeviceDocument + * Returns an instance of the DeviceDocument * which is an implementation of the <code>DocumentMerger</code> * interface. * * @param doc <code>Document</code> to merge. * * @return A Device Document object - */ + */ public Document createDeviceDocument(String name, InputStream is) throws IOException { diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSDecoder.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSDecoder.java index dff7c2a105cb..5ac9bc01c725 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSDecoder.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSDecoder.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -132,7 +132,7 @@ final class WSDecoder implements DOCConstants { java.util.Vector v = new java.util.Vector(20, 20); WseFontTable fontTable = null; WseColorTable colorTable = null; - + // rawData is the document data to be parsed. byte rawData[] = parseRecords(recs); @@ -147,7 +147,7 @@ final class WSDecoder implements DOCConstants { int nChars = util.intFrom4bytes(rawData, 10); int miscSize = util.intFrom4bytes(rawData, 14); int curIndex = 18; - + while (curIndex < rawData.length) { if (WsePara.isValid(rawData, curIndex)) { v.add(new WsePara(rawData, curIndex)); diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSEncoder.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSEncoder.java index bbab2c76a2d9..15cf4ed36544 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSEncoder.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSEncoder.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -120,12 +120,12 @@ final class WSEncoder { Vector allRecs = new Vector(); int nElements = elements.size(); - + // Count up the number of paragraphs, atoms, and characters. int currElement = 0; while (currElement < nElements) { Wse e = (Wse)elements.elementAt(currElement++); - if (e.getClass() == WsePara.class) + if (e.getClass() == WsePara.class) nrParagraphs++; if (e.getClass() == WseTextRun.class) { nrAtoms++; @@ -144,12 +144,12 @@ final class WSEncoder { currRecLen += header.getByteCount(); if (ft != null) { - System.arraycopy(ft.getBytes(), 0, currRec, currRecLen, + System.arraycopy(ft.getBytes(), 0, currRec, currRecLen, ft.getByteCount()); currRecLen += ft.getByteCount(); } if (ct != null) { - System.arraycopy(ct.getBytes(), 0, currRec, currRecLen, + System.arraycopy(ct.getBytes(), 0, currRec, currRecLen, ct.getByteCount()); currRecLen += ct.getByteCount(); } @@ -162,10 +162,10 @@ final class WSEncoder { System.arraycopy(e.getBytes(), 0, currRec, currRecLen, length); currRecLen += length; } else { - // Copy in enough to get to full size, then create a + // Copy in enough to get to full size, then create a // new Record and add it to the Vector. int firstPartLen = 4096 - currRecLen; - System.arraycopy(e.getBytes(), 0, currRec, currRecLen, + System.arraycopy(e.getBytes(), 0, currRec, currRecLen, firstPartLen); Record r = new Record(currRec); allRecs.addElement(r); @@ -188,7 +188,7 @@ final class WSEncoder { // Record 0 is the WordSmith header. Do it last since it - // contains totals for the entire document. It goes + // contains totals for the entire document. It goes // before everything else. ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/Wse.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/Wse.java index 2a45df280cdd..4f1a7141f348 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/Wse.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/Wse.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -48,7 +48,7 @@ import org.openoffice.xmerge.converter.xml.*; * @author David Proulx */ abstract class Wse { - + /** * Return true if <code>dataArray[startIndex]</code> is the start * of a valid element of this type. @@ -63,7 +63,7 @@ abstract class Wse { return false; } - + /** * Compute and return the index of the first <code>byte</code> * following this element. It is assumed that the element @@ -88,7 +88,7 @@ abstract class Wse { * object. */ abstract int getByteCount(); - + /** * Return an <code>byte</code> array representing this element. diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseColorTable.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseColorTable.java index ec4d6bf57f67..bbb22952a24a 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseColorTable.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseColorTable.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -76,18 +76,18 @@ class WseColorTable extends Wse { i += 2; // Skip leading "64" and table length field. for (int k = 0; k < 16; k++) { - fgColors[k] = new Color(((int)dataArray[i+1]) & 0xFF, - ((int)dataArray[i+2]) & 0xFF, + fgColors[k] = new Color(((int)dataArray[i+1]) & 0xFF, + ((int)dataArray[i+2]) & 0xFF, ((int)dataArray[i+3]) & 0xFF); i += 4; } for (int k = 0; k < 16; k++) { - bgColors[k] = new Color(((int)dataArray[i+1]) & 0xFF, - ((int)dataArray[i+2]) & 0xFF, + bgColors[k] = new Color(((int)dataArray[i+1]) & 0xFF, + ((int)dataArray[i+2]) & 0xFF, ((int)dataArray[i+3]) & 0xFF); i += 4; } - + } @@ -111,7 +111,7 @@ class WseColorTable extends Wse { /** - * Return true if <code>dataArray[startIndex]</code> is the start + * Return true if <code>dataArray[startIndex]</code> is the start * of a valid paragraph descriptor. * * @param dataArray <code>byte</code> array. @@ -122,7 +122,7 @@ class WseColorTable extends Wse { */ static boolean isValid(byte dataArray[], int startIndex) { try { - if (dataArray[startIndex] != 64) + if (dataArray[startIndex] != 64) return false; int len = dataArray[startIndex + 1]; len &= 0xFF; // eliminate problems with sign-extension @@ -188,12 +188,12 @@ class WseColorTable extends Wse { /** - * Return the index of the specified foreground or background + * Return the index of the specified foreground or background * <code>Color</code>. (If the color is not already in the table, * it will be added.) * * Note that the implementation of this may include a "margin of - * error" to prevent the color table from being filled up too + * error" to prevent the color table from being filled up too * quickly. * * @param c The <code>Color</code>. @@ -207,14 +207,14 @@ class WseColorTable extends Wse { */ int findColor(Color c, boolean foreground) { - Color colorArray[] = foreground ? fgColors : bgColors; + Color colorArray[] = foreground ? fgColors : bgColors; for (int i = 0; i < 16; i++) { if (colorArray[i] != null) { - if (colorArray[i].equals(c)) + if (colorArray[i].equals(c)) return i; } - else + else break; // hit a null entry - no more colors in table! } @@ -235,12 +235,12 @@ class WseColorTable extends Wse { * @param index The index * @param foreground true if foreground color, false if background * color - * + * * @return The <code>Color</code> at the specified index. */ Color getColor(int index, boolean foreground) { - Color colorArray[] = foreground ? fgColors : bgColors; + Color colorArray[] = foreground ? fgColors : bgColors; return colorArray[index]; } } diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseFontTable.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseFontTable.java index a751a93e10d0..d7bc6edd8bc2 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseFontTable.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseFontTable.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -120,7 +120,7 @@ class WseFontTable extends Wse { int len = fontNames.size(); for (int i = 0; i < len; i++) { String name = (String) fontNames.elementAt(i); - if (name.equals(fontName)) + if (name.equals(fontName)) return i; } return -1; @@ -159,13 +159,13 @@ class WseFontTable extends Wse { */ static boolean isValid(byte dataArray[], int startIndex) { try { - if (dataArray[startIndex] != 3) + if (dataArray[startIndex] != 3) return false; int len = ((dataArray[startIndex+1] << 8) | (dataArray[startIndex+2] & 0xFF)); len &= 0xFFFF; // eliminate problems with sign-extension - - if (dataArray[startIndex + len + 2] != 0) + + if (dataArray[startIndex + len + 2] != 0) return false; } catch (ArrayIndexOutOfBoundsException e) { return false; @@ -187,7 +187,7 @@ class WseFontTable extends Wse { String name = (String)fontNames.elementAt(i); length += name.length() + 1; // extra byte is for trailing "0" } - return length; + return length; } /** @@ -196,7 +196,7 @@ class WseFontTable extends Wse { * @return An <code>byte</code> array representing this font table. */ byte[] getBytes() { - + int length = getByteCount(); int nFonts = fontNames.size(); byte b[] = new byte[length]; diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseHeader.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseHeader.java index 7c59a3abe6e7..c80e03eca043 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseHeader.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseHeader.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -71,7 +71,7 @@ class WseHeader extends Wse { public WseHeader(byte dataArray[], int i) { // DJP: write this! } - + /** * Return true if <code>dataArray[startIndex]</code> is the start * of a document header. @@ -83,19 +83,19 @@ class WseHeader extends Wse { * of a document header, false otherwise. */ static boolean isValid(byte dataArray[], int startIndex) { - return ((dataArray[startIndex] == 2) + return ((dataArray[startIndex] == 2) && (dataArray[startIndex + 1] == 4)); } - + /** * Compute and return the index of the first <code>byte</code> * following this element. It is assumed that the element * starting at <code>dataArray[startIndex]</code> is valid. - * + * * @param dataArray <code>byte</code> array. * @param startIndex The start index. - * + * * @return The first <code>byte</code> following this element. */ static int computeNewIndex(byte dataArray[], int startIndex) { @@ -112,7 +112,7 @@ class WseHeader extends Wse { return 18; } - + /** * Return a <code>byte</code> array representing this element. * @@ -133,8 +133,8 @@ class WseHeader extends Wse { os.writeInt(nChars); os.writeInt(miscSize); - } catch (IOException e) { - e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); } if (bs != null) { diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WsePara.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WsePara.java index 6d0e3cde4745..36b21e21b931 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WsePara.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WsePara.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -59,19 +59,19 @@ class WsePara extends Wse { private byte lineSpace = 0; private byte outline = 0; private byte reserved = 0; - + private static final byte LS_EXACTLY = (byte)0xC0; private static final byte LS_ATLEAST = (byte)0x80; private static final byte LS_MULTIPLE = (byte)0x40; private static final byte LS_VALUEMASK = (byte)0x3F; - + private static final byte ALIGN_RIGHT = (byte)2; private static final byte ALIGN_LEFT = (byte)0; private static final byte ALIGN_CENTER = (byte)1; private static final byte ALIGN_JUST = (byte)3; private StyleCatalog sc = null; - + /** * Constructor for use when going from DOM to WordSmith. @@ -127,7 +127,7 @@ class WsePara extends Wse { if (ps.isAttributeSet(ParaStyle.TEXT_ALIGN)) { int val = ps.getAttribute(ParaStyle.TEXT_ALIGN); - + switch (val) { case ParaStyle.ALIGN_RIGHT: misc = ALIGN_RIGHT; @@ -143,9 +143,9 @@ class WsePara extends Wse { break; } } - + } - + /** * Constructor for use when going from WordSmith to DOM. @@ -166,8 +166,8 @@ class WsePara extends Wse { lineSpace = dataArray[startIndex + 8]; outline = dataArray[startIndex + 9]; } - - + + /** * Compute the index of the first <code>byte</code> following the * paragraph descriptor, assuming that @@ -183,8 +183,8 @@ class WsePara extends Wse { static int computeNewIndex(byte dataArray[], int startIndex) { return startIndex + 13; } - - + + /** * Return true if <code>dataArray[startIndex]</code> is the start * of a valid paragraph descriptor. @@ -206,8 +206,8 @@ class WsePara extends Wse { */ int getByteCount() { return 13; - } - + } + /** * Return an <code>byte</code> array representing this paragraph. * @@ -215,7 +215,7 @@ class WsePara extends Wse { */ byte[] getBytes() { byte b[] = new byte[13]; - + b[0] = 5; b[1] = spaceBefore; b[2] = spaceAfter; @@ -229,10 +229,10 @@ class WsePara extends Wse { b[10] = reserved; b[11] = 0; b[12] = 0; - + return b; } - + /** * Return a <code>ParaStyle</code> that reflects the formatting of * this run. @@ -241,26 +241,26 @@ class WsePara extends Wse { * of this run. */ ParaStyle makeStyle() { - /* Csaba: Commented out the LINE_HEIGHT syle, because there was no + /* Csaba: Commented out the LINE_HEIGHT syle, because there was no incoming data for that style. It was resulting a zero line height in the xml document, ie. the doc looked empty. */ - int attrs[] = { ParaStyle.MARGIN_LEFT, ParaStyle.MARGIN_RIGHT, + int attrs[] = { ParaStyle.MARGIN_LEFT, ParaStyle.MARGIN_RIGHT, ParaStyle.TEXT_INDENT, //ParaStyle.LINE_HEIGHT, ParaStyle.MARGIN_TOP, ParaStyle.MARGIN_BOTTOM, ParaStyle.TEXT_ALIGN }; String values[] = new String[attrs.length]; double temp; - + temp = leftIndent / 1.6; values[0] = (new Double(temp)).toString() + "mm"; - + temp = rightIndent / 1.6; values[1] = (new Double(temp)).toString() + "mm"; temp = firstIndent / 1.6; values[2] = (new Double(temp)).toString() + "mm"; - + /* if ((lineSpace & LS_MULTIPLE) != 0) { temp = (lineSpace & LS_VALUEMASK) / 2; temp *= 100; @@ -269,11 +269,11 @@ class WsePara extends Wse { values[3] = (new Double(temp)).toString() + "mm"; // DJP: handle other cases } -*/ +*/ temp = spaceBefore / 1.6; // values[4] = (new Double(temp)).toString() + "mm"; values[3] = (new Double(temp)).toString() + "mm"; - + temp = spaceAfter / 1.6; // values[5] = (new Double(temp)).toString() + "mm"; values[4] = (new Double(temp)).toString() + "mm"; @@ -290,9 +290,9 @@ class WsePara extends Wse { case ALIGN_CENTER:values[5] = "center"; break; case ALIGN_JUST: values[5] = "justified"; break; } - ParaStyle x = new ParaStyle(null, "paragraph", null, attrs, + ParaStyle x = new ParaStyle(null, "paragraph", null, attrs, values, sc); - + return x; } } diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseTextRun.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseTextRun.java index 9e58ab11e420..7a4bb325e051 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseTextRun.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseTextRun.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -57,16 +57,16 @@ import java.awt.Color; * @author David Proulx */ class WseTextRun extends Wse { - + /** Font specifier. This is an index into the font table. */ private byte fontIndex = 0; private String fontName = null; - + /** Size of the font. */ private byte fontSize = 0; - - /** - * Color of the font. This is an index into the color table. + + /** + * Color of the font. This is an index into the color table. * High nibble is background color index, low nibble is font color * index. */ @@ -76,8 +76,8 @@ class WseTextRun extends Wse { * Reference to color table for color lookups. */ private WseColorTable ct; - - /** + + /** * The modifiers for the text run. (Mostly) Bitwise flags. The "_TOKEN" * values are not yet implemented in this converter. They may not even * be implemented in WordSmith yet. @@ -95,7 +95,7 @@ class WseTextRun extends Wse { final public static int BOOKMARK_TOKEN = 0x81; final public static int ANNOTATION_TOKEN = 0x82; final public static int LINK_TOKEN = 0x83; - + /** The actual text. */ private String text; @@ -111,7 +111,7 @@ class WseTextRun extends Wse { * @param ft The font table. * @param ct The color Table. */ - public WseTextRun(String txt, TextStyle t, StyleCatalog sc, + public WseTextRun(String txt, TextStyle t, StyleCatalog sc, WseFontTable ft, WseColorTable ct) { this.sc = sc; @@ -119,17 +119,17 @@ class WseTextRun extends Wse { TextStyle ts = (TextStyle)t.getResolved(); - if (ts.isSet(TextStyle.BOLD) && ts.getAttribute(TextStyle.BOLD)) + if (ts.isSet(TextStyle.BOLD) && ts.getAttribute(TextStyle.BOLD)) modifiers |= BOLD; - if (ts.isSet(TextStyle.ITALIC) && ts.getAttribute(TextStyle.ITALIC)) + if (ts.isSet(TextStyle.ITALIC) && ts.getAttribute(TextStyle.ITALIC)) modifiers |= ITALIC; - if (ts.isSet(TextStyle.UNDERLINE) && ts.getAttribute(TextStyle.UNDERLINE)) + if (ts.isSet(TextStyle.UNDERLINE) && ts.getAttribute(TextStyle.UNDERLINE)) modifiers |= UNDERLINE; - if (ts.isSet(TextStyle.STRIKETHRU) && ts.getAttribute(TextStyle.STRIKETHRU)) + if (ts.isSet(TextStyle.STRIKETHRU) && ts.getAttribute(TextStyle.STRIKETHRU)) modifiers |= STRIKETHRU; - if (ts.isSet(TextStyle.SUPERSCRIPT) && ts.getAttribute(TextStyle.SUPERSCRIPT)) + if (ts.isSet(TextStyle.SUPERSCRIPT) && ts.getAttribute(TextStyle.SUPERSCRIPT)) modifiers |= SUPERSCRIPT; - if (ts.isSet(TextStyle.SUBSCRIPT) && ts.getAttribute(TextStyle.SUBSCRIPT)) + if (ts.isSet(TextStyle.SUBSCRIPT) && ts.getAttribute(TextStyle.SUBSCRIPT)) modifiers |= SUBSCRIPT; fontSize = (byte)(ts.getFontSize() * 2); @@ -140,52 +140,52 @@ class WseTextRun extends Wse { fontIndex = (byte)ft.getFontIndex(fontName); } - // Figure out the color index. + // Figure out the color index. Color c = t.getFontColor(); - if (c == null) + if (c == null) c = Color.black; colorIndex = (byte)ct.findColor(c, true); c = t.getBackgroundColor(); if (c == null) c = Color.white; colorIndex |= (byte)(ct.findColor(c, false) << 4); - - text = txt; - } - - + + text = txt; + } + + /** * Standard constructor for use when going from WordSmith to DOM. - * + * * @param dataArray <code>byte</code> array. * @param startIndex The start index. * @param ft The font table. * @param ct The color table. */ - public WseTextRun(byte dataArray[], int startIndex, WseFontTable ft, + public WseTextRun(byte dataArray[], int startIndex, WseFontTable ft, WseColorTable ct) { - + this.ct = ct; startIndex++; // Skip the leading "1" - + int textLen = ((dataArray[startIndex] << 8) | (dataArray[startIndex+1] & 0xFF)); startIndex += 2; - + fontIndex = dataArray[startIndex++]; if (ft != null) fontName = ft.getFontName(fontIndex); - + fontSize = dataArray[startIndex++]; - + colorIndex = dataArray[startIndex++]; modifiers = dataArray[startIndex++]; - + text = new String(dataArray, startIndex, textLen); startIndex += textLen; // skip the text } - + /** * Given a <code>byte</code> sequence, assumed to be a text run, @@ -193,25 +193,25 @@ class WseTextRun extends Wse { * * @param dataArray <code>byte</code> array. * @param startIndex The start index - * + * * @return The index of the first <code>byte</code> past the * text run. */ public static int computeNewIndex(byte dataArray[], int startIndex) { - + startIndex++; // Skip the leading "1" - + int textLen = ((dataArray[startIndex] << 8) | (dataArray[startIndex+1] & 0xFF)); startIndex += 2; - + startIndex += 4; // skip attributes // text = new String(dataArray, startIndex, textLen); startIndex += textLen; // skip the text return startIndex; } - - + + /** * Return true if the sequence starting at * <code>dataArray[startIndex]</code> is a valid text run. @@ -234,8 +234,8 @@ class WseTextRun extends Wse { */ int getByteCount() { return text.length() + 7; - } - + } + /** * Return an <code>byte</code> array representing this text run. @@ -256,8 +256,8 @@ class WseTextRun extends Wse { System.arraycopy(txtBytes, 0, b, 7, textLen); return b; } - - + + /** * Return the text of this run. * @@ -266,8 +266,8 @@ class WseTextRun extends Wse { public String getText() { return text; } - - + + /** * Return a <code>TextStyle</code> that reflects the formatting * of this run. @@ -280,11 +280,11 @@ class WseTextRun extends Wse { if ((modifiers & BOLD) != 0) mod |= TextStyle.BOLD; if ((modifiers & ITALIC) != 0) mod |= TextStyle.ITALIC; if ((modifiers & UNDERLINE) != 0) mod |= TextStyle.UNDERLINE; - if ((modifiers & STRIKETHRU) != 0) + if ((modifiers & STRIKETHRU) != 0) mod |= TextStyle.STRIKETHRU; if ((modifiers & SUPERSCRIPT) != 0) mod |= TextStyle.SUPERSCRIPT; if ((modifiers & SUBSCRIPT) != 0) mod |= TextStyle.SUBSCRIPT; - + int mask = TextStyle.BOLD | TextStyle.ITALIC | TextStyle.UNDERLINE | TextStyle.STRIKETHRU | TextStyle.SUPERSCRIPT @@ -302,7 +302,7 @@ class WseTextRun extends Wse { return x; } - + /** * Display debug information. diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/textRecord.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/textRecord.java index 59a4271566b7..01276ce79a94 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/textRecord.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/textRecord.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -34,8 +34,8 @@ import java.io.ByteArrayOutputStream; /** * This class represents a single text record in a WordSmith document. - * A record is composed of one or more "WordSmith elements", which - * include: WordSmith header, font table, color table, paragraphs, + * A record is composed of one or more "WordSmith elements", which + * include: WordSmith header, font table, color table, paragraphs, * and text runs. * * @author David Proulx @@ -102,13 +102,13 @@ class textRecord { os.write(e.getBytes()); } - } catch (IOException e) { - e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); } if (bs != null) return bs.toByteArray(); - else + else return null; } } diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/util.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/util.java index 2f3cce84f769..9dcb178197da 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/util.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/util.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/build.xml b/xmerge/source/xmerge/build.xml index f3aa6ac0fa87..8c46b46ea747 100644 --- a/xmerge/source/xmerge/build.xml +++ b/xmerge/source/xmerge/build.xml @@ -3,23 +3,23 @@ #************************************************************************* # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - + Copyright 2000, 2010 Oracle and/or its affiliates. - + OpenOffice.org - a multi-platform office productivity suite - + This file is part of OpenOffice.org. - + OpenOffice.org is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. - + OpenOffice.org is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details (a copy is included in the LICENSE file that accompanied this code). - + You should have received a copy of the GNU Lesser General Public License version 3 along with OpenOffice.org. If not, see <http://www.openoffice.org/license.html> @@ -27,7 +27,7 @@ #************************************************************************* --> - + <project name="xmerge" default="all" basedir="."> <property file="../inc/antbuild.properties"/> @@ -35,7 +35,7 @@ <property environment="env"/> <property name="env.XML_APIS_JAR" value="${solar.jar}/xml-apis.jar"/> <property name="env.XERCES_JAR" value="${solar.jar}/xercesImpl.jar"/> - + <path id="classpath"> <pathelement location="${env.XML_APIS_JAR}"/> <pathelement location="${env.XERCES_JAR}"/> @@ -60,7 +60,7 @@ <classpath refid="classpath"/> </javac> </target> - + <!-- package to jar --> <target name="jar" depends="compile"> <jar destfile="${target.jar}"> @@ -84,9 +84,9 @@ <delete dir="${class.dir}"/> <delete file="${target.jar}"/> </target> - + <target name="all" depends="jar"> </target> - + </project> diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/Convert.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/Convert.java index cff2f193769b..59b6db6aa84c 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/Convert.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/Convert.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -83,7 +83,7 @@ public class Convert implements Cloneable { } - /** + /** * Adds an <code>InputStream</code> to be used as input by the * <code>Convert</code> class. It is possible that many files * need to be converted into a single output <code>Documetn</code>, @@ -97,7 +97,7 @@ public class Convert implements Cloneable { */ public void addInputStream(String name, InputStream is) throws IOException { - + Document inputDoc; if (toOffice == true) { @@ -108,7 +108,7 @@ public class Convert implements Cloneable { inputCD.addDocument(inputDoc); } - /** + /** * Adds an <code>InputStream</code> to be used as input by the * <code>Convert</code> class. It is possible that many files * need to be converted into a single output <code>Documetn</code>, @@ -123,7 +123,7 @@ public class Convert implements Cloneable { */ public void addInputStream(String name, InputStream is,boolean isZip) throws IOException { - + Document inputDoc; if (toOffice == true) { @@ -135,25 +135,25 @@ public class Convert implements Cloneable { } - /** + /** * Returns a <code>DocumentMerger</code> for the given <code>Document</code>. * * @param origDoc The <code>Document</code> were later changes will be merged to * * @return The <code>DocumentMerger</code> object for the given document. - * + * * @throws IOException If any I/O error occurs. */ public DocumentMerger getDocumentMerger(Document origDoc) throws IOException { - + DocumentMergerFactory myDocMergerFactory = ci.getDocMergerFactory(); DocumentMerger merger = myDocMergerFactory.createDocumentMerger(origDoc); return merger; - } + } - /** - * Resets the input queue, so that the user can use this class to + /** + * Resets the input queue, so that the user can use this class to * perform another conversion. This causes the * <code>addInputStream</code> method to accept input for the next * conversion. @@ -162,9 +162,9 @@ public class Convert implements Cloneable { inputCD.reset(); } - - /** - * Clones a Convert object so another Convert object can + + /** + * Clones a Convert object so another Convert object can * do the same conversion. <code>InputStream<code> objects passed * in via calls to the <code>addInputStream</code> method are not * copied. @@ -175,7 +175,7 @@ public class Convert implements Cloneable { Convert aClone = null; - try { + try { aClone = (Convert) super.clone(); aClone.reset(); } @@ -183,8 +183,8 @@ public class Convert implements Cloneable { System.out.println("Convert clone could not be created"); } return aClone; - } - + } + /** * Convert the input specified in calls to the <code>addInputStream</code> @@ -197,11 +197,11 @@ public class Convert implements Cloneable { * @throws IOException If any I/O error occurs. */ public ConvertData convert() throws ConvertException, IOException { - + ConvertData dataOut = new ConvertData(); if (toOffice) { - + // From device format to Office format // DocumentDeserializerFactory myDocDeserializerFactory = @@ -210,23 +210,23 @@ public class Convert implements Cloneable { myDocDeserializerFactory.createDocumentDeserializer(inputCD); Document deviceDoc = deser.deserialize(); - + dataOut.addDocument(deviceDoc); - return dataOut; + return dataOut; } else { - + // From Office format to device format // DocumentSerializerFactory myDocSerializerFactory = ci.getDocSerializerFactory(); Enumeration e = inputCD.getDocumentEnumeration(); - - Document doc = (Document) e.nextElement(); + + Document doc = (Document) e.nextElement(); DocumentSerializer ser = myDocSerializerFactory.createDocumentSerializer(doc); dataOut = ser.serialize(); - + return dataOut; } } @@ -249,11 +249,11 @@ public class Convert implements Cloneable { */ public ConvertData convert(String sFromURL, String sToURL) throws ConvertException, IOException { - + ConvertData dataOut = new ConvertData(); if (toOffice) { - + // From device format to Office format // DocumentDeserializerFactory myDocDeserializerFactory = @@ -264,25 +264,25 @@ public class Convert implements Cloneable { ((DocumentDeserializer2) deser).deserialize(sFromURL,sToURL) : deser.deserialize(); - + dataOut.addDocument(officeDoc); - return dataOut; + return dataOut; } else { - + // From Office format to device format // DocumentSerializerFactory myDocSerializerFactory = ci.getDocSerializerFactory(); Enumeration e = inputCD.getDocumentEnumeration(); - - Document doc = (Document) e.nextElement(); + + Document doc = (Document) e.nextElement(); DocumentSerializer ser = myDocSerializerFactory.createDocumentSerializer(doc); dataOut = ser instanceof DocumentSerializer2 ? ((DocumentSerializer2) ser).serialize(sFromURL,sToURL) : ser.serialize(); - + return dataOut; } } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/ConvertData.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/ConvertData.java index 0a26fd08b934..b2da0e3f3e4c 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/ConvertData.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/ConvertData.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -36,7 +36,7 @@ import java.util.Enumeration; * class. The <code>ConvertData</code> contains a <code>String</code> * name and a <code>Vector</code> of <code>Document</code> objects.</p> * - * @author Martin Maher + * @author Martin Maher */ public class ConvertData { @@ -49,7 +49,7 @@ public class ConvertData { * Name of the <code>ConvertData</code> object. */ private String name; - + /** * Resets ConvertData. This empties all <code>Document</code> @@ -60,7 +60,7 @@ public class ConvertData { name = null; v.removeAllElements(); } - + /** * Returns the <code>Document</code> name. * @@ -90,7 +90,7 @@ public class ConvertData { v.add(doc); } - + /** * Gets an <code>Enumeration</code> to access the <code>Vector</code> * of <code>Document</code> objects. @@ -105,7 +105,7 @@ public class ConvertData { /** - * Gets the number of <code>Document</code> objects currently stored + * Gets the number of <code>Document</code> objects currently stored * * @return The number of <code>Document</code> objects currently * stored. diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/ConvertException.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/ConvertException.java index e21e627b65a7..5065ca20ca10 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/ConvertException.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/ConvertException.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/ConverterCapabilities.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/ConverterCapabilities.java index 4741f8580c84..b26e0d5559b8 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/ConverterCapabilities.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/ConverterCapabilities.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -29,7 +29,7 @@ package org.openoffice.xmerge; /** * <p>A <code>ConverterCapabilities</code> object is used by - * <code>DocumentMerger</code> implementations. The + * <code>DocumentMerger</code> implementations. The * <code>ConverterCapabilities</code> indicates which * "Office" XML tags are supported by the * "Device" format.</p> diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/ConverterFactory.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/ConverterFactory.java index 4eb0b15426cb..b6afe0d42bfa 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/ConverterFactory.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/ConverterFactory.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -45,8 +45,8 @@ import org.openoffice.xmerge.util.registry.ConverterInfoMgr; public class ConverterFactory { /** - * Confirms whether or not a particular conversion can be done - * based on the Mime types of the files to be converted to and + * Confirms whether or not a particular conversion can be done + * based on the Mime types of the files to be converted to and * from. * * @param mimeTypeIn The mime input type. @@ -59,15 +59,15 @@ public class ConverterFactory { ConverterInfo foundInfo = null; // findConverterInfo expects the second paramenter to be the - // destination MimeType - if (foundInfo.isValidOfficeType(mimeTypeOut)) + // destination MimeType + if (foundInfo.isValidOfficeType(mimeTypeOut)) foundInfo = ConverterInfoMgr.findConverterInfo(mimeTypeIn, mimeTypeOut); else foundInfo = ConverterInfoMgr.findConverterInfo(mimeTypeOut, mimeTypeIn); if (foundInfo != null) return true; - else + else return false; } @@ -81,32 +81,32 @@ public class ConverterFactory { * @param mimeTypeIn The mime input type. * @param mimeTypeOut The mime output type. * - * @return The first <code>Convert</code> object that supports - * the specified conversion. + * @return The first <code>Convert</code> object that supports + * the specified conversion. */ public Convert getConverter(String mimeTypeIn, String mimeTypeOut) { ConverterInfo foundInfo = null; boolean toOffice; - + toOffice = foundInfo.isValidOfficeType(mimeTypeOut); - + // findConverterInfo expects the second paramenter to be the - // destination MimeType + // destination MimeType if (toOffice) foundInfo = ConverterInfoMgr.findConverterInfo(mimeTypeIn, mimeTypeOut); - else + else foundInfo = ConverterInfoMgr.findConverterInfo(mimeTypeOut, mimeTypeIn); - + if (foundInfo != null) - return getConverter(foundInfo, toOffice); - else + return getConverter(foundInfo, toOffice); + else return null; } - + /** - * Returns the <code>Convert</code> object that is described + * Returns the <code>Convert</code> object that is described * by the <code>ConverterInfo</code> parameter. * * @param ci The <code>ConverterInfo</code> describing the converter. @@ -116,7 +116,7 @@ public class ConverterFactory { * @return The <code>Convert</code> object */ public Convert getConverter(ConverterInfo ci, boolean toOffice) { - + Convert myConvert = new Convert(ci, toOffice); return myConvert; } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/Document.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/Document.java index 8c108e0bcba8..786050a42a0e 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/Document.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/Document.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentDeserializer.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentDeserializer.java index 2fe79a09fe26..4c26453a982b 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentDeserializer.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentDeserializer.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -38,7 +38,7 @@ import java.io.IOException; * the </code>PluginFactory</code> {@link * org.openoffice.xmerge.DocumentDeserializerFactory#createDocumentDeserializer * createDocumentDeserializer} method. When it is constructed, a - * <code>ConvertData</code> object is passed in to be used as input.</p> + * <code>ConvertData</code> object is passed in to be used as input.</p> * * @author Herbie Ong * @see org.openoffice.xmerge.PluginFactory diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentDeserializer2.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentDeserializer2.java index 164b21f3428c..417144b7ac49 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentDeserializer2.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentDeserializer2.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -37,9 +37,9 @@ import java.io.IOException; * <p>The <code>PluginFactory</code> {@link * org.openoffice.xmerge.DocumentDeserializerFactory#createDocumentDeserializer * createDocumentDeserializer} method creates a <code>DocumentDeserializer</code>, - * which may or may not implement <code>DocumentDeserializer2</code>. + * which may or may not implement <code>DocumentDeserializer2</code>. * When it is constructed, a - * <code>ConvertData</code> object is passed in to be used as input.</p> + * <code>ConvertData</code> object is passed in to be used as input.</p> * * @author Henrik Just * @see org.openoffice.xmerge.PluginFactory diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentDeserializerFactory.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentDeserializerFactory.java index 07b5004a0aba..315ebc0cf051 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentDeserializerFactory.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentDeserializerFactory.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentMerger.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentMerger.java index c743ce87e7aa..3f29b2dad7f2 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentMerger.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentMerger.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -40,11 +40,11 @@ package org.openoffice.xmerge; * of doing this even if the "Device" format is lossy in * comparison to the <code>OfficeDocument</code> format.</p> * - * <p>The <code>ConverterCapabilities</code> object is what the + * <p>The <code>ConverterCapabilities</code> object is what the * DocumentMerger utilizes to know how the "Office" * <code>Document</code> tags are supported in the "Device" * format.</p> - * + * * <p>The <code>DocumentMerger</code> object is created by a * the <code>DocumentMergerFactory</code> {@link * org.openoffice.xmerge.DocumentMergerFactory#createDocumentMerger diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentMergerFactory.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentMergerFactory.java index 94de73ebd728..3daa41db4b99 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentMergerFactory.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentMergerFactory.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -39,7 +39,7 @@ package org.openoffice.xmerge; * <code>OfficeDocument</code> with the merger. The merger is capable * of doing this even if the "Device" format is lossy in * comparison to the <code>OfficeDocument</code> format.</p> - * + * * @see PluginFactory * @see DocumentMerger * @see ConverterCapabilities diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentSerializer.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentSerializer.java index f8d3eb8c64dd..d46e5baca765 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentSerializer.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentSerializer.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentSerializer2.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentSerializer2.java index d827115dd9e1..dd3ee25460a6 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentSerializer2.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentSerializer2.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -37,7 +37,7 @@ import java.io.IOException; * <p>The <code>PluginFactory</code> {@link * org.openoffice.xmerge.DocumentSerializerFactory#createDocumentSerializer * createDocumentSerializer} method creates a <code>DocumentSerializer</code>, - * which may or may not implement <code>DocumentSerializer2</code>. + * which may or may not implement <code>DocumentSerializer2</code>. * When it is constructed, a * "Office" <code>Document</code> object is passed in to * be used as input.</p> diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentSerializerFactory.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentSerializerFactory.java index be41ab32235f..6d6f47078b5e 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentSerializerFactory.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/DocumentSerializerFactory.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -42,8 +42,8 @@ package org.openoffice.xmerge; public interface DocumentSerializerFactory { /** - * <p>The <code>DocumentSerializer</code> is used to convert - * from the "Office" <code>Document</code> format + * <p>The <code>DocumentSerializer</code> is used to convert + * from the "Office" <code>Document</code> format * to the "Device" <code>Document</code> format.</p> * * The <code>ConvertData</code> object is passed along to the diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/MergeException.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/MergeException.java index 56eb3b8a6a37..8c649c8fa6cf 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/MergeException.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/MergeException.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/PluginFactory.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/PluginFactory.java index d56da6840570..de7baba4683f 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/PluginFactory.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/PluginFactory.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -41,7 +41,7 @@ import java.io.IOException; * <p>Conversion from the "Office" <code>Document</code> * format to a "Device" <code>Document</code> format may * be lossy, i.e. some information may be lost. If a plug-in - * implements the <code>DocumentMergerFactory</code> interface, + * implements the <code>DocumentMergerFactory</code> interface, * then there is the possibility for merging the changes done on the * "Device" <code>Document</code> back to the original * "Office" <code>Document</code> via the @@ -61,7 +61,7 @@ import java.io.IOException; * with the jarfile. The data in the XML file is managed by the * <code>ConverterInfo</code> object. The <code>ConverterInfoMgr</code> * manages a registry of all <code>ConverterInfo</code> objects. For - * more information about this XML file, refer to + * more information about this XML file, refer to * <a href="converter/xml/sxc/package-summary.html"> * org.openoffice.xmerge.util.registry</a>.</p> * @@ -122,7 +122,7 @@ public abstract class PluginFactory { * <code>DocumentMerger</code> object.</p> * * @param name The <code>Document</code> name. - * @param is <code>InputStream</code> object corresponding + * @param is <code>InputStream</code> object corresponding * to the <code>Document</code>. * * @return A <code>Document</code> object representing the @@ -149,9 +149,9 @@ public abstract class PluginFactory { * <code>DocumentMerger</code> object.</p> * * @param name The <code>Document</code> name. - * @param is <code>InputStream</code> object corresponding + * @param is <code>InputStream</code> object corresponding * to the <code>Document</code>. - * @param isZip <code>boolean</code> to show that the created office + * @param isZip <code>boolean</code> to show that the created office * document is to be zipped. * * @return A <code>Document</code> object representing the @@ -178,7 +178,7 @@ public abstract class PluginFactory { * <code>DocumentMerger</code> object.</p> * * @param name The <code>Document</code> name. - * @param is <code>InputStream</code> object corresponding + * @param is <code>InputStream</code> object corresponding * to the <code>Document</code>. * * @return A <code>Document</code> object representing the diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/Version.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/Version.java index 35e877d11efa..b639d95a8116 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/Version.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/Version.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/dom/DOMDocument.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/dom/DOMDocument.java index e02358440524..f7df881b1061 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/dom/DOMDocument.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/dom/DOMDocument.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -85,7 +85,7 @@ public class DOMDocument } /** - * Returns the file extension of the <code>Document</code> + * Returns the file extension of the <code>Document</code> * represented. * * @return file extension of the <code>Document</code>. @@ -154,8 +154,8 @@ public class DOMDocument } /** - * Sets the Content of the <code>Document</code> to the contents of the - * supplied <code>Node</code> list. + * Sets the Content of the <code>Document</code> to the contents of the + * supplied <code>Node</code> list. * * @return DOM <code>Document</code> object. */ @@ -200,22 +200,22 @@ public class DOMDocument DocumentBuilder builder = null; try { builder = factory.newDocumentBuilder(); - } catch (ParserConfigurationException ex) { + } catch (ParserConfigurationException ex) { System.out.println("Error:"+ ex); //throw new OfficeDocumentException(ex); } try { - + contentDoc= builder.parse(is); - - + + } catch (SAXException ex) { System.out.println("Error:"+ ex); //throw new OfficeDocumentException(ex); } } - - + + /** * Write out content to the supplied <code>OutputStream</code>. * @@ -227,7 +227,7 @@ public class DOMDocument // set bytes for writing to output stream byte contentBytes[] = docToBytes(contentDoc); - + os.write(contentBytes); } @@ -253,11 +253,11 @@ public class DOMDocument java.lang.reflect.Constructor con; java.lang.reflect.Method meth; - + String domImpl = doc.getClass().getName(); System.err.println("type b " + domImpl); - + /* * We may have multiple XML parsers in the Classpath. * Depending on which one is first, the actual type of @@ -269,11 +269,11 @@ public class DOMDocument if (domImpl.equals("com.sun.xml.tree.XmlDocument")) { System.out.println("Using JAXP"); Class jaxpDoc = Class.forName("com.sun.xml.tree.XmlDocument"); - + // The method is in the XMLDocument class itself, not a helper - meth = jaxpDoc.getMethod("write", + meth = jaxpDoc.getMethod("write", new Class[] { Class.forName("java.io.OutputStream") } ); - + meth.invoke(doc, new Object [] { baos } ); } else if (domImpl.equals("org.apache.crimson.tree.XmlDocument")) @@ -281,34 +281,34 @@ public class DOMDocument System.out.println("Using Crimson"); Class crimsonDoc = Class.forName("org.apache.crimson.tree.XmlDocument"); // The method is in the XMLDocument class itself, not a helper - meth = crimsonDoc.getMethod("write", + meth = crimsonDoc.getMethod("write", new Class[] { Class.forName("java.io.OutputStream") } ); - - meth.invoke(doc, new Object [] { baos } ); + + meth.invoke(doc, new Object [] { baos } ); } - else if (domImpl.equals("org.apache.xerces.dom.DocumentImpl") + else if (domImpl.equals("org.apache.xerces.dom.DocumentImpl") || domImpl.equals("org.apache.xerces.dom.DeferredDocumentImpl")) { System.out.println("Using Xerces"); // Try for Xerces - Class xercesSer = + Class xercesSer = Class.forName("org.apache.xml.serialize.XMLSerializer"); - + // Get the OutputStream constructor // May want to use the OutputFormat parameter at some stage too - con = xercesSer.getConstructor(new Class [] + con = xercesSer.getConstructor(new Class [] { Class.forName("java.io.OutputStream"), Class.forName("org.apache.xml.serialize.OutputFormat") } ); - - + + // Get the serialize method - meth = xercesSer.getMethod("serialize", - new Class [] { Class.forName("org.w3c.dom.Document") } ); - - + meth = xercesSer.getMethod("serialize", + new Class [] { Class.forName("org.w3c.dom.Document") } ); + + // Get an instance Object serializer = con.newInstance(new Object [] { baos, null } ); - - + + // Now call serialize to write the document meth.invoke(serializer, new Object [] { doc } ); } @@ -329,7 +329,7 @@ public class DOMDocument meth.invoke(serializer, new Object [] { doc, baos } ); } else { - // We dont have another parser + // We dont have another parser try { DOMSource domSource = new DOMSource(doc); StringWriter writer = new StringWriter(); @@ -340,7 +340,7 @@ public class DOMDocument return writer.toString().getBytes(); } catch (Exception e) { - // We don't have another parser + // We don't have another parser throw new IOException("No appropriate API (JAXP/Xerces) to serialize XML document: " + domImpl); } } @@ -366,9 +366,9 @@ public class DOMDocument * * @throws IOException If any I/O error occurs. */ - public final void initContentDOM() throws IOException { + public final void initContentDOM() throws IOException { contentDoc = createDOM(""); - + } /** @@ -394,14 +394,14 @@ public class DOMDocument } catch (ParserConfigurationException ex) { System.out.println("Error:"+ ex); - + } Element root = (Element) doc.createElement(rootName); doc.appendChild(root); - + return doc; } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDB.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDB.java index 711e02a2e940..11286ee824ce 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDB.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDB.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -138,7 +138,7 @@ public final class PalmDB { * @param attribute The PDB header attribute. * @param recs Array of <code>Record</code> objects. * - * @throws UnsupportedEncodingException If <code>name</code> is + * @throws UnsupportedEncodingException If <code>name</code> is * not properly encoded. * @throws NullPointerException If <code>recs</code> is null. */ @@ -164,7 +164,7 @@ public final class PalmDB { * @param attribute The PDB header attribute. * @param recs Array of <code>Record</code> objects. * - * @throws UnsupportedEncodingException If <code>name</code> is + * @throws UnsupportedEncodingException If <code>name</code> is * not properly encoded. * @throws NullPointerException If recs is null. */ @@ -188,10 +188,10 @@ public final class PalmDB { * @param attribute The PDB header attribute. */ public void setAttributes (int creatorID, int typeID, int version, short attribute) { - this.creatorID = creatorID; - this.typeID = typeID; - this.version = version; - this.attribute = attribute; + this.creatorID = creatorID; + this.typeID = typeID; + this.version = version; + this.attribute = attribute; } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDocument.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDocument.java index c60d1dc27e42..668bfdb7f155 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDocument.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDocument.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -47,7 +47,7 @@ import org.openoffice.xmerge.Document; * @author Martin Maher */ -public class PalmDocument +public class PalmDocument implements Document { /** @@ -88,7 +88,7 @@ public class PalmDocument * @throws NullPointerException If <code>recs</code> is null. */ public PalmDocument(String name, int creatorID, int typeID, int version, - short attribute, Record[] recs) + short attribute, Record[] recs) throws UnsupportedEncodingException { pdb = new PalmDB(name, creatorID, typeID, version, attribute, recs); fileName = pdb.getPDBNameString(); @@ -102,7 +102,7 @@ public class PalmDocument * * @throws IOException If any I/O error occurs. */ - + public void read(InputStream is) throws IOException { PdbDecoder decoder = new PdbDecoder(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -115,7 +115,7 @@ public class PalmDocument pdb = decoder.parse(bytearr); fileName = pdb.getPDBNameString(); } - + /** * Writes the <code>PalmDocument</code> to an <code>OutputStream</code>. @@ -136,7 +136,7 @@ public class PalmDocument * @return The <code>PalmDB</code>. */ public PalmDB getPdb() { - return pdb; + return pdb; } @@ -147,21 +147,21 @@ public class PalmDocument * @param pdb The new <code>PalmDB</code> value. */ public void setPdb(PalmDB pdb) { - this.pdb = pdb; + this.pdb = pdb; String name = pdb.getPDBNameString(); fileName = name; } - + /** * Returns the name of the file. - * + * * @return The name of the file represented in the * <code>PalmDocument</code>. */ public String getFileName() { - return fileName + ".pdb"; + return fileName + ".pdb"; } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbDecoder.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbDecoder.java index 441f8f0ca417..68e7c66beb11 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbDecoder.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbDecoder.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -107,7 +107,7 @@ public final class PdbDecoder { int attr = file.readInt(); recAttrs[i] = (byte) (attr >>> 24); } - + // read the records @@ -124,14 +124,14 @@ public final class PdbDecoder { file.readFully(bytes); recArray[i] = new Record(bytes, recAttrs[i]); } - + // last record file.seek(recOffset[lastIndex]); len = (int) file.length() - recOffset[lastIndex]; bytes = new byte[len]; file.readFully(bytes); recArray[lastIndex] = new Record(bytes, recAttrs[lastIndex]); - + } file.close(); @@ -142,7 +142,7 @@ public final class PdbDecoder { return pdb; } - + /** * <p>This method decodes a PDB file into a <code>PalmDB</code> * object.</p> @@ -161,12 +161,12 @@ public final class PdbDecoder { */ public PalmDB parse(byte[] b) throws IOException { - + ByteArrayInputStream bais = new ByteArrayInputStream(b); DataInputStream dis = new DataInputStream(bais); // read the PDB header - + PdbHeader header = new PdbHeader(); header.read(dis); @@ -206,21 +206,21 @@ public final class PdbDecoder { dis.readFully(bytes); recArray[i] = new Record(bytes, recAttrs[i]); } - + // last record - + dis.reset(); len = (int) dis.available() - recOffset[lastIndex]; - dis.skip(recOffset[lastIndex]); + dis.skip(recOffset[lastIndex]); bytes = new byte[len]; dis.readFully(bytes); recArray[lastIndex] = new Record(bytes, recAttrs[lastIndex]); } - + // create PalmDB and return it - + PalmDB pdb = new PalmDB(header.pdbName, header.creatorID, header.typeID, header.version, header.attribute, recArray); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbEncoder.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbEncoder.java index 3cd3eba22155..46433e88ec2e 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbEncoder.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbEncoder.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -118,7 +118,7 @@ public final class PdbEncoder { * <p>There should be a total of <code>header.numRecords</code> * of <code>Record</code> index info</p>. * - * @param os <code>OutputStream</code> to write out PDB. + * @param os <code>OutputStream</code> to write out PDB. * * @throws IOException If I/O error occurs. */ diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbHeader.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbHeader.java index 89abc3855faa..2f9d389e80cc 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbHeader.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbHeader.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbUtil.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbUtil.java index 2e2c326c249d..d0714d677960 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbUtil.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbUtil.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/Record.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/Record.java index 4e2b1263a4bb..23690792bdbf 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/Record.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/Record.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedBinaryObject.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedBinaryObject.java index 9bdc55310a16..ac82675b229d 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedBinaryObject.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedBinaryObject.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -37,53 +37,53 @@ import org.w3c.dom.Element; * have a binary representation. */ public class EmbeddedBinaryObject extends EmbeddedObject { - + /** The object's binary representation. */ protected byte[] objData = null; - + /** * Constructor for an embedded object stored using an XML representation. * * @param name The name of the object. * @param type The mime-type of the object. See the class summary. - */ + */ public EmbeddedBinaryObject(String name, String type) { super(name, type); } - - + + /** - * Package private constructor for use when reading an object from a + * Package private constructor for use when reading an object from a * compressed SX? file. * * @param name The name of the object. * @param type The mime-type of the object. See the class summary. * @param source The OfficeZip representation of the SX? file that stores * the object. - */ + */ EmbeddedBinaryObject(String name, String type, OfficeZip source) { super(name, type, source); } - + /** * This method returns the data for this object. * * @return A <code>byte</code> array containing the object's data. */ public byte[] getBinaryData() { - + if (objData == null) { // See if we came from a Zip file if (zipFile != null) { objData = zipFile.getNamedBytes(objName); } } - + return objData; } - - + + /** * Sets the data for this object. * @@ -93,8 +93,8 @@ public class EmbeddedBinaryObject extends EmbeddedObject { objData = data; hasChanged = true; } - - /** + + /** * Package private method for writing the data of the EmbeddedObject to a * SX? file. * @@ -106,22 +106,22 @@ public class EmbeddedBinaryObject extends EmbeddedObject { zip.setNamedBytes(objName, objData); } } - - - /** + + + /** * Package private method that constructs the manifest.xml entries for this * embedded object. * * @return Document <code>Document</code> containing the manifest entries. */ - void writeManifestData(Document manifestDoc) throws DOMException { + void writeManifestData(Document manifestDoc) throws DOMException { Element objNode = manifestDoc.createElement(OfficeConstants.TAG_MANIFEST_FILE); - + objNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_TYPE, objType); objNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_PATH, objName); - + manifestDoc.getDocumentElement().appendChild(objNode); } - + } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedObject.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedObject.java index 1fa29bde6ee9..11240b4bceac 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedObject.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedObject.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -36,13 +36,13 @@ import org.w3c.dom.DOMException; public abstract class EmbeddedObject { protected String objName; protected String objType; - + /** Representation of the file from which this object was read. */ protected OfficeZip zipFile = null; - + /** Flag indicating if this document has changed since reading or is new. */ protected boolean hasChanged = false; - + /** * Constructor for an embedded object stored using an XML representation. * @@ -52,13 +52,13 @@ public abstract class EmbeddedObject { public EmbeddedObject(String name, String type) { objName = name; objType = type; - + hasChanged = true; } - + /** - * Package private constructor for use when reading an object from a + * Package private constructor for use when reading an object from a * compressed SX? file. * * @param name The name of the object. @@ -71,12 +71,12 @@ public abstract class EmbeddedObject { zipFile = source; } - + /** * Retrieves the name of the embedded object represented by an instance of * this class. * - * <b>N.B.</b>The name referes to the name as found in the + * <b>N.B.</b>The name referes to the name as found in the * <code>META-INF/manifest.xml</code> file. * * @return The name of the object. @@ -84,19 +84,19 @@ public abstract class EmbeddedObject { public final String getName() { return objName; } - - - /** + + + /** * Retrieves the type of the embedded object represented by an instance of * this class. * - * The <code>META-INF/manifest.xml</code> file currently represents the + * The <code>META-INF/manifest.xml</code> file currently represents the * type of an object using MIME types. */ public final String getType() { return objType; } - + /** * Package private method for writing the data of the EmbeddedObject to a * SX? file. @@ -105,7 +105,7 @@ public abstract class EmbeddedObject { * the data is to be written to. */ abstract void write(OfficeZip zip) throws IOException; - + /** * Package private method that constructs the manifest.xml entries for this * embedded object. diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedXMLObject.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedXMLObject.java index 623e61df1e93..6e5f123ded53 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedXMLObject.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedXMLObject.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -50,20 +50,20 @@ import org.xml.sax.SAXException; * Spreadsheets created with Calc (application/vnd.sun.xml.calc) * Text created with Writer (application/vnd.sun.xml.writer) * Drawings created with Draw (application/vnd.sun.xml.draw) - * Presentations created with Impress (application/vnd.sun.xml.impress) + * Presentations created with Impress (application/vnd.sun.xml.impress) * * These object types are stored using a combination of content, settings and styles * XML files. */ public class EmbeddedXMLObject extends EmbeddedObject { - + // Entries for the subdocuments that constitute this object; protected Document contentDOM = null; protected Document settingsDOM = null; protected Document stylesDOM = null; - + private DocumentBuilder builder = null; - + /** * Constructor for an embedded object stored using an XML representation. * @@ -71,11 +71,11 @@ public class EmbeddedXMLObject extends EmbeddedObject { * @param type The mime-type of the object. See the class summary. */ public EmbeddedXMLObject(String name, String type) { - super(name, type); + super(name, type); } - + /** - * Package private constructor for use when reading an object from a + * Package private constructor for use when reading an object from a * compressed SX? file. * * @param name The name of the object. @@ -83,11 +83,11 @@ public class EmbeddedXMLObject extends EmbeddedObject { * @param source The OfficeZip representation of the SX? file that stores * the object. */ - EmbeddedXMLObject(String name, String type, OfficeZip source) { + EmbeddedXMLObject(String name, String type, OfficeZip source) { super(name, type, source); } - - + + /** * Returns the content data for this embedded object. * @@ -97,15 +97,15 @@ public class EmbeddedXMLObject extends EmbeddedObject { * @throws IOException If any IO error occurs */ public Document getContentDOM() throws SAXException, IOException { - + if (contentDOM == null) { contentDOM = getNamedDOM("content.xml"); } - + return contentDOM; } - - + + /** * Sets the content data for the embedded object. * @@ -115,8 +115,8 @@ public class EmbeddedXMLObject extends EmbeddedObject { contentDOM = content; hasChanged = true; } - - + + /** * Returns the settings data for this embedded object. * @@ -124,17 +124,17 @@ public class EmbeddedXMLObject extends EmbeddedObject { * * @throws SAXException If any parser error occurs * @throws IOException If any IO error occurs - */ + */ public Document getSettingsDOM() throws SAXException, IOException { - + if (settingsDOM == null) { settingsDOM = getNamedDOM("settings.xml"); } - + return settingsDOM; } - - + + /** * Sets the settings data for the embedded object. * @@ -145,7 +145,7 @@ public class EmbeddedXMLObject extends EmbeddedObject { hasChanged = true; } - + /** * Returns the style data for this embedded object. * @@ -153,17 +153,17 @@ public class EmbeddedXMLObject extends EmbeddedObject { * * @throws SAXException If any parser error occurs * @throws IOException If any IO error occurs - */ + */ public Document getStylesDOM() throws SAXException, IOException { - + if (stylesDOM == null) { stylesDOM = getNamedDOM("styles.xml"); } - + return stylesDOM; } - - + + /** * Sets the styles data for the embedded object. * @@ -174,7 +174,7 @@ public class EmbeddedXMLObject extends EmbeddedObject { hasChanged = true; } - + /** * This method extracts the data for the given XML file from the SX? file * and creates a DOM representation of it. @@ -187,7 +187,7 @@ public class EmbeddedXMLObject extends EmbeddedObject { * @throws SAXException If any parser error occurs * @throws IOException If any IO error occurs */ - private Document getNamedDOM(String name) throws SAXException, IOException { + private Document getNamedDOM(String name) throws SAXException, IOException { if (zipFile == null) { return null; } @@ -195,11 +195,11 @@ public class EmbeddedXMLObject extends EmbeddedObject { try { if (builder == null) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - + factory.setValidating(false); builder = factory.newDocumentBuilder(); } - + byte[] data = zipFile.getNamedBytes(new String(objName + "/" + name)); if (data != null) { return OfficeDocument.parse(builder, data); @@ -207,7 +207,7 @@ public class EmbeddedXMLObject extends EmbeddedObject { else { return null; } - + } catch (SAXException se) { throw se; @@ -219,9 +219,9 @@ public class EmbeddedXMLObject extends EmbeddedObject { throw new SAXException(pce); } } - - - /** + + + /** * Package private method for writing the data of the EmbeddedObject to a * SX? file. * @@ -231,7 +231,7 @@ public class EmbeddedXMLObject extends EmbeddedObject { void write(OfficeZip zip) throws IOException { if (hasChanged == true) { if (contentDOM != null) { - zip.setNamedBytes(new String(objName + "/content.xml"), + zip.setNamedBytes(new String(objName + "/content.xml"), OfficeDocument.docToBytes(contentDOM)); } if (settingsDOM != null) { @@ -244,8 +244,8 @@ public class EmbeddedXMLObject extends EmbeddedObject { } } } - - /** + + /** * Package private method that constructs the manifest.xml entries for this * embedded object. * @@ -253,43 +253,43 @@ public class EmbeddedXMLObject extends EmbeddedObject { */ void writeManifestData(Document manifestDoc) throws DOMException { Node root = manifestDoc.getDocumentElement(); - + if (contentDOM != null) { Element contentNode = manifestDoc.createElement(OfficeConstants.TAG_MANIFEST_FILE); - + contentNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_TYPE, "text/xml"); - contentNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_PATH, + contentNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_PATH, new String(objName + "/content.xml")); - + root.appendChild(contentNode); } - + if (settingsDOM != null) { Element settingsNode = manifestDoc.createElement(OfficeConstants.TAG_MANIFEST_FILE); - + settingsNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_TYPE, "text/xml"); settingsNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_PATH, new String(objName + "/settings.xml")); - + root.appendChild(settingsNode); } - + if (stylesDOM != null) { Element stylesNode = manifestDoc.createElement(OfficeConstants.TAG_MANIFEST_FILE); - + stylesNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_TYPE, "text/xml"); - stylesNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_PATH, + stylesNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_PATH, new String(objName + "/styles.xml")); } - - + + Element objectNode = manifestDoc.createElement(OfficeConstants.TAG_MANIFEST_FILE); - + objectNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_TYPE, objType); objectNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_PATH, new String(objName + "/")); - + root.appendChild(objectNode); } - + } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeConstants.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeConstants.java index f72e09619311..afa889cb9e3f 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeConstants.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeConstants.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -43,7 +43,7 @@ public interface OfficeConstants { * tag in content.xml. */ public final static String TAG_OFFICE_DOCUMENT_CONTENT = "office:document-content"; - + /** * Element tag for <i>office:document-settings</i>, this is the root * tag in content.xml. @@ -105,23 +105,23 @@ public interface OfficeConstants { public final static String TAG_TEXT_SEQUENCE = "text:sequence"; /** Element tag for <i>text:text-input</i>. */ - public final static String TAG_TEXT_VARIABLE_INPUT = "text:variable-input"; + public final static String TAG_TEXT_VARIABLE_INPUT = "text:variable-input"; /** Element tag for <i>text:time</i>. */ - public final static String TAG_TEXT_TIME = "text:time"; + public final static String TAG_TEXT_TIME = "text:time"; /** Element tag for <i>text:page-count</i>. */ - public final static String TAG_TEXT_PAGE_COUNT = "text:page-count"; + public final static String TAG_TEXT_PAGE_COUNT = "text:page-count"; /** Element tag for <i>text:page-number</i>. */ - public final static String TAG_TEXT_PAGE_NUMBER = "text:page-number"; + public final static String TAG_TEXT_PAGE_NUMBER = "text:page-number"; /** Element tag for <i>text:author-initials</i>. */ - public final static String TAG_TEXT_AUTHOR_INITIALS = "text:author-initials"; + public final static String TAG_TEXT_AUTHOR_INITIALS = "text:author-initials"; /** Element tag for <i>text:subject</i>. */ - public final static String TAG_TEXT_SUBJECT = "text:subject"; + public final static String TAG_TEXT_SUBJECT = "text:subject"; /** Element tag for <i>text:title</i>. */ - public final static String TAG_TEXT_TITLE = "text:title"; + public final static String TAG_TEXT_TITLE = "text:title"; /** Element tag for <i>text:creation-time</i>. */ - public final static String TAG_TEXT_CREATION_TIME = "text:creation-time"; - + public final static String TAG_TEXT_CREATION_TIME = "text:creation-time"; + /** Element tag for <i>text:date</i>. */ public final static String TAG_TEXT_DATE = "text:date"; /** Element tag for <i>text:text-input</i>. */ @@ -150,7 +150,7 @@ public interface OfficeConstants { * <i>fo:font-family</i>. */ public final static String ATTRIBUTE_FO_FONT_FAMILY = "fo:font-family"; - + /** * Attribute tag for <i>fo:font-family</i> of element * <i>fo:font-family</i>. @@ -159,7 +159,7 @@ public interface OfficeConstants { /** Element tag for <i>text:p</i>. */ public final static String TAG_PARAGRAPH = "text:p"; - + /** Element tag for <i>text:</i>. */ public final static String TAG_TEXT = "text:"; @@ -218,14 +218,14 @@ public interface OfficeConstants { public final static String TAG_TABLE_NAMED_RANGE= "table:named-range"; /** Element tag for <i>table:named-expression</i>. */ - public final static String TAG_TABLE_NAMED_EXPRESSION= "table:named-expression"; - + public final static String TAG_TABLE_NAMED_EXPRESSION= "table:named-expression"; + /** * Attribute tag for <i>table:name</i> of element * <i>table:table</i>. */ public final static String ATTRIBUTE_TABLE_NAME = "table:name"; - + /** * Attribute tag for <i>table:expression</i> of element * <i>table:named-range</i>. @@ -237,13 +237,13 @@ public interface OfficeConstants { * <i>table:named-range</i>. */ public final static String ATTRIBUTE_TABLE_BASE_CELL_ADDRESS = "table:base-cell-address"; - + /** * Attribute tag for <i>table:cell-range-address</i> of element * <i>table:named-range</i>. */ public final static String ATTRIBUTE_TABLE_CELL_RANGE_ADDRESS = "table:cell-range-address"; - + /** Element tag for <i>table:table-row</i>. */ public final static String TAG_TABLE_ROW = "table:table-row"; @@ -254,7 +254,7 @@ public interface OfficeConstants { * Attribute tag for <i>table:default-cell-style-name</i> * of element <i>table:table-column</i>. */ - public final static String ATTRIBUTE_DEFAULT_CELL_STYLE = "table:default-cell-style-name"; + public final static String ATTRIBUTE_DEFAULT_CELL_STYLE = "table:default-cell-style-name"; /** Element tag for <i>table:scenario</i>. */ public final static String TAG_TABLE_SCENARIO = "table:scenario"; @@ -355,33 +355,33 @@ public interface OfficeConstants { /** StarWriter XML <i>office:class</i> value. */ public final static String SXW_TYPE = "text"; - + /** StarCalc XML file extension. */ public final static String SXC_FILE_EXTENSION = ".sxc"; /** StarCalc XML <i>office:class</i> value. */ public final static String SXC_TYPE = "spreadsheet"; - + /** Element tag for <i>manifest:manifest</i>entry in Manifest XML */ public final static String TAG_MANIFEST_ROOT = "manifest:manifest"; - + /** Element tag for <i>manifest:file-entry</i> entry in Manifest XML. */ public final static String TAG_MANIFEST_FILE = "manifest:file-entry"; - - /** + + /** * Attribute tag for <i>manifest:media-type</i> of element - * <i>manifest:file-entry</i>. + * <i>manifest:file-entry</i>. */ public final static String ATTRIBUTE_MANIFEST_FILE_TYPE = "manifest:media-type"; - - /** + + /** * Attribute tag for <i>manifest:full-path</i> of element - * <i>manifest:file-entry</i>. + * <i>manifest:file-entry</i>. */ public final static String ATTRIBUTE_MANIFEST_FILE_PATH = "manifest:full-path"; - + // Tags and Elements for the settings.xml - + /** Element tag for <i>config:config-item</i>. */ public final static String TAG_CONFIG_ITEM = "config:config-item"; @@ -402,17 +402,17 @@ public interface OfficeConstants { * <i>config:config-item</i>. */ public final static String ATTRIBUTE_CONFIG_NAME = "config:name"; - + /** * Attribute tag for <i>config:type</i> of element * <i>config:config-item</i>. */ public final static String ATTRIBUTE_CONFIG_TYPE = "config:type"; - - + + /** StarWriter XML MIME type. */ public final static String SXW_MIME_TYPE = "application/vnd.sun.xml.writer"; - + /** StarWriter XML Template MIME type. */ public final static String STW_MIME_TYPE = "application/vnd.sun.xml.writer.template"; @@ -421,19 +421,19 @@ public interface OfficeConstants { /** StarCalc XML Template MIME type. */ public final static String STC_MIME_TYPE = "application/vnd.sun.xml.calc.template"; - + /** StarImpress XML MIME type. */ public final static String SXI_MIME_TYPE = "application/vnd.sun.xml.impress"; - + /** StarImpress XML Template MIME type. */ public final static String STI_MIME_TYPE = "application/vnd.sun.xml.impress.template"; /** StarDraw XML MIME type. */ public final static String SXD_MIME_TYPE = "application/vnd.sun.xml.draw"; - + /** StarMath XML MIME type. */ public final static String SXM_MIME_TYPE = "application/vnd.sun.xml.math"; - + /** StarWriter Global XML MIME Type */ public final static String SXG_MIME_TYPE = "application/vnd.sun.xml.writer.global"; } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java index cda6dd04965f..d3372be5a757 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -85,7 +85,7 @@ public abstract class OfficeDocument /** DOM <code>Document</code> of content.xml. */ private Document styleDoc = null; - + /** DOM <code>Docuemtn</code> of META-INF/manifest.xml. */ private Document manifestDoc = null; @@ -103,7 +103,7 @@ public abstract class OfficeDocument * XML file. */ private OfficeZip zip = null; - + /** Collection to keep track of the embedded objects in the document. */ private Map embeddedObjects = null; @@ -213,7 +213,7 @@ public abstract class OfficeDocument contentDoc = (Document)newDom; } - + /** * Sets the meta tree of the document. * @@ -223,7 +223,7 @@ public abstract class OfficeDocument metaDoc = (Document)newDom; } - + /** * Sets the settings tree of the document. * @@ -232,7 +232,7 @@ public abstract class OfficeDocument public void setSettingsDOM (Node newDom) { settingsDoc = (Document)newDom; } - + /** * Sets the style tree of the document. @@ -242,7 +242,7 @@ public abstract class OfficeDocument public void setStyleDOM (Node newDom) { styleDoc = (Document)newDom; } - + /** * Return a DOM <code>Document</code> object of the style.xml file. @@ -300,24 +300,24 @@ public abstract class OfficeDocument * @return An <code>Iterator</code> of <code>EmbeddedObject</code> objects. */ public Iterator getEmbeddedObjects() { - - if (embeddedObjects == null && manifestDoc != null) { - embeddedObjects = new HashMap(); - - // Need to read the manifest file and construct a list of objects + + if (embeddedObjects == null && manifestDoc != null) { + embeddedObjects = new HashMap(); + + // Need to read the manifest file and construct a list of objects NodeList nl = manifestDoc.getElementsByTagName(TAG_MANIFEST_FILE); - + // Dont create the HashMap if there are no embedded objects int len = nl.getLength(); for (int i = 0; i < len; i++) { Node n = nl.item(i); - + NamedNodeMap attrs = n.getAttributes(); - + String type = attrs.getNamedItem(ATTRIBUTE_MANIFEST_FILE_TYPE).getNodeValue(); String path = attrs.getNamedItem(ATTRIBUTE_MANIFEST_FILE_PATH).getNodeValue(); - - + + /* * According to OpenOffice.org XML File Format document (ver. 1) * there are only two types of embedded object: @@ -328,7 +328,7 @@ public abstract class OfficeDocument * The former are represented by one or more XML files. * The latter are in binary form. */ - if (type.startsWith("application/vnd.sun.xml")) + if (type.startsWith("application/vnd.sun.xml")) { if (path.equals("/")) { // Exclude the main document entries @@ -343,34 +343,34 @@ public abstract class OfficeDocument // document entries continue; } - else { // FIX (HJ): allows empty MIME type + else { // FIX (HJ): allows empty MIME type embeddedObjects.put(path, new EmbeddedBinaryObject(path, type, zip)); } } } - + return embeddedObjects.values().iterator(); } - + /** * Returns the embedded object corresponding to the name provided. - * The name should be stripped of any preceding path characters, such as + * The name should be stripped of any preceding path characters, such as * '/', '.' or '#'. * * @param name The name of the embedded object to retrieve. * - * @return An <code>EmbeddedObject</code> instance representing the named + * @return An <code>EmbeddedObject</code> instance representing the named * object. */ public EmbeddedObject getEmbeddedObject(String name) { if (name == null) { return null; } - + if (embeddedObjects == null) { getEmbeddedObjects(); } - + if (embeddedObjects.containsKey(name)) { return (EmbeddedObject)embeddedObjects.get(name); } @@ -378,8 +378,8 @@ public abstract class OfficeDocument return null; } } - - + + /** * Adds a new embedded object to the document. * @@ -389,15 +389,15 @@ public abstract class OfficeDocument if (embObj == null) { return; } - + if (embeddedObjects == null) { embeddedObjects = new HashMap(); } - + embeddedObjects.put(embObj.getName(), embObj); } - - + + /** * Read the Office <code>Document</code> from the given * <code>InputStream</code>. @@ -487,12 +487,12 @@ public abstract class OfficeDocument } } - + // Read in the META-INF/manifest.xml file byte manifestBytes[] = zip.getManifestXMLBytes(); - + if (manifestBytes != null) { - + try { manifestDoc = parse(builder, manifestBytes); } catch (SAXException ex) { @@ -508,7 +508,7 @@ public abstract class OfficeDocument * <code>InputStream</code>. * * @param is Office document <code>InputStream</code>. - * @param isZip <code>boolean</code> Identifies whether + * @param isZip <code>boolean</code> Identifies whether * a file is zipped or not * * @throws IOException If any I/O error occurs. @@ -524,7 +524,7 @@ public abstract class OfficeDocument } catch (ParserConfigurationException ex) { throw new OfficeDocumentException(ex); } - + if (isZip) { read(is); @@ -539,7 +539,7 @@ public abstract class OfficeDocument org.w3c.dom.Document newDoc = builder.parse(ins); //org.w3c.dom.Document newDoc = builder.parse((InputStream)is); Element rootElement=newDoc.getDocumentElement(); - + NodeList nodeList; Node tmpNode; Node rootNode = (Node)rootElement; @@ -548,38 +548,38 @@ public abstract class OfficeDocument contentDoc = createDOM(TAG_OFFICE_DOCUMENT_CONTENT); rootElement=contentDoc.getDocumentElement(); rootNode = (Node)rootElement; - + // FIX (HJ): Include office:font-decls in content DOM nodeList= newDoc.getElementsByTagName(TAG_OFFICE_FONT_DECLS); if (nodeList.getLength()>0){ tmpNode = contentDoc.importNode(nodeList.item(0),true); rootNode.appendChild(tmpNode); } - + nodeList= newDoc.getElementsByTagName(TAG_OFFICE_AUTOMATIC_STYLES); if (nodeList.getLength()>0){ tmpNode = contentDoc.importNode(nodeList.item(0),true); rootNode.appendChild(tmpNode); } - + nodeList= newDoc.getElementsByTagName(TAG_OFFICE_BODY); if (nodeList.getLength()>0){ tmpNode = contentDoc.importNode(nodeList.item(0),true); rootNode.appendChild(tmpNode); } - + /*Styles*/ styleDoc = createDOM(TAG_OFFICE_DOCUMENT_STYLES); rootElement=styleDoc.getDocumentElement(); rootNode = (Node)rootElement; - + // FIX (HJ): Include office:font-decls in styles DOM nodeList= newDoc.getElementsByTagName(TAG_OFFICE_FONT_DECLS); if (nodeList.getLength()>0){ tmpNode = styleDoc.importNode(nodeList.item(0),true); rootNode.appendChild(tmpNode); } - + nodeList= newDoc.getElementsByTagName(TAG_OFFICE_STYLES); if (nodeList.getLength()>0){ tmpNode = styleDoc.importNode(nodeList.item(0),true); @@ -592,7 +592,7 @@ public abstract class OfficeDocument tmpNode = styleDoc.importNode(nodeList.item(0),true); rootNode.appendChild(tmpNode); } - + // FIX (HJ): Include office:master-styles in styles DOM nodeList= newDoc.getElementsByTagName(TAG_OFFICE_MASTER_STYLES); if (nodeList.getLength()>0){ @@ -608,7 +608,7 @@ public abstract class OfficeDocument if (nodeList.getLength()>0){ tmpNode = settingsDoc.importNode(nodeList.item(0),true); rootNode.appendChild(tmpNode); - } + } /*Meta*/ metaDoc = createDOM(TAG_OFFICE_DOCUMENT_META); rootElement=metaDoc.getDocumentElement(); @@ -617,14 +617,14 @@ public abstract class OfficeDocument if (nodeList.getLength()>0){ tmpNode = metaDoc.importNode(nodeList.item(0),true); rootNode.appendChild(tmpNode); - } + } } } catch (SAXException ex) { throw new OfficeDocumentException(ex); } } - + } @@ -656,9 +656,9 @@ public abstract class OfficeDocument return doc; } - - - /** + + + /** * Method to return the MIME type of the document. * * @return String The document's MIME type. @@ -674,67 +674,67 @@ public abstract class OfficeDocument * @throws IOException If any I/O error occurs. */ public void write(OutputStream os) throws IOException { - if (zip == null) { + if (zip == null) { zip = new OfficeZip(); } - + initManifestDOM(); - + Element domEntry; Element manifestRoot = manifestDoc.getDocumentElement(); - + // The EmbeddedObjects come first. Iterator embObjs = getEmbeddedObjects(); while (embObjs.hasNext()) { EmbeddedObject obj = (EmbeddedObject)embObjs.next(); obj.writeManifestData(manifestDoc); - + obj.write(zip); } - + // Add in the entry for the Pictures directory. Always present. domEntry = manifestDoc.createElement(TAG_MANIFEST_FILE); domEntry.setAttribute(ATTRIBUTE_MANIFEST_FILE_PATH, "Pictures/"); domEntry.setAttribute(ATTRIBUTE_MANIFEST_FILE_TYPE, ""); manifestRoot.appendChild(domEntry); - + // Write content to the Zip file and then write any of the optional // data, if it exists. zip.setContentXMLBytes(docToBytes(contentDoc)); - + domEntry = manifestDoc.createElement(TAG_MANIFEST_FILE); domEntry.setAttribute(ATTRIBUTE_MANIFEST_FILE_PATH, "content.xml"); domEntry.setAttribute(ATTRIBUTE_MANIFEST_FILE_TYPE, "text/xml"); - + manifestRoot.appendChild(domEntry); - + if (styleDoc != null) { zip.setStyleXMLBytes(docToBytes(styleDoc)); - + domEntry = manifestDoc.createElement(TAG_MANIFEST_FILE); domEntry.setAttribute(ATTRIBUTE_MANIFEST_FILE_PATH, "styles.xml"); domEntry.setAttribute(ATTRIBUTE_MANIFEST_FILE_TYPE, "text/xml"); manifestRoot.appendChild(domEntry); } - + if (metaDoc != null) { zip.setMetaXMLBytes(docToBytes(metaDoc)); - + domEntry = manifestDoc.createElement(TAG_MANIFEST_FILE); - domEntry.setAttribute(ATTRIBUTE_MANIFEST_FILE_PATH, "meta.xml"); + domEntry.setAttribute(ATTRIBUTE_MANIFEST_FILE_PATH, "meta.xml"); domEntry.setAttribute(ATTRIBUTE_MANIFEST_FILE_TYPE, "text/xml"); manifestRoot.appendChild(domEntry); } - + if (settingsDoc != null) { zip.setSettingsXMLBytes(docToBytes(settingsDoc)); - + domEntry = manifestDoc.createElement(TAG_MANIFEST_FILE); domEntry.setAttribute(ATTRIBUTE_MANIFEST_FILE_PATH, "settings.xml"); domEntry.setAttribute(ATTRIBUTE_MANIFEST_FILE_TYPE, "text/xml"); manifestRoot.appendChild(domEntry); } - + zip.setManifestXMLBytes(docToBytes(manifestDoc)); zip.write(os); @@ -762,35 +762,35 @@ public abstract class OfficeDocument DOMImplementation domImpl = builder.getDOMImplementation(); DocumentType docType =domImpl.createDocumentType("office:document","-//OpenOffice.org//DTD OfficeDocument 1.0//EN",null); org.w3c.dom.Document newDoc = domImpl.createDocument("http://openoffice.org/2000/office","office:document",null); - - + + Element rootElement=newDoc.getDocumentElement(); - rootElement.setAttribute("xmlns:office","http://openoffice.org/2000/office"); - rootElement.setAttribute("xmlns:style","http://openoffice.org/2000/style" ); - rootElement.setAttribute("xmlns:text","http://openoffice.org/2000/text"); - rootElement.setAttribute("xmlns:table","http://openoffice.org/2000/table"); - - rootElement.setAttribute("xmlns:draw","http://openoffice.org/2000/drawing"); - rootElement.setAttribute("xmlns:fo","http://www.w3.org/1999/XSL/Format" ); - rootElement.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink" ); - rootElement.setAttribute("xmlns:dc","http://purl.org/dc/elements/1.1/" ); - rootElement.setAttribute("xmlns:meta","http://openoffice.org/2000/meta" ); - rootElement.setAttribute("xmlns:number","http://openoffice.org/2000/datastyle" ); - rootElement.setAttribute("xmlns:svg","http://www.w3.org/2000/svg" ); - rootElement.setAttribute("xmlns:chart","http://openoffice.org/2000/chart" ); - rootElement.setAttribute("xmlns:dr3d","http://openoffice.org/2000/dr3d" ); - rootElement.setAttribute("xmlns:math","http://www.w3.org/1998/Math/MathML" ); - rootElement.setAttribute("xmlns:form","http://openoffice.org/2000/form" ); - rootElement.setAttribute("xmlns:script","http://openoffice.org/2000/script" ); - rootElement.setAttribute("xmlns:config","http://openoffice.org/2001/config" ); + rootElement.setAttribute("xmlns:office","http://openoffice.org/2000/office"); + rootElement.setAttribute("xmlns:style","http://openoffice.org/2000/style" ); + rootElement.setAttribute("xmlns:text","http://openoffice.org/2000/text"); + rootElement.setAttribute("xmlns:table","http://openoffice.org/2000/table"); + + rootElement.setAttribute("xmlns:draw","http://openoffice.org/2000/drawing"); + rootElement.setAttribute("xmlns:fo","http://www.w3.org/1999/XSL/Format" ); + rootElement.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink" ); + rootElement.setAttribute("xmlns:dc","http://purl.org/dc/elements/1.1/" ); + rootElement.setAttribute("xmlns:meta","http://openoffice.org/2000/meta" ); + rootElement.setAttribute("xmlns:number","http://openoffice.org/2000/datastyle" ); + rootElement.setAttribute("xmlns:svg","http://www.w3.org/2000/svg" ); + rootElement.setAttribute("xmlns:chart","http://openoffice.org/2000/chart" ); + rootElement.setAttribute("xmlns:dr3d","http://openoffice.org/2000/dr3d" ); + rootElement.setAttribute("xmlns:math","http://www.w3.org/1998/Math/MathML" ); + rootElement.setAttribute("xmlns:form","http://openoffice.org/2000/form" ); + rootElement.setAttribute("xmlns:script","http://openoffice.org/2000/script" ); + rootElement.setAttribute("xmlns:config","http://openoffice.org/2001/config" ); // #i41033# OASIS format needs the "office:class" set. if(getDocumentMimeType() == SXC_MIME_TYPE) - rootElement.setAttribute("office:class","spreadsheet" ); + rootElement.setAttribute("office:class","spreadsheet" ); else if(getDocumentMimeType() == SXW_MIME_TYPE) - rootElement.setAttribute("office:class","text" ); - rootElement.setAttribute("office:version","1.0"); - - + rootElement.setAttribute("office:class","text" ); + rootElement.setAttribute("office:version","1.0"); + + NodeList nodeList; Node tmpNode; Node rootNode = (Node)rootElement; @@ -805,8 +805,8 @@ public abstract class OfficeDocument if (nodeList.getLength()>0){ tmpNode = newDoc.importNode(nodeList.item(0),true); rootNode.appendChild(tmpNode); - } - + } + }if (settingsDoc !=null){ nodeList= settingsDoc.getElementsByTagName(TAG_OFFICE_SETTINGS); if (nodeList.getLength()>0){ @@ -820,18 +820,18 @@ public abstract class OfficeDocument tmpNode = newDoc.importNode(nodeList.item(0),true); rootNode.appendChild(tmpNode); } - - nodeList= contentDoc.getElementsByTagName(TAG_OFFICE_BODY); + + nodeList= contentDoc.getElementsByTagName(TAG_OFFICE_BODY); if (nodeList.getLength()>0){ tmpNode = newDoc.importNode(nodeList.item(0),true); rootNode.appendChild(tmpNode); } } - + byte contentBytes[] = docToBytes(newDoc); //System.out.println(new String(contentBytes)); os.write(contentBytes); - } + } catch(Exception exc){ System.out.println("\nException in OfficeDocument.write():" +exc); } @@ -861,9 +861,9 @@ public abstract class OfficeDocument java.lang.reflect.Constructor con; java.lang.reflect.Method meth; - + String domImpl = doc.getClass().getName(); - + /* * We may have multiple XML parsers in the Classpath. * Depending on which one is first, the actual type of @@ -874,53 +874,53 @@ public abstract class OfficeDocument try { // First of all try for JAXP 1.0 if (domImpl.equals("com.sun.xml.tree.XmlDocument")) { - + Debug.log(Debug.INFO, "Using JAXP"); - + Class jaxpDoc = Class.forName("com.sun.xml.tree.XmlDocument"); - + // The method is in the XMLDocument class itself, not a helper - meth = jaxpDoc.getMethod("write", + meth = jaxpDoc.getMethod("write", new Class[] { Class.forName("java.io.OutputStream") } ); - + meth.invoke(doc, new Object [] { baos } ); } else if (domImpl.equals("org.apache.crimson.tree.XmlDocument")) { Debug.log(Debug.INFO, "Using Crimson"); - + Class crimsonDoc = Class.forName("org.apache.crimson.tree.XmlDocument"); // The method is in the XMLDocument class itself, not a helper - meth = crimsonDoc.getMethod("write", + meth = crimsonDoc.getMethod("write", new Class[] { Class.forName("java.io.OutputStream") } ); - - meth.invoke(doc, new Object [] { baos } ); + + meth.invoke(doc, new Object [] { baos } ); } - else if (domImpl.equals("org.apache.xerces.dom.DocumentImpl") + else if (domImpl.equals("org.apache.xerces.dom.DocumentImpl") || domImpl.equals("org.apache.xerces.dom.DeferredDocumentImpl")) { - + Debug.log(Debug.INFO, "Using Xerces"); - + // Try for Xerces - Class xercesSer = + Class xercesSer = Class.forName("org.apache.xml.serialize.XMLSerializer"); - + // Get the OutputStream constructor // May want to use the OutputFormat parameter at some stage too - con = xercesSer.getConstructor(new Class [] + con = xercesSer.getConstructor(new Class [] { Class.forName("java.io.OutputStream"), Class.forName("org.apache.xml.serialize.OutputFormat") } ); - - + + // Get the serialize method - meth = xercesSer.getMethod("serialize", - new Class [] { Class.forName("org.w3c.dom.Document") } ); - - + meth = xercesSer.getMethod("serialize", + new Class [] { Class.forName("org.w3c.dom.Document") } ); + + // Get an instance Object serializer = con.newInstance(new Object [] { baos, null } ); - - + + // Now call serialize to write the document meth.invoke(serializer, new Object [] { doc } ); } @@ -932,7 +932,7 @@ public abstract class OfficeDocument // Get the serialize method meth = gnuSer.getMethod("serialize", new Class [] { Class.forName("org.w3c.dom.Node"), - Class.forName("java.io.OutputStream") } ); + Class.forName("java.io.OutputStream") } ); // Get an instance Object serializer = gnuSer.newInstance(); @@ -951,7 +951,7 @@ public abstract class OfficeDocument return writer.toString().getBytes(); } catch (Exception e) { - // We don't have another parser + // We don't have another parser throw new IOException("No appropriate API (JAXP/Xerces) to serialize XML document: " + domImpl); } } @@ -981,7 +981,7 @@ public abstract class OfficeDocument contentDoc = createDOM(TAG_OFFICE_DOCUMENT_CONTENT); - // this is a work-around for a bug in Office6.0 - not really + // this is a work-around for a bug in Office6.0 - not really // needed but StarCalc 6.0 will crash without this tag. Element root = contentDoc.getDocumentElement(); @@ -1005,7 +1005,7 @@ public abstract class OfficeDocument settingsDoc = createSettingsDOM(TAG_OFFICE_DOCUMENT_SETTINGS); - // this is a work-around for a bug in Office6.0 - not really + // this is a work-around for a bug in Office6.0 - not really // needed but StarCalc 6.0 will crash without this tag. Element root = settingsDoc.getDocumentElement(); @@ -1204,7 +1204,7 @@ public abstract class OfficeDocument * * <p>This hacked code needs to be changed later on.</p> * - * <p>Issue: the new oasis input file stream means + * <p>Issue: the new oasis input file stream means * that the old input stream fails. see #i33702# </p> * * @param is <code>InputStream</code> to be filtered. @@ -1221,7 +1221,7 @@ public abstract class OfficeDocument int n = 0; while ((n=br.read(charArray, 0, charArray.length)) > 0) sBuf.append(charArray, 0, n); - + // ensure there is no trailing garbage after the end of the stream. int sIndex = sBuf.lastIndexOf("</office:document>"); sBuf.delete(sIndex, sBuf.length()); @@ -1229,36 +1229,36 @@ public abstract class OfficeDocument StringReader r = new StringReader(sBuf.toString()); return r; } - - + + /** * Method to create the initial entries in the manifest.xml file stored * in an SX? file. */ private void initManifestDOM() throws IOException { - + try { DocumentBuilder builder = factory.newDocumentBuilder(); DOMImplementation domImpl = builder.getDOMImplementation(); - DocumentType docType = domImpl.createDocumentType(TAG_MANIFEST_ROOT, - "-//OpenOffice.org//DTD Manifest 1.0//EN", + DocumentType docType = domImpl.createDocumentType(TAG_MANIFEST_ROOT, + "-//OpenOffice.org//DTD Manifest 1.0//EN", "Manifest.dtd"); manifestDoc = domImpl.createDocument("manifest", TAG_MANIFEST_ROOT, docType); } catch (ParserConfigurationException ex) { throw new OfficeDocumentException(ex); } - + // Add the <manifest:manifest> entry Element manifestRoot = manifestDoc.getDocumentElement(); - - manifestRoot.setAttribute("xmlns:manifest", "http://openoffice.org/2001/manifest"); - - Element docRoot = manifestDoc.createElement(TAG_MANIFEST_FILE); + + manifestRoot.setAttribute("xmlns:manifest", "http://openoffice.org/2001/manifest"); + + Element docRoot = manifestDoc.createElement(TAG_MANIFEST_FILE); docRoot.setAttribute(ATTRIBUTE_MANIFEST_FILE_PATH, "/"); docRoot.setAttribute(ATTRIBUTE_MANIFEST_FILE_TYPE, getDocumentMimeType()); - + manifestRoot.appendChild(docRoot); } } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocumentException.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocumentException.java index e4c6f20e8bc8..2c8ae71f2af3 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocumentException.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocumentException.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeZip.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeZip.java index 1237d07dbadd..9752650533a1 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeZip.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeZip.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -133,7 +133,7 @@ class OfficeZip { else if (name.equalsIgnoreCase(MANIFESTXML)) { manifestIndex = i; } - + } zis.close(); @@ -186,7 +186,7 @@ class OfficeZip { byte[] getSettingsXMLBytes() { return getEntryBytes(settingsIndex); } - + /** * This method returns the MANIFESTXML file in a <code>byte</code> array. * It returns null if there is no MANIFESTXML in this zip file. @@ -199,7 +199,7 @@ class OfficeZip { /** * This method returns the bytes corresponding to the entry named in the - * parameter. + * parameter. * * @param name The name of the entry in the Zip file to retrieve. * @@ -207,30 +207,30 @@ class OfficeZip { * <code>null</code> if no entry is found. */ byte[] getNamedBytes(String name) { - + // The list is not sorted, and sorting it for a binary search would // invalidate the indices stored for the main files. - - // Could improve performance by caching the name and index when + + // Could improve performance by caching the name and index when // iterating through the ZipFile in read(). for (int i = 0; i < entryList.size(); i++) { Entry e = (Entry)entryList.get(i); - + if (e.zipEntry.getName().equals(name)) { return getEntryBytes(i); } } - + return null; } - - + + /** - * This method sets the bytes for the named entry. It searches for a - * matching entry in the LinkedList. If no entry is found, a new one is + * This method sets the bytes for the named entry. It searches for a + * matching entry in the LinkedList. If no entry is found, a new one is * created. * - * Writing of data is defferred to setEntryBytes(). + * Writing of data is defferred to setEntryBytes(). * * @param name The name of the entry to search for. * @param bytes The new data to write. @@ -238,13 +238,13 @@ class OfficeZip { void setNamedBytes(String name, byte[] bytes) { for (int i = 0; i < entryList.size(); i++) { Entry e = (Entry)entryList.get(i); - + if (e.zipEntry.getName().equals(name)) { setEntryBytes(i, bytes, name); return; } } - + // If we're here, no entry was found. Call setEntryBytes with an index // of -1 to insert a new entry. setEntryBytes(-1, bytes, name); @@ -259,12 +259,12 @@ class OfficeZip { * @param index Index of <code>Entry</code> object in * <code>entryList</code>. * - * @return <code>byte</code> array associated in that + * @return <code>byte</code> array associated in that * <code>Entry</code> object or null, if there is * not such <code>Entry</code>. */ private byte[] getEntryBytes(int index) { - + byte[] bytes = null; if (index > -1) { @@ -326,16 +326,16 @@ class OfficeZip { settingsIndex = setEntryBytes(settingsIndex, bytes, SETTINGSXML); } - + /** * Set or replace the <code>byte</code> array for the MANIFESTXML file. - * + * * @param bytes <code>byte</code> array for the MANIFESTXML file. */ void setManifestXMLBytes(byte bytes[]) { manifestIndex = setEntryBytes(manifestIndex, bytes, MANIFESTXML); } - + /** * <p>Used by the <code>setContentXMLBytes</code> method and * the <code>setStyleXMLBytes</code> to either replace an diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/ParaStyle.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/ParaStyle.java index 3955222116e6..662a542d0e7b 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/ParaStyle.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/ParaStyle.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -103,19 +103,19 @@ class lineHeight extends conversionAlgorithm { */ class alignment extends conversionAlgorithm { int I(String value) { - if (value.equals("end")) + if (value.equals("end")) return ParaStyle.ALIGN_RIGHT; - if (value.equals("right")) + if (value.equals("right")) return ParaStyle.ALIGN_RIGHT; - if (value.equals("center")) + if (value.equals("center")) return ParaStyle.ALIGN_CENTER; - if (value.equals("justify")) + if (value.equals("justify")) return ParaStyle.ALIGN_JUST; - if (value.equals("justified")) + if (value.equals("justified")) return ParaStyle.ALIGN_JUST; - if (value.equals("start")) + if (value.equals("start")) return ParaStyle.ALIGN_LEFT; - if (value.equals("left")) + if (value.equals("left")) return ParaStyle.ALIGN_LEFT; Debug.log(Debug.ERROR, "Unknown string (" + value + ") in alignment.I()"); @@ -140,7 +140,7 @@ class alignment extends conversionAlgorithm { * </td></tr><tr><td> * TEXT_INDENT </td><td>mm * 100 (first line indent) * </td></tr><tr><td> - * LINE_HEIGHT </td><td>mm * 100, unless or'ed with LH_PCT, in which + * LINE_HEIGHT </td><td>mm * 100, unless or'ed with LH_PCT, in which * case it is a percentage (e.g. 200% for double spacing) * Can also be or'ed with LH_ATLEAST. Value is stored * in bits indicated by LH_VALUEMASK. @@ -151,7 +151,7 @@ class alignment extends conversionAlgorithm { * @author David Proulx */ public class ParaStyle extends Style implements Cloneable { - + /** The left margin property. */ public static final int MARGIN_LEFT = 0; /** The right margin property. */ @@ -168,8 +168,8 @@ public class ParaStyle extends Style implements Cloneable { public static final int TEXT_ALIGN = 6; // This must always be one more than highest property /** Total number of properties. */ - protected static final int NR_PROPERTIES = 7; - + protected static final int NR_PROPERTIES = 7; + /** * Array of flags indicating which attributes are set for this * paragraph <code>Style</code>. @@ -187,7 +187,7 @@ public class ParaStyle extends Style implements Cloneable { "fo:line-height", "fo:text-align" }; - + /** Array of attribute structures for this paragraph <code>Style</code>. */ protected Class algor[] = { horizSize.class, @@ -198,7 +198,7 @@ public class ParaStyle extends Style implements Cloneable { lineHeight.class, alignment.class }; - + /** Align right. */ public static final int ALIGN_RIGHT = 1; /** Align center. */ @@ -207,14 +207,14 @@ public class ParaStyle extends Style implements Cloneable { public static final int ALIGN_JUST = 3; /** Align left. */ public static final int ALIGN_LEFT = 4; - + /** Line height percentage. */ public static final int LH_PCT = 0x40000000; /** Line height minimum value. */ public static final int LH_ATLEAST = 0x20000000; /** Line height mask. */ public static final int LH_VALUEMASK = 0x00FFFFFF; - + /** Ignored tags. */ private static String[] ignored = { "style:font-name", "fo:font-size", "fo:font-weight", "fo:color", @@ -226,7 +226,7 @@ public class ParaStyle extends Style implements Cloneable { "style:line-break", "fo:keep-with-next", "fo:font-style", "text:number-lines", "text:line-number" }; - + /** * Constructor for use when going from DOM to client device format. @@ -238,9 +238,9 @@ public class ParaStyle extends Style implements Cloneable { * looking up ancestor <code>Style</code> objects. */ public ParaStyle(Node node, StyleCatalog sc) { - + super(node, sc); - + // Look for children. Only ones we care about are "style:properties" // nodes. If any are found, recursively traverse them, passing // along the style element to add properties to. @@ -264,8 +264,8 @@ public class ParaStyle extends Style implements Cloneable { } } } - - + + /** * Constructor for use when going from client device format to DOM. * @@ -287,9 +287,9 @@ public class ParaStyle extends Style implements Cloneable { setAttribute(attribs[i], values[i]); } - + /** - * Alternate constructor for use when going from client device + * Alternate constructor for use when going from client device * format to DOM. * * @param name Name of the <code>Style</code>. Can be null. @@ -309,8 +309,8 @@ public class ParaStyle extends Style implements Cloneable { for (int i = 0; i < attribs.length; i++) setAttribute(attribs[i], values[i]); } - - + + /** * This code checks whether an attribute is one that we * intentionally ignore. @@ -321,16 +321,16 @@ public class ParaStyle extends Style implements Cloneable { */ private boolean isIgnored(String attribute) { for (int i = 0; i < ignored.length; i++) { - if (ignored[i].equals(attribute)) + if (ignored[i].equals(attribute)) return true; } return false; } - + /** * Set an attribute for this paragraph <code>Style</code>. - * + * * @param attr The attribute to set. * @param value The attribute value to set. */ @@ -345,10 +345,10 @@ public class ParaStyle extends Style implements Cloneable { Debug.log(Debug.INFO, "ParaStyle Unhandled: " + attr + "=" + value); } - + /** * Check whether an attribute is set in this <code>Style</code>. - * + * * @param attrIndex The attribute index to check. * * @return true if the attribute at specified index is set, @@ -357,8 +357,8 @@ public class ParaStyle extends Style implements Cloneable { public boolean isAttributeSet(int attrIndex) { return isSet[attrIndex]; } - - + + /** * Get the value of an integer attribute. * @@ -367,12 +367,12 @@ public class ParaStyle extends Style implements Cloneable { * @return Value of the attribute, 0 if not set. */ public int getAttribute(int attrIndex) { - if (isSet[attrIndex]) + if (isSet[attrIndex]) return value[attrIndex]; else return 0; } - - + + /** * Set an attribute for this paragraph <code>Style</code>. * @@ -387,7 +387,7 @@ public class ParaStyle extends Style implements Cloneable { Debug.log(Debug.ERROR, "Instantiation error", e); } } - + /** * Return the <code>Style</code> in use. @@ -405,14 +405,14 @@ public class ParaStyle extends Style implements Cloneable { // Look up the parent style. (If there is no style catalog // specified, we can't do any lookups). ParaStyle parentStyle = null; - if (sc != null) { + if (sc != null) { if (parent != null) { parentStyle = (ParaStyle)sc.lookup(parent, family, null, this.getClass()); if (parentStyle == null) - Debug.log(Debug.ERROR, "parent style lookup of " + Debug.log(Debug.ERROR, "parent style lookup of " + parent + " failed!"); - else + else parentStyle = (ParaStyle)parentStyle.getResolved(); } else if (!name.equals("DEFAULT_STYLE")) { parentStyle = (ParaStyle)sc.lookup("DEFAULT_STYLE", null, null, @@ -434,7 +434,7 @@ public class ParaStyle extends Style implements Cloneable { return resolved; } - + /** * Private function to return the value as an element in * a Comma Separated Value (CSV) format. @@ -449,8 +449,8 @@ public class ParaStyle extends Style implements Cloneable { else return "\"\","; } - - + + /** * Private function to return the value as a last element in * a Comma Separated Value (CSV) format. @@ -466,7 +466,7 @@ public class ParaStyle extends Style implements Cloneable { return "\"\""; } - + /** * Print a Comma Separated Value (CSV) header line for the * spreadsheet dump. @@ -478,7 +478,7 @@ public class ParaStyle extends Style implements Cloneable { + toCSV("line height") + toLastCSV("txt align")); } - + /** * Dump this <code>Style</code> as a Comma Separated Value (CSV) * line. @@ -489,14 +489,14 @@ public class ParaStyle extends Style implements Cloneable { if (isSet[index]) { attributes += toCSV("" + value[index]); } - else + else attributes += toCSV(null); // unspecified } System.out.println(toCSV(name) + toCSV(family) + toCSV(parent) + attributes + toLastCSV(null)); } - - + + /** * Create the <code>Node</code> with the specified elements. * @@ -511,11 +511,11 @@ public class ParaStyle extends Style implements Cloneable { writeAttributes(node); return node; } - + /** * Return true if <code>style</code> is a subset of the - * <code>Style</code>. + * <code>Style</code>. * * @param style <code>Style</code> to check. * @@ -523,40 +523,40 @@ public class ParaStyle extends Style implements Cloneable { * otherwise. */ public boolean isSubset(Style style) { - - if (!super.isSubset(style)) + + if (!super.isSubset(style)) return false; - if (!this.getClass().isAssignableFrom(style.getClass())) + if (!this.getClass().isAssignableFrom(style.getClass())) return false; ParaStyle ps = (ParaStyle)style; - + for (int i = 0; i < NR_PROPERTIES; i++) { if (ps.isSet[i]) { // if (!isSet[i]) return false; - + if (i < NR_PROPERTIES - 1) { - // Compare the actual values. We allow a margin of error + // Compare the actual values. We allow a margin of error // here because the conversion loses precision. int diff; - if (value[i] > ps.value[i]) + if (value[i] > ps.value[i]) diff = value[i] - ps.value[i]; - else + else diff = ps.value[i] - value[i]; - if (diff > 32) + if (diff > 32) return false; } else { if (i == TEXT_ALIGN) - if ((value[i] == 0) && (ps.value[i] == 4)) + if ((value[i] == 0) && (ps.value[i] == 4)) continue; - if (value[i] != ps.value[i]) + if (value[i] != ps.value[i]) return false; } } } return true; } - - + + /** * Add <code>Style</code> attributes to the given * <code>Node</code>. This may involve writing child @@ -584,7 +584,7 @@ public class ParaStyle extends Style implements Cloneable { } node.setAttribute(attrName[LINE_HEIGHT], stringVal); } - + if (isSet[TEXT_ALIGN]) { String val; switch (value[TEXT_ALIGN]) { diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/Style.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/Style.java index 5af96be0c370..cc1e1d3d530c 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/Style.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/Style.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -37,11 +37,11 @@ import org.w3c.dom.NamedNodeMap; * <code>ParaStyle</code> are used. * * @author David Proulx - * @see <a href="TextStyle.html">TextStyle</a>, + * @see <a href="TextStyle.html">TextStyle</a>, * <a href="ParaStyle.html">ParaStyle</a> */ public class Style { - + /** Name of the <code>Style</code>. */ protected String name = null; /** Family of the <code>Style</code>. */ @@ -49,22 +49,22 @@ public class Style { /** Parent of the <code>Style</code>. */ protected String parent = null; - /** + /** * A reference to the <code>StyleCatalog</code> to be used for * looking up ancestor <code>Style</code> objects. */ protected StyleCatalog sc; - + /** * Constructor for use when going from DOM to client device format. * - * @param node A <i>style:style</i> or <i>style:default-style</i> + * @param node A <i>style:style</i> or <i>style:default-style</i> * <code>Node</code> from the document being parsed. * No checking of <code>Node</code> is done, so if it * is not of the proper type the results will be * unpredictable. - * @param sc The <code>StyleCatalog</code>, which is used for + * @param sc The <code>StyleCatalog</code>, which is used for * looking up ancestor <code>Style</code> objects. */ public Style(Node node, StyleCatalog sc) { @@ -86,12 +86,12 @@ public class Style { name = attr.getNodeValue(); } else if (attr.getNodeName().equals("style:parent-style-name")) parent = attr.getNodeValue(); - + } } } - + /** * Constructor for use when going from client device format to DOM. * @@ -99,7 +99,7 @@ public class Style { * @param family Family of the <code>Style</code> - usually * <i>paragraph</i>, <i>text</i>, etc. Can be null. * @param parent Name of the parent <code>Style</code>, or null if none. - * @param sc The <code>StyleCatalog</code>, which is used for + * @param sc The <code>StyleCatalog</code>, which is used for * looking up ancestor <code>Style</code> objects. */ public Style(String name, String family, String parent, StyleCatalog sc) { @@ -108,19 +108,19 @@ public class Style { this.family = family; this.parent = parent; } - + /** * Set the <code>StyleCatalog</code> to be used when looking up the * <code>Style</code> parent. * - * @param sc The <code>StyleCatalog</code>, which is used for + * @param sc The <code>StyleCatalog</code>, which is used for * looking up ancestor <code>Style</code> objects. */ public void setCatalog(StyleCatalog sc) { this.sc = sc; } - + /** * Returns the name of this <code>Style</code>. @@ -131,8 +131,8 @@ public class Style { return name; } - - /** + + /** * Sets the name of this <code>Style</code>. * * @param newName The new name of this <code>Style</code>. @@ -141,7 +141,7 @@ public class Style { name = newName; } - + /** * Return the family of this <code>Style</code>. * @@ -150,7 +150,7 @@ public class Style { public String getFamily() { return family; } - + /** * Return the name of the parent of this <code>Style</code>. * @@ -159,8 +159,8 @@ public class Style { public String getParent() { return parent; } - - + + /** * Return a <code>Style</code> object corresponding to this one, but with * all of the inherited information from parent <code>Style</code> @@ -175,7 +175,7 @@ public class Style { return new Style(name, family, parent, sc); } - + /** * Write a <code>Node</code> in <code>parentDoc</code> * representing this <code>Style</code>. Note that the @@ -189,8 +189,8 @@ public class Style { // DJP: write this! Should call writeAttributes() return null; } - - + + /** * Write this <code>Style</code> object's attributes to the given * <code>Node</code>. This may involve writing child @@ -204,7 +204,7 @@ public class Style { */ public void writeAttributes(Node node) { } - + /** * Return true if <code>Style</code> is a subset of this one. Note diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/StyleCatalog.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/StyleCatalog.java index effbb5548014..c783d366a68b 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/StyleCatalog.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/StyleCatalog.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -49,9 +49,9 @@ import java.lang.reflect.Constructor; * @see <a href="Style.html">Style</a> */ public class StyleCatalog { - + private Vector styles; // The actual styles - + /** * Constructor * @@ -61,8 +61,8 @@ public class StyleCatalog { public StyleCatalog(int initialEntries) { styles = new Vector(initialEntries); } - - + + /** * <p>Parse the <code>Document</code> starting from <code>node</code> * and working downward, and add all styles found, so long as their @@ -74,16 +74,16 @@ public class StyleCatalog { * classes specified for a particular family.</p> * * <p>If <code>defaultClass</code> is non-null, then all styles that - * are found will be added. Any <code>Style</code> whose family is + * are found will be added. Any <code>Style</code> whose family is * not listed in <code>families</code> will be added using defaultClass, - * which, of course, must be a subclass of <code>Style</code>. + * which, of course, must be a subclass of <code>Style</code>. * If <code>alwaysCreateDefault</code> is true, then a class * of type <code>defaultClass</code> will always be created, * regardless of whether there was also a match in * <code>families</code>.</p> * * <p>DJP Todo: make it recursive so that <code>node</code> can be - * higher up in the <code>Document</code> tree.</p> + * higher up in the <code>Document</code> tree.</p> * * @param node The node to be searched for * <code>Style</code> objects. @@ -91,27 +91,27 @@ public class StyleCatalog { * to add. * @param classes An array of class types corresponding * to the families array. - * @param defaultClass All <code>Style</code> objects that are + * @param defaultClass All <code>Style</code> objects that are * found are added to this class. * @param alwaysCreateDefault A class of type <code>defaultClass</code> * will always be created, regardless of - * whether there is a match in the + * whether there is a match in the * families array. */ public void add(Node node, String families[], Class classes[], Class defaultClass, boolean alwaysCreateDefault) { - if (node == null) + if (node == null) return; - if (families == null) + if (families == null) families = new String[0]; - if (classes == null) + if (classes == null) classes = new Class[0]; if (node.hasChildNodes()) { NodeList children = node.getChildNodes(); int len = children.getLength(); - + for (int i = 0; i < len; i++) { boolean found = false; Node child = children.item(i); @@ -122,7 +122,7 @@ public class StyleCatalog { Debug.log(Debug.ERROR, "familyName is null!"); continue; } - + for (int j = 0; j < families.length; j++) { if (families[j].equals(familyName)) { Class styleClass = classes[j]; @@ -136,8 +136,8 @@ public class StyleCatalog { } } } - - + + /** * Call the constructor of class <code>cls</code> with parameters * <code>node</code>, and add the resulting <code>Style</code> to @@ -156,22 +156,22 @@ public class StyleCatalog { p[0] = node; p[1] = this; styles.add(c.newInstance(p)); - } catch (Exception e) { + } catch (Exception e) { Debug.log(Debug.ERROR, "Exception when calling constructor", e); } } - - + + /** * Add a <code>Style</code> to the catalog. - * + * * @param s The <code>Style</code> to add. */ public void add(Style s) { styles.addElement(s); } - - + + /** * Return the first <code>Style</code> matching the specified names. * @@ -187,29 +187,29 @@ public class StyleCatalog { * @return <code>Style</code> value if all parameters match, * null otherwise */ - public Style lookup(String name, String family, String parent, + public Style lookup(String name, String family, String parent, Class styleClass) { int nStyles = styles.size(); for (int i = 0; i < nStyles; i++) { Style s = (Style)styles.elementAt(i); - if ((name != null) && (s.getName() != null) - && (!s.getName().equals(name))) + if ((name != null) && (s.getName() != null) + && (!s.getName().equals(name))) continue; - if ((family != null) && (s.getFamily() != null) - && (!s.getFamily().equals(family))) + if ((family != null) && (s.getFamily() != null) + && (!s.getFamily().equals(family))) continue; - if ((parent != null) && (s.getParent() != null) - && (!s.getParent().equals(parent))) + if ((parent != null) && (s.getParent() != null) + && (!s.getParent().equals(parent))) continue; - if ((styleClass != null) && (s.getClass() != styleClass)) + if ((styleClass != null) && (s.getClass() != styleClass)) continue; if (s.getName() == null) continue; // DJP: workaround for "null name" problem return s; } return null; // none found } - - + + /** * Given a <code>Style</code> <code>s<code> return all * <code>Style</code> objects that match. @@ -220,7 +220,7 @@ public class StyleCatalog { * empty array if none match. */ public Style[] getMatching(Style s) { - + // Run through and count the matching styles so we know how big of // an array to allocate. int matchCount = 0; @@ -229,7 +229,7 @@ public class StyleCatalog { Style p = ((Style)styles.elementAt(j)).getResolved(); if (p.isSubset(s)) matchCount++; } - + // Now allocate the array, and run through again, populating it. Style[] matchArray = new Style[matchCount]; matchCount = 0; @@ -239,7 +239,7 @@ public class StyleCatalog { } return matchArray; } - + /** * Given a <code>Style</code> <code>s</code>, return the @@ -255,8 +255,8 @@ public class StyleCatalog { // DJP ToDo: implement this return null; } - - + + /** * <p>Create a <code>Node</code> named <code>name</code> in * <code>Document</code> <code>parentDoc</code>, and write the @@ -274,33 +274,33 @@ public class StyleCatalog { */ public Element writeNode(org.w3c.dom.Document parentDoc, String name) { Element rootNode = parentDoc.createElement(name); - + int len = styles.size(); for (int j = 0; j < len; j++) { Style s = (Style)styles.get(j); - + Element styleNode = parentDoc.createElement("style:style"); - + if (s.getName() != null) styleNode.setAttribute("style:name", s.getName()); if (s.getParent() != null) styleNode.setAttribute("style:parent-style-name", s.getParent()); if (s.getFamily() != null) styleNode.setAttribute("style:family", s.getFamily()); - + Element propertiesNode = (Element) s.createNode(parentDoc, "style:properties"); - // if (propertiesNode.getFirstChild() != null) + // if (propertiesNode.getFirstChild() != null) // DJP: only add node if has children OR attributes if (propertiesNode != null) styleNode.appendChild(propertiesNode); - + rootNode.appendChild(styleNode); } - + return rootNode; } - + /** * Dump the <code>Style</code> table in Comma Separated Value (CSV) * format @@ -326,10 +326,10 @@ public class StyleCatalog { ((ParaStyle)s).dumpCSV(); } } - + } - - + + /** * Check whether a given node represents a <code>Style</code> * that should be added to the catalog, and if so, return the @@ -364,7 +364,7 @@ public class StyleCatalog { return null; } - + /** * Find the family attribute of a <code>Style</code> <code>Node</code>. * diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/TextStyle.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/TextStyle.java index 16f18cc7189e..91926310776c 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/TextStyle.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/TextStyle.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -44,7 +44,7 @@ import org.openoffice.xmerge.util.Debug; * @author David Proulx */ public class TextStyle extends Style implements Cloneable { - + final protected static int FIRST_ATTR = 0x01; /** Indicates <i>bold</i> text. */ final public static int BOLD = 0x01; @@ -60,12 +60,12 @@ public class TextStyle extends Style implements Cloneable { final public static int SUBSCRIPT = 0x20; /** Indicates the last attribute. */ final protected static int LAST_ATTR = 0x20; - + /** Values of text attributes. */ protected int values = 0; /** Bitwise mask of text attributes. */ protected int mask = 0; - + /** Font size in points. */ protected int sizeInPoints = 0; /** Font name. */ @@ -74,7 +74,7 @@ public class TextStyle extends Style implements Cloneable { protected Color fontColor = null; /** Background <code>Color</code>. */ protected Color bgColor = null; - + /** * Constructor for use when going from DOM to client device format. * @@ -86,7 +86,7 @@ public class TextStyle extends Style implements Cloneable { */ public TextStyle(Node node, StyleCatalog sc) { super(node, sc); - + // Run through the attributes of this node, saving // the ones we're interested in. NamedNodeMap attrNodes = node.getAttributes(); @@ -97,7 +97,7 @@ public class TextStyle extends Style implements Cloneable { handleAttribute(attr.getNodeName(), attr.getNodeValue()); } } - + // Look for children. Only ones we care about are "style:properties" // nodes. If any are found, recursively traverse them, passing // along the style element to add properties to. @@ -121,8 +121,8 @@ public class TextStyle extends Style implements Cloneable { } } } - - + + /** * Constructor for use when going from client device format to DOM * @@ -186,7 +186,7 @@ public class TextStyle extends Style implements Cloneable { } return new Color(red, green, blue); } - + /** * Set an attribute. @@ -195,32 +195,32 @@ public class TextStyle extends Style implements Cloneable { * @param value The attribute value to set. */ private void handleAttribute(String attr, String value) { - + if (attr.equals("fo:font-weight")) { if (value.equals("bold")) turnAttributesOn(BOLD); else if (value.equals("normal")) turnAttributesOff(BOLD); } - + else if (attr.equals("fo:font-style")) { if (value.equals("italic")) turnAttributesOn(ITALIC); else if (value.equals("oblique")) turnAttributesOn(ITALIC); else if (value.equals("normal")) turnAttributesOff(ITALIC); } - + else if (attr.equals("style:text-underline")) { if (value.equals("none")) turnAttributesOff(UNDERLINE); else turnAttributesOn(UNDERLINE); } - + else if (attr.equals("style:text-crossing-out")) { if (value.equals("none")) turnAttributesOff(STRIKETHRU); else turnAttributesOn(STRIKETHRU); } - + else if (attr.equals("style:text-position")) { if (value.startsWith("super ")) turnAttributesOn(SUPERSCRIPT); @@ -244,17 +244,17 @@ public class TextStyle extends Style implements Cloneable { } } } - + else if (attr.equals("fo:font-size")) { if (value.endsWith("pt")) { String num = value.substring(0, value.length() - 2); sizeInPoints = Integer.parseInt(num); } } - + else if (attr.equals("style:font-name")) fontName = value; - + else if (attr.equals("fo:color")) fontColor = parseColorString(value); @@ -262,13 +262,13 @@ public class TextStyle extends Style implements Cloneable { bgColor = parseColorString(value); else if (isIgnored(attr)) {} - + else { Debug.log(Debug.INFO, "TextStyle Unhandled: " + attr + "=" + value); } } - - + + /** * Return true if text <code>attribute</code> is set in this * <code>Style</code>. An attribute that is set may have a @@ -283,24 +283,24 @@ public class TextStyle extends Style implements Cloneable { public boolean isSet(int attribute) { return (!((mask & attribute) == 0)); } - - + + /** * Return true if the <code>attribute</code> is set to <i>on</i> * * @param attribute Attribute to check ({@link #BOLD}, * {@link #ITALIC}, etc.) * - * @return true if <code>attribute</code> is set to <i>on</i>, + * @return true if <code>attribute</code> is set to <i>on</i>, * otherwise false. */ public boolean getAttribute(int attribute) { - if ((mask & attribute) == 0) + if ((mask & attribute) == 0) return false; return (!((values & attribute) == 0)); } - - + + /** * Return the font size for this <code>Style</code>. * @@ -309,8 +309,8 @@ public class TextStyle extends Style implements Cloneable { public int getFontSize() { return sizeInPoints; } - - + + /** * Return the name of the font for this <code>Style</code>. * @@ -320,7 +320,7 @@ public class TextStyle extends Style implements Cloneable { public String getFontName() { return fontName; } - + /** * Return the font <code>Color</code> for this <code>Style</code>. @@ -354,15 +354,15 @@ public class TextStyle extends Style implements Cloneable { * @param backgroundColor The background <code>Color</code> to set. */ public void setColors(Color fontColor, Color backgroundColor) { - if (fontColor != null) + if (fontColor != null) this.fontColor = fontColor; if (backgroundColor != null) this.bgColor = backgroundColor; } - + /** - * Return a <code>Style</code> object corresponding to this one, + * Return a <code>Style</code> object corresponding to this one, * but with all of the inherited information from parent * <code>Style</code> objects filled in. The object returned will * be a new object, not a reference to this object, even if it does @@ -379,7 +379,7 @@ public class TextStyle extends Style implements Cloneable { } catch (Exception e) { Debug.log(Debug.ERROR, "Can't clone", e); } - + // Look up the parentStyle. (If there is no style catalog // specified, we can't do any lookups.) TextStyle parentStyle = null; @@ -398,12 +398,12 @@ public class TextStyle extends Style implements Cloneable { null, this.getClass()); } } - + // If we found a parent, for any attributes which we don't have // set, try to get the values from the parent. if (parentStyle != null) { parentStyle = (TextStyle)parentStyle.getResolved(); - + if ((sizeInPoints == 0) && (parentStyle.sizeInPoints != 0)) resolved.sizeInPoints = parentStyle.sizeInPoints; if ((fontName == null) && (parentStyle.fontName != null)) @@ -418,12 +418,12 @@ public class TextStyle extends Style implements Cloneable { resolved.values |= (parentStyle.mask & m); } } - + } return resolved; } - - + + /** * Set one or more text attributes to <i>on</i>. * @@ -433,8 +433,8 @@ public class TextStyle extends Style implements Cloneable { mask |= flags; values |= flags; } - - + + /** * Set one or more text attributes to <i>off</i>. * @@ -444,7 +444,7 @@ public class TextStyle extends Style implements Cloneable { mask |= flags; values &= ~flags; } - + /** * Private function to return the value as an element in @@ -460,8 +460,8 @@ public class TextStyle extends Style implements Cloneable { else return "\"\","; } - - + + /** * Private function to return the value as a last element in * a Comma Separated Value (CSV) format. @@ -476,8 +476,8 @@ public class TextStyle extends Style implements Cloneable { else return "\"\""; } - - + + /** * Print a Comma Separated Value (CSV) header line for the * spreadsheet dump. @@ -488,8 +488,8 @@ public class TextStyle extends Style implements Cloneable { + toCSV("Bold") + toCSV("Italic") + toCSV("Underline") + toCSV("Strikethru") + toCSV("Superscript") + toLastCSV("Subscript")); } - - + + /** * Dump this <code>Style</code> as a Comma Separated Value (CSV) line. */ @@ -503,8 +503,8 @@ public class TextStyle extends Style implements Cloneable { System.out.println(toCSV(name) + toCSV(family) + toCSV(parent) + toCSV(fontName) + toCSV("" + sizeInPoints) + attributes + toLastCSV(null)); } - - + + /** * Create a new <code>Node</code> in the <code>Document</code>, and * write this <code>Style</code> to it. @@ -521,10 +521,10 @@ public class TextStyle extends Style implements Cloneable { writeAttributes(node); return node; } - - + + /** - * Return true if <code>style</code> specifies as much or less + * Return true if <code>style</code> specifies as much or less * than this <code>Style</code>, and nothing it specifies * contradicts this <code>Style</code>. * @@ -534,43 +534,43 @@ public class TextStyle extends Style implements Cloneable { * otherwise. */ public boolean isSubset(Style style) { - if (style.getClass() != this.getClass()) + if (style.getClass() != this.getClass()) return false; TextStyle tStyle = (TextStyle)style; - - if (tStyle.values != values) + + if (tStyle.values != values) return false; - + if (tStyle.sizeInPoints != 0) { - if (sizeInPoints != tStyle.sizeInPoints) + if (sizeInPoints != tStyle.sizeInPoints) return false; } if (tStyle.fontName != null) { - if (fontName == null) + if (fontName == null) return false; - if (!fontName.equals(tStyle.fontName)) + if (!fontName.equals(tStyle.fontName)) return false; } if (tStyle.fontColor != null) { - if (fontColor == null) + if (fontColor == null) return false; - if (!fontColor.equals(tStyle.fontColor)) + if (!fontColor.equals(tStyle.fontColor)) return false; } if (tStyle.bgColor != null) { - if (bgColor == null) + if (bgColor == null) return false; - if (!bgColor.equals(tStyle.bgColor)) + if (!bgColor.equals(tStyle.bgColor)) return false; } return true; } - - + + /** * Write this <code>Style</code> object's attributes to a * <code>Node</code> in the <code>Document</code>. @@ -579,44 +579,44 @@ public class TextStyle extends Style implements Cloneable { * attributes. */ public void writeAttributes(Element node) { - + if ((mask & BOLD) != 0) if ((values & BOLD) != 0) node.setAttribute("fo:font-weight", "bold"); - + if ((mask & ITALIC) != 0) if ((values & ITALIC) != 0) node.setAttribute("fo:font-style", "italic"); - + if ((mask & UNDERLINE) != 0) if ((values & UNDERLINE) != 0) node.setAttribute("style:text-underline", "single"); - + if ((mask & STRIKETHRU) != 0) if ((values & STRIKETHRU) != 0) node.setAttribute("style:text-crossing-out", "single-line"); - + if ((mask & SUPERSCRIPT) != 0) if ((values & SUPERSCRIPT) != 0) node.setAttribute("style:text-position", "super 58%"); - + if ((mask & SUBSCRIPT) != 0) if ((values & SUBSCRIPT) != 0) node.setAttribute("style:text-position", "sub 58%"); - + if (sizeInPoints != 0) { Integer fs = new Integer(sizeInPoints); node.setAttribute("fo:font-size", fs.toString() + "pt"); } - + if (fontName != null) node.setAttribute("style:font-name", fontName); - + if (fontColor != null) node.setAttribute("fo:color", buildColorString(fontColor)); if (bgColor != null) - node.setAttribute("style:text-background-color", + node.setAttribute("style:text-background-color", buildColorString(bgColor)); } @@ -637,14 +637,14 @@ public class TextStyle extends Style implements Cloneable { String colorString = new String("#"); for (int i = 0; i <= 2; i++) { String xx = Integer.toHexString(v[i]); - if (xx.length() < 2) + if (xx.length() < 2) xx = "0" + xx; colorString += xx; } return colorString; } - - + + private static String[] ignored = { "style:text-autospace", "style:text-underline-color", "fo:margin-left", "fo:margin-right", "fo:text-indent", @@ -670,7 +670,7 @@ public class TextStyle extends Style implements Cloneable { */ private boolean isIgnored(String attribute) { for (int i = 0; i < ignored.length; i++) { - if (ignored[i].equals(attribute)) + if (ignored[i].equals(attribute)) return true; } return false; diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/BookSettings.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/BookSettings.java index 12c16d14f4b4..9c1ae2768524 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/BookSettings.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/BookSettings.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -40,7 +40,7 @@ import org.openoffice.xmerge.util.XmlUtil; /** * This is a class representing the different attributes for a worksheet - * contained in settings.xml. + * contained in settings.xml. * * @author Martin Maher */ @@ -48,16 +48,16 @@ public class BookSettings implements OfficeConstants { /** A w3c <code>Document</code>. */ private org.w3c.dom.Document settings = null; - + private boolean hasColumnRowHeaders = true; - private String activeSheet = new String(); - private Vector worksheetSettings = new Vector(); - + private String activeSheet = new String(); + private Vector worksheetSettings = new Vector(); + /** * Default Constructor for a <code>BookSettings</code> * - * @param dimension if it's a row the height, a column the width - * @param repeated + * @param dimension if it's a row the height, a column the width + * @param repeated */ public BookSettings(Node root) { readNode(root); @@ -66,7 +66,7 @@ public class BookSettings implements OfficeConstants { /** * Default Constructor for a <code>BookSettings</code> * - * @param worksheetSettings if it's a row the height, a column the width + * @param worksheetSettings if it's a row the height, a column the width */ public BookSettings(Vector worksheetSettings) { this.worksheetSettings = worksheetSettings; @@ -78,7 +78,7 @@ public class BookSettings implements OfficeConstants { public void setColumnRowHeaders(boolean hasColumnRowHeaders) { this.hasColumnRowHeaders = hasColumnRowHeaders; } - + /** * */ @@ -96,25 +96,25 @@ public class BookSettings implements OfficeConstants { } /** - * Gets the active sheet name + * Gets the active sheet name * - * @return the active sheet name + * @return the active sheet name */ public String getActiveSheet() { return activeSheet; } - + /** - * Sets the active sheet name + * Sets the active sheet name * - * @param activeSheet the active sheet name + * @param activeSheet the active sheet name */ public void setActiveSheet(String activeSheet) { this.activeSheet = activeSheet; } - + /** * Adds an XML entry for a particular setting @@ -129,22 +129,22 @@ public class BookSettings implements OfficeConstants { Element configItem = settings.createElement(TAG_CONFIG_ITEM); configItem.setAttribute(ATTRIBUTE_CONFIG_NAME, attribute); configItem.setAttribute(ATTRIBUTE_CONFIG_TYPE, type); - + configItem.appendChild(settings.createTextNode(value)); root.appendChild(configItem); } /** - * Writes out a settings.xml entry for this BookSettings object + * Writes out a settings.xml entry for this BookSettings object * - * @param settings a <code>Document</code> object representing the settings.xml + * @param settings a <code>Document</code> object representing the settings.xml * @param root the root xml node to add to */ public void writeNode(org.w3c.dom.Document settings, Node root) { - + this.settings = settings; - Element configItemMapNamed = (Element) settings.createElement(TAG_CONFIG_ITEM_MAP_NAMED); + Element configItemMapNamed = (Element) settings.createElement(TAG_CONFIG_ITEM_MAP_NAMED); configItemMapNamed.setAttribute(ATTRIBUTE_CONFIG_NAME, "Tables"); for(Enumeration e = worksheetSettings.elements();e.hasMoreElements();) { SheetSettings s = (SheetSettings) e.nextElement(); @@ -157,10 +157,10 @@ public class BookSettings implements OfficeConstants { } /** - * Sets a variable based on a String value read from XML + * Sets a variable based on a String value read from XML * - * @param name xml name of the attribute to set - * @param value String value fo the attribute + * @param name xml name of the attribute to set + * @param value String value fo the attribute */ public void addAttribute(String name, String value) { @@ -175,12 +175,12 @@ public class BookSettings implements OfficeConstants { /** * Reads document settings from xml and inits SheetSettings variables * - * @param root XML Node to read from + * @param root XML Node to read from */ public void readNode(Node root) { if (root.hasChildNodes()) { - + NodeList nodeList = root.getChildNodes(); int len = nodeList.getLength(); for (int i = 0; i < len; i++) { @@ -195,11 +195,11 @@ public class BookSettings implements OfficeConstants { Node configNameNode = cellAtt.getNamedItem(ATTRIBUTE_CONFIG_NAME); - + String name = configNameNode.getNodeValue(); NodeList nodeList2 = child.getChildNodes(); int len2 = nodeList2.getLength(); - String s = ""; + String s = ""; for (int j = 0; j < len2; j++) { Node child2 = nodeList2.item(j); if (child2.getNodeType() == Node.TEXT_NODE) { @@ -207,11 +207,11 @@ public class BookSettings implements OfficeConstants { } } addAttribute(name, s); - + } else if (nodeName.equals(TAG_CONFIG_ITEM_MAP_NAMED)) { readNode(child); - + } else if (nodeName.equals(TAG_CONFIG_ITEM_MAP_ENTRY)) { SheetSettings s = new SheetSettings(child); @@ -222,7 +222,7 @@ public class BookSettings implements OfficeConstants { Debug.log(Debug.TRACE, "<OTHERS " + XmlUtil.getNodeInfo(child) + " />"); } } - } + } } } } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/CellStyle.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/CellStyle.java index 7f02d8907141..2e3e34b6d620 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/CellStyle.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/CellStyle.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -41,7 +41,7 @@ import org.openoffice.xmerge.util.Debug; /** * Represents a text <code>Style</code> in an OpenOffice document. * - * @author Martin Maher + * @author Martin Maher */ public class CellStyle extends Style implements Cloneable { @@ -58,7 +58,7 @@ public class CellStyle extends Style implements Cloneable { */ public CellStyle(Node node, StyleCatalog sc) { super(node, sc); - + // Run through the attributes of this node, saving // the ones we're interested in. NamedNodeMap attrNodes = node.getAttributes(); @@ -69,7 +69,7 @@ public class CellStyle extends Style implements Cloneable { handleAttribute(attr.getNodeName(), attr.getNodeValue()); } } - + // Look for children. Only ones we care about are "style:properties" // nodes. If any are found, recursively traverse them, passing // along the style element to add properties to. @@ -93,18 +93,18 @@ public class CellStyle extends Style implements Cloneable { } } } - - + + /** * Constructor for use when going from client device format to DOM * - * @param name Name of cell <code>Style</code>. Can be null. - * @param family Family of text <code>Style</code> (usually + * @param name Name of cell <code>Style</code>. Can be null. + * @param family Family of text <code>Style</code> (usually * <i>text</i>). Can be null. - * @param parent Name of parent text <code>Style</code>, or null + * @param parent Name of parent text <code>Style</code>, or null * for none. - * @param fmt size in points. - * @param sc The <code>StyleCatalog</code>, which is used for + * @param fmt size in points. + * @param sc The <code>StyleCatalog</code>, which is used for * looking up ancestor <code>Style</code> objects. */ public CellStyle(String name, String family, String parent,Format fmt, StyleCatalog sc) { @@ -115,12 +115,12 @@ public class CellStyle extends Style implements Cloneable { /** * Returns the <code>Format</code> object for this particular style * - * @return the <code>Format</code> object + * @return the <code>Format</code> object */ public Format getFormat() { return fmt; } - + /** * Parse a color specification of the form <i>#rrggbb</i> * @@ -145,7 +145,7 @@ public class CellStyle extends Style implements Cloneable { } return new Color(red, green, blue, 0); } - + /** * Set an attribute. @@ -154,26 +154,26 @@ public class CellStyle extends Style implements Cloneable { * @param value The attribute value to set. */ private void handleAttribute(String attr, String value) { - + if (attr.equals("fo:font-weight")) { fmt.setAttribute(Format.BOLD, value.equals("bold")); } - + else if (attr.equals("fo:font-style")) { if (value.equals("italic") || value.equals("oblique")) fmt.setAttribute(Format.ITALIC, true); else if (value.equals("normal")) fmt.setAttribute(Format.ITALIC, false); } - + else if (attr.equals("style:text-underline")) { fmt.setAttribute(Format.UNDERLINE, !value.equals("none")); } - + else if (attr.equals("style:text-crossing-out")) { fmt.setAttribute(Format.STRIKETHRU, !value.equals("none")); } - + else if (attr.equals("style:text-position")) { if (value.startsWith("super ")) fmt.setAttribute(Format.SUPERSCRIPT, true); @@ -197,23 +197,23 @@ public class CellStyle extends Style implements Cloneable { } } } - + else if (attr.equals("fo:font-size")) { if (value.endsWith("pt")) { String num = value.substring(0, value.length() - 2); fmt.setFontSize(Integer.parseInt(num)); } } - + else if (attr.equals("style:font-name")) fmt.setFontName(value); - + else if (attr.equals("fo:color")) fmt.setForeground(parseColorString(value)); else if (attr.equals("fo:background-color")) fmt.setBackground(parseColorString(value)); - + else if (attr.equals("fo:text-align")) { if(value.equals("center")) { fmt.setAlign(Format.CENTER_ALIGN); @@ -233,7 +233,7 @@ public class CellStyle extends Style implements Cloneable { fmt.setVertAlign(Format.BOTTOM_ALIGN); } } - + else if (attr.equals("fo:border")) { fmt.setAttribute(Format.TOP_BORDER, !value.equals("none")); fmt.setAttribute(Format.BOTTOM_BORDER, !value.equals("none")); @@ -242,30 +242,30 @@ public class CellStyle extends Style implements Cloneable { } else if (attr.equals("fo:border-top")) { fmt.setAttribute(Format.TOP_BORDER, !value.equals("none")); - } + } else if (attr.equals("fo:border-bottom")) { fmt.setAttribute(Format.BOTTOM_BORDER, !value.equals("none")); - } + } else if (attr.equals("fo:border-left")) { fmt.setAttribute(Format.LEFT_BORDER, !value.equals("none")); - } + } else if (attr.equals("fo:border-right")) { fmt.setAttribute(Format.RIGHT_BORDER, !value.equals("none")); - } + } else if (attr.equals("fo:wrap-option")) { fmt.setAttribute(Format.WORD_WRAP, value.equals("wrap")); - } + } else if (isIgnored(attr)) {} - + else { Debug.log(Debug.INFO, "CellStyle Unhandled: " + attr + "=" + value); } } - - + + /** - * Return a <code>Style</code> object corresponding to this one, + * Return a <code>Style</code> object corresponding to this one, * but with all of the inherited information from parent * <code>Style</code> objects filled in. The object returned will * be a new object, not a reference to this object, even if it does @@ -282,7 +282,7 @@ public class CellStyle extends Style implements Cloneable { } catch (Exception e) { Debug.log(Debug.ERROR, "Can't clone", e); } - + // Look up the parentStyle. (If there is no style catalog // specified, we can't do any lookups.) CellStyle parentStyle = null; @@ -301,14 +301,14 @@ public class CellStyle extends Style implements Cloneable { null, this.getClass()); } } - + // If we found a parent, for any attributes which we don't have // set, try to get the values from the parent. if (parentStyle != null) { parentStyle = (CellStyle)parentStyle.getResolved(); Format parentFormat = parentStyle.getFormat(); Format resolvedFormat = resolved.getFormat(); - + if ((fmt.getAlign() == Format.LEFT_ALIGN) && (parentFormat.getAlign() != Format.LEFT_ALIGN)) resolvedFormat.setAlign(parentFormat.getAlign()); if ((fmt.getVertAlign() == Format.BOTTOM_ALIGN) && (parentFormat.getVertAlign() != Format.BOTTOM_ALIGN)) @@ -326,12 +326,12 @@ public class CellStyle extends Style implements Cloneable { resolvedFormat.setAttribute(m, parentFormat.getAttribute(m)); } } - + } return resolved; } - - + + /** * Create a new <code>Node</code> in the <code>Document</code>, and * write this <code>Style</code> to it. @@ -348,10 +348,10 @@ public class CellStyle extends Style implements Cloneable { writeAttributes(node); return node; } - - + + /** - * Return true if <code>style</code> specifies as much or less + * Return true if <code>style</code> specifies as much or less * than this <code>Style</code>, and nothing it specifies * contradicts this <code>Style</code>. * @@ -361,10 +361,10 @@ public class CellStyle extends Style implements Cloneable { * otherwise. */ public boolean isSubset(Style style) { - if (style.getClass() != this.getClass()) + if (style.getClass() != this.getClass()) return false; CellStyle tStyle = (CellStyle)style; - + Format rhs = tStyle.getFormat(); if(!fmt.isSubset(rhs)) @@ -372,8 +372,8 @@ public class CellStyle extends Style implements Cloneable { return true; } - - + + /** * Write this <code>Style</code> object's attributes to a * <code>Node</code> in the <code>Document</code>. @@ -382,73 +382,73 @@ public class CellStyle extends Style implements Cloneable { * attributes. */ public void writeAttributes(Element node) { - + if (fmt.getAlign()==Format.RIGHT_ALIGN) node.setAttribute("fo:text-align", "end"); - + if (fmt.getAlign()==Format.LEFT_ALIGN) node.setAttribute("fo:text-align", "start"); - + if (fmt.getAlign()==Format.CENTER_ALIGN) node.setAttribute("fo:text-align", "center"); - + if (fmt.getVertAlign()==Format.TOP_ALIGN) node.setAttribute("fo:vertical-align", "top"); - + if (fmt.getVertAlign()==Format.MIDDLE_ALIGN) node.setAttribute("fo:vertical-align", "middle"); - + if (fmt.getVertAlign()==Format.BOTTOM_ALIGN) node.setAttribute("fo:vertical-align", "bottom"); - + if (fmt.getAttribute(Format.BOLD)) node.setAttribute("fo:font-weight", "bold"); - + if (fmt.getAttribute(Format.ITALIC)) node.setAttribute("fo:font-style", "italic"); - + if (fmt.getAttribute(Format.UNDERLINE)) node.setAttribute("style:text-underline", "single"); - + if (fmt.getAttribute(Format.STRIKETHRU)) node.setAttribute("style:text-crossing-out", "single-line"); - + if (fmt.getAttribute(Format.SUPERSCRIPT)) node.setAttribute("style:text-position", "super 58%"); - + if (fmt.getAttribute(Format.SUBSCRIPT)) node.setAttribute("style:text-position", "sub 58%"); - + if (fmt.getFontSize() != 0) { Integer fs = new Integer(fmt.getFontSize()); node.setAttribute("fo:font-size", fs.toString() + "pt"); } - + if (fmt.getFontName() != null) node.setAttribute("style:font-name", fmt.getFontName()); - + if (fmt.getForeground() != null) node.setAttribute("fo:color", buildColorString(fmt.getForeground())); if (fmt.getBackground() != null) - node.setAttribute("fo:background-color", + node.setAttribute("fo:background-color", buildColorString(fmt.getBackground())); - + if (fmt.getAttribute(Format.TOP_BORDER)) node.setAttribute("fo:border-top", "0.0008inch solid #000000"); - + if (fmt.getAttribute(Format.BOTTOM_BORDER)) node.setAttribute("fo:border-bottom", "0.0008inch solid #000000"); - + if (fmt.getAttribute(Format.RIGHT_BORDER)) node.setAttribute("fo:border-right", "0.0008inch solid #000000"); - + if (fmt.getAttribute(Format.LEFT_BORDER)) node.setAttribute("fo:border-left", "0.0008inch solid #000000"); - + if (fmt.getAttribute(Format.WORD_WRAP)) node.setAttribute("fo:wrap-option", "wrap"); - + } @@ -468,14 +468,14 @@ public class CellStyle extends Style implements Cloneable { String colorString = new String("#"); for (int i = 0; i <= 2; i++) { String xx = Integer.toHexString(v[i]); - if (xx.length() < 2) + if (xx.length() < 2) xx = "0" + xx; colorString += xx; } return colorString; } - - + + private static String[] ignored = { "style:text-autospace", "style:text-underline-color", "fo:margin-left", "fo:margin-right", "fo:text-indent", @@ -501,7 +501,7 @@ public class CellStyle extends Style implements Cloneable { */ private boolean isIgnored(String attribute) { for (int i = 0; i < ignored.length; i++) { - if (ignored[i].equals(attribute)) + if (ignored[i].equals(attribute)) return true; } return false; diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/ColumnRowInfo.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/ColumnRowInfo.java index 444420ad0213..14c1dbfc8e77 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/ColumnRowInfo.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/ColumnRowInfo.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -35,35 +35,35 @@ package org.openoffice.xmerge.converter.xml.sxc; */ public class ColumnRowInfo { - final public static int COLUMN = 0x01; - final public static int ROW = 0x02; + final public static int COLUMN = 0x01; + final public static int ROW = 0x02; - final private static int DEFAULTROWSIZE_MIN = 250; - final private static int DEFAULTROWSIZE_MAX = 260; + final private static int DEFAULTROWSIZE_MIN = 250; + final private static int DEFAULTROWSIZE_MAX = 260; private int type; - private int dimension = 0; - private int repeated = 1; + private int dimension = 0; + private int repeated = 1; private boolean userDefined = true; private Format fmt = new Format(); /** * Constructor for a <code>ColumnRowInfo</code> * - * @param dimension if it's a row the height, a column the width - * @param repeated + * @param dimension if it's a row the height, a column the width + * @param repeated */ public ColumnRowInfo(int type) { this.type = type; } - + /** * Constructor for a <code>ColumnRowInfo</code> * - * @param dimension if it's a row the height, a column the width + * @param dimension if it's a row the height, a column the width * @param repeated how many times it is repeated - * @param type whether Row or column record + * @param type whether Row or column record */ public ColumnRowInfo(int dimension, int repeated, int type) { @@ -78,13 +78,13 @@ public class ColumnRowInfo { * @param userDefined whether the record is manually set */ public ColumnRowInfo(int dimension, int repeated, int type, boolean userDefined) { - + this(dimension, repeated, type); this.userDefined = userDefined; } - + /** - * sets the definition + * sets the definition * * @param newDefinition sets the definition */ @@ -94,8 +94,8 @@ public class ColumnRowInfo { } /** - * returns Name of the definition - * + * returns Name of the definition + * * @return the name which identifies the definition */ public Format getFormat() { @@ -104,17 +104,17 @@ public class ColumnRowInfo { } /** - * returns Name of the definition - * + * returns Name of the definition + * * @return the name which identifies the definition */ public int getSize() { return dimension; } - + /** - * sets the definition + * sets the definition * * @param newDefinition sets the definition */ @@ -125,46 +125,46 @@ public class ColumnRowInfo { /** * Returns the definition itself * - * @return the definition + * @return the definition */ public int getRepeated() { - + return repeated; } /** - * Returns the base Cell address - * + * Returns the base Cell address + * * @return the base cell address */ public void setRepeated(int repeated) { this.repeated = repeated; } - + /** * Returns the definition itself * - * @return the definition + * @return the definition */ public boolean isRow() { - + if(type==ROW) return true; - else + else return false; } /** - * Returns the base Cell address - * + * Returns the base Cell address + * * @return the base cell address */ public boolean isColumn() { if(type==COLUMN) return true; - else + else return false; } @@ -177,7 +177,7 @@ public class ColumnRowInfo { return userDefined; } - + /** * Test if the row height is default * @@ -185,11 +185,11 @@ public class ColumnRowInfo { */ public boolean isDefaultSize() { - if( type==ROW && + if( type==ROW && dimension>DEFAULTROWSIZE_MIN && dimension<DEFAULTROWSIZE_MAX) return true; - else + else return false; - } + } } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/ColumnStyle.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/ColumnStyle.java index cee83b5dde81..76c742b57496 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/ColumnStyle.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/ColumnStyle.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -40,11 +40,11 @@ import org.openoffice.xmerge.util.TwipsConverter; /** * Represents a text <code>Style</code> in an OpenOffice document. * - * @author Martin Maher + * @author Martin Maher */ public class ColumnStyle extends Style implements Cloneable { - private int colWidth = 0; + private int colWidth = 0; /** * Constructor for use when going from DOM to client device format. * @@ -56,7 +56,7 @@ public class ColumnStyle extends Style implements Cloneable { */ public ColumnStyle(Node node, StyleCatalog sc) { super(node, sc); - + // Run through the attributes of this node, saving // the ones we're interested in. NamedNodeMap attrNodes = node.getAttributes(); @@ -67,7 +67,7 @@ public class ColumnStyle extends Style implements Cloneable { handleAttribute(attr.getNodeName(), attr.getNodeValue()); } } - + // Look for children. Only ones we care about are "style:properties" // nodes. If any are found, recursively traverse them, passing // along the style element to add properties to. @@ -91,8 +91,8 @@ public class ColumnStyle extends Style implements Cloneable { } } } - - + + /** * Constructor for use when going from client device format to DOM * @@ -101,7 +101,7 @@ public class ColumnStyle extends Style implements Cloneable { * <i>text</i>). Can be null. * @param parent Name of parent text <code>Style</code>, or null * for none. - * @param mask the width of this column + * @param mask the width of this column * @param sc The <code>StyleCatalog</code>, which is used for * looking up ancestor <code>Style</code> objects. */ @@ -113,24 +113,24 @@ public class ColumnStyle extends Style implements Cloneable { /** * Returns the width of this column * - * @return the <code>Format</code> object + * @return the <code>Format</code> object */ public int getColWidth() { return colWidth; } - + /** * Sets the width of this column * - * @return the <code>Format</code> object + * @return the <code>Format</code> object */ public void setColWidth(int colWidth) { this.colWidth = colWidth; } - + /** - * Parse a colwidth in the form "1.234cm" to twips + * Parse a colwidth in the form "1.234cm" to twips * * @param value <code>String</code> specification to parse. * @@ -138,8 +138,8 @@ public class ColumnStyle extends Style implements Cloneable { */ private int parseColWidth(String value) { - int width = 255; // Default value - + int width = 255; // Default value + if(value.indexOf("cm")!=-1) { float widthCM = Float.parseFloat(value.substring(0,value.indexOf("c"))); width = TwipsConverter.cm2twips(widthCM); @@ -147,10 +147,10 @@ public class ColumnStyle extends Style implements Cloneable { float widthInch = Float.parseFloat(value.substring(0,value.indexOf("i"))); width = TwipsConverter.inches2twips(widthInch); } - + return (width); } - + /** * Set an attribute. @@ -159,7 +159,7 @@ public class ColumnStyle extends Style implements Cloneable { * @param value The attribute value to set. */ private void handleAttribute(String attr, String value) { - + if (attr.equals("style:column-width")) { colWidth = parseColWidth(value); } @@ -167,10 +167,10 @@ public class ColumnStyle extends Style implements Cloneable { Debug.log(Debug.INFO, "ColumnStyle Unhandled: " + attr + "=" + value); } } - - + + /** - * Return a <code>Style</code> object corresponding to this one, + * Return a <code>Style</code> object corresponding to this one, * but with all of the inherited information from parent * <code>Style</code> objects filled in. The object returned will * be a new object, not a reference to this object, even if it does @@ -187,7 +187,7 @@ public class ColumnStyle extends Style implements Cloneable { } catch (Exception e) { Debug.log(Debug.ERROR, "Can't clone", e); } - + // Look up the parentStyle. (If there is no style catalog // specified, we can't do any lookups.) ColumnStyle parentStyle = null; @@ -206,19 +206,19 @@ public class ColumnStyle extends Style implements Cloneable { null, this.getClass()); } } - + // If we found a parent, for any attributes which we don't have // set, try to get the values from the parent. if (parentStyle != null) { parentStyle = (ColumnStyle)parentStyle.getResolved(); - + if ((colWidth == 0) && (parentStyle.getColWidth() != 0)) resolved.setColWidth(parentStyle.getColWidth()); } return resolved; } - - + + /** * Create a new <code>Node</code> in the <code>Document</code>, and * write this <code>Style</code> to it. @@ -235,10 +235,10 @@ public class ColumnStyle extends Style implements Cloneable { writeAttributes(node); return node; } - - + + /** - * Return true if <code>style</code> specifies as much or less + * Return true if <code>style</code> specifies as much or less * than this <code>Style</code>, and nothing it specifies * contradicts this <code>Style</code>. * @@ -248,17 +248,17 @@ public class ColumnStyle extends Style implements Cloneable { * otherwise. */ public boolean isSubset(Style style) { - if (style.getClass() != this.getClass()) + if (style.getClass() != this.getClass()) return false; ColumnStyle tStyle = (ColumnStyle)style; - + if(colWidth!=tStyle.getColWidth()) return false; return true; } - - + + /** * Write this <code>Style</code> object's attributes to a * <code>Node</code> in the <code>Document</code>. @@ -269,7 +269,7 @@ public class ColumnStyle extends Style implements Cloneable { public void writeAttributes(Element node) { if(colWidth!=0) { - String width = TwipsConverter.twips2cm(colWidth) + "cm"; + String width = TwipsConverter.twips2cm(colWidth) + "cm"; node.setAttribute("style:column-width", width); } } @@ -291,7 +291,7 @@ public class ColumnStyle extends Style implements Cloneable { */ private boolean isIgnored(String attribute) { for (int i = 0; i < ignored.length; i++) { - if (ignored[i].equals(attribute)) + if (ignored[i].equals(attribute)) return true; } return false; diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/DocumentMergerImpl.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/DocumentMergerImpl.java index 5d15b2114e31..2fa5f22303b2 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/DocumentMergerImpl.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/DocumentMergerImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/Format.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/Format.java index a3abda0cd739..2bb836a7303d 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/Format.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/Format.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -33,21 +33,21 @@ import java.awt.Color; * This class specifies the format for a given spreadsheet cell. * * @author Mark Murnane - * @author Martin Maher (Extended Style Support) + * @author Martin Maher (Extended Style Support) */ public class Format implements Cloneable { /** Horizontal Alignment Constants. */ - final public static int RIGHT_ALIGN = 0x01; - final public static int CENTER_ALIGN = 0x02; - final public static int LEFT_ALIGN = 0x03; - final public static int JUST_ALIGN = 0x04; - + final public static int RIGHT_ALIGN = 0x01; + final public static int CENTER_ALIGN = 0x02; + final public static int LEFT_ALIGN = 0x03; + final public static int JUST_ALIGN = 0x04; + /** Vertical Alignment Constants. */ - final public static int TOP_ALIGN = 0x01; - final public static int MIDDLE_ALIGN = 0x02; - final public static int BOTTOM_ALIGN = 0x03; - + final public static int TOP_ALIGN = 0x01; + final public static int MIDDLE_ALIGN = 0x02; + final public static int BOTTOM_ALIGN = 0x03; + /** Indicates <i>bold</i> text. */ final public static int BOLD = 0x01; /** Indicates <i>italic</i> text. */ @@ -60,13 +60,13 @@ public class Format implements Cloneable { final public static int SUPERSCRIPT = 0x10; /** Indicates <i>subscripted</i> text. */ final public static int SUBSCRIPT = 0x20; - - final public static int LEFT_BORDER = 0x40; - final public static int RIGHT_BORDER = 0x80; - final public static int TOP_BORDER = 0x100; + + final public static int LEFT_BORDER = 0x40; + final public static int RIGHT_BORDER = 0x80; + final public static int TOP_BORDER = 0x100; final public static int BOTTOM_BORDER = 0x200; - - final public static int WORD_WRAP = 0x400; + + final public static int WORD_WRAP = 0x400; private int align; private int vertAlign; @@ -74,14 +74,14 @@ public class Format implements Cloneable { private String value; private String formatSpecifier; private int decimalPlaces; - + /** Font name. */ private String fontName; /** Font size in points. */ protected int sizeInPoints; - + private Color foreground, background; - + /** Values of text attributes. */ protected int attributes = 0; /** Bitwise mask of text attributes. */ @@ -91,9 +91,9 @@ public class Format implements Cloneable { * Constructor for creating a new <code>Format</code>. */ public Format() { - clearFormatting(); + clearFormatting(); } - + /** * Constructor that creates a new <code>Format</code> object * by setting all the format attributes. @@ -107,7 +107,7 @@ public class Format implements Cloneable { } /** - * Constructor for creating a new <code>Format</code> object + * Constructor for creating a new <code>Format</code> object * based on an existing one. * * @param fmt <code>Format</code> to copy. @@ -117,7 +117,7 @@ public class Format implements Cloneable { value = fmt.getValue(); formatSpecifier = fmt.getFormatSpecifier(); decimalPlaces = fmt.getDecimalPlaces(); - + attributes = fmt.attributes; mask = fmt.mask; @@ -128,7 +128,7 @@ public class Format implements Cloneable { background = fmt.getBackground(); sizeInPoints = fmt.sizeInPoints; } - + /** * Reset this <code>Format</code> description. @@ -147,7 +147,7 @@ public class Format implements Cloneable { foreground = null; background = null; } - + /** * Set one or more text attributes to <i>on</i>. * @@ -157,22 +157,22 @@ public class Format implements Cloneable { mask |= flags; if(toggle) { attributes |= flags; - } else { + } else { attributes &= ~flags; } } - + /** * Return true if the <code>attribute</code> is set to <i>on</i> * * @param attribute Attribute to check ({@link #BOLD}, * {@link #ITALIC}, etc.) * - * @return true if <code>attribute</code> is set to <i>on</i>, + * @return true if <code>attribute</code> is set to <i>on</i>, * otherwise false. */ public boolean getAttribute(int attribute) { - if ((mask & attribute) == 0) + if ((mask & attribute) == 0) return false; return (!((attributes & attribute) == 0)); } @@ -191,13 +191,13 @@ public class Format implements Cloneable { public boolean isSet(int attribute) { return (!((mask & attribute) == 0)); } - - + + /** * Set the formatting category of this object, ie number, date, - * currency.The <code>OfficeConstants</code> class contains string + * currency.The <code>OfficeConstants</code> class contains string * constants for the category types. - * + * * @see org.openoffice.xmerge.converter.xml.OfficeConstants * * @param newCategory The name of the category to be set. @@ -205,7 +205,7 @@ public class Format implements Cloneable { public void setCategory(String newCategory) { category = newCategory; } - + /** * Return the formatting category of the object. * @@ -220,22 +220,22 @@ public class Format implements Cloneable { /** * In the case of Formula returns the value of the formula. * - * @return The value of the formula + * @return The value of the formula */ public String getValue() { return value; } - + /** * In the case of formula the contents are set as the formula string and * the value of the formula is a formatting attribute. * - * @param newValue the formuala value + * @param newValue the formuala value */ public void setValue(String newValue) { value = newValue; } - + /** * Set the <code>Format</code> specifier for this category. @@ -245,7 +245,7 @@ public class Format implements Cloneable { public void setFormatSpecifier(String formatString) { formatSpecifier = formatString; } - + /** * Get the <code>Format</code> specifier for this category. @@ -255,17 +255,17 @@ public class Format implements Cloneable { public String getFormatSpecifier() { return formatSpecifier; } - - + + /** * Set the precision of the number to be displayed. - * + * * @param precision The number of decimal places to display. */ public void setDecimalPlaces(int precision) { decimalPlaces = precision; } - + /** * Get the number of decimal places displayed. @@ -275,17 +275,17 @@ public class Format implements Cloneable { public int getDecimalPlaces() { return decimalPlaces; } - - + + /** * Set the font used for this cell. - * + * * @param fontName The name of the font. */ public void setFontName(String fontName) { this.fontName = fontName; } - + /** * Get the font used for this cell. @@ -295,16 +295,16 @@ public class Format implements Cloneable { public String getFontName() { return fontName; } - + /** * Set the font used for this cell. - * + * * @param fontName The name of the font. */ public void setFontSize(int fontSize) { sizeInPoints = fontSize; } - + /** * Get the font used for this cell. @@ -313,17 +313,17 @@ public class Format implements Cloneable { */ public int getFontSize() { return sizeInPoints; - } + } /** * Set the alignmen used for this cell. - * + * * @param fontName The name of the font. */ public void setVertAlign(int vertAlign) { this.vertAlign = vertAlign; } - + /** * Get the alignment used for this cell. @@ -332,17 +332,17 @@ public class Format implements Cloneable { */ public int getVertAlign() { return vertAlign; - } + } /** * Set the alignmen used for this cell. - * + * * @param fontName The name of the font. */ public void setAlign(int align) { this.align = align; } - + /** * Get the alignment used for this cell. @@ -351,10 +351,10 @@ public class Format implements Cloneable { */ public int getAlign() { return align; - } + } /** * Set the Foreground <code>Color</code> for this cell. - * + * * @param color A <code>Color</code> object representing the * foreground color. */ @@ -362,7 +362,7 @@ public class Format implements Cloneable { if(c!=null) foreground = new Color(c.getRGB()); } - + /** * Get the Foreground <code>Color</code> for this cell. @@ -372,11 +372,11 @@ public class Format implements Cloneable { public Color getForeground() { return foreground; } - + /** * Set the Background <code>Color</code> for this cell - * + * * @param color A <code>Color</code> object representing * the background color. */ @@ -385,7 +385,7 @@ public class Format implements Cloneable { background = new Color(c.getRGB()); } - + /** * Get the Foreground <code>Color</code> for this cell * @@ -404,36 +404,36 @@ public class Format implements Cloneable { return new String("Value : " + getValue() + " Category : " + getCategory()); } - /** + /** * Tests if the current <code>Format</code> object has default attribute * values. * - * @return true if it contains default value + * @return true if it contains default value */ public boolean isDefault() { Format rhs = new Format(); - if (rhs.attributes!= attributes) + if (rhs.attributes!= attributes) return false; - - if (foreground!=rhs.foreground) + + if (foreground!=rhs.foreground) return false; - - if (background!=rhs.background) + + if (background!=rhs.background) return false; - if (rhs.align!= align) + if (rhs.align!= align) return false; - if (rhs.vertAlign!= vertAlign) + if (rhs.vertAlign!= vertAlign) return false; - + return true; } - + /** - * Return true if <code>style</code> specifies as much or less + * Return true if <code>style</code> specifies as much or less * than this <code>Style</code>, and nothing it specifies * contradicts this <code>Style</code>. * @@ -443,33 +443,33 @@ public class Format implements Cloneable { * otherwise. */ public boolean isSubset(Format rhs) { - if (rhs.getClass() != this.getClass()) + if (rhs.getClass() != this.getClass()) return false; - - if (rhs.attributes!= attributes) + + if (rhs.attributes!= attributes) return false; - + if (rhs.sizeInPoints != 0) { - if (sizeInPoints != rhs.sizeInPoints) + if (sizeInPoints != rhs.sizeInPoints) return false; } if (fontName!=rhs.fontName) return false; - - if (foreground!=rhs.foreground) + + if (foreground!=rhs.foreground) return false; - - if (background!=rhs.background) + + if (background!=rhs.background) return false; - if (rhs.align!= align) + if (rhs.align!= align) return false; - if (rhs.vertAlign!= vertAlign) + if (rhs.vertAlign!= vertAlign) return false; return true; - } + } } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/NameDefinition.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/NameDefinition.java index 75d2c95560f2..de83543fd86e 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/NameDefinition.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/NameDefinition.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -43,11 +43,11 @@ import org.openoffice.xmerge.util.XmlUtil; */ public class NameDefinition implements OfficeConstants { - private String name; // name which identifies the definition - private String definition; // the definition itself - private String baseCellAddress; // the basecelladdress - private boolean rangeType = false; // true if definition of type range - private boolean expressionType = false; // true if definition of type expression + private String name; // name which identifies the definition + private String definition; // the definition itself + private String baseCellAddress; // the basecelladdress + private boolean rangeType = false; // true if definition of type range + private boolean expressionType = false; // true if definition of type expression /** * Default Constructor for a <code>NameDefinition</code> @@ -56,17 +56,17 @@ public class NameDefinition implements OfficeConstants { public NameDefinition() { } - + /** * Constructor that takes a <code>Node</code> to build a * <code>NameDefinition</code> * - * @param root XML Node to read from + * @param root XML Node to read from */ public NameDefinition(Node root) { readNode(root); } - + /** * Default Constructor for a <code>NameDefinition</code> * @@ -79,10 +79,10 @@ public class NameDefinition implements OfficeConstants { this.rangeType = rangeType; this.expressionType = expressionType; } - + /** - * returns Name of the definition - * + * returns Name of the definition + * * @return the name which identifies the definition */ public String getName() { @@ -90,7 +90,7 @@ public class NameDefinition implements OfficeConstants { return name; } /** - * sets the definition + * sets the definition * * @param newDefinition sets the definition */ @@ -101,16 +101,16 @@ public class NameDefinition implements OfficeConstants { /** * Returns the definition itself * - * @return the definition + * @return the definition */ public String getDefinition() { - + return definition; } /** - * Returns the base Cell address - * + * Returns the base Cell address + * * @return the base cell address */ public String getBaseCellAddress() { @@ -119,29 +119,29 @@ public class NameDefinition implements OfficeConstants { } /** - * Tests if definition is of type expression + * Tests if definition is of type expression * * @return whether or not this name definition is of type expression */ public boolean isExpressionType() { return expressionType; } - + /** - * Tests if definition is of type range + * Tests if definition is of type range * - * @return whether or not this name definition is of type range + * @return whether or not this name definition is of type range */ public boolean isRangeType() { return rangeType; } /** - * Writes out a content.xml entry for this NameDefinition object + * Writes out a content.xml entry for this NameDefinition object * - * @param settings a <code>Document</code> object representing the settings.xml + * @param settings a <code>Document</code> object representing the settings.xml * @param root the root xml node to add to - */ + */ public void writeNode(org.w3c.dom.Document doc, Node root) { if(isRangeType()) { @@ -153,7 +153,7 @@ public class NameDefinition implements OfficeConstants { namedRangeElement.setAttribute(ATTRIBUTE_TABLE_CELL_RANGE_ADDRESS, getDefinition()); root.appendChild(namedRangeElement); } else if (isExpressionType()) { - + Debug.log(Debug.TRACE, "Found Expression Name : " + getName()); Element namedExpressionElement = (Element) doc.createElement(TAG_TABLE_NAMED_EXPRESSION); namedExpressionElement.setAttribute(ATTRIBUTE_TABLE_NAME, getName()); @@ -165,11 +165,11 @@ public class NameDefinition implements OfficeConstants { Debug.log(Debug.TRACE, "Unknown Name Definition : " + getName()); } } - + /** * Reads document settings from xml and inits Settings variables * - * @param root XML Node to read from + * @param root XML Node to read from */ public void readNode(Node root) { @@ -177,7 +177,7 @@ public class NameDefinition implements OfficeConstants { NamedNodeMap cellAtt = root.getAttributes(); if (nodeName.equals(TAG_TABLE_NAMED_RANGE)) { - + Node tableNameNode = cellAtt.getNamedItem(ATTRIBUTE_TABLE_NAME); Node tableBaseCellAddress = @@ -191,7 +191,7 @@ public class NameDefinition implements OfficeConstants { baseCellAddress = tableBaseCellAddress.getNodeValue(); expressionType = true; rangeType = false; - + } else if (nodeName.equals(TAG_TABLE_NAMED_EXPRESSION)) { Node tableNameNode = @@ -211,5 +211,5 @@ public class NameDefinition implements OfficeConstants { Debug.log(Debug.TRACE, "<OTHERS " + XmlUtil.getNodeInfo(root) + " />"); } } - + } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/RowStyle.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/RowStyle.java index 57668669877e..2b4ce04a13f0 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/RowStyle.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/RowStyle.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -40,11 +40,11 @@ import org.openoffice.xmerge.util.TwipsConverter; /** * Represents a text <code>Style</code> in an OpenOffice document. * - * @author Martin Maher + * @author Martin Maher */ public class RowStyle extends Style implements Cloneable { - private int rowHeight = 255; + private int rowHeight = 255; /** * Constructor for use when going from DOM to client device format. * @@ -56,7 +56,7 @@ public class RowStyle extends Style implements Cloneable { */ public RowStyle(Node node, StyleCatalog sc) { super(node, sc); - + // Run through the attributes of this node, saving // the ones we're interested in. NamedNodeMap attrNodes = node.getAttributes(); @@ -67,7 +67,7 @@ public class RowStyle extends Style implements Cloneable { handleAttribute(attr.getNodeName(), attr.getNodeValue()); } } - + // Look for children. Only ones we care about are "style:properties" // nodes. If any are found, recursively traverse them, passing // along the style element to add properties to. @@ -91,8 +91,8 @@ public class RowStyle extends Style implements Cloneable { } } } - - + + /** * Constructor for use when going from client device format to DOM * @@ -101,7 +101,7 @@ public class RowStyle extends Style implements Cloneable { * <i>text</i>). Can be null. * @param parent Name of parent text <code>Style</code>, or null * for none. - * @param mask The height of this row + * @param mask The height of this row * @param sc The <code>StyleCatalog</code>, which is used for * looking up ancestor <code>Style</code> objects. */ @@ -113,23 +113,23 @@ public class RowStyle extends Style implements Cloneable { /** * Returns the height of this row * - * @return the <code>Format</code> object + * @return the <code>Format</code> object */ public int getRowHeight() { return rowHeight; } - + /** * Sets the height of this row * - * @return the <code>Format</code> object + * @return the <code>Format</code> object */ public void setRowHeight(int RowHeight) { this.rowHeight = rowHeight; - } + } /** - * Parse a colheight in the form "1.234cm" to twips + * Parse a colheight in the form "1.234cm" to twips * * @param value <code>String</code> specification to parse. * @@ -137,8 +137,8 @@ public class RowStyle extends Style implements Cloneable { */ private int parseRowHeight(String value) { - int height = 255; // Default value - + int height = 255; // Default value + if(value.indexOf("cm")!=-1) { float heightCM = Float.parseFloat(value.substring(0,value.indexOf("c"))); height = TwipsConverter.cm2twips(heightCM); @@ -146,11 +146,11 @@ public class RowStyle extends Style implements Cloneable { float heightInch = Float.parseFloat(value.substring(0,value.indexOf("i"))); height = TwipsConverter.inches2twips(heightInch); } - + return (height); } - + /** * Set an attribute. @@ -159,7 +159,7 @@ public class RowStyle extends Style implements Cloneable { * @param value The attribute value to set. */ private void handleAttribute(String attr, String value) { - + if (attr.equals("style:row-height")) { rowHeight = parseRowHeight(value); } @@ -167,10 +167,10 @@ public class RowStyle extends Style implements Cloneable { Debug.log(Debug.INFO, "RowStyle Unhandled: " + attr + "=" + value); } } - - + + /** - * Return a <code>Style</code> object corresponding to this one, + * Return a <code>Style</code> object corresponding to this one, * but with all of the inherited information from parent * <code>Style</code> objects filled in. The object returned will * be a new object, not a reference to this object, even if it does @@ -187,7 +187,7 @@ public class RowStyle extends Style implements Cloneable { } catch (Exception e) { Debug.log(Debug.ERROR, "Can't clone", e); } - + // Look up the parentStyle. (If there is no style catalog // specified, we can't do any lookups.) RowStyle parentStyle = null; @@ -206,19 +206,19 @@ public class RowStyle extends Style implements Cloneable { null, this.getClass()); } } - + // If we found a parent, for any attributes which we don't have // set, try to get the values from the parent. if (parentStyle != null) { parentStyle = (RowStyle)parentStyle.getResolved(); - + if ((rowHeight == 0) && (parentStyle.getRowHeight() != 0)) resolved.setRowHeight(parentStyle.getRowHeight()); } return resolved; } - - + + /** * Create a new <code>Node</code> in the <code>Document</code>, and * write this <code>Style</code> to it. @@ -235,10 +235,10 @@ public class RowStyle extends Style implements Cloneable { writeAttributes(node); return node; } - - + + /** - * Return true if <code>style</code> specifies as much or less + * Return true if <code>style</code> specifies as much or less * than this <code>Style</code>, and nothing it specifies * contradicts this <code>Style</code>. * @@ -248,17 +248,17 @@ public class RowStyle extends Style implements Cloneable { * otherwise. */ public boolean isSubset(Style style) { - if (style.getClass() != this.getClass()) + if (style.getClass() != this.getClass()) return false; RowStyle tStyle = (RowStyle)style; - + if(rowHeight!=tStyle.getRowHeight()) return false; return true; } - - + + /** * Write this <code>Style</code> object's attributes to a * <code>Node</code> in the <code>Document</code>. @@ -269,7 +269,7 @@ public class RowStyle extends Style implements Cloneable { public void writeAttributes(Element node) { if(rowHeight!=0) { - String height = TwipsConverter.twips2cm(rowHeight) + "cm"; + String height = TwipsConverter.twips2cm(rowHeight) + "cm"; node.setAttribute("style:row-height", height); } } @@ -291,7 +291,7 @@ public class RowStyle extends Style implements Cloneable { */ private boolean isIgnored(String attribute) { for (int i = 0; i < ignored.length; i++) { - if (ignored[i].equals(attribute)) + if (ignored[i].equals(attribute)) return true; } return false; diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SheetSettings.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SheetSettings.java index 290c16bc1c0c..4258e1a5e035 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SheetSettings.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SheetSettings.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -37,7 +37,7 @@ import org.openoffice.xmerge.converter.xml.OfficeConstants; /** * This is a class representing the different attributes for a worksheet - * contained in settings.xml. + * contained in settings.xml. * * @author Martin Maher */ @@ -46,35 +46,35 @@ public class SheetSettings implements OfficeConstants { /** A w3c <code>Document</code>. */ private org.w3c.dom.Document settings = null; - private String sheetName; - private int cursorX = 0; - private int cursorY = 0; - private int splitTypeX; - private int splitTypeY; - private int splitPointX = 0; - private int splitPointY = 0; - private int posLeft = 0; - private int posRight = 0; - private int posBottom = 0; - private int posTop = 0; - private int paneNumber = 2; - - final public static int NONE = 0x00; - final public static int SPLIT = 0x01; - final public static int FREEZE = 0x02; - - + private String sheetName; + private int cursorX = 0; + private int cursorY = 0; + private int splitTypeX; + private int splitTypeY; + private int splitPointX = 0; + private int splitPointY = 0; + private int posLeft = 0; + private int posRight = 0; + private int posBottom = 0; + private int posTop = 0; + private int paneNumber = 2; + + final public static int NONE = 0x00; + final public static int SPLIT = 0x01; + final public static int FREEZE = 0x02; + + /** * Default Constructor for a <code>ColumnRowInfo</code> * */ public SheetSettings() { } - + /** * Constructor that takes a <code>Node</code> to build a <code>SheetSettings</code> * - * @param root XML Node to read from + * @param root XML Node to read from */ public SheetSettings(Node root) { readNode(root); @@ -83,26 +83,26 @@ public class SheetSettings implements OfficeConstants { /** * Constructor for a <code>ColumnRowInfo</code> * - * @param dimension if it's a row the height, a column the width - * @param repeated + * @param dimension if it's a row the height, a column the width + * @param repeated */ public SheetSettings(String name) { sheetName = name; } - + /** - * sets the position of the acitve cell + * sets the position of the acitve cell * - * @param activeCell the current curor position + * @param activeCell the current curor position */ public void setCursor(Point activeCell) { cursorX = (int) activeCell.getX(); cursorY = (int) activeCell.getY(); } - + /** - * Gets the position of the acitve cell + * Gets the position of the acitve cell * * @return The position as a <code>Point</code> */ @@ -112,33 +112,33 @@ public class SheetSettings implements OfficeConstants { } /** - * Sets the position of the freeze + * Sets the position of the freeze * * @param splitPoint the point at where the split occurs */ public void setFreeze(Point splitPoint) { - splitTypeX = FREEZE; - splitTypeY = FREEZE; - splitPointX = (int) splitPoint.getX(); - splitPointY = (int) splitPoint.getY(); + splitTypeX = FREEZE; + splitTypeY = FREEZE; + splitPointX = (int) splitPoint.getX(); + splitPointY = (int) splitPoint.getY(); } /** - * Sets the position of the split + * Sets the position of the split * * @param splitPoint the point at where the split occurs */ public void setSplit(Point splitPoint) { - splitTypeX = SPLIT; - splitTypeY = SPLIT; - splitPointX = (int) splitPoint.getX(); - splitPointY = (int) splitPoint.getY(); + splitTypeX = SPLIT; + splitTypeY = SPLIT; + splitPointX = (int) splitPoint.getX(); + splitPointY = (int) splitPoint.getY(); } - + /** - * sets the position and type of the split + * sets the position and type of the split * * @return The position as a <code>Point</code> where the split occurs */ @@ -146,9 +146,9 @@ public class SheetSettings implements OfficeConstants { return (new Point(splitPointX, splitPointY)); } - + /** - * sets the position and type of the split + * sets the position and type of the split * * @return The position as a <code>Point</code> where the split occurs */ @@ -161,7 +161,7 @@ public class SheetSettings implements OfficeConstants { * Sets the top row visible in the lower pane and the leftmost column * visibile in the right pane. * - * @param top The top row visible in the lower pane + * @param top The top row visible in the lower pane * @param left The leftmost column visibile in the right pane */ public void setTopLeft(int top, int left) { @@ -169,11 +169,11 @@ public class SheetSettings implements OfficeConstants { posLeft = left; posTop = top; } - + /** * Gets the the leftmost column visibile in the right pane. * - * @return the 0-based index to the column + * @return the 0-based index to the column */ public int getLeft() { @@ -183,16 +183,16 @@ public class SheetSettings implements OfficeConstants { * Sets the top row visible in the lower pane and the leftmost column * visibile in the right pane. * - * @param top The top row visible in the lower pane + * @param top The top row visible in the lower pane * @param left The leftmost column visibile in the right pane */ public int getTop() { return posTop; } - + /** - * Gets the active Panel + * Gets the active Panel * 0 - Bottom Right, 1 - Top Right * 2 - Bottom Left, 3 - Top Left * @@ -202,32 +202,32 @@ public class SheetSettings implements OfficeConstants { return paneNumber; } - + /** - * Sets the sheetname this settings object applies to + * Sets the sheetname this settings object applies to * - * @param sheetName the name of the worksheet + * @param sheetName the name of the worksheet */ public void setSheetName(String sheetName) { this.sheetName = sheetName; } - + /** * Sets the active pane number * 0 - Bottom Right, 1 - Top Right * 2 - Bottom Left, 3 - Top Left * - * @param paneNumber the pane number + * @param paneNumber the pane number */ public void setPaneNumber(int paneNumber) { this.paneNumber = paneNumber; } - + /** - * Gets the name of the worksheet these <code>Settings</code> apply to + * Gets the name of the worksheet these <code>Settings</code> apply to * * @return the name of the worksheet */ @@ -249,54 +249,54 @@ public class SheetSettings implements OfficeConstants { Element configItem = settings.createElement(TAG_CONFIG_ITEM); configItem.setAttribute(ATTRIBUTE_CONFIG_NAME, attribute); configItem.setAttribute(ATTRIBUTE_CONFIG_TYPE, type); - + configItem.appendChild(settings.createTextNode(value)); root.appendChild(configItem); } /** - * Writes out a settings.xml entry for this SheetSettings object + * Writes out a settings.xml entry for this SheetSettings object * - * @param settings a <code>Document</code> object representing the settings.xml + * @param settings a <code>Document</code> object representing the settings.xml * @param root the root xml node to add to */ public void writeNode(org.w3c.dom.Document settings, Node root) { - + this.settings = settings; - Element configItemMapEntry = (Element) settings.createElement(TAG_CONFIG_ITEM_MAP_ENTRY); + Element configItemMapEntry = (Element) settings.createElement(TAG_CONFIG_ITEM_MAP_ENTRY); configItemMapEntry.setAttribute(ATTRIBUTE_CONFIG_NAME, getSheetName()); - addConfigItem(configItemMapEntry, "CursorPositionX", "int", Integer.toString(cursorX)); - addConfigItem(configItemMapEntry, "CursorPositionY", "int", Integer.toString(cursorY)); + addConfigItem(configItemMapEntry, "CursorPositionX", "int", Integer.toString(cursorX)); + addConfigItem(configItemMapEntry, "CursorPositionY", "int", Integer.toString(cursorY)); String splitMode = Integer.toString(splitTypeX); if(splitPointX==0) { splitMode = "0"; } - addConfigItem(configItemMapEntry, "HorizontalSplitMode", "short", splitMode); + addConfigItem(configItemMapEntry, "HorizontalSplitMode", "short", splitMode); splitMode = Integer.toString(splitTypeY); if(splitPointY==0) { splitMode = "0"; } - addConfigItem(configItemMapEntry, "VerticalSplitMode", "short", splitMode); - - addConfigItem(configItemMapEntry, "HorizontalSplitPosition", "int", Integer.toString(splitPointX)); - addConfigItem(configItemMapEntry, "VerticalSplitPosition", "int", Integer.toString(splitPointY)); - addConfigItem(configItemMapEntry, "ActiveSplitRange", "short", Integer.toString(paneNumber)); - - addConfigItem(configItemMapEntry, "PositionLeft", "int", "0"); - addConfigItem(configItemMapEntry, "PositionRight", "int", Integer.toString(posLeft)); - addConfigItem(configItemMapEntry, "PositionTop", "int", "0"); - addConfigItem(configItemMapEntry, "PositionBottom", "int", Integer.toString(posTop)); + addConfigItem(configItemMapEntry, "VerticalSplitMode", "short", splitMode); + + addConfigItem(configItemMapEntry, "HorizontalSplitPosition", "int", Integer.toString(splitPointX)); + addConfigItem(configItemMapEntry, "VerticalSplitPosition", "int", Integer.toString(splitPointY)); + addConfigItem(configItemMapEntry, "ActiveSplitRange", "short", Integer.toString(paneNumber)); + + addConfigItem(configItemMapEntry, "PositionLeft", "int", "0"); + addConfigItem(configItemMapEntry, "PositionRight", "int", Integer.toString(posLeft)); + addConfigItem(configItemMapEntry, "PositionTop", "int", "0"); + addConfigItem(configItemMapEntry, "PositionBottom", "int", Integer.toString(posTop)); root.appendChild(configItemMapEntry); } /** - * Sets a variable based on a String value read from XML + * Sets a variable based on a String value read from XML * - * @param name xml name of the attribute to set - * @param value String value fo the attribute + * @param name xml name of the attribute to set + * @param value String value fo the attribute */ public void addAttribute(String name, String value) { @@ -304,7 +304,7 @@ public class SheetSettings implements OfficeConstants { cursorX = Integer.parseInt(value); } else if(name.equals("CursorPositionY")) { cursorY = Integer.parseInt(value); - + } else if(name.equals("HorizontalSplitPosition")) { splitPointX = Integer.parseInt(value); } else if(name.equals("VerticalSplitPosition")) { @@ -316,7 +316,7 @@ public class SheetSettings implements OfficeConstants { posLeft = Integer.parseInt(value); } else if(name.equals("PositionBottom")) { posTop = Integer.parseInt(value); - + } else if(name.equals("HorizontalSplitMode")) { splitTypeX = Integer.parseInt(value); } else if(name.equals("VerticalSplitMode")) { @@ -327,10 +327,10 @@ public class SheetSettings implements OfficeConstants { /** * Reads document settings from xml and inits SheetSettings variables * - * @param root XML Node to read from + * @param root XML Node to read from */ public void readNode(Node root) { - + NamedNodeMap sheetAtt = root.getAttributes(); Node sheetNameNode = sheetAtt.getNamedItem(ATTRIBUTE_CONFIG_NAME); @@ -348,24 +348,24 @@ public class SheetSettings implements OfficeConstants { String nodeName = child.getNodeName(); if (nodeName.equals(TAG_CONFIG_ITEM)) { - + NamedNodeMap cellAtt = child.getAttributes(); Node configNameNode = cellAtt.getNamedItem(ATTRIBUTE_CONFIG_NAME); - + String name = configNameNode.getNodeValue(); NodeList nodeList2 = child.getChildNodes(); int len2 = nodeList2.getLength(); - String s = ""; + String s = ""; for (int j = 0; j < len2; j++) { Node child2 = nodeList2.item(j); if (child2.getNodeType() == Node.TEXT_NODE) { s = child2.getNodeValue(); } } - addAttribute(name, s); - } + addAttribute(name, s); + } } } } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetDecoder.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetDecoder.java index 609169fd26b6..169f54a65845 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetDecoder.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetDecoder.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -46,14 +46,14 @@ public abstract class SpreadsheetDecoder { */ public SpreadsheetDecoder(String name, String password) throws IOException { } - + /** * Returns the total number of sheets in the WorkBook. * * @return The number of sheets in the WorkBook. */ public abstract int getNumberOfSheets(); - + /** * Returns an Enumeration to a Vector of <code>NameDefinition</code>. * @@ -62,7 +62,7 @@ public abstract class SpreadsheetDecoder { public abstract Enumeration getNameDefinitions(); /** - * Returns an <code>BookSettings</code> + * Returns an <code>BookSettings</code> * * @return The Enumeration */ @@ -74,14 +74,14 @@ public abstract class SpreadsheetDecoder { * @return The Enumeration */ public abstract Enumeration getColumnRowInfos(); - + /** * Returns the number of populated rows in the current WorkSheet. * * @return the number of populated rows in the current WorkSheet. */ public abstract int getNumberOfRows(); - + /** * Returns the number of populated columns in the current WorkSheet. @@ -90,14 +90,14 @@ public abstract class SpreadsheetDecoder { */ public abstract int getNumberOfColumns(); - + /** * Returns the name of the current WorkSheet. * * @return Name of the current WorkSheet. */ public abstract String getSheetName(); - + /** * Returns the number of the active column. @@ -105,7 +105,7 @@ public abstract class SpreadsheetDecoder { * @return The number of the active column. */ public abstract int getColNumber(); - + /** * Returns the number of the active row. @@ -114,16 +114,16 @@ public abstract class SpreadsheetDecoder { */ public abstract int getRowNumber(); - + /** - * Sets the active WorkSheet. + * Sets the active WorkSheet. * * @param sheetIndex The index of the sheet to be made active. * * @throws IOException If any I/O error occurs. */ public abstract void setWorksheet(int sheetIndex) throws IOException; - + /** * Move on the next populated cell in the current WorkSheet. @@ -134,7 +134,7 @@ public abstract class SpreadsheetDecoder { */ public abstract boolean goToNextCell() throws IOException; - + /** * Return the contents of the active cell. * @@ -148,7 +148,7 @@ public abstract class SpreadsheetDecoder { * * @return The cell value. */ - public abstract String getCellValue(); + public abstract String getCellValue(); /** * Return the data type of the active cell. @@ -157,7 +157,7 @@ public abstract class SpreadsheetDecoder { */ public abstract String getCellDataType(); - + /** * Return a <code>Format</code> object describing the active cells * formatting. @@ -166,7 +166,7 @@ public abstract class SpreadsheetDecoder { */ public abstract Format getCellFormat(); - + /** * Add the contents of a <code>ConvertData</code> to the workbook. * diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetEncoder.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetEncoder.java index f92d0bdcf6e0..fc965bcd88b1 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetEncoder.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetEncoder.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -31,7 +31,7 @@ import java.io.IOException; import java.util.Vector; /** - * <p>This class is a abstract class for encoding an SXC into an + * <p>This class is a abstract class for encoding an SXC into an * alternative spreadsheet format.</p> * * <p>TODO - Add appropriate exceptions to each of the methods.</p> @@ -43,7 +43,7 @@ public abstract class SpreadsheetEncoder { /** * Creates new SpreadsheetEncoder. - * + * * @param name The name of the WorkBook to be created. * @param password An optional password for the WorkBook. * @@ -75,14 +75,14 @@ public abstract class SpreadsheetEncoder { /** * Add a cell to the current WorkSheet. - * + * * @param row The row number of the cell * @param column The column number of the cell * @param fmt The <code>Format</code> object describing the * appearance of this cell. * @param cellContents The text or formula of the cell's contents. */ - public abstract void addCell(int row, int column, + public abstract void addCell(int row, int column, Format fmt, String cellContents) throws IOException; @@ -124,6 +124,6 @@ public abstract class SpreadsheetEncoder { * @param columnWidths An <code>IntArrayList</code> of column * widths. */ - public abstract void addSettings(BookSettings s) throws IOException; + public abstract void addSettings(BookSettings s) throws IOException; } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcConstants.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcConstants.java index 1d150b80e2c8..32fd85fa071a 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcConstants.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcConstants.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -31,7 +31,7 @@ package org.openoffice.xmerge.converter.xml.sxc; /** * Interface defining constants for Sxc attributes. * - * @author Martin Maher + * @author Martin Maher */ public interface SxcConstants { @@ -45,5 +45,5 @@ public interface SxcConstants { public static final String TABLE_CELL_STYLE_FAMILY = "table-cell"; /** Name of the default style. */ - public static final String DEFAULT_STYLE = "Default"; + public static final String DEFAULT_STYLE = "Default"; } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocument.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocument.java index 94ab8f1730b7..5561ef3c9d9c 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocument.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocument.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -31,7 +31,7 @@ import org.openoffice.xmerge.converter.xml.OfficeDocument; import org.openoffice.xmerge.converter.xml.OfficeConstants; /** - * This class is an implementation of <code>OfficeDocument</code> for + * This class is an implementation of <code>OfficeDocument</code> for * the SXC format. */ public class SxcDocument extends OfficeDocument { @@ -78,7 +78,7 @@ public class SxcDocument extends OfficeDocument { protected String getOfficeClassAttribute() { return OfficeConstants.SXC_TYPE; } - + /** * Method to return the MIME type of the document. * @@ -87,6 +87,6 @@ public class SxcDocument extends OfficeDocument { protected final String getDocumentMimeType() { return OfficeConstants.SXC_MIME_TYPE; } - + } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentDeserializer.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentDeserializer.java index 737223dd1663..2eb507d09b7b 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentDeserializer.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentDeserializer.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -60,7 +60,7 @@ import org.openoffice.xmerge.util.Debug; * * @author Paul Rank * @author Mark Murnane - * @author Martin Maher + * @author Martin Maher */ public abstract class SxcDocumentDeserializer implements OfficeConstants, DocumentDeserializer { @@ -79,14 +79,14 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, /** An <code>ConvertData</code> object assigned to this object. */ private ConvertData cd = null; - + /** A style catalog for the workbook */ private StyleCatalog styleCat = null; private int textStyles = 1; private int colStyles = 1; private int rowStyles = 1; - + /** * Constructor. * @@ -98,7 +98,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, } - /** + /** * This abstract method will be implemented by concrete subclasses * and will return an application-specific Decoder. * @@ -112,7 +112,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, public abstract SpreadsheetDecoder createDecoder(String workbook, String[] worksheetNames, String password) throws IOException; - + /** * <p>This method will return the name of the WorkBook from the * <code>ConvertData</code>. Allows for situations where the @@ -121,14 +121,14 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, * <p>Implemented in the Deserializer as the Decoder's constructor requires * a name.</p> * - * @param cd The <code>ConvertData</code> containing the Device + * @param cd The <code>ConvertData</code> containing the Device * content. * * @return The WorkBook name. */ protected abstract String getWorkbookName(ConvertData cd) throws IOException; - + /** * This method will return the name of the WorkSheet from the * <code>ConvertData</code>. @@ -139,8 +139,8 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, * @return The WorkSheet names. */ protected abstract String[] getWorksheetNames(ConvertData cd) throws IOException; - - + + /** * <p>Method to convert a set of "Device" * <code>Document</code> objects into a <code>SxcDocument</code> @@ -170,9 +170,9 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, sxcDoc.initContentDOM(); sxcDoc.initSettingsDOM(); - // Default to an initial 5 entries in the catalog. + // Default to an initial 5 entries in the catalog. styleCat = new StyleCatalog(5); - + doc = sxcDoc.getContentDOM(); settings = sxcDoc.getSettingsDOM(); initFontTable(); @@ -204,14 +204,14 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, * */ private void initFontTable() { - - String fontTable[]= new String[] { "Tahoma", "Tahoma", "swiss", "variable", + + String fontTable[]= new String[] { "Tahoma", "Tahoma", "swiss", "variable", "Courier New", "'Courier New'", "modern", "fixed"}; // Traverse to the office:body element. // There should only be one. NodeList list = doc.getElementsByTagName(TAG_OFFICE_FONT_DECLS); Node root = list.item(0); - + for(int i=0;i<fontTable.length;) { // Create an element node for the table @@ -262,8 +262,8 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, processTable(node); } } - - // Add the Defined Name table if there is one + + // Add the Defined Name table if there is one Enumeration nameDefinitionTable = decoder.getNameDefinitions(); if(nameDefinitionTable.hasMoreElements()) { processNameDefinition(node, nameDefinitionTable); @@ -271,16 +271,16 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, // add settings NodeList settingsList = settings.getElementsByTagName(TAG_OFFICE_SETTINGS); - Node settingsNode = settingsList.item(0);; + Node settingsNode = settingsList.item(0);; processSettings(settingsNode); } - - + + /** * This method process the settings portion - * of the <code>Document</code>. + * of the <code>Document</code>. * * @param root The root <code>Node</code> of the * <code>Document</code> we are building. This @@ -288,23 +288,23 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, * tag. */ protected void processSettings(Node root) { - - Element configItemSetEntry = (Element) settings.createElement(TAG_CONFIG_ITEM_SET); + + Element configItemSetEntry = (Element) settings.createElement(TAG_CONFIG_ITEM_SET); configItemSetEntry.setAttribute(ATTRIBUTE_CONFIG_NAME, "view-settings"); - Element configItemMapIndexed = (Element) settings.createElement(TAG_CONFIG_ITEM_MAP_INDEXED); + Element configItemMapIndexed = (Element) settings.createElement(TAG_CONFIG_ITEM_MAP_INDEXED); configItemMapIndexed.setAttribute(ATTRIBUTE_CONFIG_NAME, "Views"); - Element configItemMapEntry = (Element) settings.createElement(TAG_CONFIG_ITEM_MAP_ENTRY); + Element configItemMapEntry = (Element) settings.createElement(TAG_CONFIG_ITEM_MAP_ENTRY); BookSettings bs = (BookSettings) decoder.getSettings(); bs.writeNode(settings, configItemMapEntry); - + configItemMapIndexed.appendChild(configItemMapEntry); configItemSetEntry.appendChild(configItemMapIndexed); root.appendChild(configItemSetEntry); } - + /** * This method process a Name Definition Table and generates a portion - * of the <code>Document</code>. + * of the <code>Document</code>. * * @param root The root <code>Node</code> of the * <code>Document</code> we are building. This @@ -329,7 +329,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, Debug.log(Debug.TRACE, "</NAMED-EXPRESSIONS>"); } - + /** * This method process a WorkSheet and generates a portion * of the <code>Document</code>. A spreadsheet is represented @@ -366,7 +366,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, // add the various different table-columns processColumns(tableElement); - + // Get each cell and add to doc processCells(tableElement); @@ -390,7 +390,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, protected void processColumns(Node root) throws IOException { for(Enumeration e = decoder.getColumnRowInfos();e.hasMoreElements();) { - + ColumnRowInfo ci = (ColumnRowInfo) e.nextElement(); if(ci.isColumn()) { ColumnStyle cStyle = new ColumnStyle("Default",SxcConstants.COLUMN_STYLE_FAMILY, @@ -399,7 +399,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, Style result[] = (Style[]) styleCat.getMatching(cStyle); String styleName; if(result.length==0) { - + cStyle.setName("co" + colStyles++); styleName = cStyle.getName(); Debug.log(Debug.TRACE,"No existing style found, adding " + styleName); @@ -454,8 +454,8 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, // The number of columns in the spreadsheet int lastColumn = decoder.getNumberOfColumns(); - - // + + // Node autoStylesNode = null; // Loop over all cells in the spreadsheet @@ -505,7 +505,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, Style result[] = (Style[]) styleCat.getMatching(rStyle); String styleName; if(result.length==0) { - + rStyle.setName("ro" + rowStyles++); styleName = rStyle.getName(); Debug.log(Debug.TRACE,"No existing style found, adding " + styleName); @@ -514,12 +514,12 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, RowStyle existingStyle = (RowStyle) result[0]; styleName = existingStyle.getName(); Debug.log(Debug.TRACE,"Existing style found : " + styleName); - } + } rowElement.setAttribute(ATTRIBUTE_TABLE_STYLE_NAME, styleName); // For now we will not use the repeat column attribute } } - + // Append the row element to the root node root.appendChild(rowElement); @@ -554,7 +554,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, // Get the type of the data in the cell String cellType = decoder.getCellDataType(); - // Get the cell format + // Get the cell format Format fmt = decoder.getCellFormat(); // Create an element node for the cell @@ -570,14 +570,14 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, autoStylesNode = doc.createElement(TAG_OFFICE_AUTOMATIC_STYLES); doc.insertBefore(autoStylesNode, bodyNode); } - + CellStyle tStyle = new - CellStyle( "Default",SxcConstants.TABLE_CELL_STYLE_FAMILY, + CellStyle( "Default",SxcConstants.TABLE_CELL_STYLE_FAMILY, SxcConstants.DEFAULT_STYLE, fmt, null); String styleName; Style result[] = (Style[]) styleCat.getMatching(tStyle); if(result.length==0) { - + tStyle.setName("ce" + textStyles++); styleName = tStyle.getName(); Debug.log(Debug.TRACE,"No existing style found, adding " + styleName); @@ -587,9 +587,9 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, styleName = existingStyle.getName(); Debug.log(Debug.TRACE,"Existing style found : " + styleName); } - + cellElement.setAttribute(ATTRIBUTE_TABLE_STYLE_NAME, styleName); - + // Store the cell data into the appropriate attributes processCellData(cellElement, cellType, cellContents); @@ -613,7 +613,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, int numSkippedCells = lastColumn - col + 1; addEmptyCells(numSkippedCells, rowElement); } - + // Now write the style catalog to the document if(autoStylesNode!=null) { Debug.log(Debug.TRACE,"Well the autostyle node was found!!!"); @@ -637,7 +637,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, * It is called when the conversion process encounters * a row (or rows) that do not contain any data in its cells. * - * @param numEmptyRows The number of empty rows that we + * @param numEmptyRows The number of empty rows that we * need to add to the <code>Document</code>. * @param root The <code>Node</code> of the * <code>Document</code> we are building @@ -685,7 +685,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, * current row. * @param row The <code>Node</code> of the * <code>Document</code> we - * are building that we will + * are building that we will * append our empty cell * <code>Node</code> objects. * This <code>Node</code> should @@ -724,7 +724,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, * the appropriate attributes on the cell <code>Element</code>. * * @param cellElement A TAG_TABLE_CELL <code>Element</code> - * that we will be adding attributes to + * that we will be adding attributes to * based on the type of data in the cell. * @param type The type of data contained in the cell. * @param contents The contents of the data contained in @@ -761,7 +761,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, } else if (type.equals(CELLTYPE_BOOLEAN)) { - // StarOffice XML format requires stored boolean value + // StarOffice XML format requires stored boolean value // to be in lower case cellElement.setAttribute(ATTRIBUTE_TABLE_BOOLEAN_VALUE, contents.toLowerCase()); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentSerializer.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentSerializer.java index d32f82eb64b6..b0cfc09893bc 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentSerializer.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentSerializer.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -195,10 +195,10 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, styleCat = new StyleCatalog(25); NodeList nl = null; - String families[] = new String[] { SxcConstants.COLUMN_STYLE_FAMILY, + String families[] = new String[] { SxcConstants.COLUMN_STYLE_FAMILY, SxcConstants.ROW_STYLE_FAMILY, SxcConstants.TABLE_CELL_STYLE_FAMILY }; - Class classes[] = new Class[] { ColumnStyle.class, + Class classes[] = new Class[] { ColumnStyle.class, RowStyle.class, CellStyle.class}; /* @@ -408,14 +408,14 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, } else { - RowStyle rStyle = ( RowStyle)styleCat.lookup(styleName, + RowStyle rStyle = ( RowStyle)styleCat.lookup(styleName, SxcConstants.ROW_STYLE_FAMILY, null, RowStyle.class); int rowHeight = rStyle.getRowHeight(); Debug.log(Debug.TRACE, "traverseTableRow() Row Height : " + rowHeight); - ColumnRowInfo ri = new ColumnRowInfo( rowHeight, + ColumnRowInfo ri = new ColumnRowInfo( rowHeight, repeatedRows, ColumnRowInfo.ROW, rowHeight!=0); @@ -746,7 +746,7 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, if(tableFormulaNode != null) { - if(tableValueTypeNode == null) { // If there is no value-type Node we must assume string-value + if(tableValueTypeNode == null) { // If there is no value-type Node we must assume string-value fmt.setCategory(CELLTYPE_STRING); Node tableStringValueNode = cellAtt.getNamedItem(ATTRIBUTE_TABLE_STRING_VALUE); fmt.setValue(tableStringValueNode.getNodeValue()); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcPluginFactory.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcPluginFactory.java index b3fa9ada5b70..401bdff1f533 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcPluginFactory.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcPluginFactory.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -39,7 +39,7 @@ import org.openoffice.xmerge.DocumentMergerFactory; /** * General implementation of the <code>PluginFactory</code> interface * for SXC <code>Document</code> objects. - * + * * @see org.openoffice.xmerge.DocumentDeserializer * @see org.openoffice.xmerge.DocumentMerger * @see org.openoffice.xmerge.DocumentSerializer diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxw/SxwDocument.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxw/SxwDocument.java index 0fcf2bb76f64..0485c4a435c0 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxw/SxwDocument.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxw/SxwDocument.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -80,7 +80,7 @@ public class SxwDocument extends OfficeDocument { protected String getOfficeClassAttribute() { return OfficeConstants.SXW_TYPE; } - + /** * Method to return the MIME type of the document. * @@ -89,6 +89,6 @@ public class SxwDocument extends OfficeDocument { protected final String getDocumentMimeType() { return OfficeConstants.SXW_MIME_TYPE; } - + } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxw/SxwPluginFactory.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxw/SxwPluginFactory.java index 0207f76320bb..a1f53bfd9ede 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxw/SxwPluginFactory.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxw/SxwPluginFactory.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -37,7 +37,7 @@ import org.openoffice.xmerge.util.registry.ConverterInfo; /** * General implementation of the <code>PluginFactory</code> interface * for SXW documents. - * + * * @see org.openoffice.xmerge.DocumentDeserializer * @see org.openoffice.xmerge.DocumentMerger * @see org.openoffice.xmerge.DocumentSerializer @@ -53,7 +53,7 @@ public abstract class SxwPluginFactory extends PluginFactory { public SxwPluginFactory (ConverterInfo ci) { super(ci); } - + public Document createOfficeDocument(String name, InputStream is) throws IOException { @@ -63,7 +63,7 @@ public abstract class SxwPluginFactory extends PluginFactory { doc.read(is); return doc; } - + public Document createOfficeDocument(String name, InputStream is,boolean isZip) throws IOException { diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/ConverterCapabilitiesImpl.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/ConverterCapabilitiesImpl.java index 96c9bbb65040..5f6e4ac38ce2 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/ConverterCapabilitiesImpl.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/ConverterCapabilitiesImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentDeserializerImpl.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentDeserializerImpl.java index b6440691a220..e118cc690ea0 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentDeserializerImpl.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentDeserializerImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -79,7 +79,7 @@ import java.io.FileNotFoundException; * PluginFactoryImpl}.</p> * * <p>The <code>serialize</code> method transforms the DOM - * document from the given <code>Document</code> object by + * document from the given <code>Document</code> object by * means of a supplied Xsl Stylesheet.</p> * * @author Aidan Butler @@ -97,7 +97,7 @@ public final class DocumentDeserializerImpl * to this object. * * @param pf A <code>PluginFactoryImpl</code> object. - * + * * @param cd A <code>ConvertData</code> object to read data for * the conversion process by the <code>deserialize</code> * method. @@ -108,17 +108,17 @@ public final class DocumentDeserializerImpl } - + /* * This method performs the xslt transformation on the supplied <code> * Document</code> and returns a <code>ByteArrayOutputStream</code> object. * * Xslt transformation code * - * @return baos A <code>ByteArrayOutputStream</code> object containing + * @return baos A <code>ByteArrayOutputStream</code> object containing * the result of the Xslt transformation. * @throws TransformerException,TransformerConfigurationException - * , FileNotFoundException,IOException + * , FileNotFoundException,IOException * */ public Document deserialize() throws ConvertException, IOException { @@ -129,10 +129,10 @@ public final class DocumentDeserializerImpl GenericOfficeDocument doc = null; ByteArrayOutputStream baos =null; GenericOfficeDocument sxwDoc = new GenericOfficeDocument("output"); - while (enumerate.hasMoreElements()) { + while (enumerate.hasMoreElements()) { docOut = (DOMDocument) enumerate.nextElement(); } - domDoc = docOut.getContentDOM(); + domDoc = docOut.getContentDOM(); try{ baos = transform(domDoc); sxwDoc.initContentDOM(); @@ -140,7 +140,7 @@ public final class DocumentDeserializerImpl dFactory.setNamespaceAware(true); DocumentBuilder dBuilder = dFactory.newDocumentBuilder(); sxwDoc.setContentDOM(dBuilder.parse(new ByteArrayInputStream(baos.toByteArray()))); - + } catch(Exception e){ System.out.println("The following error occurred:"+e); @@ -166,23 +166,23 @@ public final class DocumentDeserializerImpl return null; } } - else + else return null; } /* - * This method performs the xslt transformation on the supplied Dom Tree. + * This method performs the xslt transformation on the supplied Dom Tree. * * Xslt transformation code * * @throws TransformerException,TransformerConfigurationException - * , FileNotFoundException,IOException + * , FileNotFoundException,IOException * */ - private ByteArrayOutputStream transform(org.w3c.dom.Document xmlDoc) + private ByteArrayOutputStream transform(org.w3c.dom.Document xmlDoc) throws TransformerException,TransformerConfigurationException , FileNotFoundException,IOException{ - + log("\nTransforming..."); ConverterInfo ci = pluginFactory.getConverterInfo(); ByteArrayOutputStream baos= new ByteArrayOutputStream(); @@ -190,7 +190,7 @@ public final class DocumentDeserializerImpl DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance(); dFactory.setNamespaceAware(true); DocumentBuilder dBuilder = dFactory.newDocumentBuilder(); - + String teststr = ci.getXsltDeserial(); teststr= teststr.substring(0,6); org.w3c.dom.Document xslDoc=null; @@ -200,21 +200,21 @@ public final class DocumentDeserializerImpl xslDoc= dBuilder.parse(ci.getXsltDeserial()); } - else{ + else{ log(ci.getJarName()+"!/"+ci.getXsltDeserial()); xslDoc = dBuilder.parse( "jar:"+ci.getJarName()+"!/"+ci.getXsltDeserial()); } - + DOMSource xslDomSource = new DOMSource(xslDoc); DOMSource xmlDomSource = new DOMSource(xmlDoc); - + //call the tranformer using the XSL, Source and Result dom. - TransformerFactory tFactory = TransformerFactory.newInstance(); + TransformerFactory tFactory = TransformerFactory.newInstance(); tFactory.setURIResolver(this); Transformer transformer = tFactory.newTransformer(xslDomSource); - transformer.transform(xmlDomSource,new StreamResult(baos)); + transformer.transform(xmlDomSource,new StreamResult(baos)); /* // Serialize for output to standard out Serializer serializer = SerializerFactory.getSerializer @@ -222,9 +222,9 @@ public final class DocumentDeserializerImpl serializer.setOutputStream(System.out); serializer.asDOMSerializer().serialize(xmlDomResult.getNode()); */ - + log("\n** Transform Complete ***"); - + } catch (StackOverflowError sOE){ System.out.println("\nERROR : Stack Overflow Error During Transformation\n Try increasing the stack size by passing the -Xss1m option to the JRE."); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentMergerImpl.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentMergerImpl.java index 2098c1b7cfdc..6416d0d531a0 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentMergerImpl.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentMergerImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentSerializerImpl.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentSerializerImpl.java index feb8f7f0f750..5bf8d4983da1 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentSerializerImpl.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentSerializerImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -70,7 +70,7 @@ import java.io.FileNotFoundException; * PluginFactoryImpl}.</p> * * <p>The <code>serialize</code> method transforms the DOM - * document from the given <code>Document</code> object by + * document from the given <code>Document</code> object by * means of a supplied Xsl Stylesheet.</p> * * @author Aidan Butler @@ -83,12 +83,12 @@ public final class DocumentSerializerImpl /** SXW <code>Document</code> object that this converter processes. */ private GenericOfficeDocument sxwDoc = null; - + private PluginFactoryImpl pluginFactory = null; /** * Constructor. - * + * * @param pf A <code>PluginFactoryImpl</code> * @param doc A SXW <code>Document</code> to be converted. */ @@ -100,8 +100,8 @@ public final class DocumentSerializerImpl /** * Method to convert a <code>Document</code> with an xsl stylesheet. - * It creates a <code>Document</code> object, which is then transformed - * with the Xslt processer. A <code>ConvertData </code> object is + * It creates a <code>Document</code> object, which is then transformed + * with the Xslt processer. A <code>ConvertData </code> object is * constructed and returned. * * @return cd A <code>ConvertData</code> object. @@ -124,29 +124,29 @@ public final class DocumentSerializerImpl DocumentType docType =domImpl.createDocumentType("office:document","-//OpenOffice.org//DTD OfficeDocument 1.0//EN",null); org.w3c.dom.Document newDoc = domImpl.createDocument("http://openoffice.org/2000/office","office:document",docType); - + Element rootElement=newDoc.getDocumentElement(); - rootElement.setAttribute("xmlns:office","http://openoffice.org/2000/office"); - rootElement.setAttribute("xmlns:style","http://openoffice.org/2000/style" ); - rootElement.setAttribute("xmlns:text","http://openoffice.org/2000/text"); - rootElement.setAttribute("xmlns:table","http://openoffice.org/2000/table"); - - rootElement.setAttribute("xmlns:draw","http://openoffice.org/2000/drawing"); - rootElement.setAttribute("xmlns:fo","http://www.w3.org/1999/XSL/Format" ); - rootElement.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink" ); - rootElement.setAttribute("xmlns:dc","http://purl.org/dc/elements/1.1/" ); - rootElement.setAttribute("xmlns:meta","http://openoffice.org/2000/meta" ); - rootElement.setAttribute("xmlns:number","http://openoffice.org/2000/datastyle" ); - rootElement.setAttribute("xmlns:svg","http://www.w3.org/2000/svg" ); - rootElement.setAttribute("xmlns:chart","http://openoffice.org/2000/chart" ); - rootElement.setAttribute("xmlns:dr3d","http://openoffice.org/2000/dr3d" ); - rootElement.setAttribute("xmlns:math","http://www.w3.org/1998/Math/MathML" ); - rootElement.setAttribute("xmlns:form","http://openoffice.org/2000/form" ); - rootElement.setAttribute("xmlns:script","http://openoffice.org/2000/script" ); - rootElement.setAttribute("xmlns:config","http://openoffice.org/2001/config" ); - rootElement.setAttribute("office:class","text" ); - rootElement.setAttribute("office:version","1.0"); - + rootElement.setAttribute("xmlns:office","http://openoffice.org/2000/office"); + rootElement.setAttribute("xmlns:style","http://openoffice.org/2000/style" ); + rootElement.setAttribute("xmlns:text","http://openoffice.org/2000/text"); + rootElement.setAttribute("xmlns:table","http://openoffice.org/2000/table"); + + rootElement.setAttribute("xmlns:draw","http://openoffice.org/2000/drawing"); + rootElement.setAttribute("xmlns:fo","http://www.w3.org/1999/XSL/Format" ); + rootElement.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink" ); + rootElement.setAttribute("xmlns:dc","http://purl.org/dc/elements/1.1/" ); + rootElement.setAttribute("xmlns:meta","http://openoffice.org/2000/meta" ); + rootElement.setAttribute("xmlns:number","http://openoffice.org/2000/datastyle" ); + rootElement.setAttribute("xmlns:svg","http://www.w3.org/2000/svg" ); + rootElement.setAttribute("xmlns:chart","http://openoffice.org/2000/chart" ); + rootElement.setAttribute("xmlns:dr3d","http://openoffice.org/2000/dr3d" ); + rootElement.setAttribute("xmlns:math","http://www.w3.org/1998/Math/MathML" ); + rootElement.setAttribute("xmlns:form","http://openoffice.org/2000/form" ); + rootElement.setAttribute("xmlns:script","http://openoffice.org/2000/script" ); + rootElement.setAttribute("xmlns:config","http://openoffice.org/2001/config" ); + rootElement.setAttribute("office:class","text" ); + rootElement.setAttribute("office:version","1.0"); + NodeList nodeList; Node tmpNode; @@ -169,7 +169,7 @@ public final class DocumentSerializerImpl tmpNode = newDoc.importNode(nodeList.item(0),true); rootNode.appendChild(tmpNode); } - nodeList= domDoc.getElementsByTagName(TAG_OFFICE_BODY); + nodeList= domDoc.getElementsByTagName(TAG_OFFICE_BODY); if (nodeList.getLength()>0){ tmpNode = newDoc.importNode(nodeList.item(0),true); rootNode.appendChild(tmpNode); @@ -179,17 +179,17 @@ public final class DocumentSerializerImpl }catch(Exception e){ System.out.println("\nAn Exception occurred with Xslt Serializer"+e); } - + } - + try{ baos=transform(domDoc); } catch (Exception e){ System.out.println("\n Error with Xslt\n"); } - - String ext = pluginFactory.getDeviceFileExtension(); + + String ext = pluginFactory.getDeviceFileExtension(); DOMDocument resultDomDoc=(DOMDocument)pluginFactory.createDeviceDocument(docName,new ByteArrayInputStream(baos.toByteArray())); cd.addDocument (resultDomDoc); return cd; @@ -213,26 +213,26 @@ public final class DocumentSerializerImpl return null; } } - else + else return null; } /* * This method performs the sxl transformation on the supplied <code> - * Document</code> and returns a <code>DOMResult</code> object. + * Document</code> and returns a <code>DOMResult</code> object. * * Xslt transformation code * - * @return baos A <code>ByteArrayOutputStream</code> object containing + * @return baos A <code>ByteArrayOutputStream</code> object containing * the result of the Xslt transformation. * @throws TransformerException,TransformerConfigurationException - * , FileNotFoundException,IOException + * , FileNotFoundException,IOException * */ - private ByteArrayOutputStream transform(org.w3c.dom.Document domDoc) + private ByteArrayOutputStream transform(org.w3c.dom.Document domDoc) throws TransformerException,TransformerConfigurationException , FileNotFoundException,IOException{ //System.out.println("\nTransforming..."); @@ -240,13 +240,13 @@ public final class DocumentSerializerImpl //DOMResult xmlDomResult = new DOMResult(); ByteArrayOutputStream baos= new ByteArrayOutputStream(); try{ - + DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance(); dFactory.setNamespaceAware(true); - + DocumentBuilder dBuilder = dFactory.newDocumentBuilder(); String teststr = ci.getXsltSerial(); - + teststr= teststr.substring(0,6); org.w3c.dom.Document xslDoc=null; if ((teststr.equals("http:/"))||(teststr.equals("file:/")) @@ -255,23 +255,23 @@ public final class DocumentSerializerImpl xslDoc= dBuilder.parse(ci.getXsltSerial()); } - else{ + else{ //System.out.println(ci.getJarName()+"!/"+ci.getXsltSerial()); xslDoc = dBuilder.parse( "jar:"+ci.getJarName()+"!/"+ci.getXsltSerial()); } - - DOMSource xslDomSource = new DOMSource(xslDoc); - DOMSource xmlDomSource = new DOMSource(domDoc); - + + DOMSource xslDomSource = new DOMSource(xslDoc); + DOMSource xmlDomSource = new DOMSource(domDoc); + //call the tranformer using the XSL, Source and Result. - TransformerFactory tFactory = TransformerFactory.newInstance(); + TransformerFactory tFactory = TransformerFactory.newInstance(); tFactory.setURIResolver(this); Transformer transformer = tFactory.newTransformer(xslDomSource); transformer.transform(xmlDomSource, new StreamResult(baos)); - - /* + + /* transformer.transform(xmlDomSource, xmlDomResult); //Removed this impl because the DocType was not being written out // Serialize for output to standard out @@ -281,8 +281,8 @@ public final class DocumentSerializerImpl serializer.setOutputStream(baos); serializer.asDOMSerializer().serialize(xmlDomResult.getNode()); //serializer.asDOMSerializer().serialize(xmlDomSource.getNode()); - - + + //System.out.println("\n** Transform Complete ***"); */ } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/GenericOfficeDocument.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/GenericOfficeDocument.java index ce28b76c8034..d0ecb2c943ac 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/GenericOfficeDocument.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/GenericOfficeDocument.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -30,7 +30,7 @@ package org.openoffice.xmerge.converter.xml.xslt; import org.openoffice.xmerge.converter.xml.OfficeDocument; /** - * This class is an implementation of <code>OfficeDocument</code> for + * This class is an implementation of <code>OfficeDocument</code> for * the generic office format. */ public class GenericOfficeDocument extends OfficeDocument { @@ -75,10 +75,10 @@ public class GenericOfficeDocument extends OfficeDocument { * @return The Office attribute for the generic format. */ protected String getOfficeClassAttribute() { - + return ""; } - + /** * Method to return the MIME type of the document. * @@ -88,6 +88,6 @@ public class GenericOfficeDocument extends OfficeDocument { /* TODO: Determine the MIME-type from the input. */ return ""; } - + } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/PluginFactoryImpl.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/PluginFactoryImpl.java index ec977438a8da..36872751e999 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/PluginFactoryImpl.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/PluginFactoryImpl.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -57,7 +57,7 @@ import java.util.Properties; * {@link org.openoffice.xmerge.Document Document} * object, i.e. {@link * org.openoffice.xmerge.converter.xml.sxw.SxwDocument - * SxwDocument} that the converters in this class work with. Thus, + * SxwDocument} that the converters in this class work with. Thus, * this class only implements the methods that produces the converters, * i.e. {@link * org.openoffice.xmerge.DocumentSerializer @@ -71,10 +71,10 @@ public final class PluginFactoryImpl extends PluginFactory implements DocumentDeserializerFactory, DocumentSerializerFactory, DocumentMergerFactory { - public PluginFactoryImpl (ConverterInfo ci) { + public PluginFactoryImpl (ConverterInfo ci) { super(ci); } - + /** ConverterCapabilities object for this type of conversion. */ private final static ConverterCapabilities converterCap = new ConverterCapabilitiesImpl(); @@ -90,7 +90,7 @@ public final class PluginFactoryImpl extends PluginFactory * * @return A <code>DocumentSerializerImpl</code> object. */ - public DocumentSerializer createDocumentSerializer(Document doc) { + public DocumentSerializer createDocumentSerializer(Document doc) { return new DocumentSerializerImpl(this,doc); } @@ -98,9 +98,9 @@ public final class PluginFactoryImpl extends PluginFactory /** * Returns an instance of <code>DocumentDeserializerImpl</code>, * which is an implementation of the <code>DocumentDeserializer</code> - * interface. + * interface. * - * @param cd <code>ConvertData</code> object. + * @param cd <code>ConvertData</code> object. * * @return A DocumentDeserializerImpl object. */ @@ -108,9 +108,9 @@ public final class PluginFactoryImpl extends PluginFactory return new DocumentDeserializerImpl(this,cd); } - + public org.openoffice.xmerge.Document createDeviceDocument(java.lang.String str, java.io.InputStream inputStream) throws java.io.IOException { - String ext = this.getDeviceFileExtension(); + String ext = this.getDeviceFileExtension(); DOMDocument domDoc = new DOMDocument(str,ext); domDoc.read(inputStream); return domDoc; @@ -125,7 +125,7 @@ public final class PluginFactoryImpl extends PluginFactory doc.read(is); return doc; } - + public Document createOfficeDocument(String name, InputStream is,boolean isZip) throws IOException { @@ -136,11 +136,11 @@ public final class PluginFactoryImpl extends PluginFactory } /** - * Returns a <code>String</code> containing the file extension of a + * Returns a <code>String</code> containing the file extension of a * <code>Document</code>. This method uses a properties file to determine - * a mapping from the device mime in the <code>ConverterInfo</code> to a - * particular file extension. If a mapping is not specified, the default - * is ".txt". + * a mapping from the device mime in the <code>ConverterInfo</code> to a + * particular file extension. If a mapping is not specified, the default + * is ".txt". * * @return <code>String</code>. */ @@ -154,24 +154,24 @@ public final class PluginFactoryImpl extends PluginFactory String mimeType = null; ConverterInfo ci = this.getConverterInfo(); Enumeration enumerate = ci.getDeviceMime(); - while (enumerate.hasMoreElements()) { + while (enumerate.hasMoreElements()) { mimeType= (String) enumerate.nextElement(); } try { props.load(is); - + String info = props.getProperty(mimeType); if (info != null) { ext = info; } } catch (Exception e) { - + // It is okay for the property file to not exist. // } - return ext; + return ext; } - + /** * Returns an instance of <code>DocumentMergerImpl</code>, * which is an implementation of the <code>DocumentMerger</code> @@ -181,7 +181,7 @@ public final class PluginFactoryImpl extends PluginFactory * * @return A DocumentMergerImpl object. */ - public DocumentMerger createDocumentMerger(Document doc) { + public DocumentMerger createDocumentMerger(Document doc) { ConverterCapabilities cc = converterCap; DocumentMergerImpl merger = new DocumentMergerImpl(doc, cc); return merger; diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/DiffAlgorithm.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/DiffAlgorithm.java index dbbeda41ce31..76158a7053c0 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/DiffAlgorithm.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/DiffAlgorithm.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/Difference.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/Difference.java index 032489f12d79..31977b36f377 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/Difference.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/Difference.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -66,10 +66,10 @@ public final class Difference { /** * <p>The position of the content that should be operated on (original * iterator).</p> - * - * <p>For ADD, the orgPosition is the position of the original sequence - * where the diff will insert (the element count is starting from 0, and - * always insert before the element). The modPosition is the position + * + * <p>For ADD, the orgPosition is the position of the original sequence + * where the diff will insert (the element count is starting from 0, and + * always insert before the element). The modPosition is the position * of the diff in the modified sequence (also starting from 0).</p> * * <blockquote><pre> @@ -90,15 +90,15 @@ public final class Difference { * <diff orgPos=2 modPos=5 operation=ADD> <-- element F * * </pre> </blockquote> - * <p>One can notice the add operation is inserted before the position. - * Hence, in order to append an element, we will have a position of + * <p>One can notice the add operation is inserted before the position. + * Hence, in order to append an element, we will have a position of * original sequence length + 1 to denote an append.</p> * * <p>For DELETE, orgPosition is the position that the element * will be deleted (starting from 0) and modPosition is the position * where the deleted element should be (consider as an ADD).</p> * - * <p>The modPosition is less useful and it is difficult to understand + * <p>The modPosition is less useful and it is difficult to understand * how the position is calculated. One can just skip this piece of * information. It is useful if one wants to reverse the role * of original sequence and modified sequence and find out the diff diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/Iterator.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/Iterator.java index 2b5e05301a9e..5ebfa7b2f499 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/Iterator.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/Iterator.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -99,7 +99,7 @@ public interface Iterator { * own equal method, with this equivalent method, we can allow * flexibility for the <code>Iterator</code> to choose a custom way * to compare two objects. Two objects can even be compared based on - * the position in the <code>Iterator</code> rather than by + * the position in the <code>Iterator</code> rather than by * the content via this option. * * @param obj1 The first <code>Object</code>. diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/MergeAlgorithm.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/MergeAlgorithm.java index c3b5f3c30284..b1d4d5b510fd 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/MergeAlgorithm.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/MergeAlgorithm.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/NodeMergeAlgorithm.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/NodeMergeAlgorithm.java index 9ff56172bb13..9337816c64ab 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/NodeMergeAlgorithm.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/NodeMergeAlgorithm.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CellNodeIterator.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CellNodeIterator.java index 068aeed80266..95fddea14cb9 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CellNodeIterator.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CellNodeIterator.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CharArrayLCSAlgorithm.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CharArrayLCSAlgorithm.java index 0c50750ecacd..9026303ca3d3 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CharArrayLCSAlgorithm.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CharArrayLCSAlgorithm.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -33,7 +33,7 @@ import org.openoffice.xmerge.merger.Difference; /** * <p>This is an implementations of <code>DiffAlgorithm</code> interface * which will difference char arrays.</p> - * + * * <p>It also use Longest Common Subsequence (LCS). The algorithm is based * on the book "Introduction to Algorithms" by Thomas H.Cormen, * Charles E.Leiserson, and Ronald L.Riverst (MIT Press 1990) page 314.</p> @@ -156,7 +156,7 @@ public class CharArrayLCSAlgorithm { * table to get the difference result (and also the LCS). * * @param diffTable The difference table containing the - * <code>Difference</code> result. + * <code>Difference</code> result. * @param i The nth element in original sequence to * compare. This method is called recursively * with i and j decreased until 0. diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CharacterParser.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CharacterParser.java index c9e245422200..1a047d130a03 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CharacterParser.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CharacterParser.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/IteratorLCSAlgorithm.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/IteratorLCSAlgorithm.java index 8eaa4e7c5081..ae90274bfaf1 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/IteratorLCSAlgorithm.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/IteratorLCSAlgorithm.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/IteratorRowCompare.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/IteratorRowCompare.java index 98336b2fc748..fa6642432838 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/IteratorRowCompare.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/IteratorRowCompare.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -46,7 +46,7 @@ import org.openoffice.xmerge.converter.xml.OfficeConstants; * </li><li> * Otherwise check whether the row repeated attribute is the same. * </li><li> - * If the row repeated attribute is the same, then compare two rows + * If the row repeated attribute is the same, then compare two rows * and mark it as <i>change</i> if those rows are different. * </li><li> * If the row repeated attribute is different, then split the rows and @@ -76,7 +76,7 @@ public class IteratorRowCompare implements DiffAlgorithm { * * @param orgSeq The original sequence. * @param modSeq The modified (or changed) sequence to - * compare against with the origial. + * compare against with the origial. * * @return An array of Difference objects. */ @@ -127,11 +127,11 @@ public class IteratorRowCompare implements DiffAlgorithm { int modRowNum = 1; if (orgRowRepeated.length() > 0) { - orgRowNum = + orgRowNum = Integer.valueOf(orgRowRepeated).intValue(); } if (modRowRepeated.length() > 0) { - modRowNum = + modRowNum = Integer.valueOf(modRowRepeated).intValue(); } @@ -169,7 +169,7 @@ public class IteratorRowCompare implements DiffAlgorithm { } if (different) { - Difference diff = new Difference(Difference.CHANGE, + Difference diff = new Difference(Difference.CHANGE, i, j); diffVector.add(diff); } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/NodeIterator.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/NodeIterator.java index 3aae917ecba6..308affeb130a 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/NodeIterator.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/NodeIterator.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -118,7 +118,7 @@ public abstract class NodeIterator implements Iterator { if (currentPosition < 0 || currentPosition >= nodeList.size()) { return null; - } + } return nodeList.get(currentPosition); } @@ -190,7 +190,7 @@ public abstract class NodeIterator implements Iterator { break nodeCheck; } - // try to compare attributes + // try to compare attributes if (!attributesEqual(node1, node2)) { break nodeCheck; } @@ -203,7 +203,7 @@ public abstract class NodeIterator implements Iterator { } else if (!node1.hasChildNodes() || !node2.hasChildNodes()) { equal = false; break nodeCheck; - // need to compare if both node has children + // need to compare if both node has children } else if (!childrenEqual(node1, node2)) { break nodeCheck; } @@ -273,7 +273,7 @@ public abstract class NodeIterator implements Iterator { boolean equal = false; String nodeName = node1.getNodeName(); - NamedNodeMap attrNode[] = new NamedNodeMap[2]; + NamedNodeMap attrNode[] = new NamedNodeMap[2]; attrNode[0] = node1.getAttributes(); attrNode[1] = node2.getAttributes(); @@ -311,24 +311,24 @@ public abstract class NodeIterator implements Iterator { String srcAttrName = srcAttr.getNodeName(); // copy the supported attrs - if (cc_ == null || + if (cc_ == null || cc_.canConvertAttribute(nodeName, srcAttrName)) { // check whether the attribute exist in dst node Node dstAttr = attrNode[dst].getNamedItem(srcAttrName); if (dstAttr == null) { - Debug.log(Debug.INFO, + Debug.log(Debug.INFO, "[NodeIterator] Attr not exist in dst - " + srcAttrName); break attrCheck; } - // then compare the attribute values + // then compare the attribute values if (!srcAttr.getNodeValue().equals( dstAttr.getNodeValue())) { - Debug.log(Debug.INFO, - "[NodeIterator] Attr diff src: " + + Debug.log(Debug.INFO, + "[NodeIterator] Attr diff src: " + srcAttr.getNodeValue() + " dst: "+ dstAttr.getNodeValue()); break attrCheck; diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/ObjectArrayIterator.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/ObjectArrayIterator.java index 6f230af22310..d52b53fd78a7 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/ObjectArrayIterator.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/ObjectArrayIterator.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/ParaNodeIterator.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/ParaNodeIterator.java index d7deb43a3baa..2e16275e0e44 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/ParaNodeIterator.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/ParaNodeIterator.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -67,7 +67,7 @@ public final class ParaNodeIterator extends NodeIterator { /** - * Overwrite the parent <code>nodeSupported</code> method. + * Overwrite the parent <code>nodeSupported</code> method. * * @param node <code>Node</code> to check. * diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/RowIterator.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/RowIterator.java index 0c92540b6d01..0e514209e2f0 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/RowIterator.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/RowIterator.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/TextNodeEntry.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/TextNodeEntry.java index 57a467e4da75..8840585b2b92 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/TextNodeEntry.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/TextNodeEntry.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/TextNodeIterator.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/TextNodeIterator.java index 619440e775af..b1da7bcdcdaf 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/TextNodeIterator.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/TextNodeIterator.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/CharacterBaseParagraphMerge.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/CharacterBaseParagraphMerge.java index ed26f5292c24..adcd483dd44a 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/CharacterBaseParagraphMerge.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/CharacterBaseParagraphMerge.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -160,7 +160,7 @@ public final class CharacterBaseParagraphMerge char[] modTextArray = modParser.getCharArray(); String tmpString; - // Handle situation where getNodeValue returns null + // Handle situation where getNodeValue returns null // if (orgNode.getNodeValue() != null) tmpString = orgNode.getNodeValue(); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/DocumentMerge.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/DocumentMerge.java index 3ac34e2264aa..5c293000a964 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/DocumentMerge.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/DocumentMerge.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -194,7 +194,7 @@ public class DocumentMerge implements MergeAlgorithm { } - /** + /** * Removes the specified <code>Node</code>. * * @param node <code>Node</code> to remove. diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/PositionBaseRowMerge.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/PositionBaseRowMerge.java index 04838dcd06a4..4d912d1c8a56 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/PositionBaseRowMerge.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/PositionBaseRowMerge.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -53,7 +53,7 @@ public final class PositionBaseRowMerge implements NodeMergeAlgorithm { /** * Constructor. - * + * * @param cc The <code>ConverterCapabilities</code>. */ public PositionBaseRowMerge(ConverterCapabilities cc) { @@ -219,7 +219,7 @@ public final class PositionBaseRowMerge implements NodeMergeAlgorithm { if (attrNodes != null) { // copy the first text:p node. As it's not necessary only string - // type cell can have a text:p section. + // type cell can have a text:p section. NodeList paraNodes = modCell.getElementsByTagName(OfficeConstants.TAG_PARAGRAPH); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/SheetMerge.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/SheetMerge.java index 4e59a4b0bb44..edb95cfd9cb2 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/SheetMerge.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/SheetMerge.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -35,7 +35,7 @@ import org.openoffice.xmerge.merger.NodeMergeAlgorithm; /** * This class extends the <code>DocumentMerge</code> class. - * This class will merge two spreadsheet documents. + * This class will merge two spreadsheet documents. * The main difference between this implementation and * <code>DocumentMerge</code> * is that this merge will try to maintain unsupported features by @@ -76,7 +76,7 @@ public final class SheetMerge extends DocumentMerge { private void clearRow(Node node) { NodeList children = node.getChildNodes(); int numOfChildren = children.getLength(); - + // clear all the cells under the row node but maintain any unsupported // features // TODO: we can actually check anything left after the clear up. diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/SheetUtil.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/SheetUtil.java index 1f64cc38a946..0329434105b8 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/SheetUtil.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/SheetUtil.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -36,12 +36,12 @@ import org.openoffice.xmerge.ConverterCapabilities; import org.openoffice.xmerge.converter.xml.OfficeConstants; -/** +/** * Utility methods to handle sheet XML tree. */ public class SheetUtil { - /** + /** * <p>Empty the content of a cell value. This includes the following: * </p> * @@ -59,14 +59,14 @@ public class SheetUtil { NamedNodeMap attrNodes = node.getAttributes(); if (attrNodes != null) { - - // empty the first text:p node. + + // empty the first text:p node. // Note: it's not necessary only string type cell contain text:p // basically, all different type of cell will contain one Element cell = (Element)node; // get the paragraph node list - NodeList paraNodes = + NodeList paraNodes = cell.getElementsByTagName(OfficeConstants.TAG_PARAGRAPH); Node firstParaNode = paraNodes.item(0); @@ -77,8 +77,8 @@ public class SheetUtil { parent.removeChild(firstParaNode); } - // check all the attributes and remove those we supported in - // converter + // check all the attributes and remove those we supported in + // converter // NOTE: for attribute list, refer to section 4.7.2 in specification int len = attrNodes.getLength(); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/test/ConverterInfoList.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/test/ConverterInfoList.java index 105b39bd90a0..f9742c48a743 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/test/ConverterInfoList.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/test/ConverterInfoList.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -87,7 +87,7 @@ public class ConverterInfoList { /** - * Returns a <code>Vector</code> containing a list of + * Returns a <code>Vector</code> containing a list of * <code>String</code> objects. Each <code>String</code> * describes a plug-in to be loaded into the registry. * diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/test/Driver.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/test/Driver.java index 1e661274a465..5855727364ef 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/test/Driver.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/test/Driver.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -147,7 +147,7 @@ public final class Driver { while (dfEnum.hasMoreElements()) { processFile = (String)dfEnum.nextElement(); File f = new File(processFile); - + // Make sure the input file actually exists before using it if (!f.exists()) { System.out.println(processFile + " does not exist!"); @@ -158,7 +158,7 @@ public final class Driver { } } catch (Exception addExcept) { System.out.println("\nFile <" + processFile + "> is not in <" + - fromMime + "> format"); + fromMime + "> format"); throw new IllegalArgumentException(); } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/ActiveSyncDriver.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/ActiveSyncDriver.java index 21c6b645c6b6..fb7941a15ae0 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/ActiveSyncDriver.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/ActiveSyncDriver.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -44,19 +44,19 @@ public class ActiveSyncDriver { if (args.length != 4) { return; } - + ActiveSyncDriver asd = new ActiveSyncDriver(); - + try { // At the moment can't really signal back to the calling DLL asd.Convert(args[0], args[1], args[2], args[3]); - } + } catch (Exception e) { return; } } - - + + private boolean Convert(String srcMime, String dstMime, String srcFile, String dstFile) throws Exception { /* * The classpath passed in by XMergeSync.dll should contain all of the @@ -65,24 +65,24 @@ public class ActiveSyncDriver { * the Pocket Word and Pocket Excel plugins. */ String ooClassDir = null; - String strClassPath = System.getProperty("java.class.path"); - + String strClassPath = System.getProperty("java.class.path"); + StringTokenizer st = new StringTokenizer(strClassPath, ";"); - + // There should be at least one element, but just in case while (st.hasMoreTokens()) { String s = st.nextToken(); - + if (s.endsWith("xmerge.jar")) { ooClassDir = s.substring(0, s.indexOf("xmerge.jar")); } } - + if (ooClassDir == null) { return true; } - - + + /* * The XMergeSync.dll should will have checked for the presence of the * jars at the same location already. @@ -99,24 +99,24 @@ public class ActiveSyncDriver { { pluginJar = new File(ooClassDir + "pexcel.jar"); } - - ConverterInfoReader cirPlugin = new ConverterInfoReader(pluginJar.toURL().toString(), false); - + + ConverterInfoReader cirPlugin = new ConverterInfoReader(pluginJar.toURL().toString(), false); + ConverterInfoMgr.addPlugIn(cirPlugin.getConverterInfoEnumeration()); - + ConverterFactory cf = new ConverterFactory(); Convert conv = cf.getConverter(srcMime, dstMime); - + if (conv == null) { return false; } - + // Everything is registered so do the conversion FileInputStream fis = new FileInputStream(srcFile); FileOutputStream fos = new FileOutputStream(dstFile); - + conv.addInputStream(srcFile, fis); - + ConvertData dataOut; try { dataOut = conv.convert(); @@ -124,21 +124,21 @@ public class ActiveSyncDriver { catch (Exception e) { return false; } - + if (dataOut == null) { return false; } // Get the document and write it out. - Document doc = (Document)dataOut.getDocumentEnumeration().nextElement(); + Document doc = (Document)dataOut.getDocumentEnumeration().nextElement(); if (doc == null) { return false; } - + doc.write(fos); fos.flush(); fos.close(); - - return true; + + return true; } } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/ColourConverter.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/ColourConverter.java index 525ecb4384d9..33ef294d4ae8 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/ColourConverter.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/ColourConverter.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -39,10 +39,10 @@ import java.awt.Color; * values to a colour table. * * These colour indices are based on the Windows VGA 16 colour palette, which - * later was used as the basis for the named colours in the HTML 3.2 + * later was used as the basis for the named colours in the HTML 3.2 * specification. * - * In Pocket Word's case, the match to the VGA 16 palette is not exact as it + * In Pocket Word's case, the match to the VGA 16 palette is not exact as it * swaps Grey and Silver, with Silver being the darker colour (i.e. having the * lower RGB value). */ @@ -51,67 +51,67 @@ public class ColourConverter { /** Colour table index for Black */ private static final short BLACK = 0; - + /** Colour table index for Silver */ private static final short SILVER = 1; - + /** Colour table index for Grey */ private static final short GREY = 2; - + /** Colour table index for White */ private static final short WHITE = 3; - + /** Colour table index for Red */ private static final short RED = 4; - + /** Colour table index for Lime */ private static final short LIME = 5; - + /** Colour table index for Blue */ private static final short BLUE = 6; - + /** Colour table index for Aqua */ private static final short AQUA = 7; - + /** Colour table index for Fuchsia */ private static final short FUCHSIA = 8; - + /** Colour table index for Yellow */ private static final short YELLOW = 9; - + /** Colour table index for Maroon */ private static final short MAROON = 10; - + /** Colour table index for Green */ private static final short GREEN = 11; - + /** Colour table index for Navy */ private static final short NAVY = 12; - + /** Colour table index for Teal */ private static final short TEAL = 13; - + /** Colour table index for Purple */ private static final short PURPLE = 14; - + /** Colour table index for Olive */ public static final short OLIVE = 15; private short tableLookup[] = null; - /** + /** * Default constructor used in the case where a lookup table is not * required */ public ColourConverter() { - + } - - /** + + /** * Constructor that passes in the colour lookup table. This is required in * cases where the 16 colour values are something other than there default * values (e.g. in the case of pocket Excel) - * + * * @param short[] a 16 bit array mapping the 16 colours to there values */ public ColourConverter(short lookup[]) { @@ -124,20 +124,20 @@ public class ColourConverter { * values in the colorTable */ private short colourLookup(short colour) { - + if(tableLookup!=null) { return tableLookup[colour]; } else { return colour; } } - + /** * Uses the colour table it it exists to translate default values to * values in the colorTable */ private short indexLookup(short index) { - + short result = 0; if(tableLookup!=null) { @@ -150,14 +150,14 @@ public class ColourConverter { } return result; - } + } /** * This method maps a Pocket Word colour index value to an RGB value as * used by OpenOffice. * * @param index The index into Pocket Word's colour table. * - * @return A Color object representing the RGB value of the Pocket Word + * @return A Color object representing the RGB value of the Pocket Word * colour. */ public Color convertToRGB (short colour) { @@ -167,95 +167,95 @@ public class ColourConverter { int r = 0; int g = 0; int b = 0; - + switch (index) { case SILVER: r = g = b = 128; break; - + case GREY: r = g = b = 192; break; - + case WHITE: r = g = b = 255; break; - + case RED: r = 255; break; - + case LIME: g = 255; break; - + case BLUE: b = 255; break; - + case AQUA: g = b = 255; break; - + case FUCHSIA: r = b = 255; break; - + case YELLOW: r = g = 255; break; - + case MAROON: r = 128; break; - + case GREEN: g = 128; break; - + case NAVY: b = 128; break; - + case TEAL: b = g = 128; break; - + case PURPLE: r = b = 128; break; - + case OLIVE: r = g = 128; break; - + case BLACK: default: r = g = b = 0; break; } - + return new Color(r, g, b); } - - + + /** * This method approximates an RGB value (as used by Writer) to one of the - * 16 available colours + * 16 available colours * * Most of the supported colours have their components set to either 0, 128 * or 255. The exception is 'Grey' which is 0xC0C0C0. * * @param colour Color object representing the RGB value of the colour. * - * @return Index into the Pocket Word colour table which represents the + * @return Index into the Pocket Word colour table which represents the * closest match to the specified colour. */ public short convertFromRGB (Color colour) { int matchedRGB = 0; short indexColour = 0; int reducedMap[] = new int[] { 0, 0, 128 }; - + int red = colour.getRed(); int green = colour.getGreen(); int blue = colour.getBlue(); @@ -264,14 +264,14 @@ public class ColourConverter { // white so we modify the rgb values if the colour is sufficently // white if(red>0xC0 && green>0xC0 && blue>0xC0) { - + if(red!=0xFF) red = getClosest(red, reducedMap); if(green!=0xFF) green = getClosest(green, reducedMap); if(blue!=0xFF) blue = getClosest(blue, reducedMap); - } + } /* * Need to derive an RGB value that has been rounded to match the ones @@ -280,10 +280,10 @@ public class ColourConverter { matchedRGB += getClosest(red) << 16; matchedRGB += getClosest(green) << 8; matchedRGB += getClosest(blue); - + /* - * The colour map used by Pocket Word doesn't have any combinations of - * values beyond 0 and any other value. A value of 255 in any RGB + * The colour map used by Pocket Word doesn't have any combinations of + * values beyond 0 and any other value. A value of 255 in any RGB * code indicates a dominant colour. Other colours are only modifiers * to the principal colour(s). Thus, for this conversion, modifiers * can be dropped. @@ -298,10 +298,10 @@ public class ColourConverter { } if ((matchedRGB & 0xFF) == 0x80) { matchedRGB ^= 0x80; - } + } } - - + + /* * And now for the actual matching ... * @@ -316,18 +316,18 @@ public class ColourConverter { */ switch (matchedRGB) { case 0x000000: - indexColour = BLACK; + indexColour = BLACK; break; - + case 0x808080: if (!isGrey(colour)) { - indexColour = SILVER; + indexColour = SILVER; } else { indexColour = GREY; } break; - + case 0xFFFFFF: if (!isGrey(colour)) { indexColour = WHITE; @@ -336,76 +336,76 @@ public class ColourConverter { indexColour = GREY; } break; - + case 0xFF0000: indexColour = RED; break; - + case 0x00FF00: indexColour = LIME; break; - + case 0x0000FF: indexColour = BLUE; break; - + case 0x00FFFF: indexColour = AQUA; break; - + case 0xFF00FF: indexColour = FUCHSIA; break; - + case 0xFFFF00: indexColour = YELLOW; break; - + case 0x800000: indexColour = MAROON; break; - + case 0x008000: indexColour = GREEN; break; - + case 0x000080: indexColour = NAVY; break; - + case 0x008080: indexColour = TEAL; break; - + case 0x800080: indexColour = PURPLE; break; - + case 0x808000: indexColour = OLIVE; break; - + default: // Just in case! indexColour = BLACK; break; } - + return colourLookup(indexColour); } - + /* * Default implementation, checks for the closest of value to 0, 128 or 255. */ private int getClosest(int value) { int points[] = new int[] { 0, 128, 255 }; - + return getClosest(value, points); } - - + + /* - * Utility method that returns the closest of the three points to the value + * Utility method that returns the closest of the three points to the value * supplied. */ private int getClosest(int value, int[] points) { @@ -413,7 +413,7 @@ public class ColourConverter { if (value == points[0] || value == points[1] || value == points[2]) { return value; } - + if (value < points[1]) { int x = value - points[0]; return (Math.round((float)x / (points[1] - points[0])) == 1 ? points[1] : points[0]); @@ -423,24 +423,24 @@ public class ColourConverter { return (Math.round((float)x / (points[2] - points[1])) >= 1 ? points[2] : points[1]); } } - - + + /* * Checks to see if the supplied colour can be considered to be grey. */ private boolean isGrey(Color c) { int matchedRGB = 0; int points[] = new int[] { 128, 192, 255 }; - + matchedRGB += getClosest(c.getRed(), points) << 16; matchedRGB += getClosest(c.getGreen(), points) << 8; matchedRGB += getClosest(c.getBlue(), points); - + if (matchedRGB == 0xC0C0C0) { return true; } - + return false; } } - + diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/Debug.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/Debug.java index ff8954434419..8b9f06eb4e86 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/Debug.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/Debug.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/EndianConverter.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/EndianConverter.java index e2337b0e9c41..c41a428dd0c2 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/EndianConverter.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/EndianConverter.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -29,10 +29,10 @@ package org.openoffice.xmerge.util; /** - * <p>Helper class providing static methods to convert data to/from + * <p>Helper class providing static methods to convert data to/from * Network Byte Order (Big Endian).</p> * - * <p>With the introduction of <code>java.nio.ByteOrder</code> and + * <p>With the introduction of <code>java.nio.ByteOrder</code> and * <code>java.nio.ByteBuffer</code> in Java 1.4, it may no longer be * necessary to use this class in the future.</p> * @@ -40,55 +40,55 @@ package org.openoffice.xmerge.util; * @version 1.1 */ public class EndianConverter { - + /** * <p>Convert a <code>short</code> to a Little Endian representation.</p> * * @param value The <code>short</code> to be converted. * - * @return Two element <code>byte</code> array containing the converted + * @return Two element <code>byte</code> array containing the converted * value. */ public static byte[] writeShort (short value) { byte[] leShort = new byte[2]; - + leShort[0] = (byte) value; leShort[1] = (byte) (value >>> 8); - + return leShort; } - - + + /** * <p>Convert an integer to a Little Endian representation.</p> * * @param value The <code>int</code> to be converted. * - * @return Four element <code>byte</code> array containing the converted + * @return Four element <code>byte</code> array containing the converted * value. */ public static byte[] writeInt (int value) { byte[] leInt = new byte[4]; - + leInt[0] = (byte) value; leInt[1] = (byte) (value >>> 8); leInt[2] = (byte) (value >>> 16); leInt[3] = (byte) (value >>> 24); - + return leInt; } /** - * <p>Converts a <code>double</code> to a Little Endian representation - * of a float in IEEE-754 format. + * <p>Converts a <code>double</code> to a Little Endian representation + * of a float in IEEE-754 format. * - * <p>An array with more than eight elements can be used, but only the first + * <p>An array with more than eight elements can be used, but only the first * eight elements will be read.</p> * - * @param value <code>double</code> containing the value to be converted + * @param value <code>double</code> containing the value to be converted * * @return <code>byte</code> array containing the LE representation of a IEEE-754 float - */ + */ public static byte[] writeDouble(double value) { long myDouble = Double.doubleToLongBits(value); @@ -103,50 +103,50 @@ public class EndianConverter { leDouble[6] = (byte) (myDouble >>> 48); leDouble[7] = (byte) (myDouble >>> 56); - return leDouble; - } - + return leDouble; + } + /** - * <p>Convert a Little Endian representation of a short to a Java + * <p>Convert a Little Endian representation of a short to a Java * <code>short</code> (Network Byte Order).</p> * - * <p>An array with more than two elements can be used, but only the first + * <p>An array with more than two elements can be used, but only the first * two elements will be read.</p> * - * @param value <code>byte</code> array containing the LE representation + * @param value <code>byte</code> array containing the LE representation * of the value. * * @return <code>short</code> containing the converted value. */ public static short readShort (byte[] value) { int high, low; - + high = value[1] & 0xFF; low = value[0] & 0xFF; - + return (short)(high << 8 | low); } - - + + /** - * <p>Convert a Little Endian representation of an integer to a Java + * <p>Convert a Little Endian representation of an integer to a Java * <code>int</code> (Network Byte Order).</p> * - * <p>An array with more than four elements can be used, but only the first + * <p>An array with more than four elements can be used, but only the first * four elements will be read.</p> * - * @param value <code>byte</code> array containing the LE representation + * @param value <code>byte</code> array containing the LE representation * of the value. * * @return <code>int</code> containing the converted value. - */ + */ public static int readInt(byte[] value) { int number = 0; - + for (int i = 0; i < 4; i++) { number |= (value[i] & 0xFF) << ( i * 8); - } - + } + return number; } @@ -154,25 +154,25 @@ public class EndianConverter { * <p>Convert a Little Endian representation of a float in IEEE-754 Little * Endian to a Java <code>double</code> (Network Byte Order).</p> * - * <p>An array with more than eight elements can be used, but only the first + * <p>An array with more than eight elements can be used, but only the first * eight elements will be read.</p> * - * @param value <code>byte</code> array containing the LE representation - * of a IEEE-754 float. + * @param value <code>byte</code> array containing the LE representation + * of a IEEE-754 float. * * @return <code>double</code> containing the converted value. - */ + */ public static double readDouble(byte[] value) { - - long lvalue = ( ((long)(value[7]) << 56) + - ((long)(value[6]&0xFF) << 48) + - ((long)(value[5]&0xFF) << 40) + - ((long)(value[4]&0xFF) << 32) + - ((long)(value[3]&0xFF) << 24) + - ((long)(value[2]&0xFF) << 16) + - ((long)(value[1]&0xFF) << 8) + + + long lvalue = ( ((long)(value[7]) << 56) + + ((long)(value[6]&0xFF) << 48) + + ((long)(value[5]&0xFF) << 40) + + ((long)(value[4]&0xFF) << 32) + + ((long)(value[3]&0xFF) << 24) + + ((long)(value[2]&0xFF) << 16) + + ((long)(value[1]&0xFF) << 8) + (long)(value[0]&0xFF)); - + return Double.longBitsToDouble(lvalue); } } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/IntArrayList.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/IntArrayList.java index ff7a253d9db9..a317fa2997e1 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/IntArrayList.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/IntArrayList.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -79,7 +79,7 @@ public class IntArrayList { * @param minCapacity The minimum capacity of the list. * @param fillValue This method adds in a integer for each * slot that was added to ensure that the - * list meets the minimum capacity. + * list meets the minimum capacity. * <code>fillValue</code> is the value * used as the initial value of these * added elements. diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/OfficeUtil.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/OfficeUtil.java index a122068523ae..64a37037c406 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/OfficeUtil.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/OfficeUtil.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -44,9 +44,9 @@ import java.util.Vector; * @version 1.1 */ public class OfficeUtil implements OfficeConstants { - + /** - * <p>Method to replace whitespace character within text with appropriate + * <p>Method to replace whitespace character within text with appropriate * OpenOffice tags.</p> * * @param text The text to parse for whitespace. @@ -57,7 +57,7 @@ public class OfficeUtil implements OfficeConstants { public static Node[] parseText(String text, Document parentDoc) { Vector nodeVec = new Vector(); - /* + /* * Break up the text from the text run into Open * Office text runs. There may be more runs in OO because * runs of 2 or more spaces map to nodes. @@ -80,7 +80,7 @@ public class OfficeUtil implements OfficeConstants { closerIndex = spaceIndex; else closerIndex = (spaceIndex > tabIndex) ? tabIndex : spaceIndex; - + /* * If there is any text prior to the first occurrence of a * tab or spaces, create a text node from it, then chop it @@ -93,7 +93,7 @@ public class OfficeUtil implements OfficeConstants { } text = text.substring(closerIndex); - /* + /* * Handle either tab character or space sequence by creating * an element for it, and then chopping out the text that * represented it in "text". @@ -110,7 +110,7 @@ public class OfficeUtil implements OfficeConstants { nrSpaces++; Element spaceNode = parentDoc.createElement(TAG_SPACE); - spaceNode.setAttribute(ATTRIBUTE_SPACE_COUNT, + spaceNode.setAttribute(ATTRIBUTE_SPACE_COUNT, new Integer(nrSpaces).toString()); nodeVec.add(spaceNode); text = text.substring(nrSpaces); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/Resources.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/Resources.java index 266113abf0bb..44db518b3389 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/Resources.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/Resources.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/TwipsConverter.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/TwipsConverter.java index be85f54c5376..fe3931a5aadf 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/TwipsConverter.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/TwipsConverter.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -29,19 +29,19 @@ package org.openoffice.xmerge.util; /** - * <p>Helper class providing static methods to convert data to/from + * <p>Helper class providing static methods to convert data to/from * twips</p> * - * @author Martin Maher + * @author Martin Maher */ public class TwipsConverter { - + /** * <p>Convert from twips to cm's</p> * * @param value The <code>short</code> to be converted. * - * @return float containing the converted + * @return float containing the converted */ public static float twips2cm(int value) { @@ -50,50 +50,50 @@ public class TwipsConverter { return cm; } - - - + + + /** * <p>Convert from cm's to twips</p> * - * @param value <code>byte</code> array containing the LE representation + * @param value <code>byte</code> array containing the LE representation * of the value. * * @return int containing the converted value. */ public static int cm2twips(float value) { - - int twips = (int) ((value/2.54)*1440); - + + int twips = (int) ((value/2.54)*1440); + return twips; } - + /** * <p>Convert from twips to cm's</p> * * @param value The <code>short</code> to be converted. * - * @return float containing the converted + * @return float containing the converted */ public static float twips2inches(int value) { return (float) value/1440; } - - - + + + /** * <p>Convert from cm's to twips</p> * - * @param value <code>byte</code> array containing the LE representation + * @param value <code>byte</code> array containing the LE representation * of the value. * * @return int containing the converted value. */ public static int inches2twips(float value) { - + return (int) (value*1440); } - - + + } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/XmlUtil.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/XmlUtil.java index 09006520e364..9b3ec402b2e8 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/XmlUtil.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/XmlUtil.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -135,10 +135,10 @@ public final class XmlUtil { * @return Name and type of XML DOM <code>Node</code>. */ public static String getNodeInfo(Node node) { - + String str = null; switch (node.getNodeType()) { - + case Node.ELEMENT_NODE: str = "ELEMENT"; break; diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfo.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfo.java index c28e75995e3d..359bcbfeb222 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfo.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfo.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -44,7 +44,7 @@ import org.openoffice.xmerge.DocumentMergerFactory; */ public class ConverterInfo { - /** + /** * Keep track of the valid Office mime types */ private static String[] validOfficeTypes; @@ -90,9 +90,9 @@ public class ConverterInfo { * @param impl The implementation class name of * PluginFactory. * @param xsltSerial The url of the serializer xsl stylesheet - * @param xsltDeserial The url of the deserializer xsl stylesheet + * @param xsltDeserial The url of the deserializer xsl stylesheet * - * @throws RegistryException If <code>ci</code> cannot + * @throws RegistryException If <code>ci</code> cannot * be loaded. */ public ConverterInfo(String jarName, String officeMime, @@ -168,7 +168,7 @@ public class ConverterInfo { * @param impl The implementation class name of * PluginFactory. * - * @throws RegistryException If <code>ci</code> cannot + * @throws RegistryException If <code>ci</code> cannot * be loaded. */ @@ -234,13 +234,13 @@ public class ConverterInfo { /** - * Create a default constructor so we can use isValidOfficeType + * Create a default constructor so we can use isValidOfficeType * without having to actually have a valid ConverterInfo. */ private ConverterInfo() { } - - + + /** * Returns an instance of the DocumentDeserializerFactory interface. * @@ -280,7 +280,7 @@ public class ConverterInfo { return piJarName; } - + /** * Returns the office mime-type. * @@ -289,7 +289,7 @@ public class ConverterInfo { public String getOfficeMime() { return piOfficeMime; } - + /** * Returns an <code>Enumeration</code> of <code>String</code> @@ -301,7 +301,7 @@ public class ConverterInfo { public Enumeration getDeviceMime() { return(piDeviceMime.elements()); } - + /** * Returns the display name. @@ -312,7 +312,7 @@ public class ConverterInfo { return piDisplayName; } - + /** * Returns the description. * @@ -321,7 +321,7 @@ public class ConverterInfo { public String getDescription() { return piDescription; } - + /** * Returns the version. @@ -331,7 +331,7 @@ public class ConverterInfo { public String getVersion() { return piVersion; } - + /** * Returns the vendor name. @@ -342,7 +342,7 @@ public class ConverterInfo { return piVendor; } - + /** * Returns the implementation class name of PluginFactory. * @@ -412,7 +412,7 @@ public class ConverterInfo { } /** - * Returns a <code>String</code> containing the Xslt stylesheet url that + * Returns a <code>String</code> containing the Xslt stylesheet url that * is to be used by the Xslt Plugin Serializer. * * @return <code>String</code> @@ -422,8 +422,8 @@ public class ConverterInfo { return piXsltSerial; } - /** - * Returns a <code>String</code> containing the xslt stylesheet url that + /** + * Returns a <code>String</code> containing the xslt stylesheet url that * is to be used by the Xslt Plugin Deserializer. * * @return <code>String</code> diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoMgr.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoMgr.java index 66fede923a65..0993924c129f 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoMgr.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoMgr.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -55,7 +55,7 @@ public final class ConverterInfoMgr { * Adds a converter plug-in to the registry. The * <code>ConverterInfo</code> must have a unique DisplayName * and must have non-null values for DisplayName, ClassImpl, - * OfficeMime, and DeviceMime. + * OfficeMime, and DeviceMime. * * @param ConverterInfo A <code>ConverterInfo</code> object * describing a plug-in. @@ -102,7 +102,7 @@ public final class ConverterInfoMgr { throw re; } } - + // Since this is a adding to a static Vector, make sure this // add method call is synchronized. // @@ -110,15 +110,15 @@ public final class ConverterInfoMgr { converterInfoList.add(ci); } } - + /** * Adds a <code>Vector</code> of converter plug-ins to the registry. - * Each <code>ConverterInfo</code> in the <code>Vector</code> must have + * Each <code>ConverterInfo</code> in the <code>Vector</code> must have * a unique DisplayName and must have non-null values for DisplayName, - * ClassImpl, OfficeMime, and DeviceMime. + * ClassImpl, OfficeMime, and DeviceMime. * - * @param ciVectory A <code>Vector</code> of <code>ConverterInfo</code> + * @param ciVectory A <code>Vector</code> of <code>ConverterInfo</code> * objects describing one or more plug-in(s). * * @throws RegistryException If a <code>ConverterInfo</code> in the @@ -152,7 +152,7 @@ public final class ConverterInfoMgr { * * @param jar The name of the jarfile. * - * @return True if a <code>ConverterInfo</code> object was + * @return True if a <code>ConverterInfo</code> object was * removed, false otherwise. */ public static boolean removeByJar(String jar) { @@ -190,7 +190,7 @@ public final class ConverterInfoMgr { * * @param name The display name. * - * @return True if a <code>ConverterInfo</code> object was + * @return True if a <code>ConverterInfo</code> object was * removed, false otherwise. */ public static boolean removeByName(String name) { @@ -220,7 +220,7 @@ public final class ConverterInfoMgr { * @param deviceMime The device mime. * @param officeMime The office mime. * - * @return The first plug-in that supports the specified + * @return The first plug-in that supports the specified * conversion. */ public static ConverterInfo findConverterInfo(String deviceMime, String officeMime) { @@ -325,9 +325,9 @@ public final class ConverterInfoMgr { /** - * main to let the user specify what plug-ins to register from + * main to let the user specify what plug-ins to register from * jarfiles and to display the currently registered plug-ins. - * + * * @param args Not used. */ public static void main(String args[]) { @@ -360,7 +360,7 @@ public final class ConverterInfoMgr { } System.out.println(""); - + // Quit // if (c == 'Q') { @@ -392,7 +392,7 @@ public final class ConverterInfoMgr { } } - // Unload by Display Name or Jarfile + // Unload by Display Name or Jarfile // } else if (c == 'T') { if (validate== true){ @@ -426,7 +426,7 @@ public final class ConverterInfoMgr { } else { System.out.println("Remove failed."); } - + } catch (Exception e) { System.out.println("Error removing value from registry"); System.out.println("Error msg: " + e.getMessage()); @@ -451,7 +451,7 @@ public final class ConverterInfoMgr { System.out.println("Error adding data to registry"); System.out.println("Error msg: " + e.getMessage()); } - + if (c == 'F') { System.out.println("Enter office mime: "); } else { @@ -506,7 +506,7 @@ public final class ConverterInfoMgr { int feCnt = 1; while (fromEnum.hasMoreElements()) { - System.out.println(" DeviceMime : (#" + feCnt + ") : " + + System.out.println(" DeviceMime : (#" + feCnt + ") : " + (String)fromEnum.nextElement()); feCnt++; } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoReader.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoReader.java index 2bf02bb00aae..238fd59f9608 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoReader.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoReader.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -63,16 +63,16 @@ public class ConverterInfoReader { /** - * Constructor. A jar file is passed in. The jar file is + * Constructor. A jar file is passed in. The jar file is * parsed and the <code>Vector</code> of <code>ConverterInfo</code> * objects is built. * * @param jar The URL of the jar file to process. * @param shouldvalidate Boolean to enable or disable xml validation. * - * @throws IOException If the jar file cannot + * @throws IOException If the jar file cannot * be read or if the - * META-INF/converter.xml + * META-INF/converter.xml * can not be read in the * jar file. * @throws ParserConfigurationException If the DocumentBuilder @@ -110,11 +110,11 @@ public class ConverterInfoReader { // istream = jarfile.getInputStream(jarentry); isource = new InputSource(istream); - + // Get the DOM builder and build the document. // builderFactory = DocumentBuilderFactory.newInstance(); - + //DTD validation if (shouldvalidate){ System.out.println("Validating xml..."); @@ -133,7 +133,7 @@ public class ConverterInfoReader { /** * Loops over the <i>converter</i> <code>Node</code> in the converter.xml * file and processes them. - * + * * @throws RegistryException If the plug-in associated with a * specific <i>converter</i> <code>Node</code> * cannot be loaded. @@ -142,7 +142,7 @@ public class ConverterInfoReader { Node converterNode; NodeList converterNodes = document.getElementsByTagName(TAG_CONVERTER); - + for (int i=0; i < converterNodes.getLength(); i++) { converterNode = converterNodes.item(i); if (converterNode.getNodeType() == Node.ELEMENT_NODE) { @@ -161,7 +161,7 @@ public class ConverterInfoReader { * @param e The <code>Element</code> corresponding to the * <i>converter</i> XML tag. * - * + * * @throws RegistryException If the plug-in cannot be loaded. */ private void parseConverterNode(Element e) throws RegistryException { @@ -180,11 +180,11 @@ public class ConverterInfoReader { String xsltDeserial= null; String temp; - temp = e.getAttribute(ATTRIB_OFFICE_TYPE); + temp = e.getAttribute(ATTRIB_OFFICE_TYPE); if (temp.length() != 0) { officeMime = temp; } - + temp = e.getAttribute(ATTRIB_VERSION); if (temp.length() != 0) { version = temp; @@ -198,7 +198,7 @@ public class ConverterInfoReader { detailElement = (Element)detailNode; elementTagName = detailElement.getTagName(); - + if (TAG_NAME.equalsIgnoreCase(elementTagName)) { name = getTextValue(detailElement); } else if (TAG_DESC.equalsIgnoreCase(elementTagName)) { @@ -206,13 +206,13 @@ public class ConverterInfoReader { } else if (TAG_VENDOR.equalsIgnoreCase(elementTagName)) { vendor = getTextValue(detailElement); } else if (TAG_XSLT_SERIAL.equalsIgnoreCase(elementTagName)) { - xsltSerial = getTextValue(detailElement); + xsltSerial = getTextValue(detailElement); } else if (TAG_XSLT_DESERIAL.equalsIgnoreCase(elementTagName)) { xsltDeserial = getTextValue(detailElement); } else if (TAG_CLASS_IMPL.equalsIgnoreCase(elementTagName)) { classImpl = getTextValue(detailElement); } else if (TAG_TARGET.equalsIgnoreCase(elementTagName)) { - + temp = detailElement.getAttribute(ATTRIB_DEVICE_TYPE); if (temp.length() != 0) { deviceMime.add(temp); @@ -223,12 +223,12 @@ public class ConverterInfoReader { ConverterInfo converterInfo; if ((xsltSerial==null) || (xsltDeserial==null)){ converterInfo = new ConverterInfo(jarfilename, - officeMime, deviceMime, name, + officeMime, deviceMime, name, desc, version, vendor,classImpl); } else{ converterInfo = new ConverterInfo(jarfilename, - officeMime, deviceMime, name, + officeMime, deviceMime, name, desc, version, vendor,classImpl, xsltSerial,xsltDeserial); } @@ -244,7 +244,7 @@ public class ConverterInfoReader { * <code>Element</code>. * * @param e The <code>Element</code> to process. - * + * * @return The text value of the <code>Element</code>. */ private String getTextValue(Element e) { diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/RegistryException.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/RegistryException.java index b073d7d2a383..ea370d386c1c 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/RegistryException.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/RegistryException.java @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/build.xml b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/build.xml index 5bc7c608886d..525546d2f7fc 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/build.xml +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/build.xml @@ -3,23 +3,23 @@ #************************************************************************* # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - + Copyright 2000, 2010 Oracle and/or its affiliates. - + OpenOffice.org - a multi-platform office productivity suite - + This file is part of OpenOffice.org. - + OpenOffice.org is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. - + OpenOffice.org is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details (a copy is included in the LICENSE file that accompanied this code). - + You should have received a copy of the GNU Lesser General Public License version 3 along with OpenOffice.org. If not, see <http://www.openoffice.org/license.html> @@ -130,6 +130,6 @@ </fileset> </delete> </target> - + </project> diff --git a/xmerge/util/build.xml b/xmerge/util/build.xml index b83dc2a1394c..f15ad3acff08 100644 --- a/xmerge/util/build.xml +++ b/xmerge/util/build.xml @@ -1,23 +1,23 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - + Copyright 2000, 2010 Oracle and/or its affiliates. - + OpenOffice.org - a multi-platform office productivity suite - + This file is part of OpenOffice.org. - + OpenOffice.org is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. - + OpenOffice.org is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details (a copy is included in the LICENSE file that accompanied this code). - + You should have received a copy of the GNU Lesser General Public License version 3 along with OpenOffice.org. If not, see <http://www.openoffice.org/license.html> @@ -27,27 +27,27 @@ <project name="xmrg_util" default="main" basedir="."> <property file="../source/inc/antbuild.properties"/> - + <property name="javadoc.dir" location="${build.dir}/javadoc"/> <property environment="env"/> <property name="env.XML_APIS_JAR" value="${solar.jar}/xml-apis.jar"/> <property name="env.XERCES_JAR" value="${solar.jar}/xercesImpl.jar"/> - + <path id="classpath"> <pathelement location="${env.XML_APIS_JAR}"/> <pathelement location="${env.XERCES_JAR}"/> <pathelement location="${solar.jar}/unoil.jar"/> <pathelement location="${solar.jar}/ridl.jar"/> <pathelement location="${solar.jar}/jurt.jar"/> - <pathelement location="${solar.jar}/juh.jar"/> + <pathelement location="${solar.jar}/juh.jar"/> <pathelement location="${build.dir}/xmerge.jar"/> </path> - + <target name="init"> <mkdir dir="${javadoc.dir}"/> </target> - + <!-- build javadoc --> <target name="javadoc" depends="init"> <javadoc destdir="${javadoc.dir}" @@ -85,10 +85,10 @@ <target name="all" depends="javadoc"> </target> - + <target name="clean"> <delete file="${javadoc.dir}"/> </target> - + </project> diff --git a/xmerge/workben/XmlDiff.java b/xmerge/workben/XmlDiff.java index 7a60dd26bf46..e41dbbb6b9b0 100644 --- a/xmerge/workben/XmlDiff.java +++ b/xmerge/workben/XmlDiff.java @@ -1,7 +1,7 @@ /************************************************************************ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -123,15 +123,15 @@ public final class XmlDiff { String node2Str = ""; if (node1 != null) { - node1Str = "[Type]:" + nodeInfo(node1) + - " [Name]:" + node1.getNodeName(); + node1Str = "[Type]:" + nodeInfo(node1) + + " [Name]:" + node1.getNodeName(); if (node1.getNodeValue() != null) node1Str += " [Value]:" + node1.getNodeValue(); } if (node2 != null) { node2Str = "[Type]:" + nodeInfo(node2) + - " [Name]:" + node2.getNodeName(); + " [Name]:" + node2.getNodeName(); if (node2.getNodeValue() != null) node2Str += " [Value]:" + node2.getNodeValue(); } @@ -142,10 +142,10 @@ public final class XmlDiff { } private String nodeInfo(Node node) { - + String str = null; switch (node.getNodeType()) { - + case Node.ELEMENT_NODE: str = "ELEMENT"; break; @@ -212,12 +212,12 @@ public final class XmlDiff { equal = true; break; } else if (node1 == null || node2 == null) { - diffLog("DIFF: one of the node is null", node1, node2); + diffLog("DIFF: one of the node is null", node1, node2); break; } if (node1.getNodeType() != node2.getNodeType()) { - diffLog("DIFF: nodetype is different", node1, node2); + diffLog("DIFF: nodetype is different", node1, node2); break; } @@ -225,15 +225,15 @@ public final class XmlDiff { // empty } else if (node1.getNodeName() == null || node2.getNodeName() == null) { - diffLog("DIFF: one of the nodeName is null", node1, node2); + diffLog("DIFF: one of the nodeName is null", node1, node2); break; } else if (!node1.getNodeName().equals(node2.getNodeName())) { - diffLog("DIFF: nodeName is different", node1, node2); + diffLog("DIFF: nodeName is different", node1, node2); break; } if (ignoreTag(node1.getNodeName())) { - diffLog("DIFF: Some tag(s) is ignored", node1, node2); + diffLog("DIFF: Some tag(s) is ignored", node1, node2); equal = true; break; } @@ -242,10 +242,10 @@ public final class XmlDiff { // empty } else if (node1.getNodeValue() == null || node2.getNodeValue() == null) { - diffLog("DIFF: one of the nodevalue is null", node1, node2); + diffLog("DIFF: one of the nodevalue is null", node1, node2); break; } else if (!node1.getNodeValue().equals(node2.getNodeValue())) { - diffLog("DIFF: nodeValue is different", node1, node2); + diffLog("DIFF: nodeValue is different", node1, node2); break; } @@ -263,12 +263,12 @@ public final class XmlDiff { } if (node1Children == null || node2Children == null) { - diffLog("DIFF: one node's children is null", node1, node2); + diffLog("DIFF: one node's children is null", node1, node2); break; } if (node1Children.getLength() != node2Children.getLength()) { - diffLog("DIFF: num of children is different", node1, node2); + diffLog("DIFF: num of children is different", node1, node2); break; } @@ -354,7 +354,7 @@ public final class XmlDiff { private String [] parseTags(String tagsString) { Vector tagsVector = new Vector(); - if (tagsString.length() == 0) + if (tagsString.length() == 0) return null; int start = 0; @@ -452,7 +452,7 @@ public final class XmlDiff { same = xmldiff.diff(); } - System.out.println("Diff result: " + same); + System.out.println("Diff result: " + same); } } diff --git a/xmerge/workben/build.xml b/xmerge/workben/build.xml index 4e7afc14188b..ed8da0ccb444 100644 --- a/xmerge/workben/build.xml +++ b/xmerge/workben/build.xml @@ -2,23 +2,23 @@ <!-- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - + Copyright 2000, 2010 Oracle and/or its affiliates. - + OpenOffice.org - a multi-platform office productivity suite - + This file is part of OpenOffice.org. - + OpenOffice.org is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. - + OpenOffice.org is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details (a copy is included in the LICENSE file that accompanied this code). - + You should have received a copy of the GNU Lesser General Public License version 3 along with OpenOffice.org. If not, see <http://www.openoffice.org/license.html> @@ -124,5 +124,5 @@ </fileset> </delete> </target> - + </project> diff --git a/xmerge/workben/jstyle.pl b/xmerge/workben/jstyle.pl index ce6108bb7bba..3c300c29a227 100644 --- a/xmerge/workben/jstyle.pl +++ b/xmerge/workben/jstyle.pl @@ -3,7 +3,7 @@ #*************************************************************************** # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -35,25 +35,25 @@ if 0; # # jstyle - check for some common stylistic errors. # -# jstyle is a sort of "lint" for Java coding style. +# jstyle is a sort of "lint" for Java coding style. # -# There's a lot this can't check for, like proper -# indentation of continuation lines. There's also -# a lot more this could check for. +# There's a lot this can't check for, like proper +# indentation of continuation lines. There's also +# a lot more this could check for. # -# A note to the non perl literate: +# A note to the non perl literate: # -# perl regular expressions are pretty much like egrep -# regular expressions, with the following special symbols +# perl regular expressions are pretty much like egrep +# regular expressions, with the following special symbols # -# \s any space character -# \S any non-space character -# \w any "word" character [a-zA-Z0-9_] -# \W any non-word character -# \d a digit [0-9] -# \D a non-digit -# \b word boundary (between \w and \W) -# \B non-word boundary +# \s any space character +# \S any non-space character +# \w any "word" character [a-zA-Z0-9_] +# \W any non-word character +# \d a digit [0-9] +# \D a non-digit +# \b word boundary (between \w and \W) +# \B non-word boundary # #require "getopts.pl"; # XXX - because some versions of perl can not find the lib directory, @@ -111,14 +111,14 @@ sub Getopts { $usage = "usage: jstyle [-c] [-h] [-p] [-s] [-t] [-v] [-C] file ... - -c check continuation line indenting - -h perform heuristic checks that are sometimes wrong - -p perform some of the more picky checks - -s check for spaces vs. tabs - -t insist on indenting by tabs - -v verbose - -C don't check anything in header block comments - -S print out overall statistics + -c check continuation line indenting + -h perform heuristic checks that are sometimes wrong + -p perform some of the more picky checks + -s check for spaces vs. tabs + -t insist on indenting by tabs + -v verbose + -C don't check anything in header block comments + -S print out overall statistics "; if (!&Getopts("chpstvCS")) { @@ -194,7 +194,7 @@ $filename = $_[0]; line: while (<STDIN>) { ++$totlines; - s/\r?\n$//; # strip return and newline + s/\r?\n$//; # strip return and newline # save the original line, then remove all text from within # double or single quotes, we do not want to check such text. @@ -241,19 +241,19 @@ line: while (<STDIN>) { do err("line > 100 characters ($l)"); } } -# this is the fastest way to check line length, -# but it doesnt work with perl 3.0. -# if ($line =~ tr/\t/\t/ * 7 + length($line) > 80) { -# $pos = $oldp = $p = 0; -# while (($p = index($line, "\t", $p)) >= 0) { -# $pos = ($pos + $p - $oldp + 8) & ~7; -# $oldp = ++$p; -# } -# $pos += length($line) - $oldp; -# if ($pos > 80) { -# do err("line > 80 characters"); -# } -# } +# this is the fastest way to check line length, +# but it doesnt work with perl 3.0. +# if ($line =~ tr/\t/\t/ * 7 + length($line) > 80) { +# $pos = $oldp = $p = 0; +# while (($p = index($line, "\t", $p)) >= 0) { +# $pos = ($pos + $p - $oldp + 8) & ~7; +# $oldp = ++$p; +# } +# $pos += length($line) - $oldp; +# if ($pos > 80) { +# do err("line > 80 characters"); +# } +# } # remember whether we expect to be inside a continuation line. $in_continuation = $expect_continuation; @@ -385,7 +385,7 @@ if (0) { do err("tabs between spaces"); } - if ($in_comment) { # still in comment + if ($in_comment) { # still in comment $prev = $line; next line; } @@ -397,7 +397,7 @@ if (0) { do err("missing blank before close comment"); } # allow // at beginnging of line, often used to comment out code - if (/.\/\/\S/) { # C++ comments + if (/.\/\/\S/) { # C++ comments do err("missing blank after start comment"); } # check for unterminated single line comments. @@ -407,7 +407,7 @@ if (0) { # delete any comments and check everything else. s/\/\*.*\*\///g; - s/\/\/.*$//; # C++ comments + s/\/\/.*$//; # C++ comments # delete any trailing whitespace; we have already checked for that. s/\s*$//; |