summaryrefslogtreecommitdiff
path: root/svtools/source/misc
diff options
context:
space:
mode:
Diffstat (limited to 'svtools/source/misc')
-rw-r--r--svtools/source/misc/acceleratorexecute.cxx578
-rw-r--r--svtools/source/misc/chartprettypainter.cxx140
-rw-r--r--svtools/source/misc/cliplistener.cxx98
-rw-r--r--svtools/source/misc/dialogclosedlistener.cxx75
-rw-r--r--svtools/source/misc/dialogcontrolling.cxx314
-rw-r--r--svtools/source/misc/ehdl.cxx489
-rw-r--r--svtools/source/misc/ehdl.src40
-rw-r--r--svtools/source/misc/embedhlp.cxx955
-rw-r--r--svtools/source/misc/embedtransfer.cxx256
-rw-r--r--svtools/source/misc/errtxt.src514
-rw-r--r--svtools/source/misc/helpagent.src41
-rw-r--r--svtools/source/misc/helpagentwindow.cxx192
-rw-r--r--svtools/source/misc/imagemgr.cxx881
-rw-r--r--svtools/source/misc/imagemgr.src452
-rw-r--r--svtools/source/misc/imageresourceaccess.cxx211
-rw-r--r--svtools/source/misc/imap.cxx1222
-rw-r--r--svtools/source/misc/imap2.cxx751
-rw-r--r--svtools/source/misc/imap3.cxx97
-rw-r--r--svtools/source/misc/itemdel.cxx135
-rw-r--r--svtools/source/misc/langtab.cxx208
-rw-r--r--svtools/source/misc/langtab.src329
-rwxr-xr-xsvtools/source/misc/makefile.mk84
-rw-r--r--svtools/source/misc/stringtransfer.cxx112
-rwxr-xr-xsvtools/source/misc/svtaccessiblefactory.cxx355
-rw-r--r--svtools/source/misc/svtdata.cxx73
-rw-r--r--svtools/source/misc/templatefoldercache.cxx919
-rw-r--r--svtools/source/misc/transfer.cxx2422
-rw-r--r--svtools/source/misc/transfer2.cxx635
-rw-r--r--svtools/source/misc/unitconv.cxx763
-rw-r--r--svtools/source/misc/wallitem.cxx65
-rwxr-xr-xsvtools/source/misc/xwindowitem.cxx97
31 files changed, 13503 insertions, 0 deletions
diff --git a/svtools/source/misc/acceleratorexecute.cxx b/svtools/source/misc/acceleratorexecute.cxx
new file mode 100644
index 000000000000..6458e359a49c
--- /dev/null
+++ b/svtools/source/misc/acceleratorexecute.cxx
@@ -0,0 +1,578 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include "acceleratorexecute.hxx"
+
+//===============================================
+// includes
+
+#ifndef __COM_SUN_STAR_FRAME_XMODULEMANAGER_HPP_
+#include <com/sun/star/frame/XModuleManager.hpp>
+#endif
+
+#ifndef __COM_SUN_STAR_FRAME_XDESKTOP_HPP_
+#include <com/sun/star/frame/XDesktop.hpp>
+#endif
+
+#ifndef __COM_SUN_STAR_UI_XUICONFIGURATIONMANAGER_HPP_
+#include <com/sun/star/ui/XUIConfigurationManager.hpp>
+#endif
+
+#ifndef __COM_SUN_STAR_UI_XMODULEUICONFIGURATIONMANAGERSUPPLIER_HPP_
+#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
+#endif
+
+#ifndef __COM_SUN_STAR_UI_XUICONFIGURATIONMANAGERSUPPLIER_HPP_
+#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
+#endif
+
+#ifndef __COM_SUN_STAR_AWT_XTOPWINDOW_HPP_
+#include <com/sun/star/awt/XTopWindow.hpp>
+#endif
+
+#ifndef __COM_SUN_STAR_AWT_KEYMODIFIER_HPP_
+#include <com/sun/star/awt/KeyModifier.hpp>
+#endif
+
+#ifndef __COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+
+#ifndef __COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+
+#ifndef __COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+#include <toolkit/helper/vclunohelper.hxx>
+
+#include <vcl/window.hxx>
+#include <vcl/svapp.hxx>
+#include <vos/mutex.hxx>
+
+//===============================================
+// namespace
+
+namespace css = ::com::sun::star;
+
+namespace svt
+{
+
+//===============================================
+// definitions
+
+//-----------------------------------------------
+class SVT_DLLPRIVATE AsyncAccelExec
+{
+ public:
+
+ //---------------------------------------
+ /** creates a new instance of this class, which can be used
+ one times only!
+
+ This instance can be forced to execute it's internal set request
+ asynchronous. After that it deletes itself !
+ */
+ static AsyncAccelExec* createOnShotInstance(const css::uno::Reference< css::frame::XDispatch >& xDispatch,
+ const css::util::URL& aURL );
+
+ void execAsync();
+
+ private:
+
+ //---------------------------------------
+ /** @short allow creation of instances of this class
+ by using our factory only!
+ */
+ SVT_DLLPRIVATE AsyncAccelExec(const css::uno::Reference< css::frame::XDispatch >& xDispatch,
+ const css::util::URL& aURL );
+
+ DECL_DLLPRIVATE_LINK(impl_ts_asyncCallback, void*);
+
+ private:
+
+ ::vcl::EventPoster m_aAsyncCallback;
+ css::uno::Reference< css::frame::XDispatch > m_xDispatch;
+ css::util::URL m_aURL;
+};
+
+//-----------------------------------------------
+AcceleratorExecute::AcceleratorExecute()
+ : TMutexInit ( )
+ , m_aAsyncCallback(LINK(this, AcceleratorExecute, impl_ts_asyncCallback))
+{
+}
+
+//-----------------------------------------------
+AcceleratorExecute::AcceleratorExecute(const AcceleratorExecute&)
+ : TMutexInit ( )
+ , m_aAsyncCallback(LINK(this, AcceleratorExecute, impl_ts_asyncCallback))
+{
+ // copy construction sint supported in real ...
+ // but we need this ctor to init our async callback ...
+}
+
+//-----------------------------------------------
+AcceleratorExecute::~AcceleratorExecute()
+{
+ // does nothing real
+}
+
+//-----------------------------------------------
+AcceleratorExecute* AcceleratorExecute::createAcceleratorHelper()
+{
+ AcceleratorExecute* pNew = new AcceleratorExecute();
+ return pNew;
+}
+
+//-----------------------------------------------
+void AcceleratorExecute::init(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR,
+ const css::uno::Reference< css::frame::XFrame >& xEnv )
+{
+ // SAFE -> ----------------------------------
+ ::osl::ResettableMutexGuard aLock(m_aLock);
+
+ // take over the uno service manager
+ m_xSMGR = xSMGR;
+
+ // specify our internal dispatch provider
+ // frame or desktop?! => document or global config.
+ sal_Bool bDesktopIsUsed = sal_False;
+ m_xDispatcher = css::uno::Reference< css::frame::XDispatchProvider >(xEnv, css::uno::UNO_QUERY);
+ if (!m_xDispatcher.is())
+ {
+ aLock.clear();
+ // <- SAFE ------------------------------
+
+ css::uno::Reference< css::frame::XDispatchProvider > xDispatcher(
+ xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")),
+ css::uno::UNO_QUERY_THROW);
+
+ // SAFE -> ------------------------------
+ aLock.reset();
+
+ m_xDispatcher = xDispatcher;
+ bDesktopIsUsed = sal_True;
+ }
+
+ aLock.clear();
+ // <- SAFE ----------------------------------
+
+ // open all needed configuration objects
+ css::uno::Reference< css::ui::XAcceleratorConfiguration > xGlobalCfg;
+ css::uno::Reference< css::ui::XAcceleratorConfiguration > xModuleCfg;
+ css::uno::Reference< css::ui::XAcceleratorConfiguration > xDocCfg ;
+
+ // global cfg
+ xGlobalCfg = AcceleratorExecute::st_openGlobalConfig(xSMGR);
+ if (!bDesktopIsUsed)
+ {
+ // module cfg
+ xModuleCfg = AcceleratorExecute::st_openModuleConfig(xSMGR, xEnv);
+
+ // doc cfg
+ css::uno::Reference< css::frame::XController > xController;
+ css::uno::Reference< css::frame::XModel > xModel;
+ xController = xEnv->getController();
+ if (xController.is())
+ xModel = xController->getModel();
+ if (xModel.is())
+ xDocCfg = AcceleratorExecute::st_openDocConfig(xModel);
+ }
+
+ // SAFE -> ------------------------------
+ aLock.reset();
+
+ m_xGlobalCfg = xGlobalCfg;
+ m_xModuleCfg = xModuleCfg;
+ m_xDocCfg = xDocCfg ;
+
+ aLock.clear();
+ // <- SAFE ----------------------------------
+}
+
+//-----------------------------------------------
+sal_Bool AcceleratorExecute::execute(const KeyCode& aVCLKey)
+{
+ css::awt::KeyEvent aAWTKey = AcceleratorExecute::st_VCLKey2AWTKey(aVCLKey);
+ return execute(aAWTKey);
+}
+
+//-----------------------------------------------
+sal_Bool AcceleratorExecute::execute(const css::awt::KeyEvent& aAWTKey)
+{
+ ::rtl::OUString sCommand = impl_ts_findCommand(aAWTKey);
+
+ // No Command found? Do nothing! User isnt interested on any error handling .-)
+ if (!sCommand.getLength())
+ return sal_False;
+
+ // SAFE -> ----------------------------------
+ ::osl::ResettableMutexGuard aLock(m_aLock);
+
+ css::uno::Reference< css::frame::XDispatchProvider > xProvider = m_xDispatcher;
+
+ aLock.clear();
+ // <- SAFE ----------------------------------
+
+ // convert command in URL structure
+ css::uno::Reference< css::util::XURLTransformer > xParser = impl_ts_getURLParser();
+ css::util::URL aURL;
+ aURL.Complete = sCommand;
+ xParser->parseStrict(aURL);
+
+ // ask for dispatch object
+ css::uno::Reference< css::frame::XDispatch > xDispatch = xProvider->queryDispatch(aURL, ::rtl::OUString(), 0);
+ sal_Bool bRet = xDispatch.is();
+ if ( bRet )
+ {
+ // Note: Such instance can be used one times only and destroy itself afterwards .-)
+ AsyncAccelExec* pExec = AsyncAccelExec::createOnShotInstance(xDispatch, aURL);
+ pExec->execAsync();
+ }
+
+ return bRet;
+}
+
+//-----------------------------------------------
+css::awt::KeyEvent AcceleratorExecute::st_VCLKey2AWTKey(const KeyCode& aVCLKey)
+{
+ css::awt::KeyEvent aAWTKey;
+ aAWTKey.Modifiers = 0;
+ aAWTKey.KeyCode = (sal_Int16)aVCLKey.GetCode();
+
+ if (aVCLKey.IsShift())
+ aAWTKey.Modifiers |= css::awt::KeyModifier::SHIFT;
+ if (aVCLKey.IsMod1())
+ aAWTKey.Modifiers |= css::awt::KeyModifier::MOD1;
+ if (aVCLKey.IsMod2())
+ aAWTKey.Modifiers |= css::awt::KeyModifier::MOD2;
+ if (aVCLKey.IsMod3())
+ aAWTKey.Modifiers |= css::awt::KeyModifier::MOD3;
+ return aAWTKey;
+}
+
+//-----------------------------------------------
+KeyCode AcceleratorExecute::st_AWTKey2VCLKey(const css::awt::KeyEvent& aAWTKey)
+{
+ sal_Bool bShift = ((aAWTKey.Modifiers & css::awt::KeyModifier::SHIFT) == css::awt::KeyModifier::SHIFT );
+ sal_Bool bMod1 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD1 ) == css::awt::KeyModifier::MOD1 );
+ sal_Bool bMod2 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD2 ) == css::awt::KeyModifier::MOD2 );
+ sal_Bool bMod3 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD3 ) == css::awt::KeyModifier::MOD3 );
+ USHORT nKey = (USHORT)aAWTKey.KeyCode;
+
+ return KeyCode(nKey, bShift, bMod1, bMod2, bMod3);
+}
+//-----------------------------------------------
+::rtl::OUString AcceleratorExecute::findCommand(const css::awt::KeyEvent& aKey)
+{
+ return impl_ts_findCommand(aKey);
+}
+//-----------------------------------------------
+::rtl::OUString AcceleratorExecute::impl_ts_findCommand(const css::awt::KeyEvent& aKey)
+{
+ // SAFE -> ----------------------------------
+ ::osl::ResettableMutexGuard aLock(m_aLock);
+
+ css::uno::Reference< css::ui::XAcceleratorConfiguration > xGlobalCfg = m_xGlobalCfg;
+ css::uno::Reference< css::ui::XAcceleratorConfiguration > xModuleCfg = m_xModuleCfg;
+ css::uno::Reference< css::ui::XAcceleratorConfiguration > xDocCfg = m_xDocCfg ;
+
+ aLock.clear();
+ // <- SAFE ----------------------------------
+
+ ::rtl::OUString sCommand;
+
+ try
+ {
+ if (xDocCfg.is())
+ sCommand = xDocCfg->getCommandByKeyEvent(aKey);
+ if (sCommand.getLength())
+ return sCommand;
+ }
+ catch(const css::container::NoSuchElementException&)
+ {}
+
+ try
+ {
+ if (xModuleCfg.is())
+ sCommand = xModuleCfg->getCommandByKeyEvent(aKey);
+ if (sCommand.getLength())
+ return sCommand;
+ }
+ catch(const css::container::NoSuchElementException&)
+ {}
+
+ try
+ {
+ if (xGlobalCfg.is())
+ sCommand = xGlobalCfg->getCommandByKeyEvent(aKey);
+ if (sCommand.getLength())
+ return sCommand;
+ }
+ catch(const css::container::NoSuchElementException&)
+ {}
+
+ // fall back to functional key codes
+ if( aKey.Modifiers == 0 )
+ {
+ switch( aKey.KeyCode )
+ {
+ case com::sun::star::awt::Key::DELETE_TO_BEGIN_OF_LINE:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DelToStartOfLine" ) );
+
+ case com::sun::star::awt::Key::DELETE_TO_END_OF_LINE:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DelToEndOfLine" ) );
+
+ case com::sun::star::awt::Key::DELETE_TO_BEGIN_OF_PARAGRAPH:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DelToStartOfPara" ) );
+
+ case com::sun::star::awt::Key::DELETE_TO_END_OF_PARAGRAPH:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DelToEndOfPara" ) );
+
+ case com::sun::star::awt::Key::DELETE_WORD_BACKWARD:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DelToStartOfWord" ) );
+
+ case com::sun::star::awt::Key::DELETE_WORD_FORWARD:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DelToEndOfWord" ) );
+
+ case com::sun::star::awt::Key::INSERT_LINEBREAK:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertLinebreak" ) );
+
+ case com::sun::star::awt::Key::INSERT_PARAGRAPH:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertPara" ) );
+
+ case com::sun::star::awt::Key::MOVE_WORD_BACKWARD:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToPrevWord" ) );
+
+ case com::sun::star::awt::Key::MOVE_WORD_FORWARD:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToNextWord" ) );
+
+ case com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_LINE:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToStartOfLine" ) );
+
+ case com::sun::star::awt::Key::MOVE_TO_END_OF_LINE:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToEndOfLine" ) );
+
+ case com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_PARAGRAPH:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToStartOfPara" ) );
+
+ case com::sun::star::awt::Key::MOVE_TO_END_OF_PARAGRAPH:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToEndOfPara" ) );
+
+ case com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_DOCUMENT:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToStartOfDoc" ) );
+
+ case com::sun::star::awt::Key::MOVE_TO_END_OF_DOCUMENT:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToEndOfDoc" ) );
+
+ case com::sun::star::awt::Key::SELECT_BACKWARD:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharLeftSel" ) );
+
+ case com::sun::star::awt::Key::SELECT_FORWARD:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharRightSel" ) );
+
+ case com::sun::star::awt::Key::SELECT_WORD_BACKWARD:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:WordLeftSel" ) );
+
+ case com::sun::star::awt::Key::SELECT_WORD_FORWARD:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:WordRightSel" ) );
+
+ case com::sun::star::awt::Key::SELECT_WORD:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:SelectWord" ) );
+
+ case com::sun::star::awt::Key::SELECT_LINE:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "" ) );
+
+ case com::sun::star::awt::Key::SELECT_PARAGRAPH:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:SelectText" ) );
+
+ case com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_LINE:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StartOfLineSel" ) );
+
+ case com::sun::star::awt::Key::SELECT_TO_END_OF_LINE:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:EndOfLineSel" ) );
+
+ case com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_PARAGRAPH:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StartOfParaSel" ) );
+
+ case com::sun::star::awt::Key::SELECT_TO_END_OF_PARAGRAPH:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:EndOfParaSel" ) );
+
+ case com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_DOCUMENT:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StartOfDocumentSel" ) );
+
+ case com::sun::star::awt::Key::SELECT_TO_END_OF_DOCUMENT:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:EndOfDocumentSel" ) );
+
+ case com::sun::star::awt::Key::SELECT_ALL:
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:SelectAll" ) );
+ default:
+ break;
+ }
+ }
+
+ return ::rtl::OUString();
+}
+
+//-----------------------------------------------
+css::uno::Reference< css::ui::XAcceleratorConfiguration > AcceleratorExecute::st_openGlobalConfig(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
+{
+ css::uno::Reference< css::ui::XAcceleratorConfiguration > xAccCfg(
+ xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.ui.GlobalAcceleratorConfiguration")),
+ css::uno::UNO_QUERY_THROW);
+ return xAccCfg;
+}
+
+//-----------------------------------------------
+css::uno::Reference< css::ui::XAcceleratorConfiguration > AcceleratorExecute::st_openModuleConfig(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
+ const css::uno::Reference< css::frame::XFrame >& xFrame)
+{
+ css::uno::Reference< css::frame::XModuleManager > xModuleDetection(
+ xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager")),
+ css::uno::UNO_QUERY_THROW);
+
+ ::rtl::OUString sModule;
+ try
+ {
+ sModule = xModuleDetection->identify(xFrame);
+ }
+ catch(const css::uno::RuntimeException&rEx)
+ { (void) rEx; throw; }
+ catch(const css::uno::Exception&)
+ { return css::uno::Reference< css::ui::XAcceleratorConfiguration >(); }
+
+ css::uno::Reference< css::ui::XModuleUIConfigurationManagerSupplier > xUISupplier(
+ xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")),
+ css::uno::UNO_QUERY_THROW);
+
+ css::uno::Reference< css::ui::XAcceleratorConfiguration > xAccCfg;
+ try
+ {
+ css::uno::Reference< css::ui::XUIConfigurationManager > xUIManager = xUISupplier->getUIConfigurationManager(sModule);
+ xAccCfg = css::uno::Reference< css::ui::XAcceleratorConfiguration >(xUIManager->getShortCutManager(), css::uno::UNO_QUERY_THROW);
+ }
+ catch(const css::container::NoSuchElementException&)
+ {}
+ return xAccCfg;
+}
+
+//-----------------------------------------------
+css::uno::Reference< css::ui::XAcceleratorConfiguration > AcceleratorExecute::st_openDocConfig(const css::uno::Reference< css::frame::XModel >& xModel)
+{
+ css::uno::Reference< css::ui::XAcceleratorConfiguration > xAccCfg;
+ css::uno::Reference< css::ui::XUIConfigurationManagerSupplier > xUISupplier(xModel, css::uno::UNO_QUERY);
+ if (xUISupplier.is())
+ {
+ css::uno::Reference< css::ui::XUIConfigurationManager > xUIManager = xUISupplier->getUIConfigurationManager();
+ xAccCfg.set(xUIManager->getShortCutManager(), css::uno::UNO_QUERY_THROW);
+ }
+ return xAccCfg;
+}
+
+//-----------------------------------------------
+css::uno::Reference< css::util::XURLTransformer > AcceleratorExecute::impl_ts_getURLParser()
+{
+ // SAFE -> ----------------------------------
+ ::osl::ResettableMutexGuard aLock(m_aLock);
+
+ if (m_xURLParser.is())
+ return m_xURLParser;
+ css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR;
+
+ aLock.clear();
+ // <- SAFE ----------------------------------
+
+ css::uno::Reference< css::util::XURLTransformer > xParser(
+ xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer")),
+ css::uno::UNO_QUERY_THROW);
+
+ // SAFE -> ----------------------------------
+ aLock.reset();
+ m_xURLParser = xParser;
+ aLock.clear();
+ // <- SAFE ----------------------------------
+
+ return xParser;
+}
+
+//-----------------------------------------------
+IMPL_LINK(AcceleratorExecute, impl_ts_asyncCallback, void*, EMPTYARG)
+{
+ // replaced by AsyncAccelExec!
+ return 0;
+}
+
+//-----------------------------------------------
+AsyncAccelExec::AsyncAccelExec(const css::uno::Reference< css::frame::XDispatch >& xDispatch,
+ const css::util::URL& aURL )
+ : m_aAsyncCallback(LINK(this, AsyncAccelExec, impl_ts_asyncCallback))
+ , m_xDispatch (xDispatch )
+ , m_aURL (aURL )
+{
+}
+
+//-----------------------------------------------
+AsyncAccelExec* AsyncAccelExec::createOnShotInstance(const css::uno::Reference< css::frame::XDispatch >& xDispatch,
+ const css::util::URL& aURL )
+{
+ AsyncAccelExec* pExec = new AsyncAccelExec(xDispatch, aURL);
+ return pExec;
+}
+
+//-----------------------------------------------
+void AsyncAccelExec::execAsync()
+{
+ m_aAsyncCallback.Post(0);
+}
+
+//-----------------------------------------------
+IMPL_LINK(AsyncAccelExec, impl_ts_asyncCallback, void*,)
+{
+ if (! m_xDispatch.is())
+ return 0;
+
+ try
+ {
+ m_xDispatch->dispatch(m_aURL, css::uno::Sequence< css::beans::PropertyValue >());
+ }
+ catch(const css::lang::DisposedException&)
+ {}
+ catch(const css::uno::RuntimeException& )
+ { throw; }
+ catch(const css::uno::Exception&)
+ {}
+
+ delete this;
+
+ return 0;
+}
+
+} // namespace svt
diff --git a/svtools/source/misc/chartprettypainter.cxx b/svtools/source/misc/chartprettypainter.cxx
new file mode 100644
index 000000000000..bc2d02384816
--- /dev/null
+++ b/svtools/source/misc/chartprettypainter.cxx
@@ -0,0 +1,140 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include <svtools/chartprettypainter.hxx>
+
+#include <tools/globname.hxx>
+#include <sot/clsids.hxx>
+// header for function rtl_createUuid
+#include <rtl/uuid.h>
+#include <vcl/pdfextoutdevdata.hxx>
+
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <svtools/embedhlp.hxx>
+
+using namespace ::com::sun::star;
+
+ChartPrettyPainter::ChartPrettyPainter()
+{
+}
+
+ChartPrettyPainter::~ChartPrettyPainter()
+{
+}
+
+bool ChartPrettyPainter::DoPaint(OutputDevice* /*pOutDev*/, const Rectangle& /*rLogicObjectRect*/) const
+{
+ return false;
+}
+
+//static
+const uno::Sequence<sal_Int8>& ChartPrettyPainter::getUnoTunnelId()
+{
+ static uno::Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+bool ChartPrettyPainter::IsChart( const svt::EmbeddedObjectRef& xObjRef )
+{
+ if ( !xObjRef.is() )
+ return false;
+
+ SvGlobalName aObjClsId( xObjRef->getClassID() );
+ if(
+ SvGlobalName(SO3_SCH_CLASSID_30) == aObjClsId
+ || SvGlobalName(SO3_SCH_CLASSID_40) == aObjClsId
+ || SvGlobalName(SO3_SCH_CLASSID_50) == aObjClsId
+ || SvGlobalName(SO3_SCH_CLASSID_60) == aObjClsId)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+bool ChartPrettyPainter::ShouldPrettyPaintChartOnThisDevice( OutputDevice* pOutDev )
+{
+ if( !pOutDev )
+ return false;
+ //at least the print preview in calc has a paint loop due to too much invalidate calls deep in sdr
+ //to avoid the paint loop we use the metafile replacement in this case instead of direct rendering
+ if( OUTDEV_WINDOW == pOutDev->GetOutDevType() )
+ return false;
+ if( OUTDEV_PRINTER == pOutDev->GetOutDevType() )
+ return true;
+ vcl::PDFExtOutDevData* pPDFData = PTR_CAST( vcl::PDFExtOutDevData, pOutDev->GetExtOutDevData() );
+ if( pPDFData )
+ return true;
+ return false;
+}
+
+bool ChartPrettyPainter::DoPrettyPaintChart( uno::Reference< frame::XModel > xChartModel, OutputDevice* pOutDev, const Rectangle& rLogicObjectRect )
+{
+ //charts must be painted resolution dependent!! #i82893#, #i75867#
+ if( !xChartModel.is() || !ShouldPrettyPaintChartOnThisDevice( pOutDev ) )
+ return false;
+
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory > xFact( xChartModel, uno::UNO_QUERY );
+ OSL_ENSURE( xFact.is(), "Chart cannot be painted pretty!\n" );
+ if( xFact.is() )
+ {
+ uno::Reference< lang::XUnoTunnel > xChartRenderer( xFact->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.ChartRenderer" ) ) ), uno::UNO_QUERY );
+ OSL_ENSURE( xChartRenderer.is(), "Chart cannot be painted pretty!\n" );
+ if( xChartRenderer.is() )
+ {
+ ChartPrettyPainter* pPrettyPainter = reinterpret_cast<ChartPrettyPainter*>(
+ xChartRenderer->getSomething( ChartPrettyPainter::getUnoTunnelId() ));
+ if( pPrettyPainter )
+ return pPrettyPainter->DoPaint(pOutDev, rLogicObjectRect);
+ }
+ }
+ }
+ catch( uno::Exception& e )
+ {
+ (void)e;
+ DBG_ERROR( "Chart cannot be painted pretty!" );
+ }
+ return false;
+}
+
diff --git a/svtools/source/misc/cliplistener.cxx b/svtools/source/misc/cliplistener.cxx
new file mode 100644
index 000000000000..8fb61a5a1cb9
--- /dev/null
+++ b/svtools/source/misc/cliplistener.cxx
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
+
+#include <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+#include <vos/mutex.hxx>
+
+#include "cliplistener.hxx"
+#include <svtools/transfer.hxx>
+
+using namespace ::com::sun::star;
+
+// -----------------------------------------------------------------------------
+
+TransferableClipboardListener::TransferableClipboardListener( const Link& rCallback ) :
+ aLink( rCallback )
+{
+}
+
+TransferableClipboardListener::~TransferableClipboardListener()
+{
+}
+
+void SAL_CALL TransferableClipboardListener::disposing( const lang::EventObject& )
+ throw(uno::RuntimeException)
+{
+}
+
+void SAL_CALL TransferableClipboardListener::changedContents(
+ const datatransfer::clipboard::ClipboardEvent& rEventObject )
+ throw(uno::RuntimeException)
+{
+ if ( aLink.IsSet() )
+ {
+ const ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ TransferableDataHelper aDataHelper( rEventObject.Contents );
+ aLink.Call( &aDataHelper );
+ }
+}
+
+void TransferableClipboardListener::AddRemoveListener( Window* pWin, BOOL bAdd )
+{
+ try
+ {
+ if ( pWin )
+ {
+ uno::Reference<datatransfer::clipboard::XClipboard> xClipboard = pWin->GetClipboard();
+ uno::Reference<datatransfer::clipboard::XClipboardNotifier> xClpbrdNtfr( xClipboard, uno::UNO_QUERY );
+ if( xClpbrdNtfr.is() )
+ {
+ uno::Reference<datatransfer::clipboard::XClipboardListener> xClipEvtLstnr( this );
+ if( bAdd )
+ xClpbrdNtfr->addClipboardListener( xClipEvtLstnr );
+ else
+ xClpbrdNtfr->removeClipboardListener( xClipEvtLstnr );
+ }
+ }
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+}
+
+void TransferableClipboardListener::ClearCallbackLink()
+{
+ aLink = Link();
+}
+
diff --git a/svtools/source/misc/dialogclosedlistener.cxx b/svtools/source/misc/dialogclosedlistener.cxx
new file mode 100644
index 000000000000..a08c8a3b6dd5
--- /dev/null
+++ b/svtools/source/misc/dialogclosedlistener.cxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_svtools.hxx"
+#include "dialogclosedlistener.hxx"
+
+//.........................................................................
+namespace svt
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::ui::dialogs;
+
+ //=====================================================================
+ //= DialogClosedListener
+ //=====================================================================
+ //---------------------------------------------------------------------
+ DialogClosedListener::DialogClosedListener()
+ {
+ }
+
+ DialogClosedListener::DialogClosedListener( const Link& rLink ) :
+
+ m_aDialogClosedLink( rLink )
+
+ {
+ }
+
+ // XDialogClosedListener methods
+ void SAL_CALL DialogClosedListener::dialogClosed( const DialogClosedEvent& aEvent ) throw (RuntimeException)
+ {
+ if ( m_aDialogClosedLink.IsSet() )
+ {
+ ::com::sun::star::ui::dialogs::DialogClosedEvent aEvt( aEvent );
+ m_aDialogClosedLink.Call( &aEvt );
+ }
+ }
+
+ // XEventListener methods
+ void SAL_CALL DialogClosedListener::disposing( const EventObject& ) throw(RuntimeException)
+ {
+ m_aDialogClosedLink = Link();
+ }
+
+//.........................................................................
+} // namespace svt
+//.........................................................................
+
+
diff --git a/svtools/source/misc/dialogcontrolling.cxx b/svtools/source/misc/dialogcontrolling.cxx
new file mode 100644
index 000000000000..7565dad731f7
--- /dev/null
+++ b/svtools/source/misc/dialogcontrolling.cxx
@@ -0,0 +1,314 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include "dialogcontrolling.hxx"
+#include <vcl/window.hxx>
+
+#include <algorithm>
+#include <functional>
+
+//........................................................................
+namespace svt
+{
+//........................................................................
+
+ //=====================================================================
+ //= IWindowOperator
+ //=====================================================================
+ //---------------------------------------------------------------------
+ IWindowOperator::~IWindowOperator()
+ {
+ }
+
+ //=====================================================================
+ //= IWindowEventFilter
+ //=====================================================================
+ //---------------------------------------------------------------------
+ IWindowEventFilter::~IWindowEventFilter()
+ {
+ }
+
+ //=====================================================================
+ //= DialogController_Data
+ //=====================================================================
+ struct DialogController_Data
+ {
+ Window& rInstigator;
+ ::std::vector< Window* > aConcernedWindows;
+ PWindowEventFilter pEventFilter;
+ PWindowOperator pOperator;
+
+ DialogController_Data( Window& _rInstigator, const PWindowEventFilter _pEventFilter, const PWindowOperator _pOperator )
+ :rInstigator( _rInstigator )
+ ,pEventFilter( _pEventFilter )
+ ,pOperator( _pOperator )
+ {
+ }
+ };
+
+ //=====================================================================
+ //= DialogController
+ //=====================================================================
+ //---------------------------------------------------------------------
+ DialogController::DialogController( Window& _rInstigator, const PWindowEventFilter& _pEventFilter,
+ const PWindowOperator& _pOperator )
+ :m_pImpl( new DialogController_Data( _rInstigator, _pEventFilter, _pOperator ) )
+ {
+ DBG_ASSERT( m_pImpl->pEventFilter.get() && m_pImpl->pOperator.get(),
+ "DialogController::DialogController: invalid filter and/or operator!" );
+
+ m_pImpl->rInstigator.AddEventListener( LINK( this, DialogController, OnWindowEvent ) );
+ }
+
+ //---------------------------------------------------------------------
+ DialogController::~DialogController()
+ {
+ reset();
+ }
+
+ //---------------------------------------------------------------------
+ void DialogController::reset()
+ {
+ m_pImpl->rInstigator.RemoveEventListener( LINK( this, DialogController, OnWindowEvent ) );
+ m_pImpl->aConcernedWindows.clear();
+ m_pImpl->pEventFilter.reset();
+ m_pImpl->pOperator.reset();
+ }
+
+ //---------------------------------------------------------------------
+ void DialogController::addDependentWindow( Window& _rWindow )
+ {
+ m_pImpl->aConcernedWindows.push_back( &_rWindow );
+
+ VclWindowEvent aEvent( &_rWindow, 0, NULL );
+ impl_update( aEvent, _rWindow );
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( DialogController, OnWindowEvent, const VclWindowEvent*, _pEvent )
+ {
+ if ( m_pImpl->pEventFilter->payAttentionTo( *_pEvent ) )
+ impl_updateAll( *_pEvent );
+ return 0L;
+ }
+
+ //---------------------------------------------------------------------
+ void DialogController::impl_updateAll( const VclWindowEvent& _rTriggerEvent )
+ {
+ for ( ::std::vector< Window* >::iterator loop = m_pImpl->aConcernedWindows.begin();
+ loop != m_pImpl->aConcernedWindows.end();
+ ++loop
+ )
+ impl_update( _rTriggerEvent, *(*loop) );
+ }
+
+ //---------------------------------------------------------------------
+ void DialogController::impl_update( const VclWindowEvent& _rTriggerEvent, Window& _rWindow )
+ {
+ m_pImpl->pOperator->operateOn( _rTriggerEvent, _rWindow );
+ }
+
+ //=====================================================================
+ //= ControlDependencyManager_Data
+ //=====================================================================
+ struct ControlDependencyManager_Data
+ {
+ ::std::vector< PDialogController > aControllers;
+ };
+
+ //=====================================================================
+ //= ControlDependencyManager
+ //=====================================================================
+ //---------------------------------------------------------------------
+ ControlDependencyManager::ControlDependencyManager()
+ :m_pImpl( new ControlDependencyManager_Data )
+ {
+ }
+
+ //---------------------------------------------------------------------
+ ControlDependencyManager::~ControlDependencyManager()
+ {
+ }
+
+ //---------------------------------------------------------------------
+ namespace
+ {
+ struct ResetDialogController : public ::std::unary_function< const PDialogController&, void >
+ {
+ void operator()( const PDialogController& _pController )
+ {
+ _pController->reset();
+ }
+ };
+ }
+
+ //---------------------------------------------------------------------
+ void ControlDependencyManager::clear()
+ {
+ ::std::for_each( m_pImpl->aControllers.begin(), m_pImpl->aControllers.end(), ResetDialogController() );
+ m_pImpl->aControllers.clear();
+ }
+
+ //---------------------------------------------------------------------
+ void ControlDependencyManager::addController( const PDialogController& _pController )
+ {
+ OSL_ENSURE( _pController.get() != NULL, "ControlDependencyManager::addController: invalid controller, this will crash, sooner or later!" );
+ m_pImpl->aControllers.push_back( _pController );
+ }
+
+ //---------------------------------------------------------------------
+ void ControlDependencyManager::enableOnRadioCheck( RadioButton& _rRadio, Window& _rDependentWindow )
+ {
+ PDialogController pController( new RadioDependentEnabler( _rRadio ) );
+ pController->addDependentWindow( _rDependentWindow );
+ m_pImpl->aControllers.push_back( pController );
+ }
+
+ //---------------------------------------------------------------------
+ void ControlDependencyManager::enableOnRadioCheck( RadioButton& _rRadio, Window& _rDependentWindow1, Window& _rDependentWindow2 )
+ {
+ PDialogController pController( new RadioDependentEnabler( _rRadio ) );
+ pController->addDependentWindow( _rDependentWindow1 );
+ pController->addDependentWindow( _rDependentWindow2 );
+ m_pImpl->aControllers.push_back( pController );
+ }
+
+ //---------------------------------------------------------------------
+ void ControlDependencyManager::enableOnRadioCheck( RadioButton& _rRadio, Window& _rDependentWindow1, Window& _rDependentWindow2, Window& _rDependentWindow3 )
+ {
+ PDialogController pController( new RadioDependentEnabler( _rRadio ) );
+ pController->addDependentWindow( _rDependentWindow1 );
+ pController->addDependentWindow( _rDependentWindow2 );
+ pController->addDependentWindow( _rDependentWindow3 );
+ m_pImpl->aControllers.push_back( pController );
+ }
+
+ //---------------------------------------------------------------------
+ void ControlDependencyManager::enableOnRadioCheck( RadioButton& _rRadio, Window& _rDependentWindow1, Window& _rDependentWindow2, Window& _rDependentWindow3, Window& _rDependentWindow4 )
+ {
+ PDialogController pController( new RadioDependentEnabler( _rRadio ) );
+ pController->addDependentWindow( _rDependentWindow1 );
+ pController->addDependentWindow( _rDependentWindow2 );
+ pController->addDependentWindow( _rDependentWindow3 );
+ pController->addDependentWindow( _rDependentWindow4 );
+ m_pImpl->aControllers.push_back( pController );
+ }
+
+ //---------------------------------------------------------------------
+ void ControlDependencyManager::enableOnRadioCheck( RadioButton& _rRadio, Window& _rDependentWindow1, Window& _rDependentWindow2, Window& _rDependentWindow3, Window& _rDependentWindow4, Window& _rDependentWindow5 )
+ {
+ PDialogController pController( new RadioDependentEnabler( _rRadio ) );
+ pController->addDependentWindow( _rDependentWindow1 );
+ pController->addDependentWindow( _rDependentWindow2 );
+ pController->addDependentWindow( _rDependentWindow3 );
+ pController->addDependentWindow( _rDependentWindow4 );
+ pController->addDependentWindow( _rDependentWindow5 );
+ m_pImpl->aControllers.push_back( pController );
+ }
+
+ //---------------------------------------------------------------------
+ void ControlDependencyManager::enableOnRadioCheck( RadioButton& _rRadio, Window& _rDependentWindow1, Window& _rDependentWindow2, Window& _rDependentWindow3, Window& _rDependentWindow4, Window& _rDependentWindow5, Window& _rDependentWindow6 )
+ {
+ PDialogController pController( new RadioDependentEnabler( _rRadio ) );
+ pController->addDependentWindow( _rDependentWindow1 );
+ pController->addDependentWindow( _rDependentWindow2 );
+ pController->addDependentWindow( _rDependentWindow3 );
+ pController->addDependentWindow( _rDependentWindow4 );
+ pController->addDependentWindow( _rDependentWindow5 );
+ pController->addDependentWindow( _rDependentWindow6 );
+ m_pImpl->aControllers.push_back( pController );
+ }
+
+ //---------------------------------------------------------------------
+ void ControlDependencyManager::enableOnCheckMark( CheckBox& _rBox, Window& _rDependentWindow )
+ {
+ PDialogController pController( new RadioDependentEnabler( _rBox ) );
+ pController->addDependentWindow( _rDependentWindow );
+ m_pImpl->aControllers.push_back( pController );
+ }
+
+ //---------------------------------------------------------------------
+ void ControlDependencyManager::enableOnCheckMark( CheckBox& _rBox, Window& _rDependentWindow1, Window& _rDependentWindow2 )
+ {
+ PDialogController pController( new RadioDependentEnabler( _rBox ) );
+ pController->addDependentWindow( _rDependentWindow1 );
+ pController->addDependentWindow( _rDependentWindow2 );
+ m_pImpl->aControllers.push_back( pController );
+ }
+
+ //---------------------------------------------------------------------
+ void ControlDependencyManager::enableOnCheckMark( CheckBox& _rBox, Window& _rDependentWindow1, Window& _rDependentWindow2, Window& _rDependentWindow3 )
+ {
+ PDialogController pController( new RadioDependentEnabler( _rBox ) );
+ pController->addDependentWindow( _rDependentWindow1 );
+ pController->addDependentWindow( _rDependentWindow2 );
+ pController->addDependentWindow( _rDependentWindow3 );
+ m_pImpl->aControllers.push_back( pController );
+ }
+
+ //---------------------------------------------------------------------
+ void ControlDependencyManager::enableOnCheckMark( CheckBox& _rBox, Window& _rDependentWindow1, Window& _rDependentWindow2, Window& _rDependentWindow3, Window& _rDependentWindow4 )
+ {
+ PDialogController pController( new RadioDependentEnabler( _rBox ) );
+ pController->addDependentWindow( _rDependentWindow1 );
+ pController->addDependentWindow( _rDependentWindow2 );
+ pController->addDependentWindow( _rDependentWindow3 );
+ pController->addDependentWindow( _rDependentWindow4 );
+ m_pImpl->aControllers.push_back( pController );
+ }
+
+ //---------------------------------------------------------------------
+ void ControlDependencyManager::enableOnCheckMark( CheckBox& _rBox, Window& _rDependentWindow1, Window& _rDependentWindow2, Window& _rDependentWindow3, Window& _rDependentWindow4, Window& _rDependentWindow5 )
+ {
+ PDialogController pController( new RadioDependentEnabler( _rBox ) );
+ pController->addDependentWindow( _rDependentWindow1 );
+ pController->addDependentWindow( _rDependentWindow2 );
+ pController->addDependentWindow( _rDependentWindow3 );
+ pController->addDependentWindow( _rDependentWindow4 );
+ pController->addDependentWindow( _rDependentWindow5 );
+ m_pImpl->aControllers.push_back( pController );
+ }
+
+ //---------------------------------------------------------------------
+ void ControlDependencyManager::enableOnCheckMark( CheckBox& _rBox, Window& _rDependentWindow1, Window& _rDependentWindow2, Window& _rDependentWindow3, Window& _rDependentWindow4, Window& _rDependentWindow5, Window& _rDependentWindow6 )
+ {
+ PDialogController pController( new RadioDependentEnabler( _rBox ) );
+ pController->addDependentWindow( _rDependentWindow1 );
+ pController->addDependentWindow( _rDependentWindow2 );
+ pController->addDependentWindow( _rDependentWindow3 );
+ pController->addDependentWindow( _rDependentWindow4 );
+ pController->addDependentWindow( _rDependentWindow5 );
+ pController->addDependentWindow( _rDependentWindow6 );
+ m_pImpl->aControllers.push_back( pController );
+ }
+
+//........................................................................
+} // namespace svt
+//........................................................................
+
diff --git a/svtools/source/misc/ehdl.cxx b/svtools/source/misc/ehdl.cxx
new file mode 100644
index 000000000000..8834f5497e5a
--- /dev/null
+++ b/svtools/source/misc/ehdl.cxx
@@ -0,0 +1,489 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <vos/mutex.hxx>
+#include <tools/debug.hxx>
+#include <tools/rcid.h>
+#include <vcl/wintypes.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#if defined(OS2)
+#include <vcl/sound.hxx>
+#endif
+
+#ifndef GCC
+#endif
+
+#include <svtools/ehdl.hxx>
+#include <svtools/svtdata.hxx>
+#include <svtools/svtools.hrc>
+#include "sfxecode.hxx"
+
+//=========================================================================
+
+static USHORT aWndFunc(
+ Window *pWin, // Parent des Dialoges
+ USHORT nFlags,
+ const String &rErr, // Fehlertext
+ const String &rAction) // Actiontext
+
+/* [Beschreibung]
+
+ Bringt eine Fehlerbox auf den Schirm. Je nach nFlags werden
+ Error/ Info usw. Boxen mit den gewuenschten Buttons angezeigt
+
+ Rueckgabewert ist der gedrueckte Button
+
+ */
+
+
+{
+ vos:: OGuard aGuard( Application::GetSolarMutex() );
+
+ // aus den Flags die benoetigten WinBits ermitteln
+ WinBits eBits=0;
+ if ( (ERRCODE_BUTTON_CANCEL|ERRCODE_BUTTON_RETRY) == (nFlags & (ERRCODE_BUTTON_CANCEL|ERRCODE_BUTTON_RETRY)) )
+ eBits = WB_RETRY_CANCEL;
+ else if ( ERRCODE_BUTTON_OK_CANCEL == (nFlags & ERRCODE_BUTTON_OK_CANCEL) )
+ eBits = WB_OK_CANCEL;
+ else if ( ERRCODE_BUTTON_OK == (nFlags & ERRCODE_BUTTON_OK) )
+ eBits = WB_OK;
+ else if ( ERRCODE_BUTTON_YES_NO_CANCEL == (nFlags & ERRCODE_BUTTON_YES_NO_CANCEL) )
+ eBits = WB_YES_NO_CANCEL;
+ else if ( ERRCODE_BUTTON_YES_NO == (nFlags & ERRCODE_BUTTON_YES_NO) )
+ eBits = WB_YES_NO;
+
+ switch(nFlags & 0x0f00)
+ {
+ case ERRCODE_BUTTON_DEF_OK:
+ eBits |= WB_DEF_OK;
+ break;
+
+ case ERRCODE_BUTTON_DEF_CANCEL:
+ eBits |= WB_DEF_CANCEL;
+ break;
+
+ case ERRCODE_BUTTON_DEF_YES:
+ eBits |= WB_DEF_YES;
+ break;
+
+ case ERRCODE_BUTTON_DEF_NO:
+ eBits |= WB_DEF_NO;
+ break;
+ }
+
+ String aErr(SvtResId(STR_ERR_HDLMESS));
+ String aAction(rAction);
+ if ( aAction.Len() )
+ aAction += String::CreateFromAscii( ":\n" );
+ aErr.SearchAndReplace(String::CreateFromAscii( "$(ACTION)" ), aAction);
+ aErr.SearchAndReplace(String::CreateFromAscii( "$(ERROR)" ), rErr);
+
+ MessBox* pBox;
+ switch ( nFlags & 0xf000 )
+ {
+ case ERRCODE_MSG_ERROR:
+ pBox = new ErrorBox(pWin, eBits, aErr);
+ break;
+
+ case ERRCODE_MSG_WARNING:
+ pBox = new WarningBox(pWin, eBits, aErr);
+ break;
+
+ case ERRCODE_MSG_INFO:
+ pBox = new InfoBox(pWin, aErr);
+ break;
+
+ case ERRCODE_MSG_QUERY:
+ pBox = new QueryBox(pWin, eBits, aErr);
+ break;
+
+ default:
+ {
+ DBG_ERRORFILE( "no MessBox type");
+ pBox = NULL;
+ return ERRCODE_BUTTON_OK;
+ }
+ }
+
+ USHORT nRet = RET_CANCEL;
+ switch ( pBox->Execute() )
+ {
+ case RET_OK:
+ nRet = ERRCODE_BUTTON_OK;
+ break;
+ case RET_CANCEL:
+ nRet = ERRCODE_BUTTON_CANCEL;
+ break;
+ case RET_RETRY:
+ nRet = ERRCODE_BUTTON_RETRY;
+ break;
+ case RET_YES:
+ nRet = ERRCODE_BUTTON_YES;
+ break;
+ case RET_NO:
+ nRet = ERRCODE_BUTTON_NO;
+ break;
+ default:
+ DBG_ERRORFILE( "Unknown MessBox return value" );
+ break;
+ }
+ delete pBox;
+ return nRet;
+}
+
+//-------------------------------------------------------------------------
+
+SfxErrorHandler::SfxErrorHandler(USHORT nIdP, ULONG lStartP, ULONG lEndP, ResMgr *pMgrP) :
+
+ lStart(lStartP), lEnd(lEndP), nId(nIdP), pMgr(pMgrP), pFreeMgr( NULL )
+
+{
+ RegisterDisplay(&aWndFunc);
+ if( ! pMgr )
+ {
+ com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale();
+ pFreeMgr = pMgr = ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(ofa), aLocale );
+ }
+}
+
+//-------------------------------------------------------------------------
+
+SfxErrorHandler::~SfxErrorHandler()
+{
+ if( pFreeMgr )
+ delete pFreeMgr;
+}
+
+//-------------------------------------------------------------------------
+
+BOOL SfxErrorHandler::CreateString(
+ const ErrorInfo *pErr, String &rStr, USHORT& nFlags) const
+
+/* [Beschreibung]
+
+ Der Fehlerstring fuer die ErrorInfo pErr wird zusammengesetzt.
+
+ */
+
+{
+ ULONG nErrCode = pErr->GetErrorCode() & ERRCODE_ERROR_MASK;
+ if( nErrCode>=lEnd || nErrCode<=lStart )
+ return FALSE;
+ MessageInfo *pMsgInfo=PTR_CAST(MessageInfo,pErr);
+ if(pMsgInfo)
+ {
+ if(GetMessageString(nErrCode, rStr, nFlags))
+ {
+ for (xub_StrLen i = 0; i < rStr.Len();)
+ {
+ i = rStr.SearchAndReplace(String::CreateFromAscii( "$(ARG1)" ),
+ pMsgInfo->GetMessageArg(), i);
+ if (i == STRING_NOTFOUND)
+ break;
+ i = i + pMsgInfo->GetMessageArg().Len();
+ }
+ return TRUE;
+ }
+ }
+ else if(GetErrorString(nErrCode, rStr, nFlags))
+ {
+ StringErrorInfo *pStringInfo=PTR_CAST(StringErrorInfo,pErr);
+ if(pStringInfo)
+ for (xub_StrLen i = 0; i < rStr.Len();)
+ {
+ i = rStr.SearchAndReplace(String::CreateFromAscii( "$(ARG1)" ),
+ pStringInfo->GetErrorString(), i);
+ if (i == STRING_NOTFOUND)
+ break;
+ i = i + pStringInfo->GetErrorString().Len();
+ }
+ else
+ {
+ TwoStringErrorInfo * pTwoStringInfo = PTR_CAST(TwoStringErrorInfo,
+ pErr);
+ if (pTwoStringInfo)
+ for (USHORT i = 0; i < rStr.Len();)
+ {
+ USHORT nArg1Pos = rStr.Search(String::CreateFromAscii( "$(ARG1)" ), i);
+ USHORT nArg2Pos = rStr.Search(String::CreateFromAscii( "$(ARG2)" ), i);
+ if (nArg1Pos < nArg2Pos)
+ {
+ rStr.Replace(nArg1Pos, 7, pTwoStringInfo->GetArg1());
+ i = nArg1Pos + pTwoStringInfo->GetArg1().Len();
+ }
+ else if (nArg2Pos < nArg1Pos)
+ {
+ rStr.Replace(nArg2Pos, 7, pTwoStringInfo->GetArg2());
+ i = nArg2Pos + pTwoStringInfo->GetArg2().Len();
+ }
+ else break;
+ }
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//-------------------------------------------------------------------------
+
+class ResString: public String
+
+/* [Beschreibung]
+
+ Hilfsklasse zum Auslesen eines Strings und optionaler ExtraData aus
+ einer String Resource.
+
+ */
+
+{
+ USHORT nFlags;
+ public:
+ USHORT GetFlags() const {return nFlags;}
+ const String & GetString() const {return *this;}
+ ResString( ResId &rId);
+};
+
+//-------------------------------------------------------------------------
+
+ResString::ResString(ResId & rId):
+ String(rId.SetAutoRelease(FALSE)),
+ nFlags(0)
+{
+ ResMgr * pResMgr = rId.GetResMgr();
+ // String ctor temporarily sets global ResManager
+ if (pResMgr->GetRemainSize())
+ nFlags = USHORT(pResMgr->ReadShort());
+ rId.SetAutoRelease(TRUE);
+ pResMgr->PopContext();
+}
+
+//-------------------------------------------------------------------------
+
+struct ErrorResource_Impl : private Resource
+
+/* [Beschreibung]
+
+ Hilfsklasse zum Zugriff auf String SubResourcen einer Resource
+ */
+
+{
+
+ ResId aResId;
+
+ ErrorResource_Impl(ResId& rErrIdP, USHORT nId)
+ : Resource(rErrIdP),aResId(nId,*rErrIdP.GetResMgr()){}
+
+ ~ErrorResource_Impl() { FreeResource(); }
+
+ operator ResString(){ return ResString( aResId ); }
+ operator BOOL(){return IsAvailableRes(aResId.SetRT(RSC_STRING));}
+
+};
+
+
+BOOL SfxErrorHandler::GetClassString(ULONG lClassId, String &rStr) const
+
+/* [Beschreibung]
+
+ Erzeugt den String fuer die Klasse des Fehlers. Wird immer aus der
+ Resource des Sfx gelesen
+
+ */
+
+{
+ BOOL bRet = FALSE;
+ com::sun::star::lang::Locale aLocale( Application::GetSettings().GetUILocale() );
+ ResMgr* pResMgr = ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(ofa), aLocale );
+ if( pResMgr )
+ {
+ ResId aId(RID_ERRHDL, *pResMgr );
+ ErrorResource_Impl aEr(aId, (USHORT)lClassId);
+ if(aEr)
+ {
+ rStr=((ResString)aEr).GetString();
+ bRet = TRUE;
+ }
+ }
+ delete pResMgr;
+ return bRet;
+}
+
+//-------------------------------------------------------------------------
+
+BOOL SfxErrorHandler::GetMessageString(
+ ULONG lErrId, String &rStr, USHORT &nFlags) const
+
+/* [Beschreibung]
+
+ Erzeugt den String fuer die Ausgabe in einer MessageBox
+
+ */
+
+{
+ BOOL bRet = FALSE;
+ ResId *pResId= new ResId(nId, *pMgr);
+
+ ErrorResource_Impl aEr(*pResId, (USHORT)lErrId);
+ if(aEr)
+ {
+ ResString aErrorString(aEr);
+ USHORT nResFlags = aErrorString.GetFlags();
+ if( nResFlags )
+ nFlags=aErrorString.GetFlags();
+ rStr = aErrorString.GetString();
+ bRet = TRUE;
+ }
+
+ delete pResId;
+ return bRet;
+}
+
+//-------------------------------------------------------------------------
+
+BOOL SfxErrorHandler::GetErrorString(
+ ULONG lErrId, String &rStr, USHORT &nFlags) const
+
+/* [Beschreibung]
+ Erzeugt den Fehlerstring fuer den eigentlichen Fehler ohne
+ dessen Klasse
+
+ */
+
+{
+ vos:: OGuard aGuard( Application::GetSolarMutex() );
+
+ BOOL bRet = FALSE;
+ rStr=String(SvtResId(RID_ERRHDL_CLASS));
+ ResId aResId(nId, *pMgr);
+
+ {
+ ErrorResource_Impl aEr(aResId, (USHORT)lErrId);
+ if(aEr)
+ {
+ ResString aErrorString(aEr);
+
+ USHORT nResFlags = aErrorString.GetFlags();
+ if ( nResFlags )
+ nFlags = nResFlags;
+ rStr.SearchAndReplace(
+ String::CreateFromAscii("$(ERROR)"), aErrorString.GetString());
+ bRet = TRUE;
+ }
+ else
+ bRet = FALSE;
+ }
+
+ if( bRet )
+ {
+ String aErrStr;
+ GetClassString(lErrId & ERRCODE_CLASS_MASK,
+ aErrStr);
+ if(aErrStr.Len())
+ aErrStr+=String::CreateFromAscii( ".\n" );
+ rStr.SearchAndReplace(String::CreateFromAscii( "$(CLASS)" ),aErrStr);
+ }
+
+ return bRet;
+}
+
+//-------------------------------------------------------------------------
+
+SfxErrorContext::SfxErrorContext(
+ USHORT nCtxIdP, Window *pWindow, USHORT nResIdP, ResMgr *pMgrP)
+: ErrorContext(pWindow), nCtxId(nCtxIdP), nResId(nResIdP), pMgr(pMgrP)
+{
+ if( nResId==USHRT_MAX )
+ nResId=RID_ERRCTX;
+}
+
+//-------------------------------------------------------------------------
+
+SfxErrorContext::SfxErrorContext(
+ USHORT nCtxIdP, const String &aArg1P, Window *pWindow,
+ USHORT nResIdP, ResMgr *pMgrP)
+: ErrorContext(pWindow), nCtxId(nCtxIdP), nResId(nResIdP), pMgr(pMgrP),
+ aArg1(aArg1P)
+{
+ if( nResId==USHRT_MAX )
+ nResId=RID_ERRCTX;
+}
+
+//-------------------------------------------------------------------------
+
+BOOL SfxErrorContext::GetString(ULONG nErrId, String &rStr)
+
+/* [Beschreibung]
+
+ Baut die Beschreibung eines ErrorContextes auf
+ */
+
+{
+ bool bRet = false;
+ ResMgr* pFreeMgr = NULL;
+ if( ! pMgr )
+ {
+ com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale();
+ pFreeMgr = pMgr = ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(ofa), aLocale );
+ }
+ if( pMgr )
+ {
+ vos:: OGuard aGuard( Application::GetSolarMutex() );
+
+ ResId aResId( nResId, *pMgr );
+
+ ErrorResource_Impl aTestEr( aResId, nCtxId );
+ if ( aTestEr )
+ {
+ rStr = ( (ResString)aTestEr ).GetString();
+ rStr.SearchAndReplace( String::CreateFromAscii( "$(ARG1)" ), aArg1 );
+ bRet = true;
+ }
+ else
+ {
+ DBG_ERRORFILE( "ErrorContext cannot find the resource" );
+ bRet = false;
+ }
+
+ if ( bRet )
+ {
+ USHORT nId = ( nErrId & ERRCODE_WARNING_MASK ) ? ERRCTX_WARNING : ERRCTX_ERROR;
+ ResId aSfxResId( RID_ERRCTX, *pMgr );
+ ErrorResource_Impl aEr( aSfxResId, nId );
+ rStr.SearchAndReplace( String::CreateFromAscii( "$(ERR)" ), ( (ResString)aEr ).GetString() );
+ }
+ }
+
+ if( pFreeMgr )
+ {
+ delete pFreeMgr;
+ pMgr = NULL;
+ }
+ return bRet;
+}
diff --git a/svtools/source/misc/ehdl.src b/svtools/source/misc/ehdl.src
new file mode 100644
index 000000000000..436e06b7f3c5
--- /dev/null
+++ b/svtools/source/misc/ehdl.src
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#define __RSC
+#include <svtools/svtools.hrc>
+#include "sfxecode.hxx"
+ // pragma ----------------------------------------------------------------
+
+String STR_ERR_HDLMESS
+{
+ Text = "$(ACTION)$(ERROR)" ;
+};
+String RID_ERRHDL_CLASS
+{
+ Text = "$(CLASS)$(ERROR)" ;
+};
diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx
new file mode 100644
index 000000000000..3aa0016c225e
--- /dev/null
+++ b/svtools/source/misc/embedhlp.cxx
@@ -0,0 +1,955 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include <svtools/embedhlp.hxx>
+#include <svtools/filter.hxx>
+#include <svtools/svtools.hrc>
+#include <svtools/svtdata.hxx>
+
+#include <comphelper/embeddedobjectcontainer.hxx>
+#include <comphelper/seqstream.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/streamwrap.hxx>
+
+#include <tools/globname.hxx>
+#include <sot/clsids.hxx>
+#include <com/sun/star/util/XModifyListener.hpp>
+#ifndef _COM_SUN_STAR_UTIL_XMODIFYiBLE_HPP_
+#include <com/sun/star/util/XModifiable.hpp>
+#endif
+#include <com/sun/star/embed/EmbedStates.hpp>
+#include <com/sun/star/embed/EmbedMisc.hpp>
+#include <com/sun/star/embed/XStateChangeListener.hpp>
+#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#include <com/sun/star/chart2/XDefaultSizeTransmitter.hpp>
+#include <cppuhelper/implbase4.hxx>
+#include "vcl/svapp.hxx"
+#include <rtl/logfile.hxx>
+#include <vos/mutex.hxx>
+
+using namespace com::sun::star;
+
+namespace svt
+{
+
+class EmbedEventListener_Impl : public ::cppu::WeakImplHelper4 < embed::XStateChangeListener,
+ document::XEventListener,
+ util::XModifyListener,
+ util::XCloseListener >
+{
+public:
+ EmbeddedObjectRef* pObject;
+ sal_Int32 nState;
+
+ EmbedEventListener_Impl( EmbeddedObjectRef* p ) :
+ pObject(p)
+ , nState(-1)
+ {}
+
+ static EmbedEventListener_Impl* Create( EmbeddedObjectRef* );
+
+ virtual void SAL_CALL changingState( const lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState )
+ throw (embed::WrongStateException, uno::RuntimeException);
+ virtual void SAL_CALL stateChanged( const lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState )
+ throw (uno::RuntimeException);
+ virtual void SAL_CALL queryClosing( const lang::EventObject& Source, ::sal_Bool GetsOwnership )
+ throw (util::CloseVetoException, uno::RuntimeException);
+ virtual void SAL_CALL notifyClosing( const lang::EventObject& Source ) throw (uno::RuntimeException);
+ virtual void SAL_CALL notifyEvent( const document::EventObject& aEvent ) throw( uno::RuntimeException );
+ virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) throw( uno::RuntimeException );
+ virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+};
+
+EmbedEventListener_Impl* EmbedEventListener_Impl::Create( EmbeddedObjectRef* p )
+{
+ EmbedEventListener_Impl* xRet = new EmbedEventListener_Impl( p );
+ xRet->acquire();
+
+ if ( p->GetObject().is() )
+ {
+ p->GetObject()->addStateChangeListener( xRet );
+
+ uno::Reference < util::XCloseable > xClose( p->GetObject(), uno::UNO_QUERY );
+ DBG_ASSERT( xClose.is(), "Object does not support XCloseable!" );
+ if ( xClose.is() )
+ xClose->addCloseListener( xRet );
+
+ uno::Reference < document::XEventBroadcaster > xBrd( p->GetObject(), uno::UNO_QUERY );
+ if ( xBrd.is() )
+ xBrd->addEventListener( xRet );
+
+ xRet->nState = p->GetObject()->getCurrentState();
+ if ( xRet->nState == embed::EmbedStates::RUNNING )
+ {
+ uno::Reference < util::XModifiable > xMod( p->GetObject()->getComponent(), uno::UNO_QUERY );
+ if ( xMod.is() )
+ // listen for changes in running state (update replacements in case of changes)
+ xMod->addModifyListener( xRet );
+ }
+ }
+
+ return xRet;
+}
+
+void SAL_CALL EmbedEventListener_Impl::changingState( const lang::EventObject&,
+ ::sal_Int32,
+ ::sal_Int32 )
+ throw ( embed::WrongStateException,
+ uno::RuntimeException )
+{
+}
+
+void SAL_CALL EmbedEventListener_Impl::stateChanged( const lang::EventObject&,
+ ::sal_Int32 nOldState,
+ ::sal_Int32 nNewState )
+ throw ( uno::RuntimeException )
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ nState = nNewState;
+ if ( !pObject )
+ return;
+
+ uno::Reference < util::XModifiable > xMod( pObject->GetObject()->getComponent(), uno::UNO_QUERY );
+ if ( nNewState == embed::EmbedStates::RUNNING )
+ {
+ // TODO/LATER: container must be set before!
+ // When is this event created? Who sets the new container when it changed?
+ if( ( pObject->GetViewAspect() != embed::Aspects::MSOLE_ICON ) && nOldState != embed::EmbedStates::LOADED && !pObject->IsChart() )
+ // get new replacement after deactivation
+ pObject->UpdateReplacement();
+
+ if( pObject->IsChart() && nOldState == embed::EmbedStates::UI_ACTIVE )
+ {
+ //create a new metafile replacement when leaving the edit mode
+ //for buggy documents where the old image looks different from the correct one
+ if( xMod.is() && !xMod->isModified() )//in case of modification a new replacement will be requested anyhow
+ pObject->UpdateReplacementOnDemand();
+ }
+
+ if ( xMod.is() && nOldState == embed::EmbedStates::LOADED )
+ // listen for changes (update replacements in case of changes)
+ xMod->addModifyListener( this );
+ }
+ else if ( nNewState == embed::EmbedStates::LOADED )
+ {
+ // in loaded state we can't listen
+ if ( xMod.is() )
+ xMod->removeModifyListener( this );
+ }
+}
+
+void SAL_CALL EmbedEventListener_Impl::modified( const lang::EventObject& ) throw (uno::RuntimeException)
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ if ( pObject && pObject->GetViewAspect() != embed::Aspects::MSOLE_ICON )
+ {
+ if ( nState == embed::EmbedStates::RUNNING )
+ {
+ // updates only necessary in non-active states
+ if( pObject->IsChart() )
+ pObject->UpdateReplacementOnDemand();
+ else
+ pObject->UpdateReplacement();
+ }
+ else if ( nState == embed::EmbedStates::UI_ACTIVE || nState == embed::EmbedStates::INPLACE_ACTIVE )
+ {
+ // in case the object is inplace or UI active the replacement image should be updated on demand
+ pObject->UpdateReplacementOnDemand();
+ }
+ }
+}
+
+void SAL_CALL EmbedEventListener_Impl::notifyEvent( const document::EventObject& aEvent ) throw( uno::RuntimeException )
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+#if 0
+ if ( pObject && aEvent.EventName.equalsAscii("OnSaveDone") || aEvent.EventName.equalsAscii("OnSaveAsDone") )
+ {
+ // TODO/LATER: container must be set before!
+ // When is this event created? Who sets the new container when it changed?
+ pObject->UpdateReplacement();
+ }
+ else
+#endif
+ if ( pObject && aEvent.EventName.equalsAscii("OnVisAreaChanged") && pObject->GetViewAspect() != embed::Aspects::MSOLE_ICON && !pObject->IsChart() )
+ {
+ pObject->UpdateReplacement();
+ }
+}
+
+void SAL_CALL EmbedEventListener_Impl::queryClosing( const lang::EventObject& Source, ::sal_Bool )
+ throw ( util::CloseVetoException, uno::RuntimeException)
+{
+ // An embedded object can be shared between several objects (f.e. for undo purposes)
+ // the object will not be closed before the last "customer" is destroyed
+ // Now the EmbeddedObjectRef helper class works like a "lock" on the object
+ if ( pObject && pObject->IsLocked() && Source.Source == pObject->GetObject() )
+ throw util::CloseVetoException();
+}
+
+void SAL_CALL EmbedEventListener_Impl::notifyClosing( const lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException)
+{
+ if ( pObject && Source.Source == pObject->GetObject() )
+ {
+ pObject->Clear();
+ pObject = 0;
+ }
+}
+
+void SAL_CALL EmbedEventListener_Impl::disposing( const lang::EventObject& aEvent ) throw( uno::RuntimeException )
+{
+ if ( pObject && aEvent.Source == pObject->GetObject() )
+ {
+ pObject->Clear();
+ pObject = 0;
+ }
+}
+
+struct EmbeddedObjectRef_Impl
+{
+ EmbedEventListener_Impl* xListener;
+ ::rtl::OUString aPersistName;
+ ::rtl::OUString aMediaType;
+ comphelper::EmbeddedObjectContainer* pContainer;
+ Graphic* pGraphic;
+ Graphic* pHCGraphic;
+ sal_Int64 nViewAspect;
+ BOOL bIsLocked;
+ sal_Bool bNeedUpdate;
+
+ // #i104867#
+ sal_uInt32 mnGraphicVersion;
+ awt::Size aDefaultSizeForChart_In_100TH_MM;//#i103460# charts do not necessaryly have an own size within ODF files, in this case they need to use the size settings from the surrounding frame, which is made available with this member
+};
+
+void EmbeddedObjectRef::Construct_Impl()
+{
+ mpImp = new EmbeddedObjectRef_Impl;
+ mpImp->pContainer = 0;
+ mpImp->pGraphic = 0;
+ mpImp->pHCGraphic = 0;
+ mpImp->nViewAspect = embed::Aspects::MSOLE_CONTENT;
+ mpImp->bIsLocked = FALSE;
+ mpImp->bNeedUpdate = sal_False;
+ mpImp->mnGraphicVersion = 0;
+ mpImp->aDefaultSizeForChart_In_100TH_MM = awt::Size(8000,7000);
+}
+
+EmbeddedObjectRef::EmbeddedObjectRef()
+{
+ Construct_Impl();
+}
+
+EmbeddedObjectRef::EmbeddedObjectRef( const NS_UNO::Reference < NS_EMBED::XEmbeddedObject >& xObj, sal_Int64 nAspect )
+{
+ Construct_Impl();
+ mpImp->nViewAspect = nAspect;
+ mxObj = xObj;
+ mpImp->xListener = EmbedEventListener_Impl::Create( this );
+}
+
+EmbeddedObjectRef::EmbeddedObjectRef( const EmbeddedObjectRef& rObj )
+{
+ mpImp = new EmbeddedObjectRef_Impl;
+ mpImp->pContainer = rObj.mpImp->pContainer;
+ mpImp->nViewAspect = rObj.mpImp->nViewAspect;
+ mpImp->bIsLocked = rObj.mpImp->bIsLocked;
+ mxObj = rObj.mxObj;
+ mpImp->xListener = EmbedEventListener_Impl::Create( this );
+ mpImp->aPersistName = rObj.mpImp->aPersistName;
+ mpImp->aMediaType = rObj.mpImp->aMediaType;
+ mpImp->bNeedUpdate = rObj.mpImp->bNeedUpdate;
+ mpImp->aDefaultSizeForChart_In_100TH_MM = rObj.mpImp->aDefaultSizeForChart_In_100TH_MM;
+
+ if ( rObj.mpImp->pGraphic && !rObj.mpImp->bNeedUpdate )
+ mpImp->pGraphic = new Graphic( *rObj.mpImp->pGraphic );
+ else
+ mpImp->pGraphic = 0;
+
+ mpImp->pHCGraphic = 0;
+ mpImp->mnGraphicVersion = 0;
+}
+
+EmbeddedObjectRef::~EmbeddedObjectRef()
+{
+ delete mpImp->pGraphic;
+ if ( mpImp->pHCGraphic )
+ DELETEZ( mpImp->pHCGraphic );
+ Clear();
+}
+/*
+EmbeddedObjectRef& EmbeddedObjectRef::operator = ( const EmbeddedObjectRef& rObj )
+{
+ DBG_ASSERT( !mxObj.is(), "Never assign an already assigned object!" );
+
+ delete mpImp->pGraphic;
+ if ( mpImp->pHCGraphic ) DELETEZ( mpImp->pHCGraphic );
+ Clear();
+
+ mpImp->nViewAspect = rObj.mpImp->nViewAspect;
+ mpImp->bIsLocked = rObj.mpImp->bIsLocked;
+ mxObj = rObj.mxObj;
+ mpImp->xListener = EmbedEventListener_Impl::Create( this );
+ mpImp->pContainer = rObj.mpImp->pContainer;
+ mpImp->aPersistName = rObj.mpImp->aPersistName;
+ mpImp->aMediaType = rObj.mpImp->aMediaType;
+ mpImp->bNeedUpdate = rObj.mpImp->bNeedUpdate;
+
+ if ( rObj.mpImp->pGraphic && !rObj.mpImp->bNeedUpdate )
+ mpImp->pGraphic = new Graphic( *rObj.mpImp->pGraphic );
+ else
+ mpImp->pGraphic = 0;
+ return *this;
+}
+*/
+void EmbeddedObjectRef::Assign( const NS_UNO::Reference < NS_EMBED::XEmbeddedObject >& xObj, sal_Int64 nAspect )
+{
+ DBG_ASSERT( !mxObj.is(), "Never assign an already assigned object!" );
+
+ Clear();
+ mpImp->nViewAspect = nAspect;
+ mxObj = xObj;
+ mpImp->xListener = EmbedEventListener_Impl::Create( this );
+
+ //#i103460#
+ {
+ ::com::sun::star::uno::Reference < ::com::sun::star::chart2::XDefaultSizeTransmitter > xSizeTransmitter( xObj, uno::UNO_QUERY );
+ DBG_ASSERT( xSizeTransmitter.is(), "Object does not support XDefaultSizeTransmitter -> will cause #i103460#!" );
+ if( xSizeTransmitter.is() )
+ xSizeTransmitter->setDefaultSize( mpImp->aDefaultSizeForChart_In_100TH_MM );
+ }
+}
+
+void EmbeddedObjectRef::Clear()
+{
+ if ( mxObj.is() && mpImp->xListener )
+ {
+ mxObj->removeStateChangeListener( mpImp->xListener );
+
+ uno::Reference < util::XCloseable > xClose( mxObj, uno::UNO_QUERY );
+ if ( xClose.is() )
+ xClose->removeCloseListener( mpImp->xListener );
+
+ uno::Reference < document::XEventBroadcaster > xBrd( mxObj, uno::UNO_QUERY );
+ if ( xBrd.is() )
+ xBrd->removeEventListener( mpImp->xListener );
+
+ if ( mpImp->bIsLocked )
+ {
+ if ( xClose.is() )
+ {
+ try
+ {
+ mxObj->changeState( embed::EmbedStates::LOADED );
+ xClose->close( sal_True );
+ }
+ catch ( util::CloseVetoException& )
+ {
+ // there's still someone who needs the object!
+ }
+ catch ( uno::Exception& )
+ {
+ OSL_ENSURE( sal_False, "Error on switching of the object to loaded state and closing!\n" );
+ }
+ }
+ }
+
+ if ( mpImp->xListener )
+ {
+ mpImp->xListener->pObject = 0;
+ mpImp->xListener->release();
+ mpImp->xListener = 0;
+ }
+
+ mxObj = 0;
+ mpImp->bNeedUpdate = sal_False;
+ }
+
+ mpImp->pContainer = 0;
+ mpImp->bIsLocked = FALSE;
+ mpImp->bNeedUpdate = sal_False;
+}
+
+void EmbeddedObjectRef::AssignToContainer( comphelper::EmbeddedObjectContainer* pContainer, const ::rtl::OUString& rPersistName )
+{
+ mpImp->pContainer = pContainer;
+ mpImp->aPersistName = rPersistName;
+
+ if ( mpImp->pGraphic && !mpImp->bNeedUpdate && pContainer )
+ SetGraphicToContainer( *mpImp->pGraphic, *pContainer, mpImp->aPersistName, ::rtl::OUString() );
+}
+
+comphelper::EmbeddedObjectContainer* EmbeddedObjectRef::GetContainer() const
+{
+ return mpImp->pContainer;
+}
+
+::rtl::OUString EmbeddedObjectRef::GetPersistName() const
+{
+ return mpImp->aPersistName;
+}
+
+MapUnit EmbeddedObjectRef::GetMapUnit() const
+{
+ if ( mpImp->nViewAspect == embed::Aspects::MSOLE_CONTENT )
+ return VCLUnoHelper::UnoEmbed2VCLMapUnit( mxObj->getMapUnit( mpImp->nViewAspect ) );
+ else
+ // TODO/LATER: currently only CONTENT aspect requires communication with the object
+ return MAP_100TH_MM;
+}
+
+sal_Int64 EmbeddedObjectRef::GetViewAspect() const
+{
+ return mpImp->nViewAspect;
+}
+
+void EmbeddedObjectRef::SetViewAspect( sal_Int64 nAspect )
+{
+ mpImp->nViewAspect = nAspect;
+}
+
+void EmbeddedObjectRef::Lock( BOOL bLock )
+{
+ mpImp->bIsLocked = bLock;
+}
+
+BOOL EmbeddedObjectRef::IsLocked() const
+{
+ return mpImp->bIsLocked;
+}
+
+void EmbeddedObjectRef::GetReplacement( BOOL bUpdate )
+{
+ if ( bUpdate )
+ {
+ DELETEZ( mpImp->pGraphic );
+ mpImp->aMediaType = ::rtl::OUString();
+ mpImp->pGraphic = new Graphic;
+ if ( mpImp->pHCGraphic )
+ DELETEZ( mpImp->pHCGraphic );
+ mpImp->mnGraphicVersion++;
+ }
+ else if ( !mpImp->pGraphic )
+ {
+ mpImp->pGraphic = new Graphic;
+ mpImp->mnGraphicVersion++;
+ }
+ else
+ {
+ DBG_ERROR("No update, but replacement exists already!");
+ return;
+ }
+
+ SvStream* pGraphicStream = GetGraphicStream( bUpdate );
+ if ( pGraphicStream )
+ {
+ GraphicFilter* pGF = GraphicFilter::GetGraphicFilter();
+ if( mpImp->pGraphic )
+ pGF->ImportGraphic( *mpImp->pGraphic, String(), *pGraphicStream, GRFILTER_FORMAT_DONTKNOW );
+ mpImp->mnGraphicVersion++;
+ delete pGraphicStream;
+ }
+}
+
+Graphic* EmbeddedObjectRef::GetGraphic( ::rtl::OUString* pMediaType ) const
+{
+ if ( mpImp->bNeedUpdate )
+ // bNeedUpdate will be set to false while retrieving new replacement
+ const_cast < EmbeddedObjectRef* >(this)->GetReplacement( sal_True );
+ else if ( !mpImp->pGraphic )
+ const_cast < EmbeddedObjectRef* >(this)->GetReplacement( FALSE );
+
+ if ( mpImp->pGraphic && pMediaType )
+ *pMediaType = mpImp->aMediaType;
+ return mpImp->pGraphic;
+}
+
+Size EmbeddedObjectRef::GetSize( MapMode* pTargetMapMode ) const
+{
+ MapMode aSourceMapMode( MAP_100TH_MM );
+ Size aResult;
+
+ if ( mpImp->nViewAspect == embed::Aspects::MSOLE_ICON )
+ {
+ Graphic* pGraphic = GetGraphic();
+ if ( pGraphic )
+ {
+ aSourceMapMode = pGraphic->GetPrefMapMode();
+ aResult = pGraphic->GetPrefSize();
+ }
+ else
+ aResult = Size( 2500, 2500 );
+ }
+ else
+ {
+ awt::Size aSize;
+
+ if ( mxObj.is() )
+ {
+ try
+ {
+ aSize = mxObj->getVisualAreaSize( mpImp->nViewAspect );
+ }
+ catch( embed::NoVisualAreaSizeException& )
+ {
+ }
+ catch( uno::Exception& )
+ {
+ OSL_ENSURE( sal_False, "Something went wrong on getting of the size of the object!" );
+ }
+
+ try
+ {
+ aSourceMapMode = VCLUnoHelper::UnoEmbed2VCLMapUnit( mxObj->getMapUnit( mpImp->nViewAspect ) );
+ }
+ catch( uno::Exception )
+ {
+ OSL_ENSURE( sal_False, "Can not get the map mode!" );
+ }
+ }
+
+ if ( !aSize.Height && !aSize.Width )
+ {
+ aSize.Width = 5000;
+ aSize.Height = 5000;
+ }
+
+ aResult = Size( aSize.Width, aSize.Height );
+ }
+
+ if ( pTargetMapMode )
+ aResult = OutputDevice::LogicToLogic( aResult, aSourceMapMode, *pTargetMapMode );
+
+ return aResult;
+}
+
+Graphic* EmbeddedObjectRef::GetHCGraphic() const
+{
+ if ( !mpImp->pHCGraphic )
+ {
+ uno::Reference< io::XInputStream > xInStream;
+ try
+ {
+ // if the object needs size on load, that means that it is not our object
+ // currently the HC mode is supported only for OOo own objects so the following
+ // check is used as an optimization
+ // TODO/LATER: shouldn't there be a special status flag to detect alien implementation?
+ if ( mpImp->nViewAspect == embed::Aspects::MSOLE_CONTENT
+ && mxObj.is() && !( mxObj->getStatus( mpImp->nViewAspect ) & embed::EmbedMisc::EMBED_NEEDSSIZEONLOAD ) )
+ {
+ // TODO/LATER: optimization, it makes no sence to do it for OLE objects
+ if ( mxObj->getCurrentState() == embed::EmbedStates::LOADED )
+ mxObj->changeState( embed::EmbedStates::RUNNING );
+
+ // TODO: return for the aspect of the document
+ embed::VisualRepresentation aVisualRepresentation;
+ uno::Reference< datatransfer::XTransferable > xTransferable( mxObj->getComponent(), uno::UNO_QUERY );
+ if ( !xTransferable.is() )
+ throw uno::RuntimeException();
+
+ datatransfer::DataFlavor aDataFlavor(
+ ::rtl::OUString::createFromAscii(
+ "application/x-openoffice-highcontrast-gdimetafile;windows_formatname=\"GDIMetaFile\"" ),
+ ::rtl::OUString::createFromAscii( "GDIMetaFile" ),
+ ::getCppuType( (const uno::Sequence< sal_Int8 >*) NULL ) );
+
+ uno::Sequence < sal_Int8 > aSeq;
+ if ( ( xTransferable->getTransferData( aDataFlavor ) >>= aSeq ) && aSeq.getLength() )
+ xInStream = new ::comphelper::SequenceInputStream( aSeq );
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ }
+
+ if ( xInStream.is() )
+ {
+ SvStream* pStream = NULL;
+ pStream = ::utl::UcbStreamHelper::CreateStream( xInStream );
+ if ( pStream )
+ {
+ if ( !pStream->GetError() )
+ {
+ GraphicFilter* pGF = GraphicFilter::GetGraphicFilter();
+ Graphic* pGraphic = new Graphic();
+ if ( pGF->ImportGraphic( *pGraphic, String(), *pStream, GRFILTER_FORMAT_DONTKNOW ) == 0 )
+ mpImp->pHCGraphic = pGraphic;
+ else
+ delete pGraphic;
+ mpImp->mnGraphicVersion++;
+ }
+
+ delete pStream;
+ }
+ }
+ }
+
+ return mpImp->pHCGraphic;
+}
+
+void EmbeddedObjectRef::SetGraphicStream( const uno::Reference< io::XInputStream >& xInGrStream,
+ const ::rtl::OUString& rMediaType )
+{
+ if ( mpImp->pGraphic )
+ delete mpImp->pGraphic;
+ mpImp->pGraphic = new Graphic();
+ mpImp->aMediaType = rMediaType;
+ if ( mpImp->pHCGraphic )
+ DELETEZ( mpImp->pHCGraphic );
+ mpImp->mnGraphicVersion++;
+
+ SvStream* pGraphicStream = ::utl::UcbStreamHelper::CreateStream( xInGrStream );
+
+ if ( pGraphicStream )
+ {
+ GraphicFilter* pGF = GraphicFilter::GetGraphicFilter();
+ pGF->ImportGraphic( *mpImp->pGraphic, String(), *pGraphicStream, GRFILTER_FORMAT_DONTKNOW );
+ mpImp->mnGraphicVersion++;
+
+ if ( mpImp->pContainer )
+ {
+ pGraphicStream->Seek( 0 );
+ uno::Reference< io::XInputStream > xInSeekGrStream = new ::utl::OSeekableInputStreamWrapper( pGraphicStream );
+
+ mpImp->pContainer->InsertGraphicStream( xInSeekGrStream, mpImp->aPersistName, rMediaType );
+ }
+
+ delete pGraphicStream;
+ }
+
+ mpImp->bNeedUpdate = sal_False;
+
+}
+
+void EmbeddedObjectRef::SetGraphic( const Graphic& rGraphic, const ::rtl::OUString& rMediaType )
+{
+ if ( mpImp->pGraphic )
+ delete mpImp->pGraphic;
+ mpImp->pGraphic = new Graphic( rGraphic );
+ mpImp->aMediaType = rMediaType;
+ if ( mpImp->pHCGraphic )
+ DELETEZ( mpImp->pHCGraphic );
+ mpImp->mnGraphicVersion++;
+
+ if ( mpImp->pContainer )
+ SetGraphicToContainer( rGraphic, *mpImp->pContainer, mpImp->aPersistName, rMediaType );
+
+ mpImp->bNeedUpdate = sal_False;
+}
+
+SvStream* EmbeddedObjectRef::GetGraphicStream( BOOL bUpdate ) const
+{
+ RTL_LOGFILE_CONTEXT( aLog, "svtools (mv76033) svt::EmbeddedObjectRef::GetGraphicStream" );
+ DBG_ASSERT( bUpdate || mpImp->pContainer, "Can't retrieve current graphic!" );
+ uno::Reference < io::XInputStream > xStream;
+ if ( mpImp->pContainer && !bUpdate )
+ {
+ RTL_LOGFILE_CONTEXT_TRACE( aLog, "getting stream from container" );
+ // try to get graphic stream from container storage
+ xStream = mpImp->pContainer->GetGraphicStream( mxObj, &mpImp->aMediaType );
+ if ( xStream.is() )
+ {
+ const sal_Int32 nConstBufferSize = 32000;
+ SvStream *pStream = new SvMemoryStream( 32000, 32000 );
+ sal_Int32 nRead=0;
+ uno::Sequence < sal_Int8 > aSequence ( nConstBufferSize );
+ do
+ {
+ nRead = xStream->readBytes ( aSequence, nConstBufferSize );
+ pStream->Write( aSequence.getConstArray(), nRead );
+ }
+ while ( nRead == nConstBufferSize );
+ pStream->Seek(0);
+ return pStream;
+ }
+ }
+
+ if ( !xStream.is() )
+ {
+ RTL_LOGFILE_CONTEXT_TRACE( aLog, "getting stream from object" );
+ // update wanted or no stream in container storage available
+ xStream = GetGraphicReplacementStream( mpImp->nViewAspect, mxObj, &mpImp->aMediaType );
+
+ if ( xStream.is() )
+ {
+ if ( mpImp->pContainer )
+ mpImp->pContainer->InsertGraphicStream( xStream, mpImp->aPersistName, mpImp->aMediaType );
+
+ SvStream* pResult = ::utl::UcbStreamHelper::CreateStream( xStream );
+ if ( pResult && bUpdate )
+ mpImp->bNeedUpdate = sal_False;
+
+ return pResult;
+ }
+ }
+
+ return NULL;
+}
+
+void EmbeddedObjectRef::DrawPaintReplacement( const Rectangle &rRect, const String &rText, OutputDevice *pOut )
+{
+ MapMode aMM( MAP_APPFONT );
+ Size aAppFontSz = pOut->LogicToLogic( Size( 0, 8 ), &aMM, NULL );
+ Font aFnt( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "Helvetica" ) ), aAppFontSz );
+ aFnt.SetTransparent( TRUE );
+ aFnt.SetColor( Color( COL_LIGHTRED ) );
+ aFnt.SetWeight( WEIGHT_BOLD );
+ aFnt.SetFamily( FAMILY_SWISS );
+
+ pOut->Push();
+ pOut->SetBackground();
+ pOut->SetFont( aFnt );
+
+ Point aPt;
+ // Nun den Text so skalieren, dass er in das Rect passt.
+ // Wir fangen mit der Defaultsize an und gehen 1-AppFont runter
+ for( USHORT i = 8; i > 2; i-- )
+ {
+ aPt.X() = (rRect.GetWidth() - pOut->GetTextWidth( rText )) / 2;
+ aPt.Y() = (rRect.GetHeight() - pOut->GetTextHeight()) / 2;
+
+ BOOL bTiny = FALSE;
+ if( aPt.X() < 0 ) bTiny = TRUE, aPt.X() = 0;
+ if( aPt.Y() < 0 ) bTiny = TRUE, aPt.Y() = 0;
+ if( bTiny )
+ {
+ // heruntergehen bei kleinen Bildern
+ aFnt.SetSize( Size( 0, aAppFontSz.Height() * i / 8 ) );
+ pOut->SetFont( aFnt );
+ }
+ else
+ break;
+ }
+
+ Bitmap aBmp( SvtResId( BMP_PLUGIN ) );
+ long nHeight = rRect.GetHeight() - pOut->GetTextHeight();
+ long nWidth = rRect.GetWidth();
+ if( nHeight > 0 )
+ {
+ aPt.Y() = nHeight;
+ Point aP = rRect.TopLeft();
+ Size aBmpSize = aBmp.GetSizePixel();
+ // Bitmap einpassen
+ if( nHeight * 10 / nWidth
+ > aBmpSize.Height() * 10 / aBmpSize.Width() )
+ {
+ // nach der Breite ausrichten
+ // Proportion beibehalten
+ long nH = nWidth * aBmpSize.Height() / aBmpSize.Width();
+ // zentrieren
+ aP.Y() += (nHeight - nH) / 2;
+ nHeight = nH;
+ }
+ else
+ {
+ // nach der H"ohe ausrichten
+ // Proportion beibehalten
+ long nW = nHeight * aBmpSize.Width() / aBmpSize.Height();
+ // zentrieren
+ aP.X() += (nWidth - nW) / 2;
+ nWidth = nW;
+ }
+
+ pOut->DrawBitmap( aP, Size( nWidth, nHeight ), aBmp );
+ }
+
+ pOut->IntersectClipRegion( rRect );
+ aPt += rRect.TopLeft();
+ pOut->DrawText( aPt, rText );
+ pOut->Pop();
+}
+
+void EmbeddedObjectRef::DrawShading( const Rectangle &rRect, OutputDevice *pOut )
+{
+ GDIMetaFile * pMtf = pOut->GetConnectMetaFile();
+ if( pMtf && pMtf->IsRecord() )
+ return;
+
+ pOut->Push();
+ pOut->SetLineColor( Color( COL_BLACK ) );
+
+ Size aPixSize = pOut->LogicToPixel( rRect.GetSize() );
+ aPixSize.Width() -= 1;
+ aPixSize.Height() -= 1;
+ Point aPixViewPos = pOut->LogicToPixel( rRect.TopLeft() );
+ INT32 nMax = aPixSize.Width() + aPixSize.Height();
+ for( INT32 i = 5; i < nMax; i += 5 )
+ {
+ Point a1( aPixViewPos ), a2( aPixViewPos );
+ if( i > aPixSize.Width() )
+ a1 += Point( aPixSize.Width(), i - aPixSize.Width() );
+ else
+ a1 += Point( i, 0 );
+ if( i > aPixSize.Height() )
+ a2 += Point( i - aPixSize.Height(), aPixSize.Height() );
+ else
+ a2 += Point( 0, i );
+
+ pOut->DrawLine( pOut->PixelToLogic( a1 ), pOut->PixelToLogic( a2 ) );
+ }
+
+ pOut->Pop();
+
+}
+
+BOOL EmbeddedObjectRef::TryRunningState()
+{
+ return TryRunningState( mxObj );
+}
+
+BOOL EmbeddedObjectRef::TryRunningState( const uno::Reference < embed::XEmbeddedObject >& xEmbObj )
+{
+ if ( !xEmbObj.is() )
+ return FALSE;
+
+ try
+ {
+ if ( xEmbObj->getCurrentState() == embed::EmbedStates::LOADED )
+ xEmbObj->changeState( embed::EmbedStates::RUNNING );
+ }
+ catch ( uno::Exception& )
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+void EmbeddedObjectRef::SetGraphicToContainer( const Graphic& rGraphic,
+ comphelper::EmbeddedObjectContainer& aContainer,
+ const ::rtl::OUString& aName,
+ const ::rtl::OUString& aMediaType )
+{
+ SvMemoryStream aStream;
+ aStream.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
+ if ( rGraphic.ExportNative( aStream ) )
+ {
+ aStream.Seek( 0 );
+
+ uno::Reference < io::XInputStream > xStream = new ::utl::OSeekableInputStreamWrapper( aStream );
+ aContainer.InsertGraphicStream( xStream, aName, aMediaType );
+ }
+ else
+ OSL_ENSURE( sal_False, "Export of graphic is failed!\n" );
+}
+
+sal_Bool EmbeddedObjectRef::ObjectIsModified( const uno::Reference< embed::XEmbeddedObject >& xObj )
+ throw( uno::Exception )
+{
+ sal_Bool bResult = sal_False;
+
+ sal_Int32 nState = xObj->getCurrentState();
+ if ( nState != embed::EmbedStates::LOADED && nState != embed::EmbedStates::RUNNING )
+ {
+ // the object is active so if the model is modified the replacement
+ // should be retrieved from the object
+ uno::Reference< util::XModifiable > xModifiable( xObj->getComponent(), uno::UNO_QUERY );
+ if ( xModifiable.is() )
+ bResult = xModifiable->isModified();
+ }
+
+ return bResult;
+}
+
+uno::Reference< io::XInputStream > EmbeddedObjectRef::GetGraphicReplacementStream(
+ sal_Int64 nViewAspect,
+ const uno::Reference< embed::XEmbeddedObject >& xObj,
+ ::rtl::OUString* pMediaType )
+ throw()
+{
+ return ::comphelper::EmbeddedObjectContainer::GetGraphicReplacementStream(nViewAspect,xObj,pMediaType);
+}
+
+void EmbeddedObjectRef::UpdateReplacementOnDemand()
+{
+ DELETEZ( mpImp->pGraphic );
+ mpImp->bNeedUpdate = sal_True;
+ if ( mpImp->pHCGraphic )
+ DELETEZ( mpImp->pHCGraphic );
+ mpImp->mnGraphicVersion++;
+
+ if( mpImp->pContainer )
+ {
+ //remove graphic from container thus a new up to date one is requested on save
+ mpImp->pContainer->RemoveGraphicStream( mpImp->aPersistName );
+ }
+}
+
+BOOL EmbeddedObjectRef::IsChart() const
+{
+ //todo maybe for 3.0:
+ //if the changes work good for chart
+ //we should apply them for all own ole objects
+
+ //#i83708# #i81857# #i79578# request an ole replacement image only if really necessary
+ //as this call can be very expensive and does block the user interface as long at it takes
+
+ if ( !mxObj.is() )
+ return false;
+
+ SvGlobalName aObjClsId( mxObj->getClassID() );
+ if(
+ SvGlobalName(SO3_SCH_CLASSID_30) == aObjClsId
+ || SvGlobalName(SO3_SCH_CLASSID_40) == aObjClsId
+ || SvGlobalName(SO3_SCH_CLASSID_50) == aObjClsId
+ || SvGlobalName(SO3_SCH_CLASSID_60) == aObjClsId)
+ {
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+// #i104867#
+sal_uInt32 EmbeddedObjectRef::getGraphicVersion() const
+{
+ return mpImp->mnGraphicVersion;
+}
+
+void EmbeddedObjectRef::SetDefaultSizeForChart( const Size& rSizeIn_100TH_MM )
+{
+ //#i103460# charts do not necessaryly have an own size within ODF files,
+ //for this case they need to use the size settings from the surrounding frame,
+ //which is made available with this method
+
+ mpImp->aDefaultSizeForChart_In_100TH_MM = awt::Size( rSizeIn_100TH_MM.getWidth(), rSizeIn_100TH_MM.getHeight() );
+
+ ::com::sun::star::uno::Reference < ::com::sun::star::chart2::XDefaultSizeTransmitter > xSizeTransmitter( mxObj, uno::UNO_QUERY );
+ DBG_ASSERT( xSizeTransmitter.is(), "Object does not support XDefaultSizeTransmitter -> will cause #i103460#!" );
+ if( xSizeTransmitter.is() )
+ xSizeTransmitter->setDefaultSize( mpImp->aDefaultSizeForChart_In_100TH_MM );
+}
+
+} // namespace svt
+
diff --git a/svtools/source/misc/embedtransfer.cxx b/svtools/source/misc/embedtransfer.cxx
new file mode 100644
index 000000000000..cbf87f40b7fc
--- /dev/null
+++ b/svtools/source/misc/embedtransfer.cxx
@@ -0,0 +1,256 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <com/sun/star/embed/XComponentSupplier.hpp>
+#include <com/sun/star/embed/EmbedStates.hpp>
+#include <com/sun/star/embed/XVisualObject.hpp>
+#include <com/sun/star/embed/XEmbedPersist.hpp>
+#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#include <com/sun/star/embed/Aspects.hpp>
+
+#include <svtools/embedtransfer.hxx>
+#include <vcl/mapunit.hxx>
+#include <vcl/outdev.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/streamwrap.hxx>
+#include <unotools/tempfile.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+#include <svtools/embedhlp.hxx>
+
+using namespace ::com::sun::star;
+
+SvEmbedTransferHelper::SvEmbedTransferHelper( const uno::Reference< embed::XEmbeddedObject >& xObj,
+ Graphic* pGraphic,
+ sal_Int64 nAspect )
+: m_xObj( xObj )
+, m_pGraphic( pGraphic ? new Graphic( *pGraphic ) : NULL )
+, m_nAspect( nAspect )
+{
+ if( xObj.is() )
+ {
+ TransferableObjectDescriptor aObjDesc;
+
+ FillTransferableObjectDescriptor( aObjDesc, m_xObj, NULL, m_nAspect );
+ PrepareOLE( aObjDesc );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+SvEmbedTransferHelper::~SvEmbedTransferHelper()
+{
+ if ( m_pGraphic )
+ {
+ delete m_pGraphic;
+ m_pGraphic = NULL;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SvEmbedTransferHelper::AddSupportedFormats()
+{
+ AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+ AddFormat( FORMAT_GDIMETAFILE );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SvEmbedTransferHelper::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
+{
+ sal_Bool bRet = sal_False;
+
+ if( m_xObj.is() )
+ {
+ try
+ {
+ sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor );
+ if( HasFormat( nFormat ) )
+ {
+ if( nFormat == SOT_FORMATSTR_ID_OBJECTDESCRIPTOR )
+ {
+ TransferableObjectDescriptor aDesc;
+ FillTransferableObjectDescriptor( aDesc, m_xObj, m_pGraphic, m_nAspect );
+ bRet = SetTransferableObjectDescriptor( aDesc, rFlavor );
+ }
+ else if( nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE )
+ {
+ try
+ {
+ // TODO/LATER: Propbably the graphic should be copied here as well
+ // currently it is handled by the applications
+ utl::TempFile aTmp;
+ aTmp.EnableKillingFile( TRUE );
+ uno::Reference < embed::XEmbedPersist > xPers( m_xObj, uno::UNO_QUERY );
+ if ( xPers.is() )
+ {
+ uno::Reference < embed::XStorage > xStg = comphelper::OStorageHelper::GetTemporaryStorage();
+ ::rtl::OUString aName = ::rtl::OUString::createFromAscii("Dummy");
+ SvStream* pStream = NULL;
+ BOOL bDeleteStream = FALSE;
+ uno::Sequence < beans::PropertyValue > aEmpty;
+ xPers->storeToEntry( xStg, aName, aEmpty, aEmpty );
+ if ( xStg->isStreamElement( aName ) )
+ {
+ uno::Reference < io::XStream > xStm = xStg->cloneStreamElement( aName );
+ pStream = utl::UcbStreamHelper::CreateStream( xStm );
+ bDeleteStream = TRUE;
+ }
+ else
+ {
+ pStream = aTmp.GetStream( STREAM_STD_READWRITE );
+ uno::Reference < embed::XStorage > xStor = comphelper::OStorageHelper::GetStorageFromStream( new utl::OStreamWrapper( *pStream ) );
+ xStg->openStorageElement( aName, embed::ElementModes::READ )->copyToStorage( xStor );
+ }
+
+ ::com::sun::star::uno::Any aAny;
+ const sal_uInt32 nLen = pStream->Seek( STREAM_SEEK_TO_END );
+ ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( nLen );
+
+ pStream->Seek( STREAM_SEEK_TO_BEGIN );
+ pStream->Read( aSeq.getArray(), nLen );
+ if ( bDeleteStream )
+ delete pStream;
+
+ if( ( bRet = ( aSeq.getLength() > 0 ) ) == sal_True )
+ {
+ aAny <<= aSeq;
+ SetAny( aAny, rFlavor );
+ }
+ }
+ else
+ {
+ //TODO/LATER: how to handle objects without persistance?!
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ }
+ else if ( nFormat == FORMAT_GDIMETAFILE && m_pGraphic )
+ {
+ SvMemoryStream aMemStm( 65535, 65535 );
+ aMemStm.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
+
+ const GDIMetaFile& aMetaFile = m_pGraphic->GetGDIMetaFile();
+ ((GDIMetaFile*)(&aMetaFile))->Write( aMemStm );
+ uno::Any aAny;
+ aAny <<= uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ),
+ aMemStm.Seek( STREAM_SEEK_TO_END ) );
+ SetAny( aAny, rFlavor );
+ bRet = sal_True;
+ }
+ else if ( m_xObj.is() && :: svt::EmbeddedObjectRef::TryRunningState( m_xObj ) )
+ {
+ uno::Reference< datatransfer::XTransferable > xTransferable( m_xObj->getComponent(), uno::UNO_QUERY );
+ if ( xTransferable.is() )
+ {
+ uno::Any aAny = xTransferable->getTransferData( rFlavor );
+ SetAny( aAny, rFlavor );
+ bRet = sal_True;
+ }
+ }
+ }
+ }
+ catch( uno::Exception& )
+ {
+ // Error handling?
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void SvEmbedTransferHelper::ObjectReleased()
+{
+ m_xObj = uno::Reference< embed::XEmbeddedObject >();
+}
+
+void SvEmbedTransferHelper::FillTransferableObjectDescriptor( TransferableObjectDescriptor& rDesc,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject >& xObj,
+ Graphic* pGraphic,
+ sal_Int64 nAspect )
+{
+ //TODO/LATER: need TypeName to fill it into the Descriptor (will be shown in listbox)
+ ::com::sun::star::datatransfer::DataFlavor aFlavor;
+ SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aFlavor );
+
+ rDesc.maClassName = SvGlobalName( xObj->getClassID() );
+ rDesc.maTypeName = aFlavor.HumanPresentableName;
+
+ //TODO/LATER: the aspect size in the descriptor is wrong, unfortunately the stream
+ // representation of the descriptor allows only 4 bytes for the aspect
+ // so for internal transport something different should be found
+ rDesc.mnViewAspect = sal::static_int_cast<sal_uInt16>( nAspect );
+
+ //TODO/LATER: status needs to become sal_Int64
+ rDesc.mnOle2Misc = sal::static_int_cast<sal_Int32>(xObj->getStatus( rDesc.mnViewAspect ));
+
+ Size aSize;
+ MapMode aMapMode( MAP_100TH_MM );
+ if ( nAspect == embed::Aspects::MSOLE_ICON )
+ {
+ if ( pGraphic )
+ {
+ aMapMode = pGraphic->GetPrefMapMode();
+ aSize = pGraphic->GetPrefSize();
+ }
+ else
+ aSize = Size( 2500, 2500 );
+ }
+ else
+ {
+ try
+ {
+ awt::Size aSz;
+ aSz = xObj->getVisualAreaSize( rDesc.mnViewAspect );
+ aSize = Size( aSz.Width, aSz.Height );
+ }
+ catch( embed::NoVisualAreaSizeException& )
+ {
+ OSL_ENSURE( sal_False, "Can not get visual area size!\n" );
+ aSize = Size( 5000, 5000 );
+ }
+
+ // TODO/LEAN: getMapUnit can switch object to running state
+ aMapMode = MapMode( VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( rDesc.mnViewAspect ) ) );
+ }
+
+ rDesc.maSize = OutputDevice::LogicToLogic( aSize, aMapMode, MapMode( MAP_100TH_MM ) );
+ rDesc.maDragStartPos = Point();
+ rDesc.maDisplayName = String();
+ rDesc.mbCanLink = FALSE;
+}
+
diff --git a/svtools/source/misc/errtxt.src b/svtools/source/misc/errtxt.src
new file mode 100644
index 000000000000..f33896e20003
--- /dev/null
+++ b/svtools/source/misc/errtxt.src
@@ -0,0 +1,514 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#define __RSC
+#include <svtools/svtools.hrc>
+#include "sfxecode.hxx"
+ // pragma ----------------------------------------------------------------
+Resource RID_ERRCTX
+{
+ String ERRCTX_ERROR
+ {
+ Text [ en-US ] = "Error" ;
+ };
+ String ERRCTX_WARNING
+ {
+ Text [ en-US ] = "Warning" ;
+ };
+ String ERRCTX_SFX_LOADTEMPLATE
+ {
+ Text [ en-US ] = "$(ERR) loading the template $(ARG1)" ;
+ };
+ String ERRCTX_SFX_SAVEDOC
+ {
+ Text [ en-US ] = "$(ERR) saving the document $(ARG1)";
+ };
+ String ERRCTX_SFX_SAVEASDOC
+ {
+ Text [ en-US ] = "$(ERR) saving the document $(ARG1)";
+ };
+ String ERRCTX_SFX_DOCINFO
+ {
+ Text [ en-US ] = "$(ERR) displaying doc. information for document $(ARG1)" ;
+ };
+ String ERRCTX_SFX_DOCTEMPLATE
+ {
+ Text [ en-US ] = "$(ERR) writing document $(ARG1) as template" ;
+ };
+ String ERRCTX_SFX_MOVEORCOPYCONTENTS
+ {
+ Text [ en-US ] = "$(ERR) copying or moving document contents" ;
+ };
+ String ERRCTX_SFX_DOCMANAGER
+ {
+ Text [ en-US ] = "$(ERR) starting the Document Manager" ;
+ };
+ String ERRCTX_SFX_OPENDOC
+ {
+ Text [ en-US ] = "$(ERR) loading document $(ARG1)" ;
+ };
+ String ERRCTX_SFX_NEWDOCDIRECT
+ {
+ Text [ en-US ] = "$(ERR) creating a new document" ;
+ };
+ String ERRCTX_SFX_NEWDOC
+ {
+ Text [ en-US ] = "$(ERR) creating a new document" ;
+ };
+ String ERRCTX_SFX_CREATEOBJSH
+ {
+ Text [ en-US ] = "$(ERR) expanding entry" ;
+ };
+ String ERRCTX_SFX_LOADBASIC
+ {
+ Text [ en-US ] = "$(ERR) loading BASIC of document $(ARG1)" ;
+ };
+ String ERRCTX_SFX_SEARCHADDRESS
+ {
+ Text [ en-US ] = "$(ERR) searching for an address";
+ };
+};
+Resource RID_ERRHDL
+{
+ String ERRCODE_CLASS_ABORT
+ {
+ Text [ en-US ] = "Abort" ;
+ };
+ String ERRCODE_CLASS_NOTEXISTS
+ {
+ Text [ en-US ] = "Nonexistent object" ;
+ };
+ String ERRCODE_CLASS_ALREADYEXISTS
+ {
+ Text [ en-US ] = "Object already exists" ;
+ };
+ String ERRCODE_CLASS_ACCESS
+ {
+ Text [ en-US ] = "Object not accessible" ;
+ };
+ String ERRCODE_CLASS_PATH
+ {
+ Text [ en-US ] = "Inadmissible path" ;
+ };
+ String ERRCODE_CLASS_LOCKING
+ {
+ Text [ en-US ] = "Locking problem" ;
+ };
+ String ERRCODE_CLASS_PARAMETER
+ {
+ Text [ en-US ] = "Wrong parameter" ;
+ };
+ String ERRCODE_CLASS_SPACE
+ {
+ Text [ en-US ] = "Resource exhausted" ;
+ };
+ String ERRCODE_CLASS_NOTSUPPORTED
+ {
+ Text [ en-US ] = "Action not supported" ;
+ };
+ String ERRCODE_CLASS_READ
+ {
+ Text [ en-US ] = "Read-Error" ;
+ };
+ String ERRCODE_CLASS_WRITE
+ {
+ Text [ en-US ] = "Write Error" ;
+ };
+ String ERRCODE_CLASS_UNKNOWN
+ {
+ Text [ en-US ] = "unknown" ;
+ };
+ String ERRCODE_CLASS_VERSION
+ {
+ Text [ en-US ] = "Version Incompatibility" ;
+ };
+ String ERRCODE_CLASS_GENERAL
+ {
+ Text [ en-US ] = "General Error" ;
+ };
+ String ERRCODE_CLASS_FORMAT
+ {
+ Text [ en-US ] = "Incorrect format" ;
+ };
+ String ERRCODE_CLASS_CREATE
+ {
+ Text [ en-US ] = "Error creating object" ;
+ };
+ String ERRCODE_CLASS_SBX
+ {
+ Text [ en-US ] = "Inadmissible value or data type" ;
+ };
+ String ERRCODE_CLASS_RUNTIME
+ {
+ Text [ en-US ] = "BASIC runtime error" ;
+ };
+ String ERRCODE_CLASS_COMPILER
+ {
+ Text [ en-US ] = "BASIC syntax error" ;
+ };
+ String 1
+ {
+ Text [ en-US ] = "General Error" ;
+ };
+ String ERRCODE_IO_GENERAL
+ {
+ Text [ en-US ] = "General input/output error." ;
+ };
+ String ERRCODE_IO_MISPLACEDCHAR
+ {
+ Text [ en-US ] = "Invalid file name." ;
+ };
+ String ERRCODE_IO_NOTEXISTS
+ {
+ Text [ en-US ] = "Nonexistent file." ;
+ };
+ String ERRCODE_IO_ALREADYEXISTS
+ {
+ Text [ en-US ] = "File already exists." ;
+ };
+ String ERRCODE_IO_NOTADIRECTORY
+ {
+ Text [ en-US ] = "The object is not a directory." ;
+ };
+ String ERRCODE_IO_NOTAFILE
+ {
+ Text [ en-US ] = "The object is not a file." ;
+ };
+ String ERRCODE_IO_INVALIDDEVICE
+ {
+ Text [ en-US ] = "The specified device is invalid." ;
+ };
+ String ERRCODE_IO_ACCESSDENIED
+ {
+ Text [ en-US ] = "The object cannot be accessed\ndue to insufficient user rights." ;
+ };
+ String ERRCODE_IO_LOCKVIOLATION
+ {
+ Text [ en-US ] = "Sharing violation while accessing the object." ;
+ };
+ String ERRCODE_IO_OUTOFSPACE
+ {
+ Text [ en-US ] = "No more space on device." ;
+ };
+ String ERRCODE_IO_ISWILDCARD
+ {
+ Text [ en-US ] = "This operation cannot be run on\nfiles containing wildcards." ;
+ };
+ String ERRCODE_IO_NOTSUPPORTED
+ {
+ Text [ en-US ] = "This operation is not supported on this operating system." ;
+ };
+ String ERRCODE_IO_TOOMANYOPENFILES
+ {
+ Text [ en-US ] = "There are too many files open." ;
+ };
+ String ERRCODE_IO_CANTREAD
+ {
+ Text [ en-US ] = "Data could not be read from the file." ;
+ };
+ String ERRCODE_IO_CANTWRITE
+ {
+ Text [ en-US ] = "The file could not be written." ;
+ };
+ String ERRCODE_IO_OUTOFMEMORY
+ {
+ Text [ en-US ] = "The operation could not be run due to insufficient memory." ;
+ };
+ String ERRCODE_IO_CANTSEEK
+ {
+ Text [ en-US ] = "The seek operation could not be run." ;
+ };
+ String ERRCODE_IO_CANTTELL
+ {
+ Text [ en-US ] = "The tell operation could not be run." ;
+ };
+ String ERRCODE_IO_WRONGVERSION
+ {
+ Text [ en-US ] = "Incorrect file version." ;
+ };
+ String ERRCODE_IO_WRONGFORMAT
+ {
+ Text [ en-US ] = "Incorrect file format." ;
+ };
+ String ERRCODE_IO_INVALIDCHAR
+ {
+ Text [ en-US ] = "The file name contains invalid characters." ;
+ };
+ String ERRCODE_IO_UNKNOWN
+ {
+ Text [ en-US ] = "An unknown I/O error has occurred." ;
+ };
+ String ERRCODE_IO_INVALIDACCESS
+ {
+ Text [ en-US ] = "An invalid attempt was made to access the file." ;
+ };
+ String ERRCODE_IO_CANTCREATE
+ {
+ Text [ en-US ] = "The file could not be created." ;
+ };
+ String ERRCODE_IO_INVALIDPARAMETER
+ {
+ Text [ en-US ] = "The operation was started under an invalid parameter." ;
+ };
+ String ERRCODE_IO_ABORT
+ {
+ Text [ en-US ] = "The operation on the file was aborted." ;
+ };
+ String ERRCODE_IO_NOTEXISTSPATH
+ {
+ Text [ en-US ] = "Path to the file does not exist." ;
+ };
+ String ERRCODE_IO_RECURSIVE
+ {
+ Text [ en-US ] = "An object cannot be copied into itself." ;
+ };
+ String ERRCODE_SFX_NOSTDTEMPLATE
+ {
+ Text [ en-US ] = "The default template could not be opened." ;
+ };
+ String ERRCODE_SFX_TEMPLATENOTFOUND
+ {
+ Text [ en-US ] = "The specified template could not be found." ;
+ };
+ String ERRCODE_SFX_NOTATEMPLATE
+ {
+ Text [ en-US ] = "The file cannot be used as template." ;
+ };
+ String ERRCODE_SFX_CANTREADDOCINFO
+ {
+ Text [ en-US ] = "Document information could not be read from the file because\nthe document information format is unknown or because document information does not\nexist." ;
+ };
+ String ERRCODE_SFX_ALREADYOPEN
+ {
+ Text [ en-US ] = "This document has already been opened for editing." ;
+ };
+ String ERRCODE_SFX_WRONGPASSWORD
+ {
+ Text [ en-US ] = "The wrong password has been entered." ;
+ };
+ String ERRCODE_SFX_DOLOADFAILED
+ {
+ Text [ en-US ] = "Error reading file." ;
+ };
+ String ERRCODE_SFX_DOCUMENTREADONLY
+ {
+ Text [ en-US ] = "The document was opened as read-only." ;
+ };
+ String ERRCODE_SFX_OLEGENERAL
+ {
+ Text [ en-US ] = "General OLE Error." ;
+ };
+ String ERRCODE_INET_NAME_RESOLVE
+ {
+ Text [ en-US ] = "The host name $(ARG1) could not be resolved." ;
+ };
+ String ERRCODE_INET_CONNECT
+ {
+ Text [ en-US ] = "Could not establish network connection to $(ARG1)." ;
+ };
+ String ERRCODE_INET_READ
+ {
+ Text [ en-US ] = "Error reading data from the network.\nServer error message: $(ARG1)." ;
+ };
+ String ERRCODE_INET_WRITE
+ {
+ Text [ en-US ] = "Error transferring data to the network.\nServer error message: $(ARG1)." ;
+ };
+ String ERRCODE_INET_GENERAL
+ {
+ Text [ en-US ] = "General network error has occurred." ;
+ };
+ String ERRCODE_INET_OFFLINE
+ {
+ Text [ en-US ] = "The requested network data is not available in the cache and cannot be transmitted as the Online mode has not be activated." ;
+ };
+ String ERRCODE_SFXMSG_STYLEREPLACE
+ {
+ ExtraData = ERRCODE_MSG_ERROR | ERRCODE_BUTTON_OK_CANCEL ;
+ Text [ en-US ] = "Should the $(ARG1) Style be replaced?" ;
+ };
+ String ERRCODE_SFX_NOFILTER
+ {
+ Text [ en-US ] = "A filter has not been found." ;
+ };
+ String ERRCODE_SFX_CANTFINDORIGINAL
+ {
+ Text [ en-US ] = "The original could not be determined." ;
+ };
+ String ERRCODE_SFX_CANTCREATECONTENT
+ {
+ Text [ en-US ] = "The contents could not be created." ;
+ };
+ String ERRCODE_SFX_CANTCREATELINK
+ {
+ Text [ en-US ] = "The link could not be created." ;
+ };
+ String ERRCODE_SFX_WRONGBMKFORMAT
+ {
+ Text [ en-US ] = "The link format is invalid." ;
+ };
+ String ERRCODE_SFX_WRONGICONFILE
+ {
+ Text [ en-US ] = "The configuration of the icon display is invalid." ;
+ };
+ String ERRCODE_SFX_CANTWRITEICONFILE
+ {
+ Text [ en-US ] = "The configuration of the icon display can not be saved." ;
+ };
+ String ERRCODE_SFX_CANTDELICONFILE
+ {
+ Text [ en-US ] = "The configuration of the icon display could not be deleted." ;
+ };
+ String ERRCODE_SFX_CANTRENAMECONTENT
+ {
+ Text [ en-US ] = "Contents cannot be renamed." ;
+ };
+ String ERRCODE_SFX_INVALIDBMKPATH
+ {
+ Text [ en-US ] = "The bookmark folder is invalid." ;
+ };
+ String ERRCODE_SFX_CANTWRITEURLCFGFILE
+ {
+ Text [ en-US ] = "The configuration of the URLs to be saved locally could not be saved." ;
+ };
+ String ERRCODE_SFX_WRONGURLCFGFORMAT
+ {
+ Text [ en-US ] = "The configuration format of the URLs to be saved locally is invalid." ;
+ };
+ String ERRCODE_SFX_NODOCUMENT
+ {
+ Text [ en-US ] = "This action cannot be applied to a document that does not exist." ;
+ };
+ String ERRCODE_SFX_INVALIDLINK
+ {
+ Text [ en-US ] = "The link refers to an invalid target." ;
+ };
+ String ERRCODE_SFX_INVALIDTRASHPATH
+ {
+ Text [ en-US ] = "The Recycle Bin path is invalid." ;
+ };
+ String ERRCODE_SFX_NOTRESTORABLE
+ {
+ Text [ en-US ] = "The entry could not be restored." ;
+ };
+ String ERRCODE_IO_NAMETOOLONG
+ {
+ Text [ en-US ] = "The file name is too long for the target file system." ;
+ };
+ String ERRCODE_SFX_CONSULTUSER
+ {
+ Text [ en-US ] = "The details for running the function are incomplete." ;
+ };
+ String ERRCODE_SFX_INVALIDSYNTAX
+ {
+ Text [ en-US ] = "The input syntax is invalid." ;
+ };
+ String ERRCODE_SFX_CANTCREATEFOLDER
+ {
+ Text [ en-US ] = "The input syntax is invalid." ;
+ };
+ String ERRCODE_SFX_CANTRENAMEFOLDER
+ {
+ Text [ en-US ] = "The input syntax is invalid." ;
+ };
+ String ERRCODE_SFX_WRONG_CDF_FORMAT
+ {
+ Text [ en-US ] = "The channel document has an invalid format." ;
+ };
+ String ERRCODE_SFX_EMPTY_SERVER
+ {
+ Text [ en-US ] = "The server must not be empty." ;
+ };
+ String ERRCODE_SFX_NO_ABOBOX
+ {
+ Text [ en-US ] = "A subscription folder is required to install a Channel." ;
+ };
+ String ERRCODE_IO_NOTSTORABLEINBINARYFORMAT
+ {
+ Text [ en-US ] = "This document contains attributes that cannot be saved in the selected format.\nPlease save the document in a %PRODUCTNAME %PRODUCTVERSION file format.";
+ };
+ String ERRCODE_SFX_TARGETFILECORRUPTED
+ {
+ Text [ en-US ] = "The file $(FILENAME) cannot be saved. Please check your system settings. You can find an automatically generated backup copy of this file in folder $(PATH) named $(BACKUPNAME).";
+ };
+ String ERRCODE_SFX_NOMOREDOCUMENTSALLOWED
+ {
+ Text [ en-US ] = "The maximum number of documents that can be opened at the same time has been reached. You need to close one or more documents before you can open a new document.";
+ };
+ String ERRCODE_SFX_CANTCREATEBACKUP
+ {
+ Text [ en-US ] = "Could not create backup copy." ;
+ };
+ String ERRCODE_SFX_MACROS_SUPPORT_DISABLED
+ {
+ Text [ en-US ] = "An attempt was made to execute a macro.\nFor security reasons, macro support is disabled.";
+ };
+ String ERRCODE_SFX_DOCUMENT_MACRO_DISABLED
+ {
+ Text [ en-US ] = "This document contains macros.\n\nMacros may contain viruses. Execution of macros is disabled due to the current macro security setting in Tools - Options - %PRODUCTNAME - Security.\n\nTherefore, some functionality may not be available." ;
+ };
+ String ERRCODE_SFX_BROKENSIGNATURE
+ {
+ Text [ en-US ] = "The digitally signed document content and/or macros do not match the current document signature.\n\nThis could be the result of document manipulation or of structural document damage due to data transmission.\n\nWe recommend that you do not trust the content of the current document.\nExecution of macros is disabled for this document.\n " ;
+ };
+ String ERRCODE_SFX_INCOMPLETE_ENCRYPTION
+ {
+ Text [ en-US ] = "The encrypted document contains unexpected non-encrypted streams.\n\nThis could be the result of document manipulation.\n\nWe recommend that you do not trust the content of the current document.\nExecution of macros is disabled for this document.\n " ;
+ };
+
+ String ERRCODE_IO_INVALIDLENGTH
+ {
+ Text [ en-US ] = "Invalid data length." ;
+ };
+ String ERRCODE_IO_CURRENTDIR
+ {
+ Text [ en-US ] = "Function not possible: path contains current directory." ;
+ };
+ String ERRCODE_IO_NOTSAMEDEVICE
+ {
+ Text [ en-US ] = "Function not possible: device (drive) not identical." ;
+ };
+ String ERRCODE_IO_DEVICENOTREADY
+ {
+ Text [ en-US ] = "Device (drive) not ready." ;
+ };
+ String ERRCODE_IO_BADCRC
+ {
+ Text [ en-US ] = "Wrong check amount." ;
+ };
+ String ERRCODE_IO_WRITEPROTECTED
+ {
+ Text [ en-US ] = "Function not possible: write protected." ;
+ };
+ String ERRCODE_SFX_SHARED_NOPASSWORDCHANGE
+ {
+ Text [ en-US ] = "The password of a shared spreadsheet cannot be set or changed.\nDeactivate sharing mode first.";
+ };
+};
+
+// eof ------------------------------------------------------------------------
+
diff --git a/svtools/source/misc/helpagent.src b/svtools/source/misc/helpagent.src
new file mode 100644
index 000000000000..1f2eaaa291a3
--- /dev/null
+++ b/svtools/source/misc/helpagent.src
@@ -0,0 +1,41 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SVTOOLS_HRC
+#include <svtools/svtools.hrc>
+#endif
+
+Bitmap BMP_HELP_AGENT_IMAGE
+{
+ File = "helpagent.bmp";
+};
+
+Bitmap BMP_HELP_AGENT_CLOSER
+{
+ File = "closer.bmp";
+};
+
diff --git a/svtools/source/misc/helpagentwindow.cxx b/svtools/source/misc/helpagentwindow.cxx
new file mode 100644
index 000000000000..1d407bbdb611
--- /dev/null
+++ b/svtools/source/misc/helpagentwindow.cxx
@@ -0,0 +1,192 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include "helpagentwindow.hxx"
+#include <osl/diagnose.h>
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#include <vcl/bitmap.hxx>
+#include <svtools/svtdata.hxx>
+
+#ifndef _SVTOOLS_HRC
+#include <svtools/svtools.hrc>
+#endif
+#ifndef _SVT_HELPID_HRC
+#include <svtools/helpid.hrc>
+#endif
+
+#define WB_AGENT_STYLE 0
+
+//........................................................................
+namespace svt
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+
+ //====================================================================
+ //= CloserButton_Impl
+ //= overload of ImageButton, because sometimes vcl doesn't call the click handler
+ //====================================================================
+ //--------------------------------------------------------------------
+ class CloserButton_Impl : public ImageButton
+ {
+ public:
+ CloserButton_Impl( Window* pParent, WinBits nBits ) : ImageButton( pParent, nBits ) {}
+
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ };
+
+ //--------------------------------------------------------------------
+ void CloserButton_Impl::MouseButtonUp( const MouseEvent& rMEvt )
+ {
+ ImageButton::MouseButtonUp( rMEvt );
+ GetClickHdl().Call( this );
+ }
+
+ //====================================================================
+ //= HelpAgentWindow
+ //====================================================================
+ //--------------------------------------------------------------------
+ HelpAgentWindow::HelpAgentWindow( Window* _pParent )
+ :FloatingWindow( _pParent, WB_AGENT_STYLE)
+ ,m_pCloser(NULL)
+ ,m_pCallback(NULL)
+ {
+ // -----------------
+ // the closer button
+ Bitmap aCloserBitmap(SvtResId(BMP_HELP_AGENT_CLOSER));
+ Image aCloserImage( aCloserBitmap, Color(COL_LIGHTMAGENTA) );
+ m_pCloser = new CloserButton_Impl( this, WB_NOTABSTOP | WB_NOPOINTERFOCUS );
+ static_cast<CloserButton_Impl*>(m_pCloser)->SetModeImage( aCloserImage );
+ static_cast<CloserButton_Impl*>(m_pCloser)->SetClickHdl( LINK(this, HelpAgentWindow, OnButtonClicked) );
+ m_pCloser->SetSizePixel( implOptimalButtonSize(aCloserImage) );
+ m_pCloser->Show();
+ m_pCloser->SetZOrder( NULL, WINDOW_ZORDER_LAST );
+
+ // ----------------------------
+ // calculate our preferred size
+ Bitmap aHelpAgentBitmap(SvtResId(BMP_HELP_AGENT_IMAGE));
+ m_aPicture = Image( aHelpAgentBitmap );
+ m_aPreferredSize = m_aPicture.GetSizePixel();
+ m_aPreferredSize.Width() += 2;
+ m_aPreferredSize.Height() += 2;
+
+ Size aSize = GetSizePixel();
+ Size aOutputSize = GetOutputSizePixel();
+ m_aPreferredSize.Width() += aSize.Width() - aOutputSize.Width();
+ m_aPreferredSize.Height() += aSize.Height() - aOutputSize.Height();
+
+ SetPointer(Pointer(POINTER_REFHAND));
+ AlwaysEnableInput( TRUE, TRUE );
+
+ // unique id for the testtool
+ SetUniqueId( HID_HELPAGENT_WINDOW );
+ }
+
+ //--------------------------------------------------------------------
+ HelpAgentWindow::~HelpAgentWindow()
+ {
+ if (m_pCloser && m_pCloser->IsTracking())
+ m_pCloser->EndTracking();
+ if (m_pCloser && m_pCloser->IsMouseCaptured())
+ m_pCloser->ReleaseMouse();
+
+ delete m_pCloser;
+ }
+
+ //--------------------------------------------------------------------
+ void HelpAgentWindow::Paint( const Rectangle& rRect )
+ {
+ FloatingWindow::Paint(rRect);
+
+ Size aOutputSize( GetOutputSizePixel() );
+ Point aPoint=Point();
+ Rectangle aOutputRect( aPoint, aOutputSize );
+ Rectangle aInnerRect( aOutputRect );
+
+ // paint the background
+ SetLineColor( GetSettings().GetStyleSettings().GetFaceColor() );
+ SetFillColor( GetSettings().GetStyleSettings().GetFaceColor() );
+ DrawRect( aOutputRect );
+
+ // paint the image
+ Size aPictureSize( m_aPicture.GetSizePixel() );
+ Point aPicturePos(
+ aOutputRect.Left() + (aInnerRect.GetWidth() - aPictureSize.Width()) / 2,
+ aOutputRect.Top() + (aInnerRect.GetHeight() - aPictureSize.Height()) / 2 );
+
+ DrawImage( aPicturePos, m_aPicture, 0 );
+ }
+
+ //--------------------------------------------------------------------
+ void HelpAgentWindow::MouseButtonUp( const MouseEvent& rMEvt )
+ {
+ FloatingWindow::MouseButtonUp(rMEvt);
+
+ if (m_pCallback)
+ m_pCallback->helpRequested();
+ }
+
+ //--------------------------------------------------------------------
+ Size HelpAgentWindow::implOptimalButtonSize( const Image& _rButtonImage )
+ {
+ Size aPreferredSize = _rButtonImage.GetSizePixel();
+ // add a small frame, needed by the button
+ aPreferredSize.Width() += 5;
+ aPreferredSize.Height() += 5;
+ return aPreferredSize;
+ }
+
+ //--------------------------------------------------------------------
+ void HelpAgentWindow::Resize()
+ {
+ FloatingWindow::Resize();
+
+ Size aOutputSize = GetOutputSizePixel();
+ Size aCloserSize = m_pCloser->GetSizePixel();
+ if (m_pCloser)
+ m_pCloser->SetPosPixel( Point(aOutputSize.Width() - aCloserSize.Width() - 3, 4) );
+ }
+
+ //--------------------------------------------------------------------
+ IMPL_LINK( HelpAgentWindow, OnButtonClicked, Window*, _pWhichOne )
+ {
+ if (m_pCloser == _pWhichOne)
+ if (m_pCallback)
+ m_pCallback->closeAgent();
+ return 0L;
+ }
+
+//........................................................................
+} // namespace svt
+//........................................................................
+
diff --git a/svtools/source/misc/imagemgr.cxx b/svtools/source/misc/imagemgr.cxx
new file mode 100644
index 000000000000..c02ebc4477c6
--- /dev/null
+++ b/svtools/source/misc/imagemgr.cxx
@@ -0,0 +1,881 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+// includes --------------------------------------------------------------
+
+#include "imagemgr.hxx"
+#include <tools/urlobj.hxx>
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+#include "vcl/image.hxx"
+#include <sot/storage.hxx>
+#include <sot/clsids.hxx>
+#include <unotools/ucbhelper.hxx>
+#ifndef _UNOTOOLS_PROCESSFACTORY_HXX
+#include <comphelper/processfactory.hxx>
+#endif
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/document/XTypeDetection.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+#include <ucbhelper/content.hxx>
+#include <tools/rcid.h>
+#include <rtl/logfile.hxx>
+#include <unotools/configmgr.hxx>
+
+#include <svtools/svtools.hrc>
+#include "imagemgr.hrc"
+#include <svtools/svtdata.hxx>
+#include <vos/mutex.hxx>
+
+// globals *******************************************************************
+
+#define NO_INDEX ((USHORT)0xFFFF)
+#define CONTENT_HELPER ::utl::UCBContentHelper
+#define ASCII_STRING(s) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(s) )
+
+struct SvtExtensionResIdMapping_Impl
+{
+ const char* _pExt;
+ BOOL _bExt;
+ USHORT _nStrId;
+ USHORT _nImgId;
+};
+
+static SvtExtensionResIdMapping_Impl __READONLY_DATA ExtensionMap_Impl[] =
+{
+ { "awk", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 },
+ { "bas", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 },
+ { "bat", TRUE, STR_DESCRIPTION_BATCHFILE, 0 },
+ { "bmk", FALSE, STR_DESCRIPTION_BOOKMARKFILE, 0 },
+ { "bmp", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_BITMAP },
+ { "c", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 },
+ { "cfg", FALSE, STR_DESCRIPTION_CFGFILE, 0 },
+ { "cmd", TRUE, STR_DESCRIPTION_BATCHFILE, 0 },
+ { "cob", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 },
+ { "com", TRUE, STR_DESCRIPTION_APPLICATION, 0 },
+ { "cxx", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 },
+ { "dbf", TRUE, STR_DESCRIPTION_DATABASE_TABLE, IMG_TABLE },
+ { "def", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 },
+ { "dll", TRUE, STR_DESCRIPTION_SYSFILE, 0 },
+ { "doc", FALSE, STR_DESCRIPTION_WORD_DOC, IMG_WRITER },
+ { "dot", FALSE, STR_DESCRIPTION_WORD_DOC, IMG_WRITERTEMPLATE },
+ { "docx", FALSE, STR_DESCRIPTION_WORD_DOC, IMG_WRITER },
+ { "dxf", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_DXF },
+ { "exe", TRUE, STR_DESCRIPTION_APPLICATION, 0 },
+ { "gif", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_GIF },
+ { "h", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 },
+ { "hlp", FALSE, STR_DESCRIPTION_HELP_DOC, 0 },
+ { "hrc", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 },
+ { "htm", FALSE, STR_DESCRIPTION_HTMLFILE, IMG_HTML },
+ { "html", FALSE, STR_DESCRIPTION_HTMLFILE, IMG_HTML },
+ { "asp", FALSE, STR_DESCRIPTION_HTMLFILE, IMG_HTML },
+ { "hxx", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 },
+ { "ini", FALSE, STR_DESCRIPTION_CFGFILE, 0 },
+ { "java", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 },
+ { "jpeg", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_JPG },
+ { "jpg", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_JPG },
+ { "lha", TRUE, STR_DESCRIPTION_ARCHIVFILE, 0 },
+#ifdef WNT
+ { "lnk", FALSE, 0, 0 },
+#endif
+ { "log", TRUE, STR_DESCRIPTION_LOGFILE, 0 },
+ { "lst", TRUE, STR_DESCRIPTION_LOGFILE, 0 },
+ { "met", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_MET },
+ { "mml", FALSE, STR_DESCRIPTION_MATHML_DOC, IMG_MATH },
+ { "mod", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 },
+ { "odb", FALSE, STR_DESCRIPTION_OO_DATABASE_DOC, IMG_OO_DATABASE_DOC },
+ { "odg", FALSE, STR_DESCRIPTION_OO_DRAW_DOC, IMG_OO_DRAW_DOC },
+ { "odf", FALSE, STR_DESCRIPTION_OO_MATH_DOC, IMG_OO_MATH_DOC },
+ { "odm", FALSE, STR_DESCRIPTION_OO_GLOBAL_DOC, IMG_OO_GLOBAL_DOC },
+ { "odp", FALSE, STR_DESCRIPTION_OO_IMPRESS_DOC, IMG_OO_IMPRESS_DOC },
+ { "ods", FALSE, STR_DESCRIPTION_OO_CALC_DOC, IMG_OO_CALC_DOC },
+ { "odt", FALSE, STR_DESCRIPTION_OO_WRITER_DOC, IMG_OO_WRITER_DOC },
+ { "otg", FALSE, STR_DESCRIPTION_OO_DRAW_TEMPLATE, IMG_OO_DRAW_TEMPLATE },
+ { "otp", FALSE, STR_DESCRIPTION_OO_IMPRESS_TEMPLATE, IMG_OO_IMPRESS_TEMPLATE },
+ { "ots", FALSE, STR_DESCRIPTION_OO_CALC_TEMPLATE, IMG_OO_CALC_TEMPLATE },
+ { "ott", FALSE, STR_DESCRIPTION_OO_WRITER_TEMPLATE, IMG_OO_WRITER_TEMPLATE },
+ { "pas", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 },
+ { "pcd", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCD },
+ { "pct", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCT },
+ { "pcx", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCX },
+ { "pl", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 },
+ { "png", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_PNG },
+ { "rar", TRUE, STR_DESCRIPTION_ARCHIVFILE, 0 },
+ { "rtf", FALSE, STR_DESCRIPTION_WORD_DOC, IMG_WRITER },
+ { "sbl", FALSE, 0, 0 },
+ { "sch", FALSE, 0, 0 },
+ { "sda", FALSE, STR_DESCRIPTION_SDRAW_DOC, IMG_DRAW },
+ { "sdb", FALSE, STR_DESCRIPTION_SDATABASE_DOC, IMG_DATABASE },
+ { "sdc", FALSE, STR_DESCRIPTION_SCALC_DOC, IMG_CALC },
+ { "sdd", FALSE, STR_DESCRIPTION_SIMPRESS_DOC, IMG_IMPRESS },
+ { "sdp", FALSE, STR_DESCRIPTION_SIMPRESS_DOC, 0 },
+ { "sds", FALSE, STR_DESCRIPTION_SCHART_DOC, 0 },
+ { "sdw", FALSE, STR_DESCRIPTION_SWRITER_DOC, IMG_WRITER },
+ { "sga", FALSE, 0, 0 },
+ { "sgf", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_SGF },
+ { "sgl", FALSE, STR_DESCRIPTION_GLOBALDOC, IMG_GLOBAL_DOC },
+ { "sgv", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_SGV },
+ { "shtml", FALSE, STR_DESCRIPTION_HTMLFILE, IMG_HTML },
+ { "sim", FALSE, STR_DESCRIPTION_SIMAGE_DOC, IMG_SIM },
+ { "smf", FALSE, STR_DESCRIPTION_SMATH_DOC, IMG_MATH },
+ { "src", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 },
+ { "svh", FALSE, STR_DESCRIPTION_HELP_DOC, 0 },
+ { "svm", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_SVM },
+ { "stc", FALSE, STR_DESCRIPTION_CALC_TEMPLATE, IMG_CALCTEMPLATE },
+ { "std", FALSE, STR_DESCRIPTION_DRAW_TEMPLATE, IMG_DRAWTEMPLATE },
+ { "sti", FALSE, STR_DESCRIPTION_IMPRESS_TEMPLATE, IMG_IMPRESSTEMPLATE },
+ { "stw", FALSE, STR_DESCRIPTION_WRITER_TEMPLATE, IMG_WRITERTEMPLATE },
+ { "sxc", FALSE, STR_DESCRIPTION_SXCALC_DOC, IMG_CALC },
+ { "sxd", FALSE, STR_DESCRIPTION_SXDRAW_DOC, IMG_DRAW },
+ { "sxg", FALSE, STR_DESCRIPTION_SXGLOBAL_DOC, IMG_GLOBAL_DOC },
+ { "sxi", FALSE, STR_DESCRIPTION_SXIMPRESS_DOC, IMG_IMPRESS },
+ { "sxm", FALSE, STR_DESCRIPTION_SXMATH_DOC, IMG_MATH },
+ { "sxs", FALSE, STR_DESCRIPTION_SXCHART_DOC, 0 },
+ { "sxw", FALSE, STR_DESCRIPTION_SXWRITER_DOC, IMG_WRITER },
+ { "sys", TRUE, STR_DESCRIPTION_SYSFILE, 0 },
+ { "tif", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_TIFF },
+ { "tiff", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_TIFF },
+ { "txt", FALSE, STR_DESCRIPTION_TEXTFILE, IMG_TEXTFILE },
+ { "url", FALSE, STR_DESCRIPTION_LINK, 0 },
+ { "vor", FALSE, STR_DESCRIPTION_SOFFICE_TEMPLATE_DOC, IMG_WRITERTEMPLATE },
+ { "vxd", TRUE, STR_DESCRIPTION_SYSFILE, 0 },
+ { "wmf", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_WMF },
+ { "xls", FALSE, STR_DESCRIPTION_EXCEL_DOC, IMG_CALC },
+ { "xlt", FALSE, STR_DESCRIPTION_EXCEL_TEMPLATE_DOC, IMG_CALCTEMPLATE },
+ { "xlsx", FALSE, STR_DESCRIPTION_EXCEL_DOC, IMG_CALC },
+ { "uu", TRUE, STR_DESCRIPTION_ARCHIVFILE, 0 },
+ { "uue", TRUE, STR_DESCRIPTION_ARCHIVFILE, 0 },
+ { "z", TRUE, STR_DESCRIPTION_ARCHIVFILE, 0 },
+ { "zip", TRUE, STR_DESCRIPTION_ARCHIVFILE, 0 },
+ { "zoo", TRUE, STR_DESCRIPTION_ARCHIVFILE, 0 },
+ { "gz", TRUE, STR_DESCRIPTION_ARCHIVFILE, 0 },
+ { "ppt", FALSE, STR_DESCRIPTION_POWERPOINT, IMG_IMPRESS },
+ { "pot", FALSE, STR_DESCRIPTION_POWERPOINT_TEMPLATE, IMG_IMPRESSTEMPLATE },
+ { "pps", FALSE, STR_DESCRIPTION_POWERPOINT_SHOW, IMG_IMPRESS },
+ { "pptx", FALSE, STR_DESCRIPTION_POWERPOINT, IMG_IMPRESS },
+ { "oxt", FALSE, STR_DESCRIPTION_EXTENSION, IMG_EXTENSION },
+ { 0, FALSE, 0, 0 }
+};
+
+#ifdef OS2
+ SvtExtensionResIdMapping_Impl Mappings[] =
+ {
+ {"StarWriter 4.0", FALSE,STR_DESCRIPTION_SWRITER_DOC, IMG_WRITER},
+ {"StarWriter 3.0", FALSE,STR_DESCRIPTION_SWRITER_DOC, IMG_WRITER},
+ {"StarCalc 4.0", FALSE,STR_DESCRIPTION_SCALC_DOC, IMG_CALC},
+ {"StarCalc 3.0", FALSE,STR_DESCRIPTION_SCALC_DOC, IMG_CALC},
+ {"StarImpress 4.0", FALSE,STR_DESCRIPTION_SIMPRESS_DOC,IMG_IMPRESS},
+ {"StarDraw 4.0", FALSE,STR_DESCRIPTION_SDRAW_DOC, IMG_DRAW},
+ {"StarDraw 3.0", FALSE,STR_DESCRIPTION_SDRAW_DOC, IMG_DRAW},
+ {"StarChart 3.0", FALSE,STR_DESCRIPTION_SCHART_DOC, IMG_CHART},
+ {"StarChart 4.0", FALSE,STR_DESCRIPTION_SCHART_DOC, IMG_CHART},
+ {"Bitmap", FALSE,STR_DESCRIPTION_GRAPHIC_DOC, IMG_BITMAP},
+ {"AutoCAD", FALSE,STR_DESCRIPTION_GRAPHIC_DOC, IMG_SIM},
+ {"Gif-File", FALSE,STR_DESCRIPTION_GRAPHIC_DOC, IMG_GIF},
+ {"JPEG-File", FALSE,STR_DESCRIPTION_GRAPHIC_DOC, IMG_JPG},
+ {"Metafile ", FALSE,STR_DESCRIPTION_GRAPHIC_DOC, IMG_SIM},
+ {"Photo-CD ", FALSE,STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCD},
+ {"Mac Pict", FALSE,STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCT},
+ {"PCX-File ", FALSE,STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCX},
+ {"PNG-File", FALSE,STR_DESCRIPTION_GRAPHIC_DOC, IMG_SIM},
+ {"SV-Metafile", FALSE,STR_DESCRIPTION_GRAPHIC_DOC, IMG_SIM},
+ {"TIFF-File", FALSE,STR_DESCRIPTION_GRAPHIC_DOC, IMG_TIFF},
+ {"MS-Metafile", FALSE,STR_DESCRIPTION_GRAPHIC_DOC, IMG_WMF},
+ {"XBM-File", FALSE,STR_DESCRIPTION_GRAPHIC_DOC, IMG_BITMAP},
+ {"UniformResourceLocator", FALSE,STR_DESCRIPTION_LINK, IMG_URL},
+ {NULL, 0}
+ };
+#endif
+
+struct SvtFactory2ExtensionMapping_Impl
+{
+ const char* _pFactory;
+ const char* _pExtension;
+};
+
+// mapping from "private:factory" url to extension
+
+static SvtFactory2ExtensionMapping_Impl __READONLY_DATA Fac2ExtMap_Impl[] =
+{
+ { "swriter", "odt" },
+ { "swriter/web", "html" },
+ { "swriter/GlobalDocument", "odm" },
+ { "scalc", "ods" },
+ { "simpress", "odp" },
+ { "sdraw", "odg" },
+ { "smath", "odf" },
+ { "sdatabase", "odb" },
+ { NULL, NULL }
+};
+
+//****************************************************************************
+
+static String GetImageExtensionByFactory_Impl( const String& rURL )
+{
+ INetURLObject aObj( rURL );
+ String aPath = aObj.GetURLPath( INetURLObject::NO_DECODE );
+ String aExtension;
+
+ if ( aPath.Len() )
+ {
+ USHORT nIndex = 0;
+ while ( Fac2ExtMap_Impl[ nIndex ]._pFactory )
+ {
+ if ( aPath.EqualsAscii( Fac2ExtMap_Impl[ nIndex ]._pFactory ) )
+ {
+ // extension found
+ aExtension = String::CreateFromAscii( Fac2ExtMap_Impl[ nIndex ]._pExtension );
+ // and return it
+ return aExtension;
+ }
+ ++nIndex;
+ }
+ }
+
+ // no extension found, so use the type detection (performance brake)
+
+ try
+ {
+ // get the TypeDetection service to access all registered types
+ ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > xFac = ::comphelper::getProcessServiceFactory();
+ ::com::sun::star::uno::Reference < ::com::sun::star::document::XTypeDetection > xTypeDetector(
+ xFac->createInstance( ASCII_STRING("com.sun.star.document.TypeDetection") ), ::com::sun::star::uno::UNO_QUERY );
+
+ ::rtl::OUString aInternalType = xTypeDetector->queryTypeByURL( rURL );
+ ::com::sun::star::uno::Reference < ::com::sun::star::container::XNameAccess > xAccess( xTypeDetector, ::com::sun::star::uno::UNO_QUERY );
+ ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue > aTypeProps;
+ if ( aInternalType.getLength() > 0 && xAccess->hasByName( aInternalType ) )
+ {
+ xAccess->getByName( aInternalType ) >>= aTypeProps;
+ sal_Int32 nProps = aTypeProps.getLength();
+ for ( sal_Int32 i = 0; i < nProps; ++i )
+ {
+ const ::com::sun::star::beans::PropertyValue& rProp = aTypeProps[i];
+ if ( rProp.Name.compareToAscii("Extensions") == COMPARE_EQUAL )
+ {
+ ::com::sun::star::uno::Sequence < ::rtl::OUString > aExtensions;
+ if ( ( rProp.Value >>= aExtensions ) && aExtensions.getLength() > 0 )
+ {
+ const ::rtl::OUString* pExtensions = aExtensions.getConstArray();
+ aExtension = String( pExtensions[0] );
+ break;
+ }
+ }
+ }
+ }
+ }
+ catch( const ::com::sun::star::uno::RuntimeException& )
+ {
+ throw; // dont hide it!
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ // type detection failed -> no extension
+ }
+
+ return aExtension;
+}
+
+static USHORT GetIndexOfExtension_Impl( const String& rExtension )
+{
+ USHORT nRet = NO_INDEX;
+ if ( rExtension.Len() )
+ {
+ USHORT nIndex = 0;
+ String aExt = rExtension;
+ aExt.ToLowerAscii();
+ while ( ExtensionMap_Impl[ nIndex ]._pExt )
+ {
+ if ( aExt.EqualsAscii( ExtensionMap_Impl[ nIndex ]._pExt ) )
+ {
+ nRet = nIndex;
+ break;
+ }
+ ++nIndex;
+ }
+ }
+
+ return nRet;
+}
+
+static USHORT GetImageId_Impl( const String& rExtension )
+{
+ USHORT nImage = IMG_FILE;
+ if ( rExtension.Len() != NO_INDEX )
+ {
+ USHORT nIndex = GetIndexOfExtension_Impl( rExtension );
+ if ( nIndex != NO_INDEX )
+ {
+ nImage = ExtensionMap_Impl[ nIndex ]._nImgId;
+ if ( !nImage )
+ nImage = IMG_FILE;
+ }
+ }
+
+ return nImage;
+}
+
+static sal_Bool GetVolumeProperties_Impl( ::ucbhelper::Content& rContent, svtools::VolumeInfo& rVolumeInfo )
+{
+ sal_Bool bRet = sal_False;
+
+ try
+ {
+ bRet = ( ( rContent.getPropertyValue( ASCII_STRING("IsVolume") ) >>= rVolumeInfo.m_bIsVolume ) &&
+ ( rContent.getPropertyValue( ASCII_STRING("IsRemote") ) >>= rVolumeInfo.m_bIsRemote ) &&
+ ( rContent.getPropertyValue( ASCII_STRING("IsRemoveable") ) >>= rVolumeInfo.m_bIsRemoveable ) &&
+ ( rContent.getPropertyValue( ASCII_STRING("IsFloppy") ) >>= rVolumeInfo.m_bIsFloppy ) &&
+ ( rContent.getPropertyValue( ASCII_STRING("IsCompactDisc") ) >>= rVolumeInfo.m_bIsCompactDisc ) );
+ }
+ catch( const ::com::sun::star::uno::RuntimeException& )
+ {
+ throw; // dont hide it!
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ // type detection failed -> no extension
+ }
+
+ return bRet;
+}
+
+static USHORT GetFolderImageId_Impl( const String& rURL )
+{
+ USHORT nRet = IMG_FOLDER;
+ ::svtools::VolumeInfo aVolumeInfo;
+ try
+ {
+ ::ucbhelper::Content aCnt( rURL, ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
+ if ( GetVolumeProperties_Impl( aCnt, aVolumeInfo ) )
+ {
+ if ( aVolumeInfo.m_bIsRemote )
+ nRet = IMG_NETWORKDEV;
+ else if ( aVolumeInfo.m_bIsCompactDisc )
+ nRet = IMG_CDROMDEV;
+ else if ( aVolumeInfo.m_bIsRemoveable )
+ nRet = IMG_REMOVEABLEDEV;
+ else if ( aVolumeInfo.m_bIsVolume )
+ nRet = IMG_FIXEDDEV;
+ }
+ }
+ catch( const ::com::sun::star::uno::RuntimeException& )
+ {
+ throw; // dont hide it!
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ // ...
+ }
+ return nRet;
+}
+
+static USHORT GetImageId_Impl( const INetURLObject& rObject, sal_Bool bDetectFolder )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aTimeLog, "svtools", "hb93813", "SvFileInformationManager::GetImageId_Impl()" );
+
+ String aExt, sURL = rObject.GetMainURL( INetURLObject::NO_DECODE );
+ USHORT nImage = IMG_FILE;
+
+ if ( rObject.GetProtocol() == INET_PROT_PRIVATE )
+ {
+ String aURLPath = sURL.Copy( URL_PREFIX_PRIV_SOFFICE_LEN );
+ String aType = aURLPath.GetToken( 0, INET_PATH_TOKEN );
+ if ( aType == String( RTL_CONSTASCII_STRINGPARAM("factory") ) )
+ {
+ // detect an image id for our "private:factory" urls
+ aExt = GetImageExtensionByFactory_Impl( sURL );
+ if ( aExt.Len() > 0 )
+ nImage = GetImageId_Impl( aExt );
+ return nImage;
+ }
+ else if ( aType == String( RTL_CONSTASCII_STRINGPARAM("image") ) )
+ nImage = (USHORT)aURLPath.GetToken( 1, INET_PATH_TOKEN ).ToInt32();
+ }
+ else
+ {
+ aExt = rObject.getExtension();
+ if ( aExt.EqualsAscii( "vor" ) )
+ {
+ SotStorageRef aStorage = new SotStorage( sURL, STREAM_STD_READ );
+ USHORT nId = IMG_WRITERTEMPLATE;
+ if ( !aStorage->GetError() )
+ {
+ SvGlobalName aGlobalName = aStorage->GetClassName();
+ if ( aGlobalName == SvGlobalName(SO3_SC_CLASSID_50) || aGlobalName == SvGlobalName(SO3_SC_CLASSID_40) || aGlobalName == SvGlobalName(SO3_SC_CLASSID_30) )
+ nId = IMG_CALCTEMPLATE;
+ else if ( aGlobalName == SvGlobalName(SO3_SDRAW_CLASSID_50) )
+ nId = IMG_DRAWTEMPLATE;
+ else if ( aGlobalName == SvGlobalName(SO3_SIMPRESS_CLASSID_50) ||
+ aGlobalName == SvGlobalName(SO3_SIMPRESS_CLASSID_40) || aGlobalName == SvGlobalName(SO3_SIMPRESS_CLASSID_30) )
+ nId = IMG_IMPRESSTEMPLATE;
+ else if ( aGlobalName == SvGlobalName(SO3_SM_CLASSID_50) || aGlobalName == SvGlobalName(SO3_SM_CLASSID_40) || aGlobalName == SvGlobalName(SO3_SM_CLASSID_30) )
+ nId = IMG_MATHTEMPLATE;
+ }
+
+ return nId;
+ }
+ }
+
+ if ( nImage == IMG_FILE && sURL.Len() )
+ {
+ if ( bDetectFolder && CONTENT_HELPER::IsFolder( sURL ) )
+ nImage = GetFolderImageId_Impl( sURL );
+ else if ( aExt.Len() > 0 )
+ nImage = GetImageId_Impl( aExt );
+ }
+ return nImage;
+}
+
+static USHORT GetDescriptionId_Impl( const String& rExtension, sal_Bool& rbShowExt )
+{
+ USHORT nId = 0;
+
+ if ( rExtension.Len() != NO_INDEX )
+ {
+ USHORT nIndex = GetIndexOfExtension_Impl( rExtension );
+ if ( nIndex != NO_INDEX )
+ {
+ nId = ExtensionMap_Impl[ nIndex ]._nStrId;
+ rbShowExt = ExtensionMap_Impl[ nIndex ]._bExt;
+ }
+ }
+
+ return nId;
+}
+
+static String GetDescriptionByFactory_Impl( const String& rFactory )
+{
+ USHORT nResId = 0;
+ if ( rFactory.EqualsIgnoreCaseAscii( "swriter", 0, 7 ) )
+ nResId = STR_DESCRIPTION_FACTORY_WRITER;
+ else if ( rFactory.EqualsIgnoreCaseAscii( "scalc", 0, 5 ) )
+ nResId = STR_DESCRIPTION_FACTORY_CALC;
+ else if ( rFactory.EqualsIgnoreCaseAscii( "simpress", 0, 8 ) )
+ nResId = STR_DESCRIPTION_FACTORY_IMPRESS;
+ else if ( rFactory.EqualsIgnoreCaseAscii( "sdraw", 0, 5 ) )
+ nResId = STR_DESCRIPTION_FACTORY_DRAW;
+ else if ( rFactory.EqualsIgnoreCaseAscii( "swriter/web", 0, 11 ) )
+ nResId = STR_DESCRIPTION_FACTORY_WRITERWEB;
+ else if ( rFactory.EqualsIgnoreCaseAscii( "swriter/globaldocument", 0, 22 ) )
+ nResId = STR_DESCRIPTION_FACTORY_GLOBALDOC;
+ else if ( rFactory.EqualsIgnoreCaseAscii( "smath", 0, 5 ) )
+ nResId = STR_DESCRIPTION_FACTORY_MATH;
+ else if ( rFactory.EqualsIgnoreCaseAscii( "sdatabase", 0, 9 ) )
+ nResId = STR_DESCRIPTION_FACTORY_DATABASE;
+
+ String aRet;
+ if ( nResId )
+ {
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ aRet = String( SvtResId( nResId ) );
+ }
+ return aRet;
+}
+
+static USHORT GetFolderDescriptionId_Impl( const String& rURL )
+{
+ USHORT nRet = STR_DESCRIPTION_FOLDER;
+ svtools::VolumeInfo aVolumeInfo;
+ try
+ {
+ ::ucbhelper::Content aCnt( rURL, ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
+ if ( GetVolumeProperties_Impl( aCnt, aVolumeInfo ) )
+ {
+ if ( aVolumeInfo.m_bIsRemote )
+ nRet = STR_DESCRIPTION_REMOTE_VOLUME;
+ else if ( aVolumeInfo.m_bIsFloppy )
+ nRet = STR_DESCRIPTION_FLOPPY_VOLUME;
+ else if ( aVolumeInfo.m_bIsCompactDisc )
+ nRet = STR_DESCRIPTION_CDROM_VOLUME;
+ else if ( aVolumeInfo.m_bIsRemoveable || aVolumeInfo.m_bIsVolume )
+ nRet = STR_DESCRIPTION_LOCALE_VOLUME;
+ }
+ }
+ catch( const ::com::sun::star::uno::RuntimeException& )
+ {
+ throw; // dont hide it!
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ // ...
+ }
+ return nRet;
+}
+
+static ResMgr* GetIsoResMgr_Impl()
+{
+ static ResMgr* pIsoResMgr = NULL;
+
+ if ( !pIsoResMgr )
+ {
+ ByteString aResMgrName( "iso" );
+ pIsoResMgr = ResMgr::CreateResMgr(
+ aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
+ if ( !pIsoResMgr )
+ {
+ // no "iso" resource -> search for "ooo" resource
+ aResMgrName = ByteString( "ooo" );
+ pIsoResMgr = ResMgr::CreateResMgr(
+ aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
+ }
+ }
+
+ return pIsoResMgr;
+}
+
+static ImageList* CreateImageList_Impl( USHORT nResId )
+{
+ ImageList* pList = NULL;
+ ResMgr* pResMgr = GetIsoResMgr_Impl();
+ DBG_ASSERT( pResMgr, "SvFileInformationManager::CreateImageList_Impl(): no resmgr" );
+ ResId aResId( nResId, *pResMgr );
+ aResId.SetRT( RSC_IMAGELIST );
+ if ( pResMgr->IsAvailable( aResId ) )
+ pList = new ImageList( aResId );
+ else
+ pList = new ImageList();
+ return pList;
+}
+
+static Image GetOfficeImageFromList_Impl( USHORT nImageId, BOOL bBig, BOOL bHighContrast )
+{
+ ImageList* pList = NULL;
+
+ static ImageList* _pSmallOfficeImgList = NULL;
+ static ImageList* _pBigOfficeImgList = NULL;
+ static ImageList* _pSmallHCOfficeImgList = NULL;
+ static ImageList* _pBigHCOfficeImgList = NULL;
+ static ULONG nStyle = Application::GetSettings().GetStyleSettings().GetSymbolsStyle();
+
+ // If the style has been changed, throw away our cache of the older images
+ if ( nStyle != Application::GetSettings().GetStyleSettings().GetSymbolsStyle() )
+ {
+ delete _pSmallOfficeImgList, _pSmallOfficeImgList = NULL;
+ delete _pBigOfficeImgList, _pBigOfficeImgList = NULL;
+ delete _pSmallHCOfficeImgList, _pSmallHCOfficeImgList = NULL;
+ delete _pBigHCOfficeImgList, _pBigHCOfficeImgList = NULL;
+ nStyle = Application::GetSettings().GetStyleSettings().GetSymbolsStyle();
+ }
+
+ // #i21242# MT: For B&W we need the HC Image and must transform.
+ // bHiContrast is TRUE for all dark backgrounds, but we need HC Images for HC White also,
+ // so we can't rely on bHighContrast.
+ BOOL bBlackAndWhite = Application::GetSettings().GetStyleSettings().IsHighContrastBlackAndWhite();
+ if ( bBlackAndWhite )
+ bHighContrast = TRUE;
+
+
+ if ( bBig )
+ {
+ if ( bHighContrast )
+ {
+ if ( !_pBigHCOfficeImgList )
+ _pBigHCOfficeImgList = CreateImageList_Impl( RID_SVTOOLS_IMAGELIST_BIG_HIGHCONTRAST );
+ pList = _pBigHCOfficeImgList;
+ }
+ else
+ {
+ if ( !_pBigOfficeImgList )
+ _pBigOfficeImgList = CreateImageList_Impl( RID_SVTOOLS_IMAGELIST_BIG );
+ pList = _pBigOfficeImgList;
+ }
+ }
+ else
+ {
+ if ( bHighContrast )
+ {
+ if ( !_pSmallHCOfficeImgList )
+ _pSmallHCOfficeImgList = CreateImageList_Impl( RID_SVTOOLS_IMAGELIST_SMALL_HIGHCONTRAST );
+ pList = _pSmallHCOfficeImgList;
+ }
+ else
+ {
+ if ( !_pSmallOfficeImgList )
+ _pSmallOfficeImgList = CreateImageList_Impl( RID_SVTOOLS_IMAGELIST_SMALL );
+ pList = _pSmallOfficeImgList;
+ }
+ }
+
+ Image aImage = pList->GetImage( nImageId );
+
+ if ( bBlackAndWhite )
+ {
+ // First invert the Image, because it's designed for black background, structures are bright
+ aImage.Invert();
+ // Now make monochrome...
+ ImageColorTransform eTrans = IMAGECOLORTRANSFORM_MONOCHROME_WHITE;
+ if ( Application::GetSettings().GetStyleSettings().GetFaceColor().GetColor() == COL_WHITE )
+ eTrans = IMAGECOLORTRANSFORM_MONOCHROME_BLACK;
+ aImage = aImage.GetColorTransformedImage( eTrans );
+ }
+
+ return aImage;
+}
+
+static Image GetImageFromList_Impl( USHORT nImageId, BOOL bBig, BOOL bHighContrast )
+{
+ if ( !bBig && IMG_FOLDER == nImageId && !bHighContrast )
+ // return our new small folder image (256 colors)
+ return Image( SvtResId( IMG_SVT_FOLDER ) );
+
+ ImageList* pList = NULL;
+
+ static ImageList* _pSmallImageList = NULL;
+ static ImageList* _pBigImageList = NULL;
+ static ImageList* _pSmallHCImageList = NULL;
+ static ImageList* _pBigHCImageList = NULL;
+ static ULONG nStyle = Application::GetSettings().GetStyleSettings().GetSymbolsStyle();
+
+ // If the style has been changed, throw away our cache of the older images
+ if ( nStyle != Application::GetSettings().GetStyleSettings().GetSymbolsStyle() )
+ {
+ delete _pSmallImageList, _pSmallImageList = NULL;
+ delete _pBigImageList, _pBigImageList = NULL;
+ delete _pSmallHCImageList, _pSmallHCImageList = NULL;
+ delete _pBigHCImageList, _pBigHCImageList = NULL;
+ nStyle = Application::GetSettings().GetStyleSettings().GetSymbolsStyle();
+ }
+
+ if ( bBig )
+ {
+ if ( bHighContrast )
+ {
+ if ( !_pBigHCImageList )
+ _pBigHCImageList = new ImageList( SvtResId( RID_SVTOOLS_IMAGELIST_BIG_HIGHCONTRAST ) );
+ pList = _pBigHCImageList;
+ }
+ else
+ {
+ if ( !_pBigImageList )
+ _pBigImageList = new ImageList( SvtResId( RID_SVTOOLS_IMAGELIST_BIG ) );
+ pList = _pBigImageList;
+ }
+ }
+ else
+ {
+ if ( bHighContrast )
+ {
+ if ( !_pSmallHCImageList )
+ _pSmallHCImageList = new ImageList( SvtResId( RID_SVTOOLS_IMAGELIST_SMALL_HIGHCONTRAST ) );
+ pList = _pSmallHCImageList;
+ }
+ else
+ {
+ if ( !_pSmallImageList )
+ _pSmallImageList = new ImageList( SvtResId( RID_SVTOOLS_IMAGELIST_SMALL ) );
+ pList = _pSmallImageList;
+ }
+ }
+
+ if ( pList->HasImageAtPos( nImageId ) )
+ return pList->GetImage( nImageId );
+ else
+ return GetOfficeImageFromList_Impl( nImageId, bBig, bHighContrast );
+}
+
+//****************************************************************************
+
+void ReplaceStarOfficeVar( String& _rDescription )
+{
+ static String sVariable( RTL_CONSTASCII_STRINGPARAM( "%STAROFFICE" ) );
+ static String sProductName;
+ if ( sProductName.Len() == 0 )
+ {
+ ::rtl::OUString sTemp;
+ ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTNAME ) >>= sTemp;
+ if ( sTemp.equalsAscii( "StarSuite" ) == sal_False )
+ sProductName = String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "StarOffice" ) );
+ else
+ sProductName = String( sTemp );
+ }
+ _rDescription.SearchAndReplace( sVariable, sProductName );
+}
+
+String SvFileInformationManager::GetDescription_Impl( const INetURLObject& rObject, sal_Bool bDetectFolder )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aTimeLog, "svtools", "hb93813", "SvFileInformationManager::GetDescription_Impl()" );
+
+ String sDescription;
+ String sExtension( rObject.getExtension() ), sURL( rObject.GetMainURL( INetURLObject::NO_DECODE ) );
+ USHORT nResId = 0;
+ sal_Bool bShowExt = sal_False, bDetected = sal_False, bOnlyFile = sal_False;
+ sal_Bool bFolder = bDetectFolder ? CONTENT_HELPER::IsFolder( sURL ) : sal_False;
+ if ( !bFolder )
+ {
+ if ( !bDetected )
+ {
+ if ( rObject.GetProtocol() == INET_PROT_PRIVATE )
+ {
+ String aURLPath = sURL.Copy( URL_PREFIX_PRIV_SOFFICE_LEN );
+ String aType = aURLPath.GetToken( 0, INET_PATH_TOKEN );
+ if ( aType == String( RTL_CONSTASCII_STRINGPARAM("factory") ) )
+ {
+ sDescription = GetDescriptionByFactory_Impl( aURLPath.Copy( aURLPath.Search( INET_PATH_TOKEN ) + 1 ) );
+ bDetected = sal_True;
+ }
+ }
+
+ if ( !bDetected )
+ {
+ // search a description by extension
+ sal_Bool bExt = ( sExtension.Len() > 0 );
+ if ( bExt )
+ {
+ sExtension.ToLowerAscii();
+ nResId = GetDescriptionId_Impl( sExtension, bShowExt );
+ }
+ if ( !nResId )
+ {
+ nResId = STR_DESCRIPTION_FILE;
+ bOnlyFile = bExt;
+ }
+ }
+ }
+ }
+ else
+ nResId = GetFolderDescriptionId_Impl( sURL );
+
+ if ( nResId > 0 )
+ {
+ if ( bOnlyFile )
+ {
+ bShowExt = sal_False;
+ sExtension.ToUpperAscii();
+ sDescription = sExtension;
+ sDescription += '-';
+ }
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ sDescription += String( SvtResId( nResId ) );
+ }
+
+ DBG_ASSERT( sDescription.Len() > 0, "file without description" );
+
+ if ( bShowExt )
+ {
+ sDescription += String( RTL_CONSTASCII_STRINGPARAM(" (") );
+ sDescription += sExtension;
+ sDescription += ')';
+ }
+
+ ReplaceStarOfficeVar( sDescription );
+ return sDescription;
+}
+
+Image SvFileInformationManager::GetImage( const INetURLObject& rObject, sal_Bool bBig )
+{
+ return GetImage( rObject, bBig, FALSE );
+}
+
+Image SvFileInformationManager::GetFileImage( const INetURLObject& rObject, sal_Bool bBig )
+{
+ return GetFileImage( rObject, bBig, FALSE );
+}
+
+Image SvFileInformationManager::GetImageNoDefault( const INetURLObject& rObject, sal_Bool bBig )
+{
+ return GetImageNoDefault( rObject, bBig, FALSE );
+}
+
+Image SvFileInformationManager::GetFolderImage( const svtools::VolumeInfo& rInfo, sal_Bool bBig )
+{
+ return GetFolderImage( rInfo, bBig, FALSE );
+}
+
+Image SvFileInformationManager::GetImage( const INetURLObject& rObject, sal_Bool bBig, sal_Bool bHighContrast )
+{
+ USHORT nImage = GetImageId_Impl( rObject, sal_True );
+ DBG_ASSERT( nImage, "invalid ImageId" );
+ return GetImageFromList_Impl( nImage, bBig, bHighContrast );
+}
+
+Image SvFileInformationManager::GetFileImage( const INetURLObject& rObject, sal_Bool bBig, sal_Bool bHighContrast )
+{
+ USHORT nImage = GetImageId_Impl( rObject, sal_False );
+ DBG_ASSERT( nImage, "invalid ImageId" );
+ return GetImageFromList_Impl( nImage, bBig, bHighContrast );
+}
+
+Image SvFileInformationManager::GetImageNoDefault( const INetURLObject& rObject, sal_Bool bBig, sal_Bool bHighContrast )
+{
+ USHORT nImage = GetImageId_Impl( rObject, sal_True );
+ DBG_ASSERT( nImage, "invalid ImageId" );
+
+ if ( nImage == IMG_FILE )
+ return Image();
+
+ return GetImageFromList_Impl( nImage, bBig, bHighContrast );
+}
+
+Image SvFileInformationManager::GetFolderImage( const svtools::VolumeInfo& rInfo, sal_Bool bBig, sal_Bool bHighContrast )
+{
+ USHORT nImage = IMG_FOLDER;
+ DBG_ASSERT( nImage, "invalid ImageId" );
+
+ if ( rInfo.m_bIsRemote )
+ nImage = IMG_NETWORKDEV;
+ else if ( rInfo.m_bIsCompactDisc )
+ nImage = IMG_CDROMDEV;
+ else if ( rInfo.m_bIsRemoveable || rInfo.m_bIsFloppy )
+ nImage = IMG_REMOVEABLEDEV;
+ else if ( rInfo.m_bIsVolume )
+ nImage = IMG_FIXEDDEV;
+
+ return GetImageFromList_Impl( nImage, bBig, bHighContrast );
+}
+
+String SvFileInformationManager::GetDescription( const INetURLObject& rObject )
+{
+ return SvFileInformationManager::GetDescription_Impl( rObject, sal_True );
+}
+
+String SvFileInformationManager::GetFileDescription( const INetURLObject& rObject )
+{
+ return SvFileInformationManager::GetDescription_Impl( rObject, sal_False );
+}
+
+String SvFileInformationManager::GetFolderDescription( const svtools::VolumeInfo& rInfo )
+{
+ USHORT nResId = STR_DESCRIPTION_FOLDER;
+ if ( rInfo.m_bIsRemote )
+ nResId = STR_DESCRIPTION_REMOTE_VOLUME;
+ else if ( rInfo.m_bIsFloppy )
+ nResId = STR_DESCRIPTION_FLOPPY_VOLUME;
+ else if ( rInfo.m_bIsCompactDisc )
+ nResId = STR_DESCRIPTION_CDROM_VOLUME;
+ else if ( rInfo.m_bIsRemoveable || rInfo.m_bIsVolume )
+ nResId = STR_DESCRIPTION_LOCALE_VOLUME;
+
+ String sDescription = String( SvtResId( nResId ) );
+ return sDescription;
+}
+
diff --git a/svtools/source/misc/imagemgr.src b/svtools/source/misc/imagemgr.src
new file mode 100644
index 000000000000..cdc9f8da1c87
--- /dev/null
+++ b/svtools/source/misc/imagemgr.src
@@ -0,0 +1,452 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+ // includes ******************************************************************
+
+#include <svtools/svtools.hrc>
+#include "imagemgr.hrc"
+
+ // images ********************************************************************
+
+#define X_IMAGE_LIST \
+ IMG_WORKPLACE ; \
+ IMG_BITMAP ; \
+ IMG_EXCEL ; \
+ IMG_EXCELTEMPLATE ; \
+ IMG_FTPSERVER ; \
+ IMG_GALLERY ; \
+ IMG_GALLERYTHEME ; \
+ IMG_GIF ; \
+ IMG_HELP ; \
+ IMG_HTML ; \
+ IMG_JPG ; \
+ IMG_LINK ; \
+ IMG_LOTUS ; \
+ IMG_MATHTEMPLATE ; \
+ IMG_FILE ; \
+ IMG_APP ; \
+ IMG_PCD ; \
+ IMG_PCT ; \
+ IMG_PCX ; \
+ IMG_SIM ; \
+ IMG_TEXTFILE ; \
+ IMG_SVHELP ; \
+ IMG_TIFF ; \
+ IMG_URL ; \
+ IMG_WMF ; \
+ IMG_WORD ; \
+ IMG_FIXEDDEV ; \
+ IMG_REMOVEABLEDEV ; \
+ IMG_CDROMDEV ; \
+ IMG_NETWORKDEV ; \
+ IMG_RAMDEV ; \
+ IMG_TABLEFOLDER ; \
+ IMG_TABLE ; \
+ IMG_FOLDER ; \
+ IMG_EXPANDEDFOLDER ; \
+ IMG_XXX ; \
+ IMG_GALLERYIMPORT ; \
+ IMG_QUERYFOLDER ; \
+ IMG_QUERY ; \
+ IMG_FORM ; \
+ IMG_FORMFOLDER ; \
+ IMG_REPORT ; \
+ IMG_REPORTFOLDER ; \
+ IMG_OTHERS ; \
+ IMG_DXF ; \
+ IMG_MET ; \
+ IMG_PNG ; \
+ IMG_SGF ; \
+ IMG_SGV ; \
+ IMG_SVM ; \
+ IMG_TASK ; \
+ IMG_APPOINTMENT ; \
+ IMG_RELATION ; \
+ IMG_IMPRESSPACKED ; \
+ IMG_POWERPOINT ; \
+ IMG_POWERPOINTTEMPLATE ; \
+ IMG_OO_DATABASE_DOC ; \
+ IMG_OO_DRAW_DOC ; \
+ IMG_OO_MATH_DOC ; \
+ IMG_OO_GLOBAL_DOC ; \
+ IMG_OO_IMPRESS_DOC ; \
+ IMG_OO_CALC_DOC ; \
+ IMG_OO_WRITER_DOC ; \
+ IMG_OO_DRAW_TEMPLATE ; \
+ IMG_OO_IMPRESS_TEMPLATE ; \
+ IMG_OO_CALC_TEMPLATE ; \
+ IMG_OO_WRITER_TEMPLATE ; \
+ IMG_EXTENSION ;
+
+ImageList RID_SVTOOLS_IMAGELIST_BIG
+{
+ Prefix = "lx";
+ MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
+ IdList =
+ {
+ X_IMAGE_LIST
+ };
+ IdCount =
+ {
+ 68 ;
+ };
+};
+
+ImageList RID_SVTOOLS_IMAGELIST_SMALL
+{
+ Prefix = "sx";
+ MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
+ IdList =
+ {
+ X_IMAGE_LIST
+ };
+ IdCount =
+ {
+ 68;
+ };
+};
+
+ImageList RID_SVTOOLS_IMAGELIST_BIG_HIGHCONTRAST
+{
+ Prefix = "lxh";
+ MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
+ IdList =
+ {
+ X_IMAGE_LIST
+ };
+ IdCount =
+ {
+ 68 ;
+ };
+};
+
+ImageList RID_SVTOOLS_IMAGELIST_SMALL_HIGHCONTRAST
+{
+ Prefix = "sxh";
+ MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
+ IdList =
+ {
+ X_IMAGE_LIST
+ };
+ IdCount =
+ {
+ 68;
+ };
+};
+
+Bitmap BMP_PLUGIN
+{
+ File = "plugin.png" ;
+};
+
+// description strings
+
+String STR_DESCRIPTION_SOURCEFILE
+{
+ Text [ en-US ] = "Source code" ;
+};
+String STR_DESCRIPTION_BOOKMARKFILE
+{
+ Text [ en-US ] = "Bookmark file" ;
+};
+String STR_DESCRIPTION_GRAPHIC_DOC
+{
+ Text [ en-US ] = "Graphics" ;
+};
+String STR_DESCRIPTION_CFGFILE
+{
+ Text [ en-US ] = "Configuration file" ;
+};
+String STR_DESCRIPTION_APPLICATION
+{
+ Text [ en-US ] = "Application" ;
+};
+String STR_DESCRIPTION_DATABASE_TABLE
+{
+ Text [ en-US ] = "Database table" ;
+};
+String STR_DESCRIPTION_SYSFILE
+{
+ Text [ en-US ] = "System file" ;
+};
+String STR_DESCRIPTION_WORD_DOC
+{
+ Text [ en-US ] = "MS Word document" ;
+};
+String STR_DESCRIPTION_HELP_DOC
+{
+ Text [ en-US ] = "Help file" ;
+};
+String STR_DESCRIPTION_HTMLFILE
+{
+ Text [ en-US ] = "HTML document" ;
+};
+String STR_DESCRIPTION_ARCHIVFILE
+{
+ Text [ en-US ] = "Archive file" ;
+};
+String STR_DESCRIPTION_LOGFILE
+{
+ Text [ en-US ] = "Log file" ;
+};
+String STR_DESCRIPTION_SMATH_DOC
+{
+ Text = "StarMath 2.0 - 5.0" ;
+};
+String STR_DESCRIPTION_SCHART_DOC
+{
+ Text = "StarChart 3.0 - 5.0" ;
+};
+String STR_DESCRIPTION_SDRAW_DOC
+{
+ Text = "StarDraw 3.0 / 5.0 (StarImpress)" ;
+};
+
+String STR_DESCRIPTION_SDATABASE_DOC
+{
+ Text [ en-US ] = "%STAROFFICE Database" ;
+};
+
+String STR_DESCRIPTION_SCALC_DOC
+{
+ Text = "StarCalc 3.0 - 5.0" ;
+};
+String STR_DESCRIPTION_SIMPRESS_DOC
+{
+ Text = "StarImpress 4.0 / 5.0" ;
+};
+String STR_DESCRIPTION_SWRITER_DOC
+{
+ Text = "StarWriter 3.0 - 5.0" ;
+};
+String STR_DESCRIPTION_GLOBALDOC
+{
+ Text [ en-US ] = "StarWriter 4.0 / 5.0 Master Document" ;
+};
+String STR_DESCRIPTION_SIMAGE_DOC
+{
+ Text [ en-US ] = "%STAROFFICE Image" ;
+};
+String STR_DESCRIPTION_TEXTFILE
+{
+ Text [ en-US ] = "Text file" ;
+};
+String STR_DESCRIPTION_LINK
+{
+ Text [ en-US ] = "Link" ;
+};
+String STR_DESCRIPTION_SOFFICE_TEMPLATE_DOC
+{
+ Text [ en-US ] = "%STAROFFICE 3.0 - 5.0 Template" ;
+};
+String STR_DESCRIPTION_EXCEL_DOC
+{
+ Text [ en-US ] = "MS Excel document" ;
+};
+String STR_DESCRIPTION_EXCEL_TEMPLATE_DOC
+{
+ Text [ en-US ] = "MS Excel template" ;
+};
+String STR_DESCRIPTION_BATCHFILE
+{
+ Text [ en-US ] = "Batch file" ;
+};
+String STR_DESCRIPTION_FILE
+{
+ Text [ en-US ] = "File" ;
+};
+String STR_DESCRIPTION_FOLDER
+{
+ Text [ en-US ] = "Folder" ;
+};
+String STR_DESCRIPTION_FACTORY_WRITER
+{
+ Text [ en-US ] = "Text Document";
+};
+String STR_DESCRIPTION_FACTORY_CALC
+{
+ Text [ en-US ] = "Spreadsheet";
+};
+String STR_DESCRIPTION_FACTORY_IMPRESS
+{
+ Text [ en-US ] = "Presentation";
+};
+String STR_DESCRIPTION_FACTORY_DRAW
+{
+ Text [ en-US ] = "Drawing";
+};
+String STR_DESCRIPTION_FACTORY_WRITERWEB
+{
+ Text [ en-US ] = "HTML document";
+};
+String STR_DESCRIPTION_FACTORY_GLOBALDOC
+{
+ Text [ en-US ] = "Master document";
+};
+String STR_DESCRIPTION_FACTORY_MATH
+{
+ Text [ en-US ] = "Formula";
+};
+String STR_DESCRIPTION_FACTORY_DATABASE
+{
+ Text [ en-US ] = "Database";
+};
+String STR_DESCRIPTION_CALC_TEMPLATE
+{
+ Text [ en-US ] = "%PRODUCTNAME %PRODUCTXMLFILEFORMATVERSION Spreadsheet Template" ;
+};
+String STR_DESCRIPTION_DRAW_TEMPLATE
+{
+ Text [ en-US ] = "%PRODUCTNAME %PRODUCTXMLFILEFORMATVERSION Drawing Template" ;
+};
+String STR_DESCRIPTION_IMPRESS_TEMPLATE
+{
+ Text [ en-US ] = "%PRODUCTNAME %PRODUCTXMLFILEFORMATVERSION Presentation Template" ;
+};
+String STR_DESCRIPTION_WRITER_TEMPLATE
+{
+ Text [ en-US ] = "%PRODUCTNAME %PRODUCTXMLFILEFORMATVERSION Text Document Template" ;
+};
+String STR_DESCRIPTION_LOCALE_VOLUME
+{
+ Text [ en-US ] = "Local drive" ;
+};
+String STR_DESCRIPTION_FLOPPY_VOLUME
+{
+ Text [ en-US ] = "Disk drive" ;
+};
+String STR_DESCRIPTION_CDROM_VOLUME
+{
+ Text [ en-US ] = "CD-ROM drive" ;
+};
+String STR_DESCRIPTION_REMOTE_VOLUME
+{
+ Text [ en-US ] = "Network connection" ;
+};
+String STR_DESCRIPTION_POWERPOINT
+{
+ Text [ en-US ] = "MS PowerPoint Document";
+};
+
+String STR_DESCRIPTION_POWERPOINT_TEMPLATE
+{
+ Text [ en-US ] = "MS PowerPoint Template";
+};
+
+String STR_DESCRIPTION_POWERPOINT_SHOW
+{
+ Text [ en-US ] = "MS PowerPoint Show";
+};
+
+String STR_DESCRIPTION_SXMATH_DOC
+{
+ Text [ en-US ] = "%PRODUCTNAME %PRODUCTXMLFILEFORMATVERSION Formula" ;
+};
+
+String STR_DESCRIPTION_SXCHART_DOC
+{
+ Text [ en-US ] = "%PRODUCTNAME %PRODUCTXMLFILEFORMATVERSION Chart" ;
+};
+
+String STR_DESCRIPTION_SXDRAW_DOC
+{
+ Text [ en-US ] = "%PRODUCTNAME %PRODUCTXMLFILEFORMATVERSION Drawing" ;
+};
+
+String STR_DESCRIPTION_SXCALC_DOC
+{
+ Text [ en-US ] = "%PRODUCTNAME %PRODUCTXMLFILEFORMATVERSION Spreadsheet" ;
+};
+
+String STR_DESCRIPTION_SXIMPRESS_DOC
+{
+ Text [ en-US ] = "%PRODUCTNAME %PRODUCTXMLFILEFORMATVERSION Presentation" ;
+};
+
+String STR_DESCRIPTION_SXWRITER_DOC
+{
+ Text [ en-US ] = "%PRODUCTNAME %PRODUCTXMLFILEFORMATVERSION Text Document" ;
+};
+
+String STR_DESCRIPTION_SXGLOBAL_DOC
+{
+ Text [ en-US ] = "%PRODUCTNAME %PRODUCTXMLFILEFORMATVERSION Master Document" ;
+};
+String STR_DESCRIPTION_MATHML_DOC
+{
+ Text [ en-US ] = "MathML Document" ;
+};
+
+String STR_DESCRIPTION_OO_DATABASE_DOC
+{
+ Text [ en-US ] = "OpenDocument Database" ;
+};
+String STR_DESCRIPTION_OO_DRAW_DOC
+{
+ Text [ en-US ] = "OpenDocument Drawing" ;
+};
+String STR_DESCRIPTION_OO_MATH_DOC
+{
+ Text [ en-US ] = "OpenDocument Formula" ;
+};
+String STR_DESCRIPTION_OO_GLOBAL_DOC
+{
+ Text [ en-US ] = "OpenDocument Master Document" ;
+};
+String STR_DESCRIPTION_OO_IMPRESS_DOC
+{
+ Text [ en-US ] = "OpenDocument Presentation" ;
+};
+String STR_DESCRIPTION_OO_CALC_DOC
+{
+ Text [ en-US ] = "OpenDocument Spreadsheet" ;
+};
+String STR_DESCRIPTION_OO_WRITER_DOC
+{
+ Text [ en-US ] = "OpenDocument Text" ;
+};
+String STR_DESCRIPTION_OO_CALC_TEMPLATE
+{
+ Text [ en-US ] = "OpenDocument Spreadsheet Template" ;
+};
+String STR_DESCRIPTION_OO_DRAW_TEMPLATE
+{
+ Text [ en-US ] = "OpenDocument Drawing Template" ;
+};
+String STR_DESCRIPTION_OO_IMPRESS_TEMPLATE
+{
+ Text [ en-US ] = "OpenDocument Presentation Template" ;
+};
+String STR_DESCRIPTION_OO_WRITER_TEMPLATE
+{
+ Text [ en-US ] = "OpenDocument Text Template" ;
+};
+
+String STR_DESCRIPTION_EXTENSION
+{
+ Text [ en-US ] = "%PRODUCTNAME Extension" ;
+};
+
diff --git a/svtools/source/misc/imageresourceaccess.cxx b/svtools/source/misc/imageresourceaccess.cxx
new file mode 100644
index 000000000000..436c3f721833
--- /dev/null
+++ b/svtools/source/misc/imageresourceaccess.cxx
@@ -0,0 +1,211 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#ifndef SVTOOLS_SOURCE_MISC_IMAGERESOURCEACCESS_HXX
+#include "imageresourceaccess.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#include <com/sun/star/io/NotConnectedException.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/graphic/XGraphicProvider.hpp>
+#include <com/sun/star/io/XStream.hpp>
+/** === end UNO includes === **/
+#include <unotools/ucbstreamhelper.hxx>
+#include <tools/stream.hxx>
+#include <unotools/streamwrap.hxx>
+#include <cppuhelper/implbase2.hxx>
+
+//........................................................................
+namespace svt
+{
+//........................................................................
+
+ using namespace ::utl;
+ using namespace ::comphelper;
+ using namespace ::com::sun::star::io;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::graphic;
+
+ //====================================================================
+ //= StreamSupplier
+ //====================================================================
+ typedef ::cppu::WeakImplHelper2 < XStream
+ , XSeekable
+ > StreamSupplier_Base;
+ class StreamSupplier : public StreamSupplier_Base
+ {
+ private:
+ Reference< XInputStream > m_xInput;
+ Reference< XOutputStream > m_xOutput;
+ Reference< XSeekable > m_xSeekable;
+
+ public:
+ StreamSupplier( const Reference< XInputStream >& _rxInput, const Reference< XOutputStream >& _rxOutput );
+
+ protected:
+ // XStream
+ virtual Reference< XInputStream > SAL_CALL getInputStream( ) throw (RuntimeException);
+ virtual Reference< XOutputStream > SAL_CALL getOutputStream( ) throw (RuntimeException);
+
+ // XSeekable
+ virtual void SAL_CALL seek( ::sal_Int64 location ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int64 SAL_CALL getPosition( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int64 SAL_CALL getLength( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ };
+
+ //--------------------------------------------------------------------
+ StreamSupplier::StreamSupplier( const Reference< XInputStream >& _rxInput, const Reference< XOutputStream >& _rxOutput )
+ :m_xInput( _rxInput )
+ ,m_xOutput( _rxOutput )
+ {
+ m_xSeekable = m_xSeekable.query( m_xInput );
+ if ( !m_xSeekable.is() )
+ m_xSeekable = m_xSeekable.query( m_xOutput );
+ OSL_ENSURE( m_xSeekable.is(), "StreamSupplier::StreamSupplier: at least one of both must be seekable!" );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInputStream > SAL_CALL StreamSupplier::getInputStream( ) throw (RuntimeException)
+ {
+ return m_xInput;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XOutputStream > SAL_CALL StreamSupplier::getOutputStream( ) throw (RuntimeException)
+ {
+ return m_xOutput;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL StreamSupplier::seek( ::sal_Int64 location ) throw (IllegalArgumentException, IOException, RuntimeException)
+ {
+ if ( !m_xSeekable.is() )
+ throw NotConnectedException();
+
+ m_xSeekable->seek( location );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int64 SAL_CALL StreamSupplier::getPosition( ) throw (IOException, RuntimeException)
+ {
+ if ( !m_xSeekable.is() )
+ throw NotConnectedException();
+
+ return m_xSeekable->getPosition();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int64 SAL_CALL StreamSupplier::getLength( ) throw (IOException, RuntimeException)
+ {
+ if ( !m_xSeekable.is() )
+ throw NotConnectedException();
+
+ return m_xSeekable->getLength();
+ }
+
+ //====================================================================
+ //= GraphicAccess
+ //====================================================================
+ //--------------------------------------------------------------------
+ bool GraphicAccess::isSupportedURL( const ::rtl::OUString& _rURL )
+ {
+ if ( ( _rURL.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "private:resource/" ) ) == 0 )
+ || ( _rURL.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "private:graphicrepository/" ) ) == 0 )
+ || ( _rURL.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "private:standardimage/" ) ) == 0 )
+ || ( _rURL.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.GraphicObject:" ) ) == 0 )
+ || ( _rURL.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.extension://" ) ) == 0 )
+ )
+ return true;
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ SvStream* GraphicAccess::getImageStream( const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rImageResourceURL )
+ {
+ SvStream* pReturn = NULL;
+
+ try
+ {
+ // get a GraphicProvider
+ Reference< XGraphicProvider > xProvider;
+ if ( _rxORB.is() )
+ xProvider = xProvider.query( _rxORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.graphic.GraphicProvider" ) ) ) );
+ OSL_ENSURE( xProvider.is(), "GraphicAccess::getImageStream: could not create a graphic provider!" );
+
+ if ( !xProvider.is() )
+ return pReturn;
+
+ // let it create a graphic from the given URL
+ Sequence< PropertyValue > aMediaProperties( 1 );
+ aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
+ aMediaProperties[0].Value <<= _rImageResourceURL;
+ Reference< XGraphic > xGraphic( xProvider->queryGraphic( aMediaProperties ) );
+ OSL_ENSURE( xGraphic.is(), "GraphicAccess::getImageStream: the provider did not give us a graphic object!" );
+ if ( !xGraphic.is() )
+ return pReturn;
+
+ // copy the graphic to a in-memory buffer
+ SvMemoryStream* pMemBuffer = new SvMemoryStream;
+ Reference< XStream > xBufferAccess = new StreamSupplier(
+ new OSeekableInputStreamWrapper( *pMemBuffer ),
+ new OSeekableOutputStreamWrapper( *pMemBuffer )
+ );
+
+ aMediaProperties.realloc( 2 );
+ aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OutputStream" ) );
+ aMediaProperties[0].Value <<= xBufferAccess;
+ aMediaProperties[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MimeType" ) );
+ aMediaProperties[1].Value <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "image/png" ) );
+ xProvider->storeGraphic( xGraphic, aMediaProperties );
+
+ pMemBuffer->Seek( 0 );
+ pReturn = pMemBuffer;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "GraphicAccess::getImageStream: caught an exception!" );
+ }
+
+ return pReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInputStream > GraphicAccess::getImageXStream( const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rImageResourceURL )
+ {
+ return new OSeekableInputStreamWrapper( getImageStream( _rxORB, _rImageResourceURL ), sal_True ); // take ownership
+ }
+
+//........................................................................
+} // namespace svt
+//........................................................................
+
diff --git a/svtools/source/misc/imap.cxx b/svtools/source/misc/imap.cxx
new file mode 100644
index 000000000000..4378e0acd234
--- /dev/null
+++ b/svtools/source/misc/imap.cxx
@@ -0,0 +1,1222 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include <tools/urlobj.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/mapmod.hxx>
+#include <vcl/window.hxx>
+
+#include "svl/urihelper.hxx"
+#include <svtools/imap.hxx>
+#include <svtools/imapobj.hxx>
+#include <svtools/imapcirc.hxx>
+#include <svtools/imaprect.hxx>
+#include <svtools/imappoly.hxx>
+
+#include <string.h>
+#include <math.h>
+
+DBG_NAME( ImageMap )
+
+
+#define SCALEPOINT(aPT,aFracX,aFracY) (aPT).X()=((aPT).X()*(aFracX).GetNumerator())/(aFracX).GetDenominator(); \
+ (aPT).Y()=((aPT).Y()*(aFracY).GetNumerator())/(aFracY).GetDenominator();
+
+
+/******************************************************************************/
+
+UINT16 IMapObject::nActualTextEncoding = (UINT16) RTL_TEXTENCODING_DONTKNOW;
+
+/******************************************************************************/
+
+
+IMapObject::IMapObject()
+ : bActive( false )
+ , nReadVersion( 0 )
+{
+}
+
+IMapObject::IMapObject( const String& rURL, const String& rAltText, const String& rDesc,
+ const String& rTarget, const String& rName, BOOL bURLActive )
+: aURL( rURL )
+, aAltText( rAltText )
+, aDesc( rDesc )
+, aTarget( rTarget )
+, aName( rName )
+, bActive( bURLActive )
+, nReadVersion( 0 )
+{
+}
+
+
+/******************************************************************************
+|*
+|* Freigabe des internen Speichers
+|*
+\******************************************************************************/
+
+UINT16 IMapObject::GetVersion() const
+{
+ return IMAP_OBJ_VERSION;
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void IMapObject::Write( SvStream& rOStm, const String& rBaseURL ) const
+{
+ IMapCompat* pCompat;
+ const rtl_TextEncoding eEncoding = gsl_getSystemTextEncoding();
+
+ rOStm << GetType();
+ rOStm << GetVersion();
+ rOStm << ( (UINT16) eEncoding );
+
+ const ByteString aRelURL = ByteString( String(URIHelper::simpleNormalizedMakeRelative( rBaseURL, aURL )), eEncoding );
+ rOStm.WriteByteString( aRelURL );
+ rOStm.WriteByteString( ByteString( aAltText, eEncoding ) );
+ rOStm << bActive;
+ rOStm.WriteByteString( ByteString( aTarget, eEncoding ) );
+
+ pCompat = new IMapCompat( rOStm, STREAM_WRITE );
+
+ WriteIMapObject( rOStm );
+ aEventList.Write( rOStm ); // V4
+ rOStm.WriteByteString( ByteString( aName, eEncoding ) ); // V5
+
+ delete pCompat;
+}
+
+
+/******************************************************************************
+|*
+|* Binaer-Import
+|*
+\******************************************************************************/
+
+void IMapObject::Read( SvStream& rIStm, const String& rBaseURL )
+{
+ IMapCompat* pCompat;
+ rtl_TextEncoding nTextEncoding;
+ ByteString aString;
+
+ // Typ und Version ueberlesen wir
+ rIStm.SeekRel( 2 );
+ rIStm >> nReadVersion;
+ rIStm >> nTextEncoding;
+ rIStm.ReadByteString( aString ); aURL = String( aString.GetBuffer(), nTextEncoding );
+ rIStm.ReadByteString( aString ); aAltText = String( aString.GetBuffer(), nTextEncoding );
+ rIStm >> bActive;
+ rIStm.ReadByteString( aString ); aTarget = String( aString.GetBuffer(), nTextEncoding );
+
+ // URL absolut machen
+ aURL = URIHelper::SmartRel2Abs( INetURLObject(rBaseURL), aURL, URIHelper::GetMaybeFileHdl(), true, false, INetURLObject::WAS_ENCODED, INetURLObject::DECODE_UNAMBIGUOUS );
+ pCompat = new IMapCompat( rIStm, STREAM_READ );
+
+ ReadIMapObject( rIStm );
+
+ // ab Version 4 lesen wir eine EventListe
+ if ( nReadVersion >= 0x0004 )
+ {
+ aEventList.Read(rIStm);
+
+ // ab Version 5 kann ein Objektname vorhanden sein
+ if ( nReadVersion >= 0x0005 )
+ {
+ rIStm.ReadByteString( aString ); aName = String( aString.GetBuffer(), nTextEncoding );
+ }
+ }
+
+ delete pCompat;
+}
+
+
+/******************************************************************************
+|*
+|* Konvertierung der logischen Koordianten in Pixel
+|*
+\******************************************************************************/
+
+Point IMapObject::GetPixelPoint( const Point& rLogPoint )
+{
+ return Application::GetDefaultDevice()->LogicToPixel( rLogPoint, MapMode( MAP_100TH_MM ) );
+}
+
+
+/******************************************************************************
+|*
+|* Konvertierung der logischen Koordianten in Pixel
+|*
+\******************************************************************************/
+
+Point IMapObject::GetLogPoint( const Point& rPixelPoint )
+{
+ return Application::GetDefaultDevice()->PixelToLogic( rPixelPoint, MapMode( MAP_100TH_MM ) );
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+BOOL IMapObject::IsEqual( const IMapObject& rEqObj )
+{
+ return ( ( aURL == rEqObj.aURL ) &&
+ ( aAltText == rEqObj.aAltText ) &&
+ ( aDesc == rEqObj.aDesc ) &&
+ ( aTarget == rEqObj.aTarget ) &&
+ ( aName == rEqObj.aName ) &&
+ ( bActive == rEqObj.bActive ) );
+}
+
+
+/******************************************************************************/
+/******************************************************************************/
+/******************************************************************************/
+
+IMapRectangleObject::IMapRectangleObject( const Rectangle& rRect,
+ const String& rURL,
+ const String& rAltText,
+ const String& rDesc,
+ const String& rTarget,
+ const String& rName,
+ BOOL bURLActive,
+ BOOL bPixelCoords ) :
+ IMapObject ( rURL, rAltText, rDesc, rTarget, rName, bURLActive )
+{
+ ImpConstruct( rRect, bPixelCoords );
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void IMapRectangleObject::ImpConstruct( const Rectangle& rRect, BOOL bPixel )
+{
+ if ( bPixel )
+ aRect = Application::GetDefaultDevice()->PixelToLogic( rRect, MapMode( MAP_100TH_MM ) );
+ else
+ aRect = rRect;
+}
+
+
+/******************************************************************************
+|*
+|* Binaer-Export
+|*
+\******************************************************************************/
+
+void IMapRectangleObject::WriteIMapObject( SvStream& rOStm ) const
+{
+ rOStm << aRect;
+}
+
+
+/******************************************************************************
+|*
+|* Binaer-Import
+|*
+\******************************************************************************/
+
+void IMapRectangleObject::ReadIMapObject( SvStream& rIStm )
+{
+ rIStm >> aRect;
+}
+
+
+/******************************************************************************
+|*
+|* Typ-Rueckgabe
+|*
+\******************************************************************************/
+
+UINT16 IMapRectangleObject::GetType() const
+{
+ return IMAP_OBJ_RECTANGLE;
+}
+
+
+/******************************************************************************
+|*
+|* Hit-Test
+|*
+\******************************************************************************/
+
+BOOL IMapRectangleObject::IsHit( const Point& rPoint ) const
+{
+ return aRect.IsInside( rPoint );
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+Rectangle IMapRectangleObject::GetRectangle( BOOL bPixelCoords ) const
+{
+ Rectangle aNewRect;
+
+ if ( bPixelCoords )
+ aNewRect = Application::GetDefaultDevice()->LogicToPixel( aRect, MapMode( MAP_100TH_MM ) );
+ else
+ aNewRect = aRect;
+
+ return aNewRect;
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void IMapRectangleObject::Scale( const Fraction& rFracX, const Fraction& rFracY )
+{
+ Point aTL( aRect.TopLeft() );
+ Point aBR( aRect.BottomRight() );
+
+ if ( rFracX.GetDenominator() && rFracY.GetDenominator() )
+ {
+ SCALEPOINT( aTL, rFracX, rFracY );
+ SCALEPOINT( aBR, rFracX, rFracY );
+ }
+
+ aRect = Rectangle( aTL, aBR );
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+BOOL IMapRectangleObject::IsEqual( const IMapRectangleObject& rEqObj )
+{
+ return ( IMapObject::IsEqual( rEqObj ) && ( aRect == rEqObj.aRect ) );
+}
+
+
+/******************************************************************************/
+/******************************************************************************/
+/******************************************************************************/
+
+IMapCircleObject::IMapCircleObject( const Point& rCenter, ULONG nCircleRadius,
+ const String& rURL,
+ const String& rAltText,
+ const String& rDesc,
+ const String& rTarget,
+ const String& rName,
+ BOOL bURLActive,
+ BOOL bPixelCoords ) :
+ IMapObject ( rURL, rAltText, rDesc, rTarget, rName, bURLActive )
+{
+ ImpConstruct( rCenter, nCircleRadius, bPixelCoords );
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void IMapCircleObject::ImpConstruct( const Point& rCenter, ULONG nRad, BOOL bPixel )
+{
+ if ( bPixel )
+ {
+ MapMode aMap100( MAP_100TH_MM );
+
+ aCenter = Application::GetDefaultDevice()->PixelToLogic( rCenter, aMap100 );
+ nRadius = Application::GetDefaultDevice()->PixelToLogic( Size( nRad, 0 ), aMap100 ).Width();
+ }
+ else
+ {
+ aCenter = rCenter;
+ nRadius = nRad;
+ }
+}
+
+
+/******************************************************************************
+|*
+|* Binaer-Export
+|*
+\******************************************************************************/
+
+void IMapCircleObject::WriteIMapObject( SvStream& rOStm ) const
+{
+ UINT32 nTmp = nRadius;
+
+ rOStm << aCenter;
+ rOStm << nTmp;
+}
+
+
+/******************************************************************************
+|*
+|* Binaer-Import
+|*
+\******************************************************************************/
+
+void IMapCircleObject::ReadIMapObject( SvStream& rIStm )
+{
+ UINT32 nTmp;
+
+ rIStm >> aCenter;
+ rIStm >> nTmp;
+
+ nRadius = nTmp;
+}
+
+
+/******************************************************************************
+|*
+|* Typ-Rueckgabe
+|*
+\******************************************************************************/
+
+UINT16 IMapCircleObject::GetType() const
+{
+ return IMAP_OBJ_CIRCLE;
+}
+
+
+/******************************************************************************
+|*
+|* Hit-Test
+|*
+\******************************************************************************/
+
+BOOL IMapCircleObject::IsHit( const Point& rPoint ) const
+{
+ const Point aPoint( aCenter - rPoint );
+ BOOL bRet = FALSE;
+
+ if ( (ULONG) sqrt( (double) aPoint.X() * aPoint.X() +
+ aPoint.Y() * aPoint.Y() ) <= nRadius )
+ {
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+Point IMapCircleObject::GetCenter( BOOL bPixelCoords ) const
+{
+ Point aNewPoint;
+
+ if ( bPixelCoords )
+ aNewPoint = Application::GetDefaultDevice()->LogicToPixel( aCenter, MapMode( MAP_100TH_MM ) );
+ else
+ aNewPoint = aCenter;
+
+ return aNewPoint;
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+ULONG IMapCircleObject::GetRadius( BOOL bPixelCoords ) const
+{
+ ULONG nNewRadius;
+
+ if ( bPixelCoords )
+ nNewRadius = Application::GetDefaultDevice()->LogicToPixel( Size( nRadius, 0 ), MapMode( MAP_100TH_MM ) ).Width();
+ else
+ nNewRadius = nRadius;
+
+ return nNewRadius;
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+Rectangle IMapCircleObject::GetBoundRect() const
+{
+ long nWidth = nRadius << 1;
+
+ return Rectangle( Point( aCenter.X() - nRadius, aCenter.Y() - nRadius ),
+ Size( nWidth, nWidth ) );
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void IMapCircleObject::Scale( const Fraction& rFracX, const Fraction& rFracY )
+{
+ Fraction aAverage( rFracX );
+
+ aAverage += rFracY;
+ aAverage *= Fraction( 1, 2 );
+
+ if ( rFracX.GetDenominator() && rFracY.GetDenominator() )
+ {
+ SCALEPOINT( aCenter, rFracX, rFracY );
+ }
+
+ nRadius = ( nRadius * aAverage.GetNumerator() ) / aAverage.GetDenominator();
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+BOOL IMapCircleObject::IsEqual( const IMapCircleObject& rEqObj )
+{
+ return ( IMapObject::IsEqual( rEqObj ) &&
+ ( aCenter == rEqObj.aCenter ) &&
+ ( nRadius == rEqObj.nRadius ) );
+}
+
+
+/******************************************************************************/
+/******************************************************************************/
+/******************************************************************************/
+IMapPolygonObject::IMapPolygonObject( const Polygon& rPoly,
+ const String& rURL,
+ const String& rAltText,
+ const String& rDesc,
+ const String& rTarget,
+ const String& rName,
+ BOOL bURLActive,
+ BOOL bPixelCoords ) :
+ IMapObject ( rURL, rAltText, rDesc, rTarget, rName, bURLActive ),
+ bEllipse ( FALSE )
+{
+ ImpConstruct( rPoly, bPixelCoords );
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void IMapPolygonObject::ImpConstruct( const Polygon& rPoly, BOOL bPixel )
+{
+ if ( bPixel )
+ aPoly = Application::GetDefaultDevice()->PixelToLogic( rPoly, MapMode( MAP_100TH_MM ) );
+ else
+ aPoly = rPoly;
+}
+
+
+/******************************************************************************
+|*
+|* Binaer-Export
+|*
+\******************************************************************************/
+
+void IMapPolygonObject::WriteIMapObject( SvStream& rOStm ) const
+{
+ rOStm << aPoly;
+ rOStm << bEllipse; // >= Version 2
+ rOStm << aEllipse; // >= Version 2
+}
+
+
+/******************************************************************************
+|*
+|* Binaer-Import
+|*
+\******************************************************************************/
+
+void IMapPolygonObject::ReadIMapObject( SvStream& rIStm )
+{
+ rIStm >> aPoly;
+
+ // Version >= 2 hat zusaetzlich Ellipsen-Information
+ if ( nReadVersion >= 2 )
+ {
+ rIStm >> bEllipse;
+ rIStm >> aEllipse;
+ }
+}
+
+
+/******************************************************************************
+|*
+|* Typ-Rueckgabe
+|*
+\******************************************************************************/
+
+UINT16 IMapPolygonObject::GetType() const
+{
+ return IMAP_OBJ_POLYGON;
+}
+
+
+/******************************************************************************
+|*
+|* Hit-Test
+|*
+\******************************************************************************/
+
+BOOL IMapPolygonObject::IsHit( const Point& rPoint ) const
+{
+ return aPoly.IsInside( rPoint );
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+Polygon IMapPolygonObject::GetPolygon( BOOL bPixelCoords ) const
+{
+ Polygon aNewPoly;
+
+ if ( bPixelCoords )
+ aNewPoly = Application::GetDefaultDevice()->LogicToPixel( aPoly, MapMode( MAP_100TH_MM ) );
+ else
+ aNewPoly = aPoly;
+
+ return aNewPoly;
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void IMapPolygonObject::SetExtraEllipse( const Rectangle& rEllipse )
+{
+ if ( aPoly.GetSize() )
+ {
+ bEllipse = TRUE;
+ aEllipse = rEllipse;
+ }
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void IMapPolygonObject::Scale( const Fraction& rFracX, const Fraction& rFracY )
+{
+ USHORT nCount = aPoly.GetSize();
+
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ Point aScaledPt( aPoly[ i ] );
+
+ if ( rFracX.GetDenominator() && rFracY.GetDenominator() )
+ {
+ SCALEPOINT( aScaledPt, rFracX, rFracY );
+ }
+
+ aPoly[ i ] = aScaledPt;
+ }
+
+ if ( bEllipse )
+ {
+ Point aTL( aEllipse.TopLeft() );
+ Point aBR( aEllipse.BottomRight() );
+
+ if ( rFracX.GetDenominator() && rFracY.GetDenominator() )
+ {
+ SCALEPOINT( aTL, rFracX, rFracY );
+ SCALEPOINT( aBR, rFracX, rFracY );
+ }
+
+ aEllipse = Rectangle( aTL, aBR );
+ }
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+BOOL IMapPolygonObject::IsEqual( const IMapPolygonObject& rEqObj )
+{
+ BOOL bRet = FALSE;
+
+ if ( IMapObject::IsEqual( rEqObj ) )
+ {
+ const Polygon& rEqPoly = rEqObj.aPoly;
+ const USHORT nCount = aPoly.GetSize();
+ const USHORT nEqCount = rEqPoly.GetSize();
+ BOOL bDifferent = FALSE;
+
+ if ( nCount == nEqCount )
+ {
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ if ( aPoly[ i ] != rEqPoly[ i ] )
+ {
+ bDifferent = TRUE;
+ break;
+ }
+ }
+
+ if ( !bDifferent )
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+
+/******************************************************************************/
+/******************************************************************************/
+/******************************************************************************/
+
+
+/******************************************************************************
+|*
+|* Ctor
+|*
+\******************************************************************************/
+
+ImageMap::ImageMap( const String& rName ) :
+ aName ( rName )
+{
+}
+
+
+/******************************************************************************
+|*
+|* Copy-Ctor
+|*
+\******************************************************************************/
+
+ImageMap::ImageMap( const ImageMap& rImageMap )
+{
+ DBG_CTOR( ImageMap, NULL );
+
+ USHORT nCount = rImageMap.GetIMapObjectCount();
+
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ IMapObject* pCopyObj = rImageMap.GetIMapObject( i );
+
+ switch( pCopyObj->GetType() )
+ {
+ case( IMAP_OBJ_RECTANGLE ):
+ maList.Insert( new IMapRectangleObject( *(IMapRectangleObject*) pCopyObj ), LIST_APPEND );
+ break;
+
+ case( IMAP_OBJ_CIRCLE ):
+ maList.Insert( new IMapCircleObject( *(IMapCircleObject*) pCopyObj ), LIST_APPEND );
+ break;
+
+ case( IMAP_OBJ_POLYGON ):
+ maList.Insert( new IMapPolygonObject( *(IMapPolygonObject*) pCopyObj ), LIST_APPEND );
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ aName = rImageMap.aName;
+}
+
+
+/******************************************************************************
+|*
+|* Dtor
+|*
+\******************************************************************************/
+
+ImageMap::~ImageMap()
+{
+ DBG_DTOR( ImageMap, NULL );
+
+ ClearImageMap();
+}
+
+
+/******************************************************************************
+|*
+|* Freigabe des internen Speichers
+|*
+\******************************************************************************/
+
+void ImageMap::ClearImageMap()
+{
+ IMapObject* pObj = (IMapObject*) maList.First();
+
+ while ( pObj )
+ {
+ delete pObj;
+ pObj = (IMapObject*) maList.Next();
+ }
+
+ maList.Clear();
+
+ aName = String();
+}
+
+
+/******************************************************************************
+|*
+|* Zuweisungsoperator
+|*
+\******************************************************************************/
+
+ImageMap& ImageMap::operator=( const ImageMap& rImageMap )
+{
+ USHORT nCount = rImageMap.GetIMapObjectCount();
+
+ ClearImageMap();
+
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ IMapObject* pCopyObj = rImageMap.GetIMapObject( i );
+
+ switch( pCopyObj->GetType() )
+ {
+ case( IMAP_OBJ_RECTANGLE ):
+ maList.Insert( new IMapRectangleObject( *(IMapRectangleObject*) pCopyObj ), LIST_APPEND );
+ break;
+
+ case( IMAP_OBJ_CIRCLE ):
+ maList.Insert( new IMapCircleObject( *(IMapCircleObject*) pCopyObj ), LIST_APPEND );
+ break;
+
+ case( IMAP_OBJ_POLYGON ):
+ maList.Insert( new IMapPolygonObject( *(IMapPolygonObject*) pCopyObj ), LIST_APPEND );
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ aName = rImageMap.aName;
+
+ return *this;
+}
+
+
+/******************************************************************************
+|*
+|* Vergleichsoperator I
+|*
+\******************************************************************************/
+
+BOOL ImageMap::operator==( const ImageMap& rImageMap )
+{
+ const USHORT nCount = (USHORT) maList.Count();
+ const USHORT nEqCount = rImageMap.GetIMapObjectCount();
+ BOOL bRet = FALSE;
+
+ if ( nCount == nEqCount )
+ {
+ BOOL bDifferent = ( aName != rImageMap.aName );
+
+ for ( USHORT i = 0; ( i < nCount ) && !bDifferent; i++ )
+ {
+ IMapObject* pObj = (IMapObject*) maList.GetObject( i );
+ IMapObject* pEqObj = rImageMap.GetIMapObject( i );
+
+ if ( pObj->GetType() == pEqObj->GetType() )
+ {
+ switch( pObj->GetType() )
+ {
+ case( IMAP_OBJ_RECTANGLE ):
+ {
+ if ( !( (IMapRectangleObject*) pObj )->IsEqual( *(IMapRectangleObject*) pEqObj ) )
+ bDifferent = TRUE;
+ }
+ break;
+
+ case( IMAP_OBJ_CIRCLE ):
+ {
+ if ( !( (IMapCircleObject*) pObj )->IsEqual( *(IMapCircleObject*) pEqObj ) )
+ bDifferent = TRUE;
+ }
+ break;
+
+ case( IMAP_OBJ_POLYGON ):
+ {
+ if ( !( (IMapPolygonObject*) pObj )->IsEqual( *(IMapPolygonObject*) pEqObj ) )
+ bDifferent = TRUE;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ else
+ bDifferent = TRUE;
+ }
+
+ if ( !bDifferent )
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+
+/******************************************************************************
+|*
+|* Vergleichsoperator II
+|*
+\******************************************************************************/
+
+BOOL ImageMap::operator!=( const ImageMap& rImageMap )
+{
+ return !( *this == rImageMap );
+}
+
+
+/******************************************************************************
+|*
+|* Freigabe des internen Speichers
+|*
+\******************************************************************************/
+
+UINT16 ImageMap::GetVersion() const
+{
+ return IMAGE_MAP_VERSION;
+}
+
+
+/******************************************************************************
+|*
+|* Einfuegen eines neuen Objekts
+|*
+\******************************************************************************/
+
+void ImageMap::InsertIMapObject( const IMapObject& rIMapObject )
+{
+ switch( rIMapObject.GetType() )
+ {
+ case( IMAP_OBJ_RECTANGLE ):
+ maList.Insert( new IMapRectangleObject( (IMapRectangleObject&) rIMapObject ), LIST_APPEND );
+ break;
+
+ case( IMAP_OBJ_CIRCLE ):
+ maList.Insert( new IMapCircleObject( (IMapCircleObject&) rIMapObject ), LIST_APPEND );
+ break;
+
+ case( IMAP_OBJ_POLYGON ):
+ maList.Insert( new IMapPolygonObject( (IMapPolygonObject&) rIMapObject ), LIST_APPEND );
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+/******************************************************************************
+|*
+|* Hit-Test
+|*
+\******************************************************************************/
+
+IMapObject* ImageMap::GetHitIMapObject( const Size& rTotalSize,
+ const Size& rDisplaySize,
+ const Point& rRelHitPoint,
+ ULONG nFlags )
+{
+ Point aRelPoint( rTotalSize.Width() * rRelHitPoint.X() / rDisplaySize.Width(),
+ rTotalSize.Height() * rRelHitPoint.Y() / rDisplaySize.Height() );
+
+ // Falls Flags zur Spiegelung etc. angegeben sind, wird
+ // der zu pruefende Punkt vor der Pruefung entspr. transformiert
+ if ( nFlags )
+ {
+ if ( nFlags & IMAP_MIRROR_HORZ )
+ aRelPoint.X() = rTotalSize.Width() - aRelPoint.X();
+
+ if ( nFlags & IMAP_MIRROR_VERT )
+ aRelPoint.Y() = rTotalSize.Height() - aRelPoint.Y();
+ }
+
+ // Alle Objekte durchlaufen und HitTest ausfuehren
+ IMapObject* pObj = (IMapObject*) maList.First();
+ while ( pObj )
+ {
+ if ( pObj->IsHit( aRelPoint ) )
+ break;
+
+ pObj = (IMapObject*) maList.Next();
+ }
+
+ return( pObj ? ( pObj->IsActive() ? pObj : NULL ) : NULL );
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+Rectangle ImageMap::GetBoundRect() const
+{
+ Rectangle aBoundRect;
+ ULONG nCount = maList.Count();
+
+ for ( ULONG i = 0; i < nCount; i++ )
+ aBoundRect.Union( ( (IMapObject*) maList.GetObject( i ) )->GetBoundRect() );
+
+ return aBoundRect;
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void ImageMap::Scale( const Fraction& rFracX, const Fraction& rFracY )
+{
+ USHORT nCount = (USHORT) maList.Count();
+
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ IMapObject* pObj = GetIMapObject( i );
+
+ switch( pObj->GetType() )
+ {
+ case( IMAP_OBJ_RECTANGLE ):
+ ( (IMapRectangleObject*) pObj )->Scale( rFracX, rFracY );
+ break;
+
+ case( IMAP_OBJ_CIRCLE ):
+ ( (IMapCircleObject*) pObj )->Scale( rFracX, rFracY );
+ break;
+
+ case( IMAP_OBJ_POLYGON ):
+ ( (IMapPolygonObject*) pObj )->Scale( rFracX, rFracY );
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+
+/******************************************************************************
+|*
+|* Objekte nacheinander wegschreiben
+|*
+\******************************************************************************/
+
+void ImageMap::ImpWriteImageMap( SvStream& rOStm, const String& rBaseURL ) const
+{
+ IMapObject* pObj;
+ USHORT nCount = (USHORT) maList.Count();
+
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ pObj = (IMapObject*) maList.GetObject( i );
+ pObj->Write( rOStm, rBaseURL );
+ }
+}
+
+
+/******************************************************************************
+|*
+|* Objekte nacheinander lesen
+|*
+\******************************************************************************/
+
+void ImageMap::ImpReadImageMap( SvStream& rIStm, USHORT nCount, const String& rBaseURL )
+{
+ // neue Objekte einlesen
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ UINT16 nType;
+
+ rIStm >> nType;
+ rIStm.SeekRel( -2 );
+
+ switch( nType )
+ {
+ case ( IMAP_OBJ_RECTANGLE ):
+ {
+ IMapRectangleObject* pObj = new IMapRectangleObject;
+ pObj->Read( rIStm, rBaseURL );
+ maList.Insert( pObj, LIST_APPEND );
+ }
+ break;
+
+ case ( IMAP_OBJ_CIRCLE ):
+ {
+ IMapCircleObject* pObj = new IMapCircleObject;
+ pObj->Read( rIStm, rBaseURL );
+ maList.Insert( pObj, LIST_APPEND );
+ }
+ break;
+
+ case ( IMAP_OBJ_POLYGON ):
+ {
+ IMapPolygonObject* pObj = new IMapPolygonObject;
+ pObj->Read( rIStm, rBaseURL );
+ maList.Insert( pObj, LIST_APPEND );
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+
+/******************************************************************************
+|*
+|* Binaer speichern
+|*
+\******************************************************************************/
+
+void ImageMap::Write( SvStream& rOStm, const String& rBaseURL ) const
+{
+ IMapCompat* pCompat;
+ String aImageName( GetName() );
+ String aDummy;
+ USHORT nOldFormat = rOStm.GetNumberFormatInt();
+ UINT16 nCount = (UINT16) GetIMapObjectCount();
+ const rtl_TextEncoding eEncoding = gsl_getSystemTextEncoding();
+
+ rOStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+
+ // MagicCode schreiben
+ rOStm << IMAPMAGIC;
+ rOStm << GetVersion();
+ rOStm.WriteByteString( ByteString( aImageName, eEncoding ) );
+ rOStm.WriteByteString( ByteString( aDummy, eEncoding ) );
+ rOStm << nCount;
+ rOStm.WriteByteString( ByteString( aImageName, eEncoding ) );
+
+ pCompat = new IMapCompat( rOStm, STREAM_WRITE );
+
+ // hier kann in neueren Versionen eingefuegt werden
+
+ delete pCompat;
+
+ ImpWriteImageMap( rOStm, rBaseURL );
+
+ rOStm.SetNumberFormatInt( nOldFormat );
+}
+
+
+/******************************************************************************
+|*
+|* Binaer laden
+|*
+\******************************************************************************/
+
+void ImageMap::Read( SvStream& rIStm, const String& rBaseURL )
+{
+ ByteString aString;
+ char cMagic[6];
+ USHORT nOldFormat = rIStm.GetNumberFormatInt();
+ UINT16 nCount;
+
+ rIStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ rIStm.Read( cMagic, sizeof( cMagic ) );
+
+ if ( !memcmp( cMagic, IMAPMAGIC, sizeof( cMagic ) ) )
+ {
+ IMapCompat* pCompat;
+
+ // alten Inhalt loeschen
+ ClearImageMap();
+
+ // Version ueberlesen wir
+ rIStm.SeekRel( 2 );
+
+ rIStm.ReadByteString( aString ); aName = String( aString, gsl_getSystemTextEncoding() );
+ rIStm.ReadByteString( aString ); // Dummy
+ rIStm >> nCount;
+ rIStm.ReadByteString( aString ); // Dummy
+
+ pCompat = new IMapCompat( rIStm, STREAM_READ );
+
+ // hier kann in neueren Versionen gelesen werden
+
+ delete pCompat;
+ ImpReadImageMap( rIStm, nCount, rBaseURL );
+
+ }
+ else
+ rIStm.SetError( SVSTREAM_GENERALERROR );
+
+ rIStm.SetNumberFormatInt( nOldFormat );
+}
+
diff --git a/svtools/source/misc/imap2.cxx b/svtools/source/misc/imap2.cxx
new file mode 100644
index 000000000000..587a31d4f098
--- /dev/null
+++ b/svtools/source/misc/imap2.cxx
@@ -0,0 +1,751 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include <string.h>
+// #include <math.h>
+#include <vcl/svapp.hxx>
+#include <tools/urlobj.hxx>
+#ifndef _WRKWIN_HXX //autogen
+#include <vcl/wrkwin.hxx>
+#endif
+#include <sot/formats.hxx>
+
+#include "svl/urihelper.hxx"
+#include <svtools/imap.hxx>
+#include <svtools/imap.hxx>
+#include <svtools/imapobj.hxx>
+#include <svtools/imaprect.hxx>
+#include <svtools/imapcirc.hxx>
+#include <svtools/imappoly.hxx>
+
+#include <string.h>
+#include <math.h>
+
+#define NOTEOL(c) ((c)!='\0')
+
+
+TYPEINIT0_AUTOFACTORY( ImageMap );
+
+
+/******************************************************************************/
+/******************************************************************************/
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void IMapObject::AppendCERNCoords( const Point& rPoint100, ByteString& rStr ) const
+{
+ const Point aPixPt( Application::GetDefaultDevice()->LogicToPixel( rPoint100, MapMode( MAP_100TH_MM ) ) );
+
+ rStr += '(';
+ rStr += ByteString::CreateFromInt32( aPixPt.X() );
+ rStr += ',';
+ rStr += ByteString::CreateFromInt32( aPixPt.Y() );
+ rStr += ") ";
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void IMapObject::AppendNCSACoords( const Point& rPoint100, ByteString& rStr ) const
+{
+ const Point aPixPt( Application::GetDefaultDevice()->LogicToPixel( rPoint100, MapMode( MAP_100TH_MM ) ) );
+
+ rStr += ByteString::CreateFromInt32( aPixPt.X() );
+ rStr += ',';
+ rStr += ByteString::CreateFromInt32( aPixPt.Y() );
+ rStr += ' ';
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void IMapObject::AppendCERNURL( ByteString& rStr, const String& rBaseURL ) const
+{
+ rStr += ByteString( String(URIHelper::simpleNormalizedMakeRelative( rBaseURL, aURL )), gsl_getSystemTextEncoding() );
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void IMapObject::AppendNCSAURL( ByteString& rStr, const String& rBaseURL ) const
+{
+ rStr += ByteString( String(URIHelper::simpleNormalizedMakeRelative( rBaseURL, aURL )), gsl_getSystemTextEncoding() );
+ rStr += ' ';
+}
+
+
+/******************************************************************************/
+/******************************************************************************/
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void IMapRectangleObject::WriteCERN( SvStream& rOStm, const String& rBaseURL ) const
+{
+ ByteString aStr( "rectangle " );
+
+ AppendCERNCoords( aRect.TopLeft(), aStr );
+ AppendCERNCoords( aRect.BottomRight(), aStr );
+ AppendCERNURL( aStr, rBaseURL );
+
+ rOStm.WriteLine( aStr );
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void IMapRectangleObject::WriteNCSA( SvStream& rOStm, const String& rBaseURL ) const
+{
+ ByteString aStr( "rect " );
+
+ AppendNCSAURL( aStr, rBaseURL );
+ AppendNCSACoords( aRect.TopLeft(), aStr );
+ AppendNCSACoords( aRect.BottomRight(), aStr );
+
+ rOStm.WriteLine( aStr );
+}
+
+
+/******************************************************************************/
+/******************************************************************************/
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void IMapCircleObject::WriteCERN( SvStream& rOStm, const String& rBaseURL ) const
+{
+ ByteString aStr( "circle " );
+
+ AppendCERNCoords( aCenter, aStr );
+ aStr += ByteString::CreateFromInt32(nRadius);
+ aStr += ' ';
+ AppendCERNURL( aStr, rBaseURL );
+
+ rOStm.WriteLine( aStr );
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void IMapCircleObject::WriteNCSA( SvStream& rOStm, const String& rBaseURL ) const
+{
+ ByteString aStr( "circle " );
+
+ AppendNCSAURL( aStr, rBaseURL );
+ AppendNCSACoords( aCenter, aStr );
+ AppendNCSACoords( aCenter + Point( nRadius, 0 ), aStr );
+
+ rOStm.WriteLine( aStr );
+}
+
+
+/******************************************************************************/
+/******************************************************************************/
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void IMapPolygonObject::WriteCERN( SvStream& rOStm, const String& rBaseURL ) const
+{
+ ByteString aStr( "polygon " );
+ const USHORT nCount = aPoly.GetSize();
+
+ for ( USHORT i = 0; i < nCount; i++ )
+ AppendCERNCoords( aPoly[ i ], aStr );
+
+ AppendCERNURL( aStr, rBaseURL );
+
+ rOStm.WriteLine( aStr );
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void IMapPolygonObject::WriteNCSA( SvStream& rOStm, const String& rBaseURL ) const
+{
+ ByteString aStr( "poly " );
+ const USHORT nCount = Min( aPoly.GetSize(), (USHORT) 100 );
+
+ AppendNCSAURL( aStr, rBaseURL );
+
+ for ( USHORT i = 0; i < nCount; i++ )
+ AppendNCSACoords( aPoly[ i ], aStr );
+
+ rOStm.WriteLine( aStr );
+}
+
+
+/******************************************************************************/
+/******************************************************************************/
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void ImageMap::Write( SvStream& rOStm, ULONG nFormat, const String& rBaseURL ) const
+{
+ switch( nFormat )
+ {
+ case( IMAP_FORMAT_BIN ) : Write( rOStm, rBaseURL );
+ case( IMAP_FORMAT_CERN ) : ImpWriteCERN( rOStm, rBaseURL ); break;
+ case( IMAP_FORMAT_NCSA ) : ImpWriteNCSA( rOStm, rBaseURL ); break;
+
+ default:
+ break;
+ }
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void ImageMap::ImpWriteCERN( SvStream& rOStm, const String& rBaseURL ) const
+{
+ IMapObject* pObj;
+ USHORT nCount = (USHORT) maList.Count();
+
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ pObj = GetIMapObject( i );
+
+ switch( pObj->GetType() )
+ {
+ case( IMAP_OBJ_RECTANGLE ):
+ ( (IMapRectangleObject*) pObj )->WriteCERN( rOStm, rBaseURL );
+ break;
+
+ case( IMAP_OBJ_CIRCLE ):
+ ( (IMapCircleObject*) pObj )->WriteCERN( rOStm, rBaseURL );
+ break;
+
+ case( IMAP_OBJ_POLYGON ):
+ ( (IMapPolygonObject*) pObj )->WriteCERN( rOStm, rBaseURL );
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void ImageMap::ImpWriteNCSA( SvStream& rOStm, const String& rBaseURL ) const
+{
+ IMapObject* pObj;
+ USHORT nCount = (USHORT) maList.Count();
+
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ pObj = GetIMapObject( i );
+
+ switch( pObj->GetType() )
+ {
+ case( IMAP_OBJ_RECTANGLE ):
+ ( (IMapRectangleObject*) pObj )->WriteNCSA( rOStm, rBaseURL );
+ break;
+
+ case( IMAP_OBJ_CIRCLE ):
+ ( (IMapCircleObject*) pObj )->WriteNCSA( rOStm, rBaseURL );
+ break;
+
+ case( IMAP_OBJ_POLYGON ):
+ ( (IMapPolygonObject*) pObj )->WriteNCSA( rOStm, rBaseURL );
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+ULONG ImageMap::Read( SvStream& rIStm, ULONG nFormat, const String& rBaseURL )
+{
+ ULONG nRet = IMAP_ERR_FORMAT;
+
+ if ( nFormat == IMAP_FORMAT_DETECT )
+ nFormat = ImpDetectFormat( rIStm );
+
+ switch ( nFormat )
+ {
+ case ( IMAP_FORMAT_BIN ) : Read( rIStm, rBaseURL ); break;
+ case ( IMAP_FORMAT_CERN ) : nRet = ImpReadCERN( rIStm, rBaseURL ); break;
+ case ( IMAP_FORMAT_NCSA ) : nRet = ImpReadNCSA( rIStm, rBaseURL ); break;
+
+ default:
+ break;
+ }
+
+ if ( !rIStm.GetError() )
+ nRet = IMAP_ERR_OK;
+
+ return nRet;
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+ULONG ImageMap::ImpReadCERN( SvStream& rIStm, const String& rBaseURL )
+{
+ ByteString aStr;
+
+ // alten Inhalt loeschen
+ ClearImageMap();
+
+ while ( rIStm.ReadLine( aStr ) )
+ ImpReadCERNLine( aStr, rBaseURL );
+
+ return IMAP_ERR_OK;
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void ImageMap::ImpReadCERNLine( const ByteString& rLine, const String& rBaseURL )
+{
+ ByteString aStr( rLine );
+ ByteString aToken;
+
+ aStr.EraseLeadingChars( ' ' );
+ aStr.EraseLeadingChars( '\t' );
+ aStr.EraseAllChars( ';' );
+ aStr.ToLowerAscii();
+
+ const char* pStr = aStr.GetBuffer();
+ char cChar = *pStr++;
+
+ // Anweisung finden
+ while( ( cChar >= 'a' ) && ( cChar <= 'z' ) && NOTEOL( cChar ) )
+ {
+ aToken += cChar;
+ cChar = *pStr++;
+ }
+
+ if ( NOTEOL( cChar ) )
+ {
+ if ( ( aToken == "rectangle" ) || ( aToken == "rect" ) )
+ {
+ const Point aTopLeft( ImpReadCERNCoords( &pStr ) );
+ const Point aBottomRight( ImpReadCERNCoords( &pStr ) );
+ const String aURL( ImpReadCERNURL( &pStr, rBaseURL ) );
+ const Rectangle aRect( aTopLeft, aBottomRight );
+
+ IMapRectangleObject* pObj = new IMapRectangleObject( aRect, aURL, String(), String(), String(), String() );
+ maList.Insert( pObj, LIST_APPEND );
+ }
+ else if ( ( aToken == "circle" ) || ( aToken == "circ" ) )
+ {
+ const Point aCenter( ImpReadCERNCoords( &pStr ) );
+ const long nRadius = ImpReadCERNRadius( &pStr );
+ const String aURL( ImpReadCERNURL( &pStr, rBaseURL ) );
+
+ IMapCircleObject* pObj = new IMapCircleObject( aCenter, nRadius, aURL, String(), String(), String(), String() );
+ maList.Insert( pObj, LIST_APPEND );
+ }
+ else if ( ( aToken == "polygon" ) || ( aToken == "poly" ) )
+ {
+ const USHORT nCount = aStr.GetTokenCount( '(' ) - 1;
+ Polygon aPoly( nCount );
+ String aURL;
+
+ for ( USHORT i = 0; i < nCount; i++ )
+ aPoly[ i ] = ImpReadCERNCoords( &pStr );
+
+ aURL = ImpReadCERNURL( &pStr, rBaseURL );
+
+ IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, aURL, String(), String(), String(), String() );
+ maList.Insert( pObj, LIST_APPEND );
+ }
+ }
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+Point ImageMap::ImpReadCERNCoords( const char** ppStr )
+{
+ String aStrX;
+ String aStrY;
+ Point aPt;
+ char cChar = *(*ppStr)++;
+
+ while( NOTEOL( cChar ) && ( ( cChar < '0' ) || ( cChar > '9' ) ) )
+ cChar = *(*ppStr)++;
+
+ if ( NOTEOL( cChar ) )
+ {
+ while( NOTEOL( cChar ) && ( cChar >= '0' ) && ( cChar <= '9' ) )
+ {
+ aStrX += cChar;
+ cChar = *(*ppStr)++;
+ }
+
+ if ( NOTEOL( cChar ) )
+ {
+ while( NOTEOL( cChar ) && ( ( cChar < '0' ) || ( cChar > '9' ) ) )
+ cChar = *(*ppStr)++;
+
+ while( NOTEOL( cChar ) && ( cChar >= '0' ) && ( cChar <= '9' ) )
+ {
+ aStrY += cChar;
+ cChar = *(*ppStr)++;
+ }
+
+ if ( NOTEOL( cChar ) )
+ while( NOTEOL( cChar ) && ( cChar != ')' ) )
+ cChar = *(*ppStr)++;
+
+ aPt = Point( aStrX.ToInt32(), aStrY.ToInt32() );
+ }
+ }
+
+ return aPt;
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+long ImageMap::ImpReadCERNRadius( const char** ppStr )
+{
+ String aStr;
+ char cChar = *(*ppStr)++;
+
+ while( NOTEOL( cChar ) && ( ( cChar < '0' ) || ( cChar > '9' ) ) )
+ cChar = *(*ppStr)++;
+
+ if ( NOTEOL( cChar ) )
+ {
+ while( NOTEOL( cChar ) && ( cChar >= '0' ) && ( cChar <= '9' ) )
+ {
+ aStr += cChar;
+ cChar = *(*ppStr)++;
+ }
+ }
+
+ return aStr.ToInt32();
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+String ImageMap::ImpReadCERNURL( const char** ppStr, const String& rBaseURL )
+{
+ String aStr( String::CreateFromAscii( *ppStr ) );
+
+ aStr.EraseLeadingChars( ' ' );
+ aStr.EraseLeadingChars( '\t' );
+ aStr.EraseTrailingChars( ' ' );
+ aStr.EraseTrailingChars( '\t' );
+
+ return INetURLObject::GetAbsURL( rBaseURL, aStr );
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+ULONG ImageMap::ImpReadNCSA( SvStream& rIStm, const String& rBaseURL )
+{
+ ByteString aStr;
+
+ // alten Inhalt loeschen
+ ClearImageMap();
+
+ while ( rIStm.ReadLine( aStr ) )
+ ImpReadNCSALine( aStr, rBaseURL );
+
+ return IMAP_ERR_OK;
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+void ImageMap::ImpReadNCSALine( const ByteString& rLine, const String& rBaseURL )
+{
+ ByteString aStr( rLine );
+ ByteString aToken;
+
+ aStr.EraseLeadingChars( ' ' );
+ aStr.EraseLeadingChars( '\t' );
+ aStr.EraseAllChars( ';' );
+ aStr.ToLowerAscii();
+
+ const char* pStr = aStr.GetBuffer();
+ char cChar = *pStr++;
+
+ // Anweisung finden
+ while( ( cChar >= 'a' ) && ( cChar <= 'z' ) && NOTEOL( cChar ) )
+ {
+ aToken += cChar;
+ cChar = *pStr++;
+ }
+
+ if ( NOTEOL( cChar ) )
+ {
+ if ( aToken == "rect" )
+ {
+ const String aURL( ImpReadNCSAURL( &pStr, rBaseURL ) );
+ const Point aTopLeft( ImpReadNCSACoords( &pStr ) );
+ const Point aBottomRight( ImpReadNCSACoords( &pStr ) );
+ const Rectangle aRect( aTopLeft, aBottomRight );
+
+ IMapRectangleObject* pObj = new IMapRectangleObject( aRect, aURL, String(), String(), String(), String() );
+ maList.Insert( pObj, LIST_APPEND );
+ }
+ else if ( aToken == "circle" )
+ {
+ const String aURL( ImpReadNCSAURL( &pStr, rBaseURL ) );
+ const Point aCenter( ImpReadNCSACoords( &pStr ) );
+ const Point aDX( aCenter - ImpReadNCSACoords( &pStr ) );
+ long nRadius = (long) sqrt( (double) aDX.X() * aDX.X() +
+ (double) aDX.Y() * aDX.Y() );
+
+ IMapCircleObject* pObj = new IMapCircleObject( aCenter, nRadius, aURL, String(), String(), String(), String() );
+ maList.Insert( pObj, LIST_APPEND );
+ }
+ else if ( aToken == "poly" )
+ {
+ const USHORT nCount = aStr.GetTokenCount( ',' ) - 1;
+ const String aURL( ImpReadNCSAURL( &pStr, rBaseURL ) );
+ Polygon aPoly( nCount );
+
+ for ( USHORT i = 0; i < nCount; i++ )
+ aPoly[ i ] = ImpReadNCSACoords( &pStr );
+
+ IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, aURL, String(), String(), String(), String() );
+ maList.Insert( pObj, LIST_APPEND );
+ }
+ }
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+String ImageMap::ImpReadNCSAURL( const char** ppStr, const String& rBaseURL )
+{
+ String aStr;
+ char cChar = *(*ppStr)++;
+
+ while( NOTEOL( cChar ) && ( ( cChar == ' ' ) || ( cChar == '\t' ) ) )
+ cChar = *(*ppStr)++;
+
+ if ( NOTEOL( cChar ) )
+ {
+ while( NOTEOL( cChar ) && ( cChar != ' ' ) && ( cChar != '\t' ) )
+ {
+ aStr += cChar;
+ cChar = *(*ppStr)++;
+ }
+ }
+
+ return INetURLObject::GetAbsURL( rBaseURL, aStr );
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+Point ImageMap::ImpReadNCSACoords( const char** ppStr )
+{
+ String aStrX;
+ String aStrY;
+ Point aPt;
+ char cChar = *(*ppStr)++;
+
+ while( NOTEOL( cChar ) && ( ( cChar < '0' ) || ( cChar > '9' ) ) )
+ cChar = *(*ppStr)++;
+
+ if ( NOTEOL( cChar ) )
+ {
+ while( NOTEOL( cChar ) && ( cChar >= '0' ) && ( cChar <= '9' ) )
+ {
+ aStrX += cChar;
+ cChar = *(*ppStr)++;
+ }
+
+ if ( NOTEOL( cChar ) )
+ {
+ while( NOTEOL( cChar ) && ( ( cChar < '0' ) || ( cChar > '9' ) ) )
+ cChar = *(*ppStr)++;
+
+ while( NOTEOL( cChar ) && ( cChar >= '0' ) && ( cChar <= '9' ) )
+ {
+ aStrY += cChar;
+ cChar = *(*ppStr)++;
+ }
+
+ aPt = Point( aStrX.ToInt32(), aStrY.ToInt32() );
+ }
+ }
+
+ return aPt;
+}
+
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+ULONG ImageMap::ImpDetectFormat( SvStream& rIStm )
+{
+ ULONG nPos = rIStm.Tell();
+ ULONG nRet = IMAP_FORMAT_BIN;
+ char cMagic[6];
+
+ rIStm.Read( cMagic, sizeof( cMagic ) );
+
+ // Falls wir kein internes Format haben,
+ // untersuchen wir das Format
+ if ( memcmp( cMagic, IMAPMAGIC, sizeof( cMagic ) ) )
+ {
+ ByteString aStr;
+ long nCount = 128;
+
+ rIStm.Seek( nPos );
+ while ( rIStm.ReadLine( aStr ) && nCount-- )
+ {
+ aStr.ToLowerAscii();
+
+ if ( ( aStr.Search( "rect" ) != STRING_NOTFOUND ) ||
+ ( aStr.Search( "circ" ) != STRING_NOTFOUND ) ||
+ ( aStr.Search( "poly" ) != STRING_NOTFOUND ) )
+ {
+ if ( ( aStr.Search( '(' ) != STRING_NOTFOUND ) &&
+ ( aStr.Search( ')' ) != STRING_NOTFOUND ) )
+ {
+ nRet = IMAP_FORMAT_CERN;
+ }
+ else
+ nRet = IMAP_FORMAT_NCSA;
+
+ break;
+ }
+ }
+ }
+
+ rIStm.Seek( nPos );
+
+ return nRet;
+}
diff --git a/svtools/source/misc/imap3.cxx b/svtools/source/misc/imap3.cxx
new file mode 100644
index 000000000000..76763ae422f2
--- /dev/null
+++ b/svtools/source/misc/imap3.cxx
@@ -0,0 +1,97 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+
+#include <svtools/imap.hxx>
+
+#include <tools/debug.hxx>
+
+
+/******************************************************************************
+|*
+|* Ctor
+|*
+\******************************************************************************/
+
+IMapCompat::IMapCompat( SvStream& rStm, const USHORT nStreamMode ) :
+ pRWStm ( &rStm ),
+ nStmMode ( nStreamMode )
+{
+ DBG_ASSERT( nStreamMode == STREAM_READ || nStreamMode == STREAM_WRITE, "Wrong Mode!" );
+
+ if ( !pRWStm->GetError() )
+ {
+ if ( nStmMode == STREAM_WRITE )
+ {
+ nCompatPos = pRWStm->Tell();
+ pRWStm->SeekRel( 4 );
+ nTotalSize = nCompatPos + 4;
+ }
+ else
+ {
+ UINT32 nTotalSizeTmp;
+ *pRWStm >> nTotalSizeTmp;
+ nTotalSize = nTotalSizeTmp;
+ nCompatPos = pRWStm->Tell();
+ }
+ }
+}
+
+
+/******************************************************************************
+|*
+|* Dtor
+|*
+\******************************************************************************/
+
+IMapCompat::~IMapCompat()
+{
+ if ( !pRWStm->GetError() )
+ {
+ if ( nStmMode == STREAM_WRITE )
+ {
+ const ULONG nEndPos = pRWStm->Tell();
+
+ pRWStm->Seek( nCompatPos );
+ *pRWStm << (UINT32) ( nEndPos - nTotalSize );
+ pRWStm->Seek( nEndPos );
+ }
+ else
+ {
+ const ULONG nReadSize = pRWStm->Tell() - nCompatPos;
+
+ if ( nTotalSize > nReadSize )
+ pRWStm->SeekRel( nTotalSize - nReadSize );
+ }
+ }
+}
+
+
+
diff --git a/svtools/source/misc/itemdel.cxx b/svtools/source/misc/itemdel.cxx
new file mode 100644
index 000000000000..559d31cdeb1d
--- /dev/null
+++ b/svtools/source/misc/itemdel.cxx
@@ -0,0 +1,135 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include "itemdel.hxx"
+#include <vcl/svapp.hxx>
+#include <tools/errcode.hxx>
+#include <limits.h>
+
+#include <svtools/svtdata.hxx>
+#include <svl/svarray.hxx>
+#include <svl/itempool.hxx>
+
+// STATIC DATA -----------------------------------------------------------
+
+DBG_NAME(SfxItemDesruptor_Impl);
+
+// -----------------------------------------------------------------------
+
+class SfxItemDesruptor_Impl
+{
+ SfxPoolItem *pItem;
+ Link aLink;
+
+private:
+ DECL_LINK( Delete, void * );
+ SfxItemDesruptor_Impl( const SfxItemDesruptor_Impl& ); // n.i.
+
+public:
+ SfxItemDesruptor_Impl( SfxPoolItem *pItemToDesrupt );
+ ~SfxItemDesruptor_Impl();
+};
+
+SV_DECL_PTRARR( SfxItemDesruptorList_Impl, SfxItemDesruptor_Impl*, 4, 4 )
+
+// ------------------------------------------------------------------------
+SfxItemDesruptor_Impl::SfxItemDesruptor_Impl( SfxPoolItem *pItemToDesrupt ):
+ pItem(pItemToDesrupt),
+ aLink( LINK(this, SfxItemDesruptor_Impl, Delete) )
+{
+ DBG_CTOR(SfxItemDesruptor_Impl, 0);
+
+ DBG_ASSERT( 0 == pItem->GetRefCount(), "desrupting pooled item" );
+ pItem->SetKind( SFX_ITEMS_DELETEONIDLE );
+
+ // im Idle abarbeiten
+ GetpApp()->InsertIdleHdl( aLink, 1 );
+
+ // und in Liste eintragen (damit geflusht werden kann)
+ SfxItemDesruptorList_Impl* &rpList = ImpSvtData::GetSvtData().pItemDesruptList;
+ if ( !rpList )
+ rpList = new SfxItemDesruptorList_Impl;
+ const SfxItemDesruptor_Impl *pThis = this;
+ rpList->Insert( pThis, rpList->Count() );
+}
+
+// ------------------------------------------------------------------------
+SfxItemDesruptor_Impl::~SfxItemDesruptor_Impl()
+{
+ DBG_DTOR(SfxItemDesruptor_Impl, 0);
+
+ // aus Idle-Handler austragen
+ GetpApp()->RemoveIdleHdl( aLink );
+
+ // und aus Liste austragen
+ SfxItemDesruptorList_Impl* &rpList = ImpSvtData::GetSvtData().pItemDesruptList;
+ DBG_ASSERT( rpList, "no DesruptorList" );
+ const SfxItemDesruptor_Impl *pThis = this;
+ if ( rpList ) HACK(warum?)
+ rpList->Remove( rpList->GetPos(pThis) );
+
+ // reset RefCount (was set to SFX_ITEMS_SPECIAL before!)
+ pItem->SetRefCount( 0 );
+ //DBG_CHKOBJ( pItem, SfxPoolItem, 0 );
+ delete pItem;
+}
+
+// ------------------------------------------------------------------------
+IMPL_LINK( SfxItemDesruptor_Impl, Delete, void *, EMPTYARG )
+{
+ {DBG_CHKTHIS(SfxItemDesruptor_Impl, 0);}
+ delete this;
+ return 0;
+}
+
+// ------------------------------------------------------------------------
+SfxPoolItem* DeleteItemOnIdle( SfxPoolItem* pItem )
+{
+ DBG_ASSERT( 0 == pItem->GetRefCount(), "deleting item in use" );
+ new SfxItemDesruptor_Impl( pItem );
+ return pItem;
+}
+
+// ------------------------------------------------------------------------
+void DeleteOnIdleItems()
+{
+ SfxItemDesruptorList_Impl* &rpList
+ = ImpSvtData::GetSvtData().pItemDesruptList;
+ if ( rpList )
+ {
+ USHORT n;
+ while ( 0 != ( n = rpList->Count() ) )
+ // Remove ist implizit im Dtor
+ delete rpList->GetObject( n-1 );
+ DELETEZ(rpList);
+ }
+}
+
+
diff --git a/svtools/source/misc/langtab.cxx b/svtools/source/misc/langtab.cxx
new file mode 100644
index 000000000000..d1ff94572a99
--- /dev/null
+++ b/svtools/source/misc/langtab.cxx
@@ -0,0 +1,208 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+// include ---------------------------------------------------------------
+
+#include <tools/shl.hxx>
+#include <tools/debug.hxx>
+
+//#include <com/sun/star/i18n/XCharacterClassification.hpp>
+#include <com/sun/star/i18n/DirectionProperty.hpp>
+
+#include <i18npool/lang.h>
+#include <i18npool/mslangid.hxx>
+
+#include <svtools/svtools.hrc>
+#include <svtools/svtdata.hxx>
+#include <svtools/langtab.hxx>
+#include <unotools/syslocale.hxx>
+
+
+using namespace ::com::sun::star;
+
+//------------------------------------------------------------------------
+
+SVT_DLLPUBLIC const String ApplyLreOrRleEmbedding( const String &rText )
+{
+ const USHORT nLen = rText.Len();
+ if (nLen == 0)
+ return String();
+
+ const sal_Unicode cLRE_Embedding = 0x202A; // the start char of an LRE embedding
+ const sal_Unicode cRLE_Embedding = 0x202B; // the start char of an RLE embedding
+ const sal_Unicode cPopDirectionalFormat = 0x202C; // the unicode PDF (POP_DIRECTIONAL_FORMAT) char that terminates an LRE/RLE embedding
+
+ // check if there are alreay embedding characters at the strings start
+ // if so change nothing
+ const sal_Unicode cChar = rText.GetBuffer()[0];
+ if (cChar == cLRE_Embedding || cChar == cRLE_Embedding)
+ return rText;
+
+ // since we only call the function getCharacterDirection
+ // it does not matter which locale the CharClass is for.
+ // Thus we can readily make use of SvtSysLocale::GetCharClass()
+ // which should come at no cost...
+ SvtSysLocale aSysLocale;
+ const CharClass &rCharClass = aSysLocale.GetCharClass();
+
+ // we should look for the first non-neutral LTR or RTL character
+ // and use that to determine the embedding of the whole text...
+ // Thus we can avoid to check every character of the text.
+ bool bFound = false;
+ bool bIsRtlText = false;
+ for (USHORT i = 0; i < nLen && !bFound; ++i)
+ {
+ sal_Int16 nDirection = rCharClass.getCharacterDirection( rText, i );
+ switch (nDirection)
+ {
+ case i18n::DirectionProperty_LEFT_TO_RIGHT :
+ case i18n::DirectionProperty_LEFT_TO_RIGHT_EMBEDDING :
+ case i18n::DirectionProperty_LEFT_TO_RIGHT_OVERRIDE :
+ case i18n::DirectionProperty_EUROPEAN_NUMBER :
+ case i18n::DirectionProperty_ARABIC_NUMBER : // yes! arabic numbers are written from left to right
+ {
+ bIsRtlText = false;
+ bFound = true;
+ break;
+ }
+
+ case i18n::DirectionProperty_RIGHT_TO_LEFT :
+ case i18n::DirectionProperty_RIGHT_TO_LEFT_ARABIC :
+ case i18n::DirectionProperty_RIGHT_TO_LEFT_EMBEDDING :
+ case i18n::DirectionProperty_RIGHT_TO_LEFT_OVERRIDE :
+ {
+ bIsRtlText = true;
+ bFound = true;
+ break;
+ }
+
+ default:
+ {
+ // nothing to be done, character is considered to be neutral we need to look further ...
+ }
+ }
+ }
+
+ sal_Unicode cStart = cLRE_Embedding; // default is to use LRE embedding characters
+ if (bIsRtlText)
+ cStart = cRLE_Embedding; // then use RLE embedding
+
+ // add embedding start and end chars to the text if the direction could be determined
+ String aRes( rText );
+ if (bFound)
+ {
+ aRes.Insert( cStart, 0 );
+ aRes.Insert( cPopDirectionalFormat );
+ }
+
+ return aRes;
+}
+
+//------------------------------------------------------------------------
+
+SvtLanguageTable::SvtLanguageTable() :
+ ResStringArray( SvtResId( STR_ARR_SVT_LANGUAGE_TABLE ) )
+{
+}
+
+//------------------------------------------------------------------------
+
+SvtLanguageTable::~SvtLanguageTable()
+{
+}
+
+//------------------------------------------------------------------------
+
+const String& SvtLanguageTable::GetString( const LanguageType eType ) const
+{
+ LanguageType eLang = MsLangId::getReplacementForObsoleteLanguage( eType);
+ sal_uInt32 nPos = FindIndex( eLang );
+
+ if ( RESARRAY_INDEX_NOTFOUND != nPos && nPos < Count() )
+ return ResStringArray::GetString( nPos );
+ else
+ {
+ // If we knew what a simple "en" should alias to (en_US?) we could
+ // generally raise an error.
+ OSL_ENSURE(
+ eLang == LANGUAGE_ENGLISH, "language entry not found in resource" );
+
+ nPos = FindIndex( LANGUAGE_DONTKNOW );
+
+ if ( RESARRAY_INDEX_NOTFOUND != nPos && nPos < Count() )
+ return ResStringArray::GetString( nPos );
+ }
+ static String aEmptyStr;
+ return aEmptyStr;
+}
+
+String SvtLanguageTable::GetLanguageString( const LanguageType eType )
+{
+ static const SvtLanguageTable aLangTable;
+ return aLangTable.GetString( eType );
+}
+
+//------------------------------------------------------------------------
+
+LanguageType SvtLanguageTable::GetType( const String& rStr ) const
+{
+ LanguageType eType = LANGUAGE_DONTKNOW;
+ sal_uInt32 nCount = Count();
+
+ for ( sal_uInt32 i = 0; i < nCount; ++i )
+ {
+ if ( rStr == ResStringArray::GetString( i ) )
+ {
+ eType = LanguageType( GetValue( i ) );
+ break;
+ }
+ }
+ return eType;
+}
+
+//------------------------------------------------------------------------
+
+sal_uInt32 SvtLanguageTable::GetEntryCount() const
+{
+ return Count();
+}
+
+//------------------------------------------------------------------------
+
+LanguageType SvtLanguageTable::GetTypeAtIndex( sal_uInt32 nIndex ) const
+{
+ LanguageType nType = LANGUAGE_DONTKNOW;
+ if (nIndex < Count())
+ nType = LanguageType( GetValue( nIndex ) );
+ return nType;
+}
+
+//------------------------------------------------------------------------
+
diff --git a/svtools/source/misc/langtab.src b/svtools/source/misc/langtab.src
new file mode 100644
index 000000000000..067eb601a5af
--- /dev/null
+++ b/svtools/source/misc/langtab.src
@@ -0,0 +1,329 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+ // include ---------------------------------------------------------------
+#include <svtools/svtools.hrc>
+
+#define RSC_RESOURCE_USAGE 1
+#include <i18npool/lang.h>
+
+#define PairedList ItemList
+
+ // STR_ARR_SVT_LANGUAGE_TABLE ----------------------------------------------------
+StringArray STR_ARR_SVT_LANGUAGE_TABLE
+{
+ PairedList [ en-US ] =
+ {
+ < "[None]" ; LANGUAGE_NONE ; > ;
+ < "Unknown" ; LANGUAGE_DONTKNOW ; > ;
+ < "Default" ; LANGUAGE_SYSTEM ; > ;
+ < "Afrikaans (South Africa)" ; LANGUAGE_AFRIKAANS ; > ;
+ < "Albanian" ; LANGUAGE_ALBANIAN ; > ;
+ < "Arabic" ; LANGUAGE_ARABIC_PRIMARY_ONLY ; > ;
+ < "Arabic (Algeria)" ; LANGUAGE_ARABIC_ALGERIA ; > ;
+ < "Arabic (Bahrain)" ; LANGUAGE_ARABIC_BAHRAIN ; > ;
+ < "Arabic (Chad)" ; LANGUAGE_USER_ARABIC_CHAD ; > ;
+ < "Arabic (Comoros)" ; LANGUAGE_USER_ARABIC_COMOROS ; > ;
+ < "Arabic (Djibouti)" ; LANGUAGE_USER_ARABIC_DJIBOUTI ; > ;
+ < "Arabic (Egypt)" ; LANGUAGE_ARABIC_EGYPT ; > ;
+ < "Arabic (Eritrea)" ; LANGUAGE_USER_ARABIC_ERITREA ; > ;
+ < "Arabic (Iraq)" ; LANGUAGE_ARABIC_IRAQ ; > ;
+ < "Arabic (Israel)" ; LANGUAGE_USER_ARABIC_ISRAEL ; > ;
+ < "Arabic (Jordan)" ; LANGUAGE_ARABIC_JORDAN ; > ;
+ < "Arabic (Kuwait)" ; LANGUAGE_ARABIC_KUWAIT ; > ;
+ < "Arabic (Lebanon)" ; LANGUAGE_ARABIC_LEBANON ; > ;
+ < "Arabic (Libya)" ; LANGUAGE_ARABIC_LIBYA ; > ;
+ < "Arabic (Mauritania)" ; LANGUAGE_USER_ARABIC_MAURITANIA ; > ;
+ < "Arabic (Morocco)" ; LANGUAGE_ARABIC_MOROCCO ; > ;
+ < "Arabic (Oman)" ; LANGUAGE_ARABIC_OMAN ; > ;
+ < "Arabic (Palestine)" ; LANGUAGE_USER_ARABIC_PALESTINE ; > ;
+ < "Arabic (Qatar)" ; LANGUAGE_ARABIC_QATAR ; > ;
+ < "Arabic (Saudi Arabia)" ; LANGUAGE_ARABIC_SAUDI_ARABIA ; > ;
+ < "Arabic (Somalia)" ; LANGUAGE_USER_ARABIC_SOMALIA ; > ;
+ < "Arabic (Sudan)" ; LANGUAGE_USER_ARABIC_SUDAN ; > ;
+ < "Arabic (Syria)" ; LANGUAGE_ARABIC_SYRIA ; > ;
+ < "Arabic (Tunisia)" ; LANGUAGE_ARABIC_TUNISIA ; > ;
+ < "Arabic (UAE)" ; LANGUAGE_ARABIC_UAE ; > ;
+ < "Arabic (Yemen)" ; LANGUAGE_ARABIC_YEMEN ; > ;
+ < "Armenian" ; LANGUAGE_ARMENIAN ; > ;
+ < "Assami" ; LANGUAGE_ASSAMESE ; > ;
+ < "Azerbaijani Latin" ; LANGUAGE_AZERI_LATIN ; > ;
+ < "Azerbaijani Cyrillic" ; LANGUAGE_AZERI_CYRILLIC ; > ;
+ < "Basque" ; LANGUAGE_BASQUE ; > ;
+ < "Bengali (India)" ; LANGUAGE_BENGALI ; > ;
+ < "Bulgarian" ; LANGUAGE_BULGARIAN ; > ;
+ < "Belarusian" ; LANGUAGE_BELARUSIAN ; > ;
+ < "Catalan" ; LANGUAGE_CATALAN ; > ;
+ < "Chinese (traditional)" ; LANGUAGE_CHINESE_TRADITIONAL ; > ;
+ < "Chinese (simplified)" ; LANGUAGE_CHINESE_SIMPLIFIED ; > ;
+ < "Chinese (Hong Kong)" ; LANGUAGE_CHINESE_HONGKONG ; > ;
+ < "Chinese (Singapore)" ; LANGUAGE_CHINESE_SINGAPORE ; > ;
+ < "Chinese (Macau)" ; LANGUAGE_CHINESE_MACAU ; > ;
+ < "Croatian" ; LANGUAGE_CROATIAN ; > ;
+ < "Czech" ; LANGUAGE_CZECH ; > ;
+ < "Danish" ; LANGUAGE_DANISH ; > ;
+ < "Dutch (Netherlands)" ; LANGUAGE_DUTCH ; > ;
+ < "Dutch (Belgium)" ; LANGUAGE_DUTCH_BELGIAN ; > ;
+ < "English (USA)" ; LANGUAGE_ENGLISH_US ; > ;
+ < "English (UK)" ; LANGUAGE_ENGLISH_UK ; > ;
+ < "English (Australia)" ; LANGUAGE_ENGLISH_AUS ; > ;
+ < "English (Canada)" ; LANGUAGE_ENGLISH_CAN ; > ;
+ < "English (New Zealand)" ; LANGUAGE_ENGLISH_NZ ; > ;
+ < "English (Eire)" ; LANGUAGE_ENGLISH_EIRE ; > ;
+ < "English (South Africa)" ; LANGUAGE_ENGLISH_SAFRICA ; > ;
+ < "English (Jamaica)" ; LANGUAGE_ENGLISH_JAMAICA ; > ;
+ < "English (Caribbean)" ; LANGUAGE_ENGLISH_CARRIBEAN ; > ;
+ < "English (Belize)" ; LANGUAGE_ENGLISH_BELIZE ; > ;
+ < "English (Trinidad)" ; LANGUAGE_ENGLISH_TRINIDAD ; > ;
+ < "English (Zimbabwe)" ; LANGUAGE_ENGLISH_ZIMBABWE ; > ;
+ < "English (Philippines)" ; LANGUAGE_ENGLISH_PHILIPPINES ; > ;
+ < "English (India)" ; LANGUAGE_ENGLISH_INDIA ; > ;
+ < "Estonian" ; LANGUAGE_ESTONIAN ; > ;
+ < "Finnish" ; LANGUAGE_FINNISH ; > ;
+ < "Faroese" ; LANGUAGE_FAEROESE ; > ;
+ < "Farsi" ; LANGUAGE_FARSI ; > ;
+ < "French (France)" ; LANGUAGE_FRENCH ; > ;
+ < "French (Belgium)" ; LANGUAGE_FRENCH_BELGIAN ; > ;
+ < "French (Canada)" ; LANGUAGE_FRENCH_CANADIAN ; > ;
+ < "French (Switzerland)" ; LANGUAGE_FRENCH_SWISS ; > ;
+ < "French (Luxembourg)" ; LANGUAGE_FRENCH_LUXEMBOURG ; > ;
+ < "French (Monaco)" ; LANGUAGE_FRENCH_MONACO ; > ;
+ < "Gascon" ; LANGUAGE_USER_GASCON ; > ;
+ < "German (Germany)" ; LANGUAGE_GERMAN ; > ;
+ < "German (Switzerland)" ; LANGUAGE_GERMAN_SWISS ; > ;
+ < "German (Austria)" ; LANGUAGE_GERMAN_AUSTRIAN ; > ;
+ < "German (Luxembourg)" ; LANGUAGE_GERMAN_LUXEMBOURG ; > ;
+ < "German (Liechtenstein)" ; LANGUAGE_GERMAN_LIECHTENSTEIN ; > ;
+ < "Greek" ; LANGUAGE_GREEK ; > ;
+ < "Gujarati" ; LANGUAGE_GUJARATI ; > ;
+ < "Hebrew" ; LANGUAGE_HEBREW ; > ;
+ < "Hindi" ; LANGUAGE_HINDI ; > ;
+ < "Hungarian" ; LANGUAGE_HUNGARIAN ; > ;
+ < "Icelandic" ; LANGUAGE_ICELANDIC ; > ;
+ < "Indonesian" ; LANGUAGE_INDONESIAN ; > ;
+ < "Italian (Italy)" ; LANGUAGE_ITALIAN ; > ;
+ < "Italian (Switzerland)" ; LANGUAGE_ITALIAN_SWISS ; > ;
+ < "Japanese" ; LANGUAGE_JAPANESE ; > ;
+ < "Kannada" ; LANGUAGE_KANNADA ; > ;
+ < "Kashmiri (Kashmir)" ; LANGUAGE_KASHMIRI ; > ;
+ < "Kashmiri (India)" ; LANGUAGE_KASHMIRI_INDIA ; > ;
+ < "Kazak" ; LANGUAGE_KAZAK ; > ;
+ < "Konkani" ; LANGUAGE_KONKANI ; > ;
+ < "Korean (RoK)" ; LANGUAGE_KOREAN ; > ;
+ < "Latvian" ; LANGUAGE_LATVIAN ; > ;
+ < "Lithuanian" ; LANGUAGE_LITHUANIAN ; > ;
+ < "Macedonian" ; LANGUAGE_MACEDONIAN ; > ;
+ < "Malay (Malaysia)" ; LANGUAGE_MALAY_MALAYSIA ; > ;
+ < "Malay (Brunei Darussalam)" ; LANGUAGE_MALAY_BRUNEI_DARUSSALAM ; > ;
+ < "Malayalam" ; LANGUAGE_MALAYALAM ; > ;
+ < "Manipuri" ; LANGUAGE_MANIPURI ; > ;
+ < "Marathi" ; LANGUAGE_MARATHI ; > ;
+ < "Nepali (Nepal)" ; LANGUAGE_NEPALI ; > ;
+ < "Nepali (India)" ; LANGUAGE_NEPALI_INDIA ; > ;
+ < "Norwegian, Bokmål" ; LANGUAGE_NORWEGIAN_BOKMAL ; > ;
+ < "Norwegian, Nynorsk" ; LANGUAGE_NORWEGIAN_NYNORSK ; > ;
+ < "Oriya" ; LANGUAGE_ORIYA ; > ;
+ < "Polish" ; LANGUAGE_POLISH ; > ;
+ < "Portuguese (Portugal)" ; LANGUAGE_PORTUGUESE ; > ;
+ < "Portuguese (Brazil)" ; LANGUAGE_PORTUGUESE_BRAZILIAN ; > ;
+ < "Punjabi" ; LANGUAGE_PUNJABI ; > ;
+ < "Rhaeto-Romance" ; LANGUAGE_RHAETO_ROMAN ; > ;
+ < "Romanian" ; LANGUAGE_ROMANIAN ; > ;
+ < "Russian" ; LANGUAGE_RUSSIAN ; > ;
+ < "Sanskrit" ; LANGUAGE_SANSKRIT ; > ;
+ < "Serbian Cyrillic (Serbia and Montenegro)" ; LANGUAGE_SERBIAN_CYRILLIC ; > ;
+ < "Serbian Latin (Serbia and Montenegro)" ; LANGUAGE_SERBIAN_LATIN ; > ;
+ < "Serbian Cyrillic (Serbia)" ; LANGUAGE_USER_SERBIAN_CYRILLIC_SERBIA ; > ;
+ < "Serbian Latin (Serbia)" ; LANGUAGE_USER_SERBIAN_LATIN_SERBIA ; > ;
+ < "Serbian Cyrillic (Montenegro)" ; LANGUAGE_USER_SERBIAN_CYRILLIC_MONTENEGRO ; > ;
+ < "Serbian Latin (Montenegro)" ; LANGUAGE_USER_SERBIAN_LATIN_MONTENEGRO ; > ;
+ < "Sindhi" ; LANGUAGE_SINDHI ; > ;
+ < "Slovakian" ; LANGUAGE_SLOVAK ; > ;
+ < "Slovenian" ; LANGUAGE_SLOVENIAN ; > ;
+ < "Spanish (Spain)" ; LANGUAGE_SPANISH ; > ;
+ < "Spanish (Mexico)" ; LANGUAGE_SPANISH_MEXICAN ; > ;
+ < "Spanish (Guatemala)" ; LANGUAGE_SPANISH_GUATEMALA ; > ;
+ < "Spanish (Costa Rica)" ; LANGUAGE_SPANISH_COSTARICA ; > ;
+ < "Spanish (Panama)" ; LANGUAGE_SPANISH_PANAMA ; > ;
+ < "Spanish (Dom. Rep.)" ; LANGUAGE_SPANISH_DOMINICAN_REPUBLIC ; > ;
+ < "Spanish (Venezuela)" ; LANGUAGE_SPANISH_VENEZUELA ; > ;
+ < "Spanish (Colombia)" ; LANGUAGE_SPANISH_COLOMBIA ; > ;
+ < "Spanish (Peru)" ; LANGUAGE_SPANISH_PERU ; > ;
+ < "Spanish (Argentina)" ; LANGUAGE_SPANISH_ARGENTINA ; > ;
+ < "Spanish (Ecuador)" ; LANGUAGE_SPANISH_ECUADOR ; > ;
+ < "Spanish (Chile)" ; LANGUAGE_SPANISH_CHILE ; > ;
+ < "Spanish (Uruguay)" ; LANGUAGE_SPANISH_URUGUAY ; > ;
+ < "Spanish (Paraguay)" ; LANGUAGE_SPANISH_PARAGUAY ; > ;
+ < "Spanish (Bolivia)" ; LANGUAGE_SPANISH_BOLIVIA ; > ;
+ < "Spanish (El Salvador)" ; LANGUAGE_SPANISH_EL_SALVADOR ; > ;
+ < "Spanish (Honduras)" ; LANGUAGE_SPANISH_HONDURAS ; > ;
+ < "Spanish (Nicaragua)" ; LANGUAGE_SPANISH_NICARAGUA ; > ;
+ < "Spanish (Puerto Rico)" ; LANGUAGE_SPANISH_PUERTO_RICO ; > ;
+ < "Swahili (Kenya)" ; LANGUAGE_SWAHILI ; > ;
+ < "Swedish (Sweden)" ; LANGUAGE_SWEDISH ; > ;
+ < "Swedish (Finland)" ; LANGUAGE_SWEDISH_FINLAND ; > ;
+ < "Tajik" ; LANGUAGE_TAJIK ; > ;
+ < "Tamil" ; LANGUAGE_TAMIL ; > ;
+ < "Tatar" ; LANGUAGE_TATAR ; > ;
+ < "Telugu" ; LANGUAGE_TELUGU ; > ;
+ < "Thai" ; LANGUAGE_THAI ; > ;
+ < "Turkish" ; LANGUAGE_TURKISH ; > ;
+ < "Urdu (Pakistan)" ; LANGUAGE_URDU_PAKISTAN ; > ;
+ < "Urdu (India)" ; LANGUAGE_URDU_INDIA ; > ;
+ < "Ukrainian" ; LANGUAGE_UKRAINIAN ; > ;
+ < "Uzbek Latin" ; LANGUAGE_UZBEK_LATIN ; > ;
+ < "Welsh" ; LANGUAGE_WELSH ; > ;
+ < "User 1" ; LANGUAGE_USER1 ; > ;
+ < "User 2" ; LANGUAGE_USER2 ; > ;
+ < "User 3" ; LANGUAGE_USER3 ; > ;
+ < "User 4" ; LANGUAGE_USER4 ; > ;
+ < "User 5" ; LANGUAGE_USER5 ; > ;
+ < "User 6" ; LANGUAGE_USER6 ; > ;
+ < "User 7" ; LANGUAGE_USER7 ; > ;
+ < "User 8" ; LANGUAGE_USER8 ; > ;
+ < "User 9" ; LANGUAGE_USER9 ; > ;
+ < "Latin" ; LANGUAGE_LATIN ; > ;
+ < "Esperanto" ; LANGUAGE_USER_ESPERANTO ; > ;
+ < "Kinyarwanda (Rwanda)" ; LANGUAGE_USER_KINYARWANDA ; > ;
+ < "Maori (New Zealand)" ; LANGUAGE_MAORI_NEW_ZEALAND ; > ;
+ < "Galician" ; LANGUAGE_GALICIAN ; > ;
+ < "Dhivehi" ; LANGUAGE_DHIVEHI ; > ;
+ < "Northern Sotho" ; LANGUAGE_SEPEDI ; > ;
+ < "Gaelic (Scotland)" ; LANGUAGE_GAELIC_SCOTLAND ; > ;
+ < "Mongolian" ; LANGUAGE_MONGOLIAN ; > ;
+ < "Interlingua" ; LANGUAGE_USER_INTERLINGUA ; > ;
+ < "Bosnian" ; LANGUAGE_BOSNIAN_BOSNIA_HERZEGOVINA ; > ;
+ < "Bengali (Bangladesh)" ; LANGUAGE_BENGALI_BANGLADESH ; > ;
+ < "Occitan" ; LANGUAGE_USER_OCCITAN ; > ;
+ < "Khmer" ; LANGUAGE_KHMER ; > ;
+ < "Kurdish (Turkey)" ; LANGUAGE_USER_KURDISH_TURKEY ; > ;
+ < "Kurdish (Syria)" ; LANGUAGE_USER_KURDISH_SYRIA ; > ;
+ < "Kurdish (Iraq)" ; LANGUAGE_USER_KURDISH_IRAQ ; > ;
+ < "Kurdish (Iran)" ; LANGUAGE_USER_KURDISH_IRAN ; > ;
+ < "Sardinian" ; LANGUAGE_USER_SARDINIAN ; > ;
+ < "Dzongkha" ; LANGUAGE_DZONGKHA ; > ;
+ < "Swahili (Tanzania)" ; LANGUAGE_USER_SWAHILI_TANZANIA ; > ;
+ < "Lao" ; LANGUAGE_LAO ; > ;
+ < "Irish" ; LANGUAGE_GAELIC_IRELAND ; > ;
+ < "Tibetan (PR China)" ; LANGUAGE_TIBETAN ; > ;
+ < "Georgian" ; LANGUAGE_GEORGIAN ; > ;
+ < "Frisian" ; LANGUAGE_FRISIAN_NETHERLANDS ; > ;
+ < "Tswana (South Africa)" ; LANGUAGE_TSWANA ; > ;
+ < "Zulu" ; LANGUAGE_ZULU ; > ;
+ < "Vietnamese" ; LANGUAGE_VIETNAMESE ; > ;
+ < "Breton" ; LANGUAGE_USER_BRETON ; > ;
+ < "Kalaallisut" ; LANGUAGE_USER_KALAALLISUT ; > ;
+ < "Ndebele, South" ; LANGUAGE_USER_NDEBELE_SOUTH ; > ;
+ < "Southern Sotho" ; LANGUAGE_SESOTHO ; > ;
+ < "Swazi" ; LANGUAGE_USER_SWAZI ; > ;
+ < "Tsonga" ; LANGUAGE_TSONGA ; > ;
+ < "Venda" ; LANGUAGE_VENDA ; > ;
+ < "Tswana (Botswana)" ; LANGUAGE_USER_TSWANA_BOTSWANA ; > ;
+ < "Xhosa" ; LANGUAGE_XHOSA ; > ;
+ < "Sinhala" ; LANGUAGE_SINHALESE_SRI_LANKA ; > ;
+ < "Moore" ; LANGUAGE_USER_MOORE ; > ;
+ < "Bambara" ; LANGUAGE_USER_BAMBARA ; > ;
+ < "Akan" ; LANGUAGE_USER_AKAN ; > ;
+ < "Luxembourgish" ; LANGUAGE_USER_LUXEMBOURGISH ; > ;
+ < "Friulian" ; LANGUAGE_USER_FRIULIAN ; > ;
+ < "Fijian" ; LANGUAGE_USER_FIJIAN ; > ;
+ < "Afrikaans (Namibia)" ; LANGUAGE_USER_AFRIKAANS_NAMIBIA ; > ;
+ < "English (Namibia)" ; LANGUAGE_USER_ENGLISH_NAMIBIA ; > ;
+ < "Walloon" ; LANGUAGE_USER_WALLOON ; > ;
+ < "Coptic" ; LANGUAGE_USER_COPTIC ; > ;
+ < "Tigrigna (Eritrea)" ; LANGUAGE_TIGRIGNA_ERITREA ; > ;
+ < "Tigrigna (Ethiopia)" ; LANGUAGE_TIGRIGNA_ETHIOPIA ; > ;
+ < "Amharic" ; LANGUAGE_AMHARIC_ETHIOPIA ; > ;
+ < "Kirghiz" ; LANGUAGE_KIRGHIZ ; > ;
+ < "German (Belgium)" ; LANGUAGE_USER_GERMAN_BELGIUM ; > ;
+ < "Chuvash" ; LANGUAGE_USER_CHUVASH ; > ;
+ < "Burmese" ; LANGUAGE_BURMESE ; > ;
+ < "Hausa (Nigeria)" ; LANGUAGE_HAUSA_NIGERIA ; > ;
+ < "Hausa (Ghana)" ; LANGUAGE_USER_HAUSA_GHANA ; > ;
+ < "Éwé" ; LANGUAGE_USER_EWE_GHANA ; > ;
+ < "English (Ghana)" ; LANGUAGE_USER_ENGLISH_GHANA ; > ;
+ < "Sango" ; LANGUAGE_USER_SANGO ; > ;
+ < "Tagalog" ; LANGUAGE_USER_TAGALOG ; > ;
+ < "Ganda" ; LANGUAGE_USER_GANDA ; > ;
+ < "Lingala" ; LANGUAGE_USER_LINGALA_DRCONGO ; > ;
+ < "Low German" ; LANGUAGE_USER_LOW_GERMAN ; > ;
+ < "Hiligaynon" ; LANGUAGE_USER_HILIGAYNON ; > ;
+ < "Nyanja" ; LANGUAGE_USER_NYANJA ; > ;
+ < "Kashubian" ; LANGUAGE_USER_KASHUBIAN ; > ;
+ < "Spanish (Cuba)" ; LANGUAGE_USER_SPANISH_CUBA ; > ;
+ < "Tetun (Indonesia)" ; LANGUAGE_USER_TETUN ; > ;
+ < "Quechua (Bolivia, North)" ; LANGUAGE_USER_QUECHUA_NORTH_BOLIVIA ; > ;
+ < "Quechua (Bolivia, South)" ; LANGUAGE_USER_QUECHUA_SOUTH_BOLIVIA ; > ;
+ < "Somali" ; LANGUAGE_SOMALI ; > ;
+ < "Sami, Inari (Finland)" ; LANGUAGE_SAMI_INARI ; > ;
+ < "Sami, Lule (Norway)" ; LANGUAGE_SAMI_LULE_NORWAY ; > ;
+ < "Sami, Lule (Sweden)" ; LANGUAGE_SAMI_LULE_SWEDEN ; > ;
+ < "Sami, Northern (Finland)" ; LANGUAGE_SAMI_NORTHERN_FINLAND ; > ;
+ < "Sami, Northern (Norway)" ; LANGUAGE_SAMI_NORTHERN_NORWAY ; > ;
+ < "Sami, Northern (Sweden)" ; LANGUAGE_SAMI_NORTHERN_SWEDEN ; > ;
+ < "Sami, Skolt (Finland)" ; LANGUAGE_SAMI_SKOLT ; > ;
+ < "Sami, Southern (Norway)" ; LANGUAGE_SAMI_SOUTHERN_NORWAY ; > ;
+ < "Sami, Southern (Sweden)" ; LANGUAGE_SAMI_SOUTHERN_SWEDEN ; > ;
+ < "Sami, Kildin (Russia)" ; LANGUAGE_USER_SAMI_KILDIN_RUSSIA ; > ;
+ < "Guaraní, Paraguayan" ; LANGUAGE_GUARANI_PARAGUAY ; > ;
+ < "Bodo" ; LANGUAGE_USER_BODO_INDIA ; > ;
+ < "Dogri" ; LANGUAGE_USER_DOGRI_INDIA ; > ;
+ < "Maithili" ; LANGUAGE_USER_MAITHILI_INDIA ; > ;
+ < "Santali" ; LANGUAGE_USER_SANTALI_INDIA ; > ;
+ < "Tetun (Timor-Leste)" ; LANGUAGE_USER_TETUN_TIMOR_LESTE ; > ;
+ < "Turkmen" ; LANGUAGE_TURKMEN ; > ;
+ < "Maltese" ; LANGUAGE_MALTESE ; > ;
+ < "Tok Pisin" ; LANGUAGE_USER_TOK_PISIN ; > ;
+ < "Shuswap" ; LANGUAGE_USER_SHUSWAP ; > ;
+ < "Oromo" ; LANGUAGE_OROMO ; > ;
+ < "Greek, Ancient" ; LANGUAGE_USER_ANCIENT_GREEK ; > ;
+ < "Yiddish" ; LANGUAGE_YIDDISH ; > ;
+ < "Quechua (Ecuador)" ; LANGUAGE_QUECHUA_ECUADOR ; > ;
+ < "Uyghur" ; LANGUAGE_UIGHUR_CHINA ; > ;
+ < "Asturian" ; LANGUAGE_USER_ASTURIAN ; > ;
+ < "Sorbian, Upper" ; LANGUAGE_UPPER_SORBIAN_GERMANY ; > ;
+ < "Sorbian, Lower" ; LANGUAGE_LOWER_SORBIAN_GERMANY ; > ;
+ < "Latgalian" ; LANGUAGE_USER_LATGALIAN ; > ;
+ < "Maore" ; LANGUAGE_USER_MAORE ; > ;
+ < "Bushi" ; LANGUAGE_USER_BUSHI ; > ;
+ < "Tahitian" ; LANGUAGE_USER_TAHITIAN ; > ;
+ < "Malagasy, Plateau" ; LANGUAGE_USER_MALAGASY_PLATEAU ; > ;
+ < "Papiamentu (Netherlands Antilles)" ; LANGUAGE_PAPIAMENTU ; > ;
+ < "Papiamento (Aruba)" ; LANGUAGE_USER_PAPIAMENTU_ARUBA ; > ;
+ < "Sardinian, Campidanese" ; LANGUAGE_USER_SARDINIAN_CAMPIDANESE ; > ;
+ < "Sardinian, Gallurese" ; LANGUAGE_USER_SARDINIAN_GALLURESE ; > ;
+ < "Sardinian, Logudorese" ; LANGUAGE_USER_SARDINIAN_LOGUDORESE ; > ;
+ < "Sardinian, Sassarese" ; LANGUAGE_USER_SARDINIAN_SASSARESE ; > ;
+ < "Bafia" ; LANGUAGE_USER_BAFIA ; > ;
+ < "Gikuyu" ; LANGUAGE_USER_GIKUYU ; > ;
+ < "Yoruba" ; LANGUAGE_YORUBA ; > ;
+ < "Rusyn (Ukraine)" ; LANGUAGE_USER_RUSYN_UKRAINE ; > ;
+ < "Rusyn (Slovakia)" ; LANGUAGE_USER_RUSYN_SLOVAKIA ; > ;
+ };
+};
+
+// ********************************************************************** EOF
diff --git a/svtools/source/misc/makefile.mk b/svtools/source/misc/makefile.mk
new file mode 100755
index 000000000000..32781dbfefb1
--- /dev/null
+++ b/svtools/source/misc/makefile.mk
@@ -0,0 +1,84 @@
+#*************************************************************************
+#
+# 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>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=svtools
+TARGET=misc
+
+ENABLE_EXCEPTIONS := TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/svt.pmk
+
+# --- Files --------------------------------------------------------
+
+#use local "bmp" as it may not yet be delivered
+
+SRS1NAME=misc
+SRC1FILES=\
+ ehdl.src \
+ helpagent.src \
+ imagemgr.src \
+ langtab.src
+
+SRS2NAME=ehdl
+SRC2FILES=\
+ errtxt.src
+
+SLOFILES=\
+ $(SLO)$/acceleratorexecute.obj \
+ $(SLO)$/chartprettypainter.obj \
+ $(SLO)$/cliplistener.obj \
+ $(SLO)$/dialogclosedlistener.obj\
+ $(SLO)$/dialogcontrolling.obj \
+ $(SLO)$/ehdl.obj \
+ $(SLO)$/embedhlp.obj \
+ $(SLO)$/embedtransfer.obj \
+ $(SLO)$/helpagentwindow.obj \
+ $(SLO)$/imagemgr.obj \
+ $(SLO)$/imageresourceaccess.obj \
+ $(SLO)$/imap.obj \
+ $(SLO)$/imap2.obj \
+ $(SLO)$/imap3.obj \
+ $(SLO)$/itemdel.obj \
+ $(SLO)$/langtab.obj \
+ $(SLO)$/stringtransfer.obj \
+ $(SLO)$/svtaccessiblefactory.obj \
+ $(SLO)$/svtdata.obj \
+ $(SLO)$/templatefoldercache.obj \
+ $(SLO)$/transfer.obj \
+ $(SLO)$/transfer2.obj \
+ $(SLO)$/unitconv.obj \
+ $(SLO)$/wallitem.obj \
+ $(SLO)$/xwindowitem.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/svtools/source/misc/stringtransfer.cxx b/svtools/source/misc/stringtransfer.cxx
new file mode 100644
index 000000000000..fa216b27f99c
--- /dev/null
+++ b/svtools/source/misc/stringtransfer.cxx
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <svtools/stringtransfer.hxx>
+
+//........................................................................
+namespace svt
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::datatransfer;
+
+ //====================================================================
+ //= OStringTransferable
+ //====================================================================
+ //--------------------------------------------------------------------
+ OStringTransferable::OStringTransferable(const ::rtl::OUString& _rContent)
+ :TransferableHelper()
+ ,m_sContent( _rContent )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void OStringTransferable::AddSupportedFormats()
+ {
+ AddFormat(SOT_FORMAT_STRING);
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool OStringTransferable::GetData( const DataFlavor& _rFlavor )
+ {
+ sal_uInt32 nFormat = SotExchange::GetFormat( _rFlavor );
+ if (SOT_FORMAT_STRING == nFormat)
+ return SetString( m_sContent, _rFlavor );
+
+ return sal_False;
+ }
+
+ //====================================================================
+ //= OStringTransfer
+ //====================================================================
+ //--------------------------------------------------------------------
+ void OStringTransfer::CopyString( const ::rtl::OUString& _rContent, Window* _pWindow )
+ {
+ OStringTransferable* pTransferable = new OStringTransferable( _rContent );
+ Reference< XTransferable > xTransfer = pTransferable;
+ pTransferable->CopyToClipboard( _pWindow );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool OStringTransfer::PasteString( ::rtl::OUString& _rContent, Window* _pWindow )
+ {
+ TransferableDataHelper aClipboardData = TransferableDataHelper::CreateFromSystemClipboard( _pWindow );
+
+ // check for a string format
+ const DataFlavorExVector& rFormats = aClipboardData.GetDataFlavorExVector();
+ for ( DataFlavorExVector::const_iterator aSearch = rFormats.begin();
+ aSearch != rFormats.end();
+ ++aSearch
+ )
+ {
+ if (SOT_FORMAT_STRING == aSearch->mnSotId)
+ {
+ String sContent;
+ sal_Bool bSuccess = aClipboardData.GetString( SOT_FORMAT_STRING, sContent );
+ _rContent = sContent;
+ return bSuccess;
+ }
+ }
+
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ void OStringTransfer::StartStringDrag( const ::rtl::OUString& _rContent, Window* _pWindow, sal_Int8 _nDragSourceActions )
+ {
+ OStringTransferable* pTransferable = new OStringTransferable( _rContent );
+ Reference< XTransferable > xTransfer = pTransferable;
+ pTransferable->StartDrag(_pWindow, _nDragSourceActions);
+ }
+
+//........................................................................
+} // namespace svt
+//........................................................................
+
diff --git a/svtools/source/misc/svtaccessiblefactory.cxx b/svtools/source/misc/svtaccessiblefactory.cxx
new file mode 100755
index 000000000000..b20863db3208
--- /dev/null
+++ b/svtools/source/misc/svtaccessiblefactory.cxx
@@ -0,0 +1,355 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include "svtaccessiblefactory.hxx"
+#include <osl/module.h>
+
+// #define UNLOAD_ON_LAST_CLIENT_DYING
+ // this is not recommended currently. If enabled, the implementation will log
+ // the number of active clients, and unload the acc library when the last client
+ // goes away.
+ // Sounds like a good idea, unfortunately, there's no guarantee that all objects
+ // implemented in this library are already dead.
+ // Iow, just because an object implementing an XAccessible (implemented in this lib
+ // here) died, it's not said that everybody released all references to the
+ // XAccessibleContext used by this component, and implemented in the acc lib.
+ // So we cannot really unload the lib.
+ //
+ // Alternatively, if the lib would us own "usage counting", i.e. every component
+ // implemented therein would affect a static ref count, the acc lib could care
+ // for unloading itself.
+
+//........................................................................
+namespace svt
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::accessibility;
+
+ namespace
+ {
+#ifdef UNLOAD_ON_LAST_CLIENT_DYING
+ static oslInterlockedCount s_nAccessibleFactoryAccesss = 0;
+#endif // UNLOAD_ON_LAST_CLIENT_DYING
+ static oslModule s_hAccessibleImplementationModule = NULL;
+ static GetSvtAccessibilityComponentFactory s_pAccessibleFactoryFunc = NULL;
+ static ::rtl::Reference< IAccessibleFactory > s_pFactory;
+
+ //====================================================================
+ //= AccessibleDummyFactory
+ //====================================================================
+ class AccessibleDummyFactory : public IAccessibleFactory
+ {
+ public:
+ AccessibleDummyFactory();
+
+ protected:
+ virtual ~AccessibleDummyFactory();
+
+ private:
+ AccessibleDummyFactory( const AccessibleDummyFactory& ); // never implemented
+ AccessibleDummyFactory& operator=( const AccessibleDummyFactory& ); // never implemented
+
+ oslInterlockedCount m_refCount;
+
+ public:
+ // IReference
+ virtual oslInterlockedCount SAL_CALL acquire();
+ virtual oslInterlockedCount SAL_CALL release();
+
+ // IAccessibleFactory
+ virtual IAccessibleTabListBox*
+ createAccessibleTabListBox(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*rxParent*/,
+ SvHeaderTabListBox& /*rBox*/
+ ) const
+ {
+ return NULL;
+ }
+
+ virtual IAccessibleBrowseBox*
+ createAccessibleBrowseBox(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_rxParent*/,
+ IAccessibleTableProvider& /*_rBrowseBox*/
+ ) const
+ {
+ return NULL;
+ }
+
+ virtual table::IAccessibleTableControl*
+ createAccessibleTableControl(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_rxParent*/,
+ table::IAccessibleTable& /*_rTable*/
+ ) const
+ {
+ return NULL;
+ }
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ createAccessibleIconChoiceCtrl(
+ SvtIconChoiceCtrl& /*_rIconCtrl*/,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_xParent*/
+ ) const
+ {
+ return NULL;
+ }
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ createAccessibleTabBar(
+ TabBar& /*_rTabBar*/
+ ) const
+ {
+ return NULL;
+ }
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
+ createAccessibleTextWindowContext(
+ VCLXWindow* /*pVclXWindow*/, TextEngine& /*rEngine*/, TextView& /*rView*/, bool /*bCompoundControlChild*/
+ ) const
+ {
+ return NULL;
+ }
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ createAccessibleTreeListBox(
+ SvTreeListBox& /*_rListBox*/,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_xParent*/
+ ) const
+ {
+ return NULL;
+ }
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ createAccessibleBrowseBoxHeaderBar(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*rxParent*/,
+ IAccessibleTableProvider& /*_rOwningTable*/,
+ AccessibleBrowseBoxObjType /*_eObjType*/
+ ) const
+ {
+ return NULL;
+ }
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ createAccessibleBrowseBoxTableCell(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_rxParent*/,
+ IAccessibleTableProvider& /*_rBrowseBox*/,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& /*_xFocusWindow*/,
+ sal_Int32 /*_nRowId*/,
+ sal_uInt16 /*_nColId*/,
+ sal_Int32 /*_nOffset*/
+ ) const
+ {
+ return NULL;
+ }
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ createAccessibleBrowseBoxHeaderCell(
+ sal_Int32 /*_nColumnRowId*/,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*rxParent*/,
+ IAccessibleTableProvider& /*_rBrowseBox*/,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& /*_xFocusWindow*/,
+ AccessibleBrowseBoxObjType /*_eObjType*/
+ ) const
+ {
+ return NULL;
+ }
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ createAccessibleCheckBoxCell(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_rxParent*/,
+ IAccessibleTableProvider& /*_rBrowseBox*/,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& /*_xFocusWindow*/,
+ sal_Int32 /*_nRowPos*/,
+ sal_uInt16 /*_nColPos*/,
+ const TriState& /*_eState*/,
+ sal_Bool /*_bEnabled*/,
+ sal_Bool /*_bIsTriState*/
+ ) const
+ {
+ return NULL;
+ }
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ createEditBrowseBoxTableCellAccess(
+ const ::com::sun::star::uno::Reference< com::sun::star::accessibility::XAccessible >& /*_rxParent*/,
+ const ::com::sun::star::uno::Reference< com::sun::star::accessibility::XAccessible >& /*_rxControlAccessible*/,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& /*_rxFocusWindow*/,
+ IAccessibleTableProvider& /*_rBrowseBox*/,
+ sal_Int32 /*_nRowPos*/,
+ sal_uInt16 /*_nColPos*/
+ ) const
+ {
+ return NULL;
+ }
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
+ createAccessibleToolPanelDeck(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*i_rAccessibleParent*/,
+ ::svt::ToolPanelDeck& /*i_rPanelDeck*/
+ )
+ {
+ return NULL;
+ }
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
+ createAccessibleToolPanelTabBar(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*i_rAccessibleParent*/,
+ ::svt::IToolPanelDeck& /*i_rPanelDeck*/,
+ ::svt::PanelTabBar& /*i_rTabBar*/
+ )
+ {
+ return NULL;
+ }
+ };
+
+ //----------------------------------------------------------------
+ AccessibleDummyFactory::AccessibleDummyFactory()
+ {
+ }
+
+ //----------------------------------------------------------------
+ AccessibleDummyFactory::~AccessibleDummyFactory()
+ {
+ }
+
+ //----------------------------------------------------------------
+ oslInterlockedCount SAL_CALL AccessibleDummyFactory::acquire()
+ {
+ return osl_incrementInterlockedCount( &m_refCount );
+ }
+
+ //----------------------------------------------------------------
+ oslInterlockedCount SAL_CALL AccessibleDummyFactory::release()
+ {
+ if ( 0 == osl_decrementInterlockedCount( &m_refCount ) )
+ {
+ delete this;
+ return 0;
+ }
+ return m_refCount;
+ }
+ }
+
+ //====================================================================
+ //= AccessibleFactoryAccess
+ //====================================================================
+ //--------------------------------------------------------------------
+ AccessibleFactoryAccess::AccessibleFactoryAccess()
+ :m_bInitialized( false )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ extern "C" { static void SAL_CALL thisModule() {} }
+
+ void AccessibleFactoryAccess::ensureInitialized()
+ {
+ if ( m_bInitialized )
+ return;
+
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+
+#ifdef UNLOAD_ON_LAST_CLIENT_DYING
+ if ( 1 == osl_incrementInterlockedCount( &s_nAccessibleFactoryAccesss ) )
+ { // the first client
+#endif // UNLOAD_ON_LAST_CLIENT_DYING
+ // load the library implementing the factory
+ if ( !s_pFactory.get() )
+ {
+ const ::rtl::OUString sModuleName = ::rtl::OUString::createFromAscii(
+ SVLIBRARY( "acc" )
+ );
+ s_hAccessibleImplementationModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, 0 );
+ if ( s_hAccessibleImplementationModule != NULL )
+ {
+ const ::rtl::OUString sFactoryCreationFunc =
+ ::rtl::OUString::createFromAscii( "getSvtAccessibilityComponentFactory" );
+ s_pAccessibleFactoryFunc = (GetSvtAccessibilityComponentFactory)
+ osl_getFunctionSymbol( s_hAccessibleImplementationModule, sFactoryCreationFunc.pData );
+
+ }
+ OSL_ENSURE( s_pAccessibleFactoryFunc, "ac_registerClient: could not load the library, or not retrieve the needed symbol!" );
+
+ // get a factory instance
+ if ( s_pAccessibleFactoryFunc )
+ {
+ IAccessibleFactory* pFactory = static_cast< IAccessibleFactory* >( (*s_pAccessibleFactoryFunc)() );
+ if ( pFactory )
+ {
+ s_pFactory = pFactory;
+ pFactory->release();
+ }
+ }
+ }
+
+ if ( !s_pFactory.get() )
+ // the attempt to load the lib, or to create the factory, failed
+ // -> fall back to a dummy factory
+ s_pFactory = new AccessibleDummyFactory;
+#ifdef UNLOAD_ON_LAST_CLIENT_DYING
+ }
+#endif
+
+ m_bInitialized = true;
+ }
+
+ //--------------------------------------------------------------------
+ AccessibleFactoryAccess::~AccessibleFactoryAccess()
+ {
+ if ( m_bInitialized )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+
+#ifdef UNLOAD_ON_LAST_CLIENT_DYING
+ if( 0 == osl_decrementInterlockedCount( &s_nAccessibleFactoryAccesss ) )
+ {
+ s_pFactory = NULL;
+ s_pAccessibleFactoryFunc = NULL;
+ if ( s_hAccessibleImplementationModule )
+ {
+ osl_unloadModule( s_hAccessibleImplementationModule );
+ s_hAccessibleImplementationModule = NULL;
+ }
+ }
+#endif // UNLOAD_ON_LAST_CLIENT_DYING
+ }
+ }
+
+ //--------------------------------------------------------------------
+ IAccessibleFactory& AccessibleFactoryAccess::getFactory()
+ {
+ ensureInitialized();
+ DBG_ASSERT( s_pFactory.is(), "AccessibleFactoryAccess::getFactory: at least a dummy factory should have been created!" );
+ return *s_pFactory;
+ }
+
+//........................................................................
+} // namespace svt
+//........................................................................
diff --git a/svtools/source/misc/svtdata.cxx b/svtools/source/misc/svtdata.cxx
new file mode 100644
index 000000000000..7a04b3276c9f
--- /dev/null
+++ b/svtools/source/misc/svtdata.cxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include <map>
+#include <tools/resmgr.hxx>
+#include <tools/shl.hxx>
+#include <vos/process.hxx>
+#include <svtools/svtdata.hxx>
+#include <vcl/svapp.hxx>
+
+//============================================================================
+//
+// ImpSvtData
+//
+//============================================================================
+
+ImpSvtData::~ImpSvtData()
+{
+ delete pResMgr;
+}
+
+//============================================================================
+ResMgr * ImpSvtData::GetResMgr(const ::com::sun::star::lang::Locale aLocale)
+{
+ if (!pResMgr)
+ {
+ pResMgr = ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(svt), aLocale );
+ }
+ return pResMgr;
+}
+
+ResMgr * ImpSvtData::GetResMgr()
+{
+ return GetResMgr(Application::GetSettings().GetUILocale());
+}
+
+//============================================================================
+// static
+ImpSvtData & ImpSvtData::GetSvtData()
+{
+ void ** pAppData = GetAppData(SHL_SVT);
+ if (!*pAppData)
+ *pAppData= new ImpSvtData;
+ return *static_cast<ImpSvtData *>(*pAppData);
+}
+
diff --git a/svtools/source/misc/templatefoldercache.cxx b/svtools/source/misc/templatefoldercache.cxx
new file mode 100644
index 000000000000..62f3ec39eb6f
--- /dev/null
+++ b/svtools/source/misc/templatefoldercache.cxx
@@ -0,0 +1,919 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include "templatefoldercache.hxx"
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/localfilehelper.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/ucb/XDynamicResultSet.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/ucb/XContentAccess.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/util/XOfficeInstallationDirectories.hpp>
+#include <ucbhelper/content.hxx>
+#include <vos/ref.hxx>
+#include <vos/refernce.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/debug.hxx>
+#include <unotools/pathoptions.hxx>
+
+#include "comphelper/processfactory.hxx"
+
+#include <vector>
+#include <list>
+#include <functional>
+#include <algorithm>
+
+//.........................................................................
+namespace svt
+{
+//.........................................................................
+
+ using namespace ::utl;
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::ucb;
+ using namespace ::com::sun::star::uno;
+
+ //=====================================================================
+ //= helpers
+ //=====================================================================
+ //---------------------------------------------------------------------
+ SvStream& operator << ( SvStream& _rStorage, const util::DateTime& _rDate )
+ {
+ _rStorage << _rDate.HundredthSeconds;
+ _rStorage << _rDate.Seconds;
+ _rStorage << _rDate.Minutes;
+ _rStorage << _rDate.Hours;
+ _rStorage << _rDate.Day;
+ _rStorage << _rDate.Month;
+ _rStorage << _rDate.Year;
+
+ return _rStorage;
+ }
+
+ //---------------------------------------------------------------------
+ SvStream& operator >> ( SvStream& _rStorage, util::DateTime& _rDate )
+ {
+ _rStorage >> _rDate.HundredthSeconds;
+ _rStorage >> _rDate.Seconds;
+ _rStorage >> _rDate.Minutes;
+ _rStorage >> _rDate.Hours;
+ _rStorage >> _rDate.Day;
+ _rStorage >> _rDate.Month;
+ _rStorage >> _rDate.Year;
+
+ return _rStorage;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool operator == ( const util::DateTime& _rLHS, const util::DateTime& _rRHS )
+ {
+ return _rLHS.HundredthSeconds == _rRHS.HundredthSeconds
+ && _rLHS.Seconds == _rRHS.Seconds
+ && _rLHS.Minutes == _rRHS.Minutes
+ && _rLHS.Hours == _rRHS.Hours
+ && _rLHS.Day == _rRHS.Day
+ && _rLHS.Month == _rRHS.Month
+ && _rLHS.Year == _rRHS.Year;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool operator != ( const util::DateTime& _rLHS, const util::DateTime& _rRHS )
+ {
+ return !( _rLHS == _rRHS );
+ }
+
+ //=====================================================================
+ //= TemplateContent
+ //=====================================================================
+ struct TemplateContent;
+ typedef ::std::vector< ::vos::ORef< TemplateContent > > TemplateFolderContent;
+ typedef TemplateFolderContent::const_iterator ConstFolderIterator;
+ typedef TemplateFolderContent::iterator FolderIterator;
+
+ /** a struct describing one content in one of the template dirs (or at least it's relevant aspects)
+ */
+ struct TemplateContent : public ::vos::OReference
+ {
+ public:
+
+ private:
+ INetURLObject m_aURL;
+ String m_sLocalName; // redundant - last segment of m_aURL
+ util::DateTime m_aLastModified; // date of last modification as reported by UCP
+ TemplateFolderContent m_aSubContents; // sorted (by name) list of the children
+
+ private:
+ inline void implResetDate( )
+ {
+ m_aLastModified.HundredthSeconds = m_aLastModified.Seconds = m_aLastModified.Minutes = m_aLastModified.Hours = 0;
+ m_aLastModified.Day = m_aLastModified.Month = m_aLastModified.Year = 0;
+ }
+
+ private:
+ ~TemplateContent();
+
+ public:
+ TemplateContent();
+ TemplateContent( const INetURLObject& _rURL );
+ TemplateContent( const INetURLObject& _rURL, const util::DateTime& _rLastModified );
+
+ // attribute access
+ inline String getName( ) const { return m_sLocalName; }
+ inline String getURL( ) const { return m_aURL.GetMainURL( INetURLObject::DECODE_TO_IURI ); }
+ inline void setModDate( const util::DateTime& _rDate ) { m_aLastModified = _rDate; }
+ inline const util::DateTime& getModDate( ) const { return m_aLastModified; }
+
+ inline TemplateFolderContent& getSubContents() { return m_aSubContents; }
+ inline const TemplateFolderContent& getSubContents() const { return m_aSubContents; }
+
+ inline ConstFolderIterator begin() const { return m_aSubContents.begin(); }
+ inline ConstFolderIterator end() const { return m_aSubContents.end(); }
+ inline TemplateFolderContent::size_type
+ size() const { return m_aSubContents.size(); }
+
+ inline void push_back( const ::vos::ORef< TemplateContent >& _rxNewElement )
+ { m_aSubContents.push_back( _rxNewElement ); }
+ };
+
+ //---------------------------------------------------------------------
+ DBG_NAME( TemplateContent )
+
+ //---------------------------------------------------------------------
+ TemplateContent::TemplateContent()
+ {
+ DBG_CTOR( TemplateContent, NULL );
+ implResetDate();
+ }
+
+ //---------------------------------------------------------------------
+ TemplateContent::TemplateContent( const INetURLObject& _rURL )
+ :m_aURL( _rURL )
+ {
+ DBG_CTOR( TemplateContent, NULL );
+ DBG_ASSERT( INET_PROT_NOT_VALID != m_aURL.GetProtocol(), "TemplateContent::TemplateContent: invalid URL!" );
+ m_sLocalName = m_aURL.getName();
+ implResetDate();
+ }
+
+ //---------------------------------------------------------------------
+ TemplateContent::TemplateContent( const INetURLObject& _rURL, const util::DateTime& _rLastModified )
+ :m_aURL( _rURL )
+ ,m_aLastModified( _rLastModified )
+ {
+ DBG_CTOR( TemplateContent, NULL );
+ DBG_ASSERT( INET_PROT_NOT_VALID != m_aURL.GetProtocol(), "TemplateContent::TemplateContent: invalid URL!" );
+ m_sLocalName = m_aURL.getName();
+ }
+
+ //---------------------------------------------------------------------
+ TemplateContent::~TemplateContent()
+ {
+ DBG_DTOR( TemplateContent, NULL );
+ }
+
+ //=====================================================================
+ //= stl helpers
+ //=====================================================================
+ //---------------------------------------------------------------------
+ /// compares two TemplateContent by URL
+ struct TemplateContentURLLess
+ :public ::std::binary_function < ::vos::ORef< TemplateContent >
+ , ::vos::ORef< TemplateContent >
+ , bool
+ >
+ {
+ bool operator() ( const ::vos::ORef< TemplateContent >& _rxLHS, const ::vos::ORef< TemplateContent >& _rxRHS ) const
+ {
+ return _rxLHS->getURL() < _rxRHS->getURL()
+ ? true
+ : false;
+ }
+ };
+
+ //---------------------------------------------------------------------
+ /// sorts the sib contents of a TemplateFolderContent
+ struct SubContentSort : public ::std::unary_function< ::vos::ORef< TemplateContent >, void >
+ {
+ void operator() ( TemplateFolderContent& _rFolder ) const
+ {
+ // sort the directory by name
+ ::std::sort(
+ _rFolder.begin(),
+ _rFolder.end(),
+ TemplateContentURLLess()
+ );
+
+ // sort the sub directories by name
+ ::std::for_each(
+ _rFolder.begin(),
+ _rFolder.end(),
+ *this
+ );
+ }
+
+ void operator() ( const ::vos::ORef< TemplateContent >& _rxContent ) const
+ {
+ if ( _rxContent.isValid() && _rxContent->size() )
+ {
+ operator()( _rxContent->getSubContents() );
+ }
+ }
+ };
+ //---------------------------------------------------------------------
+ /** does a deep compare of two template contents
+ */
+ struct TemplateContentEqual
+ :public ::std::binary_function < ::vos::ORef< TemplateContent >
+ , ::vos::ORef< TemplateContent >
+ , bool
+ >
+ {
+ //.................................................................
+ bool operator() (const ::vos::ORef< TemplateContent >& _rLHS, const ::vos::ORef< TemplateContent >& _rRHS )
+ {
+ if ( !_rLHS.isValid() || !_rRHS.isValid() )
+ {
+ DBG_ERROR( "TemplateContentEqual::operator(): invalid contents!" );
+ return true;
+ // this is not strictly true, in case only one is invalid - but this is a heavy error anyway
+ }
+
+ if ( _rLHS->getURL() != _rRHS->getURL() )
+ return false;
+
+ if ( _rLHS->getModDate() != _rRHS->getModDate() )
+ return false;
+
+ if ( _rLHS->getSubContents().size() != _rRHS->getSubContents().size() )
+ return false;
+
+ if ( _rLHS->getSubContents().size() )
+ { // there are children
+ // -> compare them
+ ::std::pair< FolderIterator, FolderIterator > aFirstDifferent = ::std::mismatch(
+ _rLHS->getSubContents().begin(),
+ _rLHS->getSubContents().end(),
+ _rRHS->getSubContents().begin(),
+ *this
+ );
+ if ( aFirstDifferent.first != _rLHS->getSubContents().end() )
+ return false;// the sub contents differ
+ }
+
+ return true;
+ }
+ };
+
+ //---------------------------------------------------------------------
+ /// base class for functors which act an an SvStream
+ struct StorageHelper
+ {
+ protected:
+ SvStream& m_rStorage;
+ StorageHelper( SvStream& _rStorage ) : m_rStorage( _rStorage ) { }
+ };
+
+ //---------------------------------------------------------------------
+ /// functor which allows storing a string
+ struct StoreString
+ :public ::std::unary_function< String, void >
+ ,public StorageHelper
+ {
+ StoreString( SvStream& _rStorage ) : StorageHelper( _rStorage ) { }
+
+ void operator() ( const String& _rString ) const
+ {
+ m_rStorage.WriteByteString( _rString );
+ }
+ };
+
+ //---------------------------------------------------------------------
+ /// functor which stores the local name of a TemplateContent
+ struct StoreLocalContentName
+ :public ::std::unary_function< ::vos::ORef< TemplateContent >, void >
+ ,public StoreString
+ {
+ StoreLocalContentName( SvStream& _rStorage ) : StoreString( _rStorage ) { }
+
+ void operator() ( const ::vos::ORef< TemplateContent >& _rxContent ) const
+ {
+ DBG_ERRORFILE( "This method must not be used, the whole URL must be stored!" );
+
+ // use the base class operator with the local name of the content
+ StoreString::operator() ( _rxContent->getName() );
+ }
+ };
+
+ //---------------------------------------------------------------------
+ struct StoreContentURL
+ :public ::std::unary_function< ::vos::ORef< TemplateContent >, void >
+ ,public StoreString
+ {
+ uno::Reference< util::XOfficeInstallationDirectories > m_xOfficeInstDirs;
+
+ StoreContentURL( SvStream& _rStorage,
+ const uno::Reference<
+ util::XOfficeInstallationDirectories > &
+ xOfficeInstDirs )
+ : StoreString( _rStorage ), m_xOfficeInstDirs( xOfficeInstDirs ) { }
+
+ void operator() ( const ::vos::ORef< TemplateContent >& _rxContent ) const
+ {
+ // use the base class operator with the local name of the content
+ String sURL = _rxContent->getURL();
+ // #116281# Keep office installtion relocatable. Never store
+ // any direct references to office installation directory.
+ sURL = m_xOfficeInstDirs->makeRelocatableURL( sURL );
+ StoreString::operator() ( sURL );
+ }
+ };
+
+ //---------------------------------------------------------------------
+ /// functor which stores the complete content of a TemplateContent
+ struct StoreFolderContent
+ :public ::std::unary_function< ::vos::ORef< TemplateContent >, void >
+ ,public StorageHelper
+ {
+ uno::Reference< util::XOfficeInstallationDirectories > m_xOfficeInstDirs;
+
+ public:
+ StoreFolderContent( SvStream& _rStorage,
+ const uno::Reference<
+ util::XOfficeInstallationDirectories > &
+ xOfficeInstDirs )
+ : StorageHelper( _rStorage ), m_xOfficeInstDirs( xOfficeInstDirs ) { }
+
+ //.................................................................
+ void operator() ( const TemplateContent& _rContent ) const
+ {
+ // store the info about this content
+ m_rStorage << _rContent.getModDate();
+
+ // store the info about the children
+ // the number
+ m_rStorage << (sal_Int32)_rContent.size();
+ // their URLs ( the local name is not enough, since URL might be not a hierarchical one, "expand:" for example )
+ ::std::for_each(
+ _rContent.getSubContents().begin(),
+ _rContent.getSubContents().end(),
+ StoreContentURL( m_rStorage, m_xOfficeInstDirs )
+ );
+ // their content
+ ::std::for_each(
+ _rContent.getSubContents().begin(),
+ _rContent.getSubContents().end(),
+ *this
+ );
+ }
+
+ //.................................................................
+ void operator() ( const ::vos::ORef< TemplateContent >& _rxContent ) const
+ {
+ if ( _rxContent.isValid() )
+ {
+ operator()( *_rxContent );
+ }
+ }
+ };
+
+ //---------------------------------------------------------------------
+ /// functor which reads a complete TemplateContent instance
+ struct ReadFolderContent
+ :public ::std::unary_function< ::vos::ORef< TemplateContent >, void >
+ ,public StorageHelper
+ {
+ uno::Reference< util::XOfficeInstallationDirectories > m_xOfficeInstDirs;
+
+ ReadFolderContent( SvStream& _rStorage,
+ const uno::Reference<
+ util::XOfficeInstallationDirectories > &
+ xOfficeInstDirs )
+ : StorageHelper( _rStorage ), m_xOfficeInstDirs( xOfficeInstDirs ) { }
+
+ //.................................................................
+ void operator() ( TemplateContent& _rContent ) const
+ {
+ // store the info about this content
+ util::DateTime aModDate;
+ m_rStorage >> aModDate;
+ _rContent.setModDate( aModDate );
+
+ // store the info about the children
+ // the number
+ sal_Int32 nChildren = 0;
+ m_rStorage >> nChildren;
+ TemplateFolderContent& rChildren = _rContent.getSubContents();
+ rChildren.resize( 0 );
+ rChildren.reserve( nChildren );
+ // initialize them with their (local) names
+ while ( nChildren-- )
+ {
+ String sURL;
+ m_rStorage.ReadByteString( sURL );
+ sURL = m_xOfficeInstDirs->makeAbsoluteURL( sURL );
+ INetURLObject aChildURL( sURL );
+ rChildren.push_back( new TemplateContent( aChildURL ) );
+ }
+
+ // their content
+ ::std::for_each(
+ _rContent.getSubContents().begin(),
+ _rContent.getSubContents().end(),
+ *this
+ );
+ }
+
+ //.................................................................
+ void operator() ( const ::vos::ORef< TemplateContent >& _rxContent ) const
+ {
+ if ( _rxContent.isValid() )
+ {
+ operator()( *_rxContent );
+ }
+ }
+ };
+
+ //=====================================================================
+ //= TemplateFolderCacheImpl
+ //=====================================================================
+ class TemplateFolderCacheImpl
+ {
+ private:
+ TemplateFolderContent m_aPreviousState; // the current state of the template dirs (as found on the HD)
+ TemplateFolderContent m_aCurrentState; // the previous state of the template dirs (as found in the cache file)
+
+ osl::Mutex m_aMutex;
+ // will be lazy inited; never access directly; use getOfficeInstDirs().
+ uno::Reference< util::XOfficeInstallationDirectories > m_xOfficeInstDirs;
+
+ SvStream* m_pCacheStream;
+ sal_Bool m_bNeedsUpdate : 1;
+ sal_Bool m_bKnowState : 1;
+ sal_Bool m_bValidCurrentState : 1;
+ sal_Bool m_bAutoStoreState : 1;
+
+ public:
+ TemplateFolderCacheImpl( sal_Bool _bAutoStoreState );
+ ~TemplateFolderCacheImpl( );
+
+ sal_Bool needsUpdate( sal_Bool _bForceCheck );
+ void storeState( sal_Bool _bForceRetrieval );
+
+ private:
+ void initTemplDirs( ::std::vector< String >& _rRootDirs );
+ sal_Bool openCacheStream( sal_Bool _bForRead );
+ void closeCacheStream( );
+
+ /// read the state of the dirs from the cache file
+ sal_Bool readPreviousState();
+ /// read the current state of the dirs
+ sal_Bool readCurrentState();
+
+ String implParseSmart( const String& _rPath );
+
+ sal_Bool implReadFolder( const ::vos::ORef< TemplateContent >& _rxRoot );
+
+ static String getCacheFileName();
+ static sal_Int32 getMagicNumber();
+ static void normalize( TemplateFolderContent& _rState );
+
+ // @return <TRUE/> if the states equal
+ static sal_Bool equalStates( const TemplateFolderContent& _rLHS, const TemplateFolderContent& _rRHS );
+
+ // late initialize m_xOfficeInstDirs
+ uno::Reference< util::XOfficeInstallationDirectories > getOfficeInstDirs();
+ };
+
+ //---------------------------------------------------------------------
+ TemplateFolderCacheImpl::TemplateFolderCacheImpl( sal_Bool _bAutoStoreState )
+ :m_pCacheStream ( NULL )
+ ,m_bNeedsUpdate ( sal_True )
+ ,m_bKnowState ( sal_False )
+ ,m_bValidCurrentState ( sal_False )
+ ,m_bAutoStoreState ( _bAutoStoreState )
+ {
+ }
+
+ //---------------------------------------------------------------------
+ TemplateFolderCacheImpl::~TemplateFolderCacheImpl( )
+ {
+ // store the current state if possible and required
+ if ( m_bValidCurrentState && m_bAutoStoreState )
+ storeState( sal_False );
+
+ closeCacheStream( );
+ }
+
+ //---------------------------------------------------------------------
+ sal_Int32 TemplateFolderCacheImpl::getMagicNumber()
+ {
+ sal_Int32 nMagic = 0;
+ ( nMagic += (sal_Int8)'T' ) <<= 4;
+ ( nMagic += (sal_Int8)'D' ) <<= 4;
+ ( nMagic += (sal_Int8)'S' ) <<= 4;
+ ( nMagic += (sal_Int8)'C' ) <<= 0;
+ return nMagic;
+ }
+
+ //---------------------------------------------------------------------
+ String TemplateFolderCacheImpl::getCacheFileName()
+ {
+ return String::CreateFromAscii( ".templdir.cache" );
+ }
+
+
+ //---------------------------------------------------------------------
+ void TemplateFolderCacheImpl::normalize( TemplateFolderContent& _rState )
+ {
+ SubContentSort()( _rState );
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool TemplateFolderCacheImpl::equalStates( const TemplateFolderContent& _rLHS, const TemplateFolderContent& _rRHS )
+ {
+ if ( _rLHS.size() != _rRHS.size() )
+ return sal_False;
+
+ // as both arrays are sorted (by definition - this is a precondition of this method)
+ // we can simply go from the front to the back and compare the single elements
+
+ ::std::pair< ConstFolderIterator, ConstFolderIterator > aFirstDifferent = ::std::mismatch(
+ _rLHS.begin(),
+ _rLHS.end(),
+ _rRHS.begin(),
+ TemplateContentEqual()
+ );
+
+ return aFirstDifferent.first == _rLHS.end();
+ }
+
+ //---------------------------------------------------------------------
+ void TemplateFolderCacheImpl::storeState( sal_Bool _bForceRetrieval )
+ {
+ if ( !m_bValidCurrentState || _bForceRetrieval )
+ readCurrentState( );
+
+ if ( m_bValidCurrentState && openCacheStream( sal_False ) )
+ {
+ *m_pCacheStream << getMagicNumber();
+
+ // store the template root folders
+ // the size
+ *m_pCacheStream << (sal_Int32)m_aCurrentState.size();
+ // the complete URLs
+ ::std::for_each(
+ m_aCurrentState.begin(),
+ m_aCurrentState.end(),
+ StoreContentURL( *m_pCacheStream, getOfficeInstDirs() )
+ );
+
+ // the contents
+ ::std::for_each(
+ m_aCurrentState.begin(),
+ m_aCurrentState.end(),
+ StoreFolderContent( *m_pCacheStream, getOfficeInstDirs() )
+ );
+ }
+ }
+
+ //---------------------------------------------------------------------
+ String TemplateFolderCacheImpl::implParseSmart( const String& _rPath )
+ {
+ INetURLObject aParser;
+ aParser.SetSmartProtocol( INET_PROT_FILE );
+ aParser.SetURL( _rPath, INetURLObject::WAS_ENCODED );
+ if ( INET_PROT_NOT_VALID == aParser.GetProtocol() )
+ {
+ String sURL;
+ LocalFileHelper::ConvertPhysicalNameToURL( _rPath, sURL );
+ aParser.SetURL( sURL, INetURLObject::WAS_ENCODED );
+ }
+ return aParser.GetMainURL( INetURLObject::DECODE_TO_IURI );
+ }
+
+ //---------------------------------------------------------------------
+ void TemplateFolderCacheImpl::closeCacheStream( )
+ {
+ DELETEZ( m_pCacheStream );
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool TemplateFolderCacheImpl::implReadFolder( const ::vos::ORef< TemplateContent >& _rxRoot )
+ {
+ try
+ {
+ // create a content for the current folder root
+ Reference< XResultSet > xResultSet;
+ Sequence< ::rtl::OUString > aContentProperties( 4);
+ aContentProperties[0] = ::rtl::OUString::createFromAscii( "Title" );
+ aContentProperties[1] = ::rtl::OUString::createFromAscii( "DateModified" );
+ aContentProperties[2] = ::rtl::OUString::createFromAscii( "DateCreated" );
+ aContentProperties[3] = ::rtl::OUString::createFromAscii( "IsFolder" );
+
+ // get the set of sub contents in the folder
+ try
+ {
+ Reference< XDynamicResultSet > xDynResultSet;
+
+ ::ucbhelper::Content aTemplateRoot( _rxRoot->getURL(), Reference< XCommandEnvironment >() );
+ xDynResultSet = aTemplateRoot.createDynamicCursor( aContentProperties, ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS );
+ if ( xDynResultSet.is() )
+ xResultSet = xDynResultSet->getStaticResultSet();
+ }
+ catch( CommandAbortedException& )
+ {
+ DBG_ERRORFILE( "TemplateFolderCacheImpl::implReadFolder: caught a CommandAbortedException!" );
+ return sal_False;
+ }
+ catch( ::com::sun::star::uno::Exception& )
+ {
+ }
+
+ // collect the infos about the sub contents
+ if ( xResultSet.is() )
+ {
+ Reference< XRow > xRow( xResultSet, UNO_QUERY_THROW );
+ Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY_THROW );
+
+ while ( xResultSet->next() )
+ {
+ INetURLObject aSubContentURL( xContentAccess->queryContentIdentifierString() );
+
+ // a new content instance
+ ::vos::ORef< TemplateContent > xChild = new TemplateContent( aSubContentURL );
+
+ // the modified date
+ xChild->setModDate( xRow->getTimestamp( 2 ) ); // date modified
+ if ( xRow->wasNull() )
+ xChild->setModDate( xRow->getTimestamp( 3 ) ); // fallback: date created
+
+ // push back this content
+ _rxRoot->push_back( xChild );
+
+ // is it a folder?
+ if ( xRow->getBoolean( 4 ) && !xRow->wasNull() )
+ { // yes -> step down
+ ConstFolderIterator aNextLevelRoot = _rxRoot->end();
+ --aNextLevelRoot;
+ implReadFolder( *aNextLevelRoot );
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "TemplateFolderCacheImpl::implReadFolder: caught an exception!" );
+ return sal_False;
+ }
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool TemplateFolderCacheImpl::readCurrentState()
+ {
+ // reset
+ m_bValidCurrentState = sal_False;
+ TemplateFolderContent aTemplateFolderContent;
+ m_aCurrentState.swap( aTemplateFolderContent );
+
+ // the template directories from the config
+ String aDirs = SvtPathOptions().GetTemplatePath();
+ sal_uInt16 nDirs = aDirs.GetTokenCount( ';' );
+
+ m_aCurrentState.reserve( nDirs );
+ // loop through all the root-level template folders
+ for ( sal_uInt16 i=0; i<nDirs; ++i)
+ {
+ // create a new entry
+ m_aCurrentState.push_back( new TemplateContent( INetURLObject( aDirs.GetToken( i, ';' ) ) ) );
+ TemplateFolderContent::iterator aCurrentRoot = m_aCurrentState.end();
+ --aCurrentRoot;
+
+ if ( !implReadFolder( *aCurrentRoot ) )
+ return sal_False;
+ }
+
+ // normalize the array (which basically means "sort it")
+ normalize( m_aCurrentState );
+
+ m_bValidCurrentState = sal_True;
+ return m_bValidCurrentState;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool TemplateFolderCacheImpl::readPreviousState()
+ {
+ DBG_ASSERT( m_pCacheStream, "TemplateFolderCacheImpl::readPreviousState: not to be called without stream!" );
+
+ // reset
+ TemplateFolderContent aTemplateFolderContent;
+ m_aPreviousState.swap( aTemplateFolderContent );
+
+ // check the magic number
+ sal_Int32 nMagic = 0;
+ *m_pCacheStream >> nMagic;
+ DBG_ASSERT( getMagicNumber() == nMagic, "TemplateFolderCacheImpl::readPreviousState: invalid cache file!" );
+ if ( getMagicNumber() != nMagic )
+ return sal_False;
+
+ // the root directories
+ // their number
+ sal_Int32 nRootDirectories = 0;
+ *m_pCacheStream >> nRootDirectories;
+ // init empty TemplateContens with the URLs
+ m_aPreviousState.reserve( nRootDirectories );
+ while ( nRootDirectories-- )
+ {
+ String sURL;
+ m_pCacheStream->ReadByteString( sURL );
+ // #116281# Keep office installtion relocatable. Never store
+ // any direct references to office installation directory.
+ sURL = getOfficeInstDirs()->makeAbsoluteURL( sURL );
+ m_aPreviousState.push_back(
+ new TemplateContent( INetURLObject(sURL) ) );
+ }
+
+ // read the contents of the root folders
+ ::std::for_each(
+ m_aPreviousState.begin(),
+ m_aPreviousState.end(),
+ ReadFolderContent( *m_pCacheStream, getOfficeInstDirs() )
+ );
+
+ DBG_ASSERT( !m_pCacheStream->GetErrorCode(), "TemplateFolderCacheImpl::readPreviousState: unknown error during reading the state cache!" );
+
+ // normalize the array (which basically means "sort it")
+ normalize( m_aPreviousState );
+
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool TemplateFolderCacheImpl::openCacheStream( sal_Bool _bForRead )
+ {
+ // close any old stream instance
+ closeCacheStream( );
+
+ // get the storage directory
+ String sStorageURL = implParseSmart( SvtPathOptions().GetStoragePath() );
+ INetURLObject aStorageURL( sStorageURL );
+ if ( INET_PROT_NOT_VALID == aStorageURL.GetProtocol() )
+ {
+ DBG_ERROR( "TemplateFolderCacheImpl::openCacheStream: invalid storage path!" );
+ return sal_False;
+ }
+
+ // append our name
+ aStorageURL.Append( getCacheFileName() );
+
+ // open the stream
+ m_pCacheStream = UcbStreamHelper::CreateStream( aStorageURL.GetMainURL( INetURLObject::DECODE_TO_IURI ),
+ _bForRead ? STREAM_READ | STREAM_NOCREATE : STREAM_WRITE | STREAM_TRUNC );
+ DBG_ASSERT( m_pCacheStream, "TemplateFolderCacheImpl::openCacheStream: could not open/create the cache stream!" );
+ if ( m_pCacheStream && m_pCacheStream->GetErrorCode() )
+ {
+ DELETEZ( m_pCacheStream );
+ }
+
+ if ( m_pCacheStream )
+ m_pCacheStream->SetStreamCharSet( RTL_TEXTENCODING_UTF8 );
+
+ return NULL != m_pCacheStream;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool TemplateFolderCacheImpl::needsUpdate( sal_Bool _bForceCheck )
+ {
+ if ( m_bKnowState && !_bForceCheck )
+ return m_bNeedsUpdate;
+
+ m_bNeedsUpdate = sal_True;
+ m_bKnowState = sal_True;
+
+ if ( readCurrentState() )
+ {
+ // open the stream which contains the cached state of the directories
+ if ( openCacheStream( sal_True ) )
+ { // opening the stream succeeded
+ if ( readPreviousState() )
+ {
+ m_bNeedsUpdate = !equalStates( m_aPreviousState, m_aCurrentState );
+ }
+ else
+ {
+ closeCacheStream();
+ }
+ }
+ }
+ return m_bNeedsUpdate;
+ }
+
+ //---------------------------------------------------------------------
+ void TemplateFolderCacheImpl::initTemplDirs( ::std::vector< String >& )
+ {
+ }
+
+ //---------------------------------------------------------------------
+ uno::Reference< util::XOfficeInstallationDirectories >
+ TemplateFolderCacheImpl::getOfficeInstDirs()
+ {
+ if ( !m_xOfficeInstDirs.is() )
+ {
+ osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_xOfficeInstDirs.is() )
+ {
+ // @@@ This is bad!
+ uno::Reference< lang::XMultiServiceFactory > xSMgr
+ = comphelper::getProcessServiceFactory();
+ OSL_ENSURE( xSMgr.is(), "No service manager!" );
+
+ uno::Reference< beans::XPropertySet > xPropSet(
+ xSMgr, uno::UNO_QUERY );
+ if ( xPropSet.is() )
+ {
+ uno::Reference< uno::XComponentContext > xCtx;
+ xPropSet->getPropertyValue(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) )
+ >>= xCtx;
+
+ OSL_ENSURE( xCtx.is(),
+ "Unable to obtain component context from service manager!" );
+
+ if ( xCtx.is() )
+ {
+ xCtx->getValueByName(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "/singletons/com.sun.star.util.theOfficeInstallationDirectories" ) ) )
+ >>= m_xOfficeInstDirs;
+ }
+
+ OSL_ENSURE( m_xOfficeInstDirs.is(),
+ "Unable to obtain office directories singleton!" );
+
+ }
+ }
+ }
+ return m_xOfficeInstDirs;
+ }
+
+ //=====================================================================
+ //= TemplateFolderCache
+ //=====================================================================
+ //---------------------------------------------------------------------
+ TemplateFolderCache::TemplateFolderCache( sal_Bool _bAutoStoreState )
+ :m_pImpl( new TemplateFolderCacheImpl( _bAutoStoreState ) )
+ {
+ }
+
+ //---------------------------------------------------------------------
+ TemplateFolderCache::~TemplateFolderCache( )
+ {
+ DELETEZ( m_pImpl );
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool TemplateFolderCache::needsUpdate( sal_Bool _bForceCheck )
+ {
+ return m_pImpl->needsUpdate( _bForceCheck );
+ }
+
+ //---------------------------------------------------------------------
+ void TemplateFolderCache::storeState( sal_Bool _bForceRetrieval )
+ {
+ m_pImpl->storeState( _bForceRetrieval );
+ }
+
+//.........................................................................
+} // namespace sfx2
+//.........................................................................
+
diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx
new file mode 100644
index 000000000000..268533ebb8c8
--- /dev/null
+++ b/svtools/source/misc/transfer.cxx
@@ -0,0 +1,2422 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#ifdef WNT
+#include <tools/prewin.h>
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#pragma warning(disable: 4917)
+#endif
+#include <shlobj.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <tools/postwin.h>
+#endif
+#include <vos/mutex.hxx>
+#include <rtl/memory.h>
+#include <rtl/uuid.h>
+#include <rtl/uri.hxx>
+#ifndef DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#include <unotools/ucbstreamhelper.hxx>
+#include <sot/exchange.hxx>
+#include <sot/storage.hxx>
+#include <vcl/bitmap.hxx>
+#include <vcl/gdimtf.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/cvtgrf.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+#include <comphelper/processfactory.hxx>
+#include <sot/filelist.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+#include <comphelper/seqstream.hxx>
+#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
+#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XMIMECONTENTTYPEFACTORY_HPP_
+#include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XMIMECONTENTTYPE_HPP_
+#include <com/sun/star/datatransfer/XMimeContentType.hpp>
+#endif
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+
+#include "svl/urlbmk.hxx"
+#include "inetimg.hxx"
+#include <svtools/wmf.hxx>
+#include <svtools/imap.hxx>
+#include <svtools/transfer.hxx>
+#include <cstdio>
+
+// --------------
+// - Namespaces -
+// --------------
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::datatransfer::clipboard;
+using namespace ::com::sun::star::datatransfer::dnd;
+
+// --------------------------------
+// - TransferableObjectDescriptor -
+// --------------------------------
+
+#define TOD_SIG1 0x01234567
+#define TOD_SIG2 0x89abcdef
+
+SvStream& operator>>( SvStream& rIStm, TransferableObjectDescriptor& rObjDesc )
+{
+ sal_uInt32 nSize, nViewAspect, nSig1, nSig2;
+
+ rIStm >> nSize;
+ rIStm >> rObjDesc.maClassName;
+ rIStm >> nViewAspect;
+ rIStm >> rObjDesc.maSize.Width();
+ rIStm >> rObjDesc.maSize.Height();
+ rIStm >> rObjDesc.maDragStartPos.X();
+ rIStm >> rObjDesc.maDragStartPos.Y();
+ rIStm.ReadByteString( rObjDesc.maTypeName, gsl_getSystemTextEncoding() );
+ rIStm.ReadByteString( rObjDesc.maDisplayName, gsl_getSystemTextEncoding() );
+ rIStm >> nSig1 >> nSig2;
+
+ rObjDesc.mnViewAspect = static_cast< sal_uInt16 >( nViewAspect );
+
+ // don't use width/height info from external objects
+ if( ( TOD_SIG1 != nSig1 ) || ( TOD_SIG2 != nSig2 ) )
+ {
+ rObjDesc.maSize.Width() = 0;
+ rObjDesc.maSize.Height() = 0;
+ }
+
+ return rIStm;
+}
+
+// -----------------------------------------------------------------------------
+
+SvStream& operator<<( SvStream& rOStm, const TransferableObjectDescriptor& rObjDesc )
+{
+ const sal_uInt32 nFirstPos = rOStm.Tell(), nViewAspect = rObjDesc.mnViewAspect;
+ const sal_uInt32 nSig1 = TOD_SIG1, nSig2 = TOD_SIG2;
+
+ rOStm.SeekRel( 4 );
+ rOStm << rObjDesc.maClassName;
+ rOStm << nViewAspect;
+ rOStm << rObjDesc.maSize.Width();
+ rOStm << rObjDesc.maSize.Height();
+ rOStm << rObjDesc.maDragStartPos.X();
+ rOStm << rObjDesc.maDragStartPos.Y();
+ rOStm.WriteByteString( rObjDesc.maTypeName, gsl_getSystemTextEncoding() );
+ rOStm.WriteByteString( rObjDesc.maDisplayName, gsl_getSystemTextEncoding() );
+ rOStm << nSig1 << nSig2;
+
+ const sal_uInt32 nLastPos = rOStm.Tell();
+
+ rOStm.Seek( nFirstPos );
+ rOStm << ( nLastPos - nFirstPos );
+ rOStm.Seek( nLastPos );
+
+ return rOStm;
+}
+
+// -----------------------------------------------------------------------------
+// the reading of the parameter is done using the special service ::com::sun::star::datatransfer::MimeContentType,
+// a similar approach should be implemented for creation of the mimetype string;
+// for now the set of acceptable characters has to be hardcoded, in future it should be part of the service that creates the mimetype
+const ::rtl::OUString aQuotedParamChars = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "()<>@,;:\\\"/[]?=!#$%&'*+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz{|}~. " ) );
+
+static ::rtl::OUString ImplGetParameterString( const TransferableObjectDescriptor& rObjDesc )
+{
+ const ::rtl::OUString aChar( ::rtl::OUString::createFromAscii( "\"" ) );
+ const ::rtl::OUString aClassName( rObjDesc.maClassName.GetHexName() );
+ ::rtl::OUString aParams;
+
+ if( aClassName.getLength() )
+ {
+ aParams += ::rtl::OUString::createFromAscii( ";classname=\"" );
+ aParams += aClassName;
+ aParams += aChar;
+ }
+
+ if( rObjDesc.maTypeName.Len() )
+ {
+ aParams += ::rtl::OUString::createFromAscii( ";typename=\"" );
+ aParams += rObjDesc.maTypeName;
+ aParams += aChar;
+ }
+
+ if( rObjDesc.maDisplayName.Len() )
+ {
+ // the display name might contain unacceptable characters, encode all of them
+ // this seems to be the only parameter currently that might contain such characters
+ sal_Bool pToAccept[128];
+ for ( sal_Int32 nBInd = 0; nBInd < 128; nBInd++ )
+ pToAccept[nBInd] = sal_False;
+
+ for ( sal_Int32 nInd = 0; nInd < aQuotedParamChars.getLength(); nInd++ )
+ {
+ sal_Unicode nChar = aQuotedParamChars.getStr()[nInd];
+ if ( nChar < 128 )
+ pToAccept[nChar] = sal_True;
+ }
+
+ aParams += ::rtl::OUString::createFromAscii( ";displayname=\"" );
+ aParams += ::rtl::Uri::encode( rObjDesc.maDisplayName, pToAccept, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8 );
+ aParams += aChar;
+ }
+
+ aParams += ::rtl::OUString::createFromAscii( ";viewaspect=\"" );
+ aParams += ::rtl::OUString::valueOf( static_cast< sal_Int32 >( rObjDesc.mnViewAspect ) );
+ aParams += aChar;
+
+ aParams += ::rtl::OUString::createFromAscii( ";width=\"" );
+ aParams += ::rtl::OUString::valueOf( rObjDesc.maSize.Width() );
+ aParams += aChar;
+
+ aParams += ::rtl::OUString::createFromAscii( ";height=\"" );
+ aParams += ::rtl::OUString::valueOf( rObjDesc.maSize.Height() );
+ aParams += aChar;
+
+ aParams += ::rtl::OUString::createFromAscii( ";posx=\"" );
+ aParams += ::rtl::OUString::valueOf( rObjDesc.maDragStartPos.X() );
+ aParams += aChar;
+
+ aParams += ::rtl::OUString::createFromAscii( ";posy=\"" );
+ aParams += ::rtl::OUString::valueOf( rObjDesc.maDragStartPos.X() );
+ aParams += aChar;
+
+ return aParams;
+}
+
+// -----------------------------------------------------------------------------
+
+static void ImplSetParameterString( TransferableObjectDescriptor& rObjDesc, const DataFlavorEx& rFlavorEx )
+{
+ Reference< XMultiServiceFactory > xFact( ::comphelper::getProcessServiceFactory() );
+ Reference< XMimeContentTypeFactory > xMimeFact;
+
+ try
+ {
+ if( xFact.is() )
+ {
+ xMimeFact = Reference< XMimeContentTypeFactory >( xFact->createInstance( ::rtl::OUString::createFromAscii(
+ "com.sun.star.datatransfer.MimeContentTypeFactory" ) ),
+ UNO_QUERY );
+ }
+
+ if( xMimeFact.is() )
+ {
+ Reference< XMimeContentType > xMimeType( xMimeFact->createMimeContentType( rFlavorEx.MimeType ) );
+
+ if( xMimeType.is() )
+ {
+ const ::rtl::OUString aClassNameString( ::rtl::OUString::createFromAscii( "classname" ) );
+ const ::rtl::OUString aTypeNameString( ::rtl::OUString::createFromAscii( "typename" ) );
+ const ::rtl::OUString aDisplayNameString( ::rtl::OUString::createFromAscii( "displayname" ) );
+ const ::rtl::OUString aViewAspectString( ::rtl::OUString::createFromAscii( "viewaspect" ) );
+ const ::rtl::OUString aWidthString( ::rtl::OUString::createFromAscii( "width" ) );
+ const ::rtl::OUString aHeightString( ::rtl::OUString::createFromAscii( "height" ) );
+ const ::rtl::OUString aPosXString( ::rtl::OUString::createFromAscii( "posx" ) );
+ const ::rtl::OUString aPosYString( ::rtl::OUString::createFromAscii( "posy" ) );
+
+ if( xMimeType->hasParameter( aClassNameString ) )
+ {
+ rObjDesc.maClassName.MakeId( xMimeType->getParameterValue( aClassNameString ) );
+ }
+
+ if( xMimeType->hasParameter( aTypeNameString ) )
+ {
+ rObjDesc.maTypeName = xMimeType->getParameterValue( aTypeNameString );
+ }
+
+ if( xMimeType->hasParameter( aDisplayNameString ) )
+ {
+ // the display name might contain unacceptable characters, in this case they should be encoded
+ // this seems to be the only parameter currently that might contain such characters
+ rObjDesc.maDisplayName = ::rtl::Uri::decode( xMimeType->getParameterValue( aDisplayNameString ), rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
+ }
+
+ if( xMimeType->hasParameter( aViewAspectString ) )
+ {
+ rObjDesc.mnViewAspect = static_cast< sal_uInt16 >( xMimeType->getParameterValue( aViewAspectString ).toInt32() );
+ }
+
+ if( xMimeType->hasParameter( aWidthString ) )
+ {
+ rObjDesc.maSize.Width() = xMimeType->getParameterValue( aWidthString ).toInt32();
+ }
+
+ if( xMimeType->hasParameter( aHeightString ) )
+ {
+ rObjDesc.maSize.Height() = xMimeType->getParameterValue( aHeightString ).toInt32();
+ }
+
+ if( xMimeType->hasParameter( aPosXString ) )
+ {
+ rObjDesc.maDragStartPos.X() = xMimeType->getParameterValue( aPosXString ).toInt32();
+ }
+
+ if( xMimeType->hasParameter( aPosYString ) )
+ {
+ rObjDesc.maDragStartPos.Y() = xMimeType->getParameterValue( aPosYString ).toInt32();
+ }
+ }
+ }
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+}
+
+// -----------------------------------------
+// - TransferableHelper::TerminateListener -
+// -----------------------------------------
+
+TransferableHelper::TerminateListener::TerminateListener( TransferableHelper& rTransferableHelper ) :
+ mrParent( rTransferableHelper )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+TransferableHelper::TerminateListener::~TerminateListener()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TransferableHelper::TerminateListener::disposing( const EventObject& ) throw( RuntimeException )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TransferableHelper::TerminateListener::queryTermination( const EventObject& ) throw( TerminationVetoException, RuntimeException )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TransferableHelper::TerminateListener::notifyTermination( const EventObject& ) throw( RuntimeException )
+{
+ mrParent.ImplFlush();
+}
+
+// ----------------------
+// - TransferableHelper -
+// ----------------------
+
+TransferableHelper::TransferableHelper() :
+ mpFormats( new DataFlavorExVector ),
+ mpObjDesc( NULL )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+TransferableHelper::~TransferableHelper()
+{
+ delete mpObjDesc;
+ delete mpFormats;
+}
+
+// -----------------------------------------------------------------------------
+
+Any SAL_CALL TransferableHelper::getTransferData( const DataFlavor& rFlavor ) throw( UnsupportedFlavorException, IOException, RuntimeException )
+{
+ if( !maAny.hasValue() || !mpFormats->size() || ( maLastFormat != rFlavor.MimeType ) )
+ {
+ const ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ maLastFormat = rFlavor.MimeType;
+ maAny = Any();
+
+ try
+ {
+ DataFlavor aSubstFlavor;
+ sal_Bool bDone = sal_False;
+
+ // add formats if not already done
+ if( !mpFormats->size() )
+ AddSupportedFormats();
+
+ // check alien formats first and try to get a substitution format
+ if( SotExchange::GetFormatDataFlavor( FORMAT_STRING, aSubstFlavor ) &&
+ TransferableDataHelper::IsEqual( aSubstFlavor, rFlavor ) )
+ {
+ GetData( aSubstFlavor );
+ bDone = maAny.hasValue();
+ }
+ else if( SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_BMP, aSubstFlavor ) &&
+ TransferableDataHelper::IsEqual( aSubstFlavor, rFlavor ) &&
+ SotExchange::GetFormatDataFlavor( FORMAT_BITMAP, aSubstFlavor ) )
+ {
+ GetData( aSubstFlavor );
+ bDone = sal_True;
+ }
+ else if( SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_EMF, aSubstFlavor ) &&
+ TransferableDataHelper::IsEqual( aSubstFlavor, rFlavor ) &&
+ SotExchange::GetFormatDataFlavor( FORMAT_GDIMETAFILE, aSubstFlavor ) )
+ {
+ GetData( aSubstFlavor );
+
+ if( maAny.hasValue() )
+ {
+ Sequence< sal_Int8 > aSeq;
+
+ if( maAny >>= aSeq )
+ {
+ SvMemoryStream* pSrcStm = new SvMemoryStream( (char*) aSeq.getConstArray(), aSeq.getLength(), STREAM_WRITE | STREAM_TRUNC );
+ GDIMetaFile aMtf;
+
+ *pSrcStm >> aMtf;
+ delete pSrcStm;
+
+ Graphic aGraphic( aMtf );
+ SvMemoryStream aDstStm( 65535, 65535 );
+
+ if( GraphicConverter::Export( aDstStm, aGraphic, CVT_EMF ) == ERRCODE_NONE )
+ {
+ maAny <<= ( aSeq = Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aDstStm.GetData() ),
+ aDstStm.Seek( STREAM_SEEK_TO_END ) ) );
+ bDone = sal_True;
+ }
+ }
+ }
+ }
+ else if( SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_WMF, aSubstFlavor ) &&
+ TransferableDataHelper::IsEqual( aSubstFlavor, rFlavor ) &&
+ SotExchange::GetFormatDataFlavor( FORMAT_GDIMETAFILE, aSubstFlavor ) )
+ {
+ GetData( aSubstFlavor );
+
+ if( maAny.hasValue() )
+ {
+ Sequence< sal_Int8 > aSeq;
+
+ if( maAny >>= aSeq )
+ {
+ SvMemoryStream* pSrcStm = new SvMemoryStream( (char*) aSeq.getConstArray(), aSeq.getLength(), STREAM_WRITE | STREAM_TRUNC );
+ GDIMetaFile aMtf;
+
+ *pSrcStm >> aMtf;
+ delete pSrcStm;
+
+ SvMemoryStream aDstStm( 65535, 65535 );
+
+ // taking wmf without file header
+ if ( ConvertGDIMetaFileToWMF( aMtf, aDstStm, NULL, FALSE ) )
+ {
+ maAny <<= ( aSeq = Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aDstStm.GetData() ),
+ aDstStm.Seek( STREAM_SEEK_TO_END ) ) );
+ bDone = sal_True;
+ }
+ }
+ }
+ }
+
+ // reset Any if substitute doesn't work
+ if( !bDone && maAny.hasValue() )
+ maAny = Any();
+
+ // if any is not yet filled, use standard format
+ if( !maAny.hasValue() )
+ GetData( rFlavor );
+
+#ifdef DEBUG
+ if( maAny.hasValue() && ::com::sun::star::uno::TypeClass_STRING != maAny.getValueType().getTypeClass() )
+ fprintf( stderr, "TransferableHelper delivers sequence of data [ %s ]\n", ByteString( String( rFlavor.MimeType), RTL_TEXTENCODING_ASCII_US ).GetBuffer() );
+#endif
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+
+ if( !maAny.hasValue() )
+ throw UnsupportedFlavorException();
+ }
+
+ return maAny;
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< DataFlavor > SAL_CALL TransferableHelper::getTransferDataFlavors() throw( RuntimeException )
+{
+ const ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ try
+ {
+ if( !mpFormats->size() )
+ AddSupportedFormats();
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+
+ Sequence< DataFlavor > aRet( mpFormats->size() );
+ DataFlavorExVector::iterator aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
+ sal_uInt32 nCurPos = 0;
+
+ while( aIter != aEnd )
+ {
+ aRet[ nCurPos++ ] = *aIter++;
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL TransferableHelper::isDataFlavorSupported( const DataFlavor& rFlavor ) throw( RuntimeException )
+{
+ const ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ sal_Bool bRet = sal_False;
+
+ try
+ {
+ if( !mpFormats->size() )
+ AddSupportedFormats();
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+
+ DataFlavorExVector::iterator aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
+
+ while( aIter != aEnd )
+ {
+ if( TransferableDataHelper::IsEqual( *aIter, rFlavor ) )
+ {
+ aIter = aEnd;
+ bRet = sal_True;
+ }
+ else
+ aIter++;
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TransferableHelper::lostOwnership( const Reference< XClipboard >&, const Reference< XTransferable >& ) throw( RuntimeException )
+{
+ const ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ try
+ {
+ if( mxTerminateListener.is() )
+ {
+ Reference< XMultiServiceFactory > xFact( ::comphelper::getProcessServiceFactory() );
+
+ if( xFact.is() )
+ {
+ Reference< XDesktop > xDesktop( xFact->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ), UNO_QUERY );
+
+ if( xDesktop.is() )
+ xDesktop->removeTerminateListener( mxTerminateListener );
+ }
+
+ mxTerminateListener = Reference< XTerminateListener >();
+ }
+
+ ObjectReleased();
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TransferableHelper::disposing( const EventObject& ) throw( RuntimeException )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TransferableHelper::dragDropEnd( const DragSourceDropEvent& rDSDE ) throw( RuntimeException )
+{
+ const ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ try
+ {
+ DragFinished( rDSDE.DropSuccess ? ( rDSDE.DropAction & ~DNDConstants::ACTION_DEFAULT ) : DNDConstants::ACTION_NONE );
+ ObjectReleased();
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TransferableHelper::dragEnter( const DragSourceDragEvent& ) throw( RuntimeException )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TransferableHelper::dragExit( const DragSourceEvent& ) throw( RuntimeException )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TransferableHelper::dragOver( const DragSourceDragEvent& ) throw( RuntimeException )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TransferableHelper::dropActionChanged( const DragSourceDragEvent& ) throw( RuntimeException )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int64 SAL_CALL TransferableHelper::getSomething( const Sequence< sal_Int8 >& rId ) throw( RuntimeException )
+{
+ sal_Int64 nRet;
+
+ if( ( rId.getLength() == 16 ) &&
+ ( 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
+ {
+ nRet = sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+ else
+ nRet = 0;
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferableHelper::ImplFlush()
+{
+ if( mxClipboard.is() )
+ {
+ Reference< XFlushableClipboard > xFlushableClipboard( mxClipboard, UNO_QUERY );
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+
+ try
+ {
+ if( xFlushableClipboard.is() )
+ xFlushableClipboard->flushClipboard();
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ DBG_ERROR( "Could not flush clipboard" );
+ }
+
+ Application::AcquireSolarMutex( nRef );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferableHelper::AddFormat( SotFormatStringId nFormat )
+{
+ DataFlavor aFlavor;
+
+ if( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) )
+ AddFormat( aFlavor );
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferableHelper::AddFormat( const DataFlavor& rFlavor )
+{
+ DataFlavorExVector::iterator aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
+ sal_Bool bAdd = sal_True;
+
+ while( aIter != aEnd )
+ {
+ if( TransferableDataHelper::IsEqual( *aIter, rFlavor ) )
+ {
+ // update MimeType for SOT_FORMATSTR_ID_OBJECTDESCRIPTOR in every case
+ if( ( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR == aIter->mnSotId ) && mpObjDesc )
+ {
+ DataFlavor aObjDescFlavor;
+
+ SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDescFlavor );
+ aIter->MimeType = aObjDescFlavor.MimeType;
+ aIter->MimeType += ::ImplGetParameterString( *mpObjDesc );
+
+#ifdef DEBUG
+ fprintf( stderr, "TransferableHelper exchanged objectdescriptor [ %s ]\n",
+ ByteString( String( aIter->MimeType), RTL_TEXTENCODING_ASCII_US ).GetBuffer() );
+#endif
+ }
+
+ aIter = aEnd;
+ bAdd = sal_False;
+ }
+ else
+ aIter++;
+ }
+
+ if( bAdd )
+ {
+ DataFlavorEx aFlavorEx;
+ DataFlavor aObjDescFlavor;
+
+ aFlavorEx.MimeType = rFlavor.MimeType;
+ aFlavorEx.HumanPresentableName = rFlavor.HumanPresentableName;
+ aFlavorEx.DataType = rFlavor.DataType;
+ aFlavorEx.mnSotId = SotExchange::RegisterFormat( rFlavor );
+
+ if( ( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR == aFlavorEx.mnSotId ) && mpObjDesc )
+ aFlavorEx.MimeType += ::ImplGetParameterString( *mpObjDesc );
+
+ mpFormats->push_back( aFlavorEx );
+
+ if( FORMAT_BITMAP == aFlavorEx.mnSotId )
+ {
+ AddFormat( SOT_FORMATSTR_ID_BMP );
+ }
+ else if( FORMAT_GDIMETAFILE == aFlavorEx.mnSotId )
+ {
+ AddFormat( SOT_FORMATSTR_ID_EMF );
+ AddFormat( SOT_FORMATSTR_ID_WMF );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferableHelper::RemoveFormat( SotFormatStringId nFormat )
+{
+ DataFlavor aFlavor;
+
+ if( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) )
+ RemoveFormat( aFlavor );
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferableHelper::RemoveFormat( const DataFlavor& rFlavor )
+{
+ DataFlavorExVector::iterator aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
+
+ while( aIter != aEnd )
+ {
+ if( TransferableDataHelper::IsEqual( *aIter, rFlavor ) )
+ {
+ aIter = mpFormats->erase( aIter );
+ aEnd = mpFormats->end();
+ }
+ else
+ ++aIter;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableHelper::HasFormat( SotFormatStringId nFormat )
+{
+ DataFlavorExVector::iterator aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
+ sal_Bool bRet = sal_False;
+
+ while( aIter != aEnd )
+ {
+ if( nFormat == (*aIter).mnSotId )
+ {
+ aIter = aEnd;
+ bRet = sal_True;
+ }
+ else
+ ++aIter;
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferableHelper::ClearFormats()
+{
+ mpFormats->clear();
+ maAny.clear();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableHelper::SetAny( const Any& rAny, const DataFlavor& )
+{
+ maAny = rAny;
+ return( maAny.hasValue() );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableHelper::SetString( const ::rtl::OUString& rString, const DataFlavor& rFlavor )
+{
+ DataFlavor aFileFlavor;
+
+ if( rString.getLength() &&
+ SotExchange::GetFormatDataFlavor( FORMAT_FILE, aFileFlavor ) &&
+ TransferableDataHelper::IsEqual( aFileFlavor, rFlavor ) )
+ {
+ const String aString( rString );
+ const ByteString aByteStr( aString, gsl_getSystemTextEncoding() );
+ Sequence< sal_Int8 > aSeq( aByteStr.Len() + 1 );
+
+ rtl_copyMemory( aSeq.getArray(), aByteStr.GetBuffer(), aByteStr.Len() );
+ aSeq[ aByteStr.Len() ] = 0;
+ maAny <<= aSeq;
+ }
+ else
+ maAny <<= rString;
+
+ return( maAny.hasValue() );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableHelper::SetBitmap( const Bitmap& rBitmap, const DataFlavor& )
+{
+ if( !rBitmap.IsEmpty() )
+ {
+ SvMemoryStream aMemStm( 65535, 65535 );
+
+ aMemStm << rBitmap;
+ maAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
+ }
+
+ return( maAny.hasValue() );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableHelper::SetGDIMetaFile( const GDIMetaFile& rMtf, const DataFlavor& )
+{
+ if( rMtf.GetActionCount() )
+ {
+ SvMemoryStream aMemStm( 65535, 65535 );
+
+ ( (GDIMetaFile&) rMtf ).Write( aMemStm );
+ maAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
+ }
+
+ return( maAny.hasValue() );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableHelper::SetGraphic( const Graphic& rGraphic, const DataFlavor& )
+{
+ if( rGraphic.GetType() != GRAPHIC_NONE )
+ {
+ SvMemoryStream aMemStm( 65535, 65535 );
+
+ aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
+ aMemStm.SetCompressMode( COMPRESSMODE_NATIVE );
+ aMemStm << rGraphic;
+ maAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
+ }
+
+ return( maAny.hasValue() );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableHelper::SetImageMap( const ImageMap& rIMap, const ::com::sun::star::datatransfer::DataFlavor& )
+{
+ SvMemoryStream aMemStm( 8192, 8192 );
+
+ aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
+ rIMap.Write( aMemStm, String() );
+ maAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
+
+ return( maAny.hasValue() );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableHelper::SetTransferableObjectDescriptor( const TransferableObjectDescriptor& rDesc,
+ const ::com::sun::star::datatransfer::DataFlavor& )
+{
+ PrepareOLE( rDesc );
+
+ SvMemoryStream aMemStm( 1024, 1024 );
+
+ aMemStm << rDesc;
+ maAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Tell() );
+
+ return( maAny.hasValue() );
+ }
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableHelper::SetINetBookmark( const INetBookmark& rBmk,
+ const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
+{
+ rtl_TextEncoding eSysCSet = gsl_getSystemTextEncoding();
+
+ switch( SotExchange::GetFormat( rFlavor ) )
+ {
+ case( SOT_FORMATSTR_ID_SOLK ):
+ {
+ ByteString sURL( rBmk.GetURL(), eSysCSet ),
+ sDesc( rBmk.GetDescription(), eSysCSet );
+ ByteString sOut( ByteString::CreateFromInt32( sURL.Len() ));
+ ( sOut += '@' ) += sURL;
+ sOut += ByteString::CreateFromInt32( sDesc.Len() );
+ ( sOut += '@' ) += sDesc;
+
+ Sequence< sal_Int8 > aSeq( sOut.Len() );
+ memcpy( aSeq.getArray(), sOut.GetBuffer(), sOut.Len() );
+ maAny <<= aSeq;
+ }
+ break;
+
+ case( FORMAT_STRING ):
+ maAny <<= ::rtl::OUString( rBmk.GetURL() );
+ break;
+
+ case( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ):
+ {
+ ByteString sURL( rBmk.GetURL(), eSysCSet );
+ Sequence< sal_Int8 > aSeq( sURL.Len() );
+ memcpy( aSeq.getArray(), sURL.GetBuffer(), sURL.Len() );
+ maAny <<= aSeq;
+ }
+ break;
+
+ case( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ):
+ {
+ Sequence< sal_Int8 > aSeq( 2048 );
+
+ memset( aSeq.getArray(), 0, 2048 );
+ strcpy( reinterpret_cast< char* >( aSeq.getArray() ), ByteString( rBmk.GetURL(), eSysCSet).GetBuffer() );
+ strcpy( reinterpret_cast< char* >( aSeq.getArray() ) + 1024, ByteString( rBmk.GetDescription(), eSysCSet ).GetBuffer() );
+
+ maAny <<= aSeq;
+ }
+ break;
+
+#ifdef WNT
+ case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR:
+ {
+ Sequence< sal_Int8 > aSeq( sizeof( FILEGROUPDESCRIPTOR ) );
+ FILEGROUPDESCRIPTOR* pFDesc = (FILEGROUPDESCRIPTOR*) aSeq.getArray();
+ FILEDESCRIPTOR& rFDesc1 = pFDesc->fgd[ 0 ];
+
+ pFDesc->cItems = 1;
+ memset( &rFDesc1, 0, sizeof( FILEDESCRIPTOR ) );
+ rFDesc1.dwFlags = FD_LINKUI;
+
+ ByteString aStr( rBmk.GetDescription(), eSysCSet );
+ for( USHORT nChar = 0; nChar < aStr.Len(); ++nChar )
+ if( strchr( "\\/:*?\"<>|", aStr.GetChar( nChar ) ) )
+ aStr.Erase( nChar--, 1 );
+
+ aStr.Insert( "Shortcut to ", 0 );
+ aStr += ".URL";
+ strcpy( rFDesc1.cFileName, aStr.GetBuffer() );
+
+ maAny <<= aSeq;
+ }
+ break;
+
+ case SOT_FORMATSTR_ID_FILECONTENT:
+ {
+ String aStr( RTL_CONSTASCII_STRINGPARAM( "[InternetShortcut]\x0aURL=" ) );
+ maAny <<= ::rtl::OUString( aStr += rBmk.GetURL() );
+ }
+ break;
+#endif
+
+ default:
+ break;
+ }
+
+ return( maAny.hasValue() );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableHelper::SetINetImage( const INetImage& rINtImg,
+ const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
+{
+ SvMemoryStream aMemStm( 1024, 1024 );
+
+ aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
+ rINtImg.Write( aMemStm, SotExchange::GetFormat( rFlavor ) );
+
+ maAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
+
+ return( maAny.hasValue() );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableHelper::SetFileList( const FileList& rFileList,
+ const ::com::sun::star::datatransfer::DataFlavor& )
+{
+ SvMemoryStream aMemStm( 4096, 4096 );
+
+ aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
+ aMemStm << rFileList;
+
+ maAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ),
+ aMemStm.Seek( STREAM_SEEK_TO_END ) );
+
+ return( maAny.hasValue() );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableHelper::SetObject( void* pUserObject, sal_uInt32 nUserObjectId, const DataFlavor& rFlavor )
+{
+ SotStorageStreamRef xStm( new SotStorageStream( String() ) );
+
+ xStm->SetVersion( SOFFICE_FILEFORMAT_50 );
+
+ if( pUserObject && WriteObject( xStm, pUserObject, nUserObjectId, rFlavor ) )
+ {
+ const sal_uInt32 nLen = xStm->Seek( STREAM_SEEK_TO_END );
+ Sequence< sal_Int8 > aSeq( nLen );
+
+ xStm->Seek( STREAM_SEEK_TO_BEGIN );
+ xStm->Read( aSeq.getArray(), nLen );
+
+ if( nLen && ( SotExchange::GetFormat( rFlavor ) == SOT_FORMAT_STRING ) )
+ {
+ //JP 24.7.2001: as I know was this only for the writer application and this
+ // writes now UTF16 format into the stream
+ //JP 6.8.2001: and now it writes UTF8 because then exist no problem with
+ // little / big endians! - Bug 88121
+ maAny <<= ::rtl::OUString( reinterpret_cast< const sal_Char* >( aSeq.getConstArray() ), nLen - 1, RTL_TEXTENCODING_UTF8 );
+ }
+ else
+ maAny <<= aSeq;
+ }
+
+ return( maAny.hasValue() );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableHelper::SetInterface( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rIf,
+ const ::com::sun::star::datatransfer::DataFlavor& )
+{
+ maAny <<= rIf;
+ return( maAny.hasValue() );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableHelper::WriteObject( SotStorageStreamRef&, void*, sal_uInt32, const DataFlavor& )
+{
+ DBG_ERROR( "TransferableHelper::WriteObject( ... ) not implemented" );
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferableHelper::DragFinished( sal_Int8 )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferableHelper::ObjectReleased()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferableHelper::PrepareOLE( const TransferableObjectDescriptor& rObjDesc )
+{
+ delete mpObjDesc;
+ mpObjDesc = new TransferableObjectDescriptor( rObjDesc );
+
+ if( HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) )
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferableHelper::CopyToClipboard( Window *pWindow ) const
+{
+ DBG_ASSERT( pWindow, "Window pointer is NULL" );
+ Reference< XClipboard > xClipboard;
+
+ if( pWindow )
+ xClipboard = pWindow->GetClipboard();
+
+ if( xClipboard.is() )
+ mxClipboard = xClipboard;
+
+ if( mxClipboard.is() && !mxTerminateListener.is() )
+ {
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+
+ try
+ {
+ TransferableHelper* pThis = const_cast< TransferableHelper* >( this );
+ Reference< XMultiServiceFactory > xFact( ::comphelper::getProcessServiceFactory() );
+
+ if( xFact.is() )
+ {
+ Reference< XDesktop > xDesktop( xFact->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ), UNO_QUERY );
+
+ if( xDesktop.is() )
+ xDesktop->addTerminateListener( pThis->mxTerminateListener = new TerminateListener( *pThis ) );
+ }
+
+ mxClipboard->setContents( pThis, pThis );
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+
+ Application::AcquireSolarMutex( nRef );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferableHelper::CopyToSelection( Window *pWindow ) const
+{
+ DBG_ASSERT( pWindow, "Window pointer is NULL" );
+ Reference< XClipboard > xSelection;
+
+ if( pWindow )
+ xSelection = pWindow->GetPrimarySelection();
+
+ if( xSelection.is() && !mxTerminateListener.is() )
+ {
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+
+ try
+ {
+ TransferableHelper* pThis = const_cast< TransferableHelper* >( this );
+ Reference< XMultiServiceFactory > xFact( ::comphelper::getProcessServiceFactory() );
+
+ if( xFact.is() )
+ {
+ Reference< XDesktop > xDesktop( xFact->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ), UNO_QUERY );
+
+ if( xDesktop.is() )
+ xDesktop->addTerminateListener( pThis->mxTerminateListener = new TerminateListener( *pThis ) );
+ }
+
+ xSelection->setContents( pThis, pThis );
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+
+ Application::AcquireSolarMutex( nRef );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferableHelper::StartDrag( Window* pWindow, sal_Int8 nDnDSourceActions,
+ sal_Int32 nDnDPointer, sal_Int32 nDnDImage )
+
+{
+ DBG_ASSERT( pWindow, "Window pointer is NULL" );
+ Reference< XDragSource > xDragSource( pWindow->GetDragSource() );
+
+ if( xDragSource.is() )
+ {
+ /*
+ * #96792# release mouse before actually starting DnD.
+ * This is necessary for the X11 DnD implementation to work.
+ */
+ if( pWindow->IsMouseCaptured() )
+ pWindow->ReleaseMouse();
+
+ const Point aPt( pWindow->GetPointerPosPixel() );
+
+ // On Mac OS X we are forced to execute 'startDrag' synchronously
+ // contrary to the XDragSource interface specification because
+ // we can receive drag events from the system only in the main
+ // thread
+#if !defined(QUARTZ)
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+#endif
+
+ try
+ {
+ DragGestureEvent aEvt;
+ aEvt.DragAction = DNDConstants::ACTION_COPY;
+ aEvt.DragOriginX = aPt.X();
+ aEvt.DragOriginY = aPt.Y();
+ aEvt.DragSource = xDragSource;
+
+ xDragSource->startDrag( aEvt, nDnDSourceActions, nDnDPointer, nDnDImage, this, this );
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+
+ // See above for the reason of this define
+#if !defined(QUARTZ)
+ Application::AcquireSolarMutex( nRef );
+#endif
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferableHelper::ClearSelection( Window *pWindow )
+{
+ DBG_ASSERT( pWindow, "Window pointer is NULL" );
+ Reference< XClipboard > xSelection( pWindow->GetPrimarySelection() );
+
+ if( xSelection.is() )
+ xSelection->setContents( NULL, NULL );
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XClipboard> TransferableHelper::GetSystemClipboard()
+{
+ Window *pFocusWindow = Application::GetFocusWindow();
+
+ if( pFocusWindow )
+ return pFocusWindow->GetClipboard();
+
+ return Reference< XClipboard > ();
+}
+
+// -----------------------------------------------------------------------------
+
+const Sequence< sal_Int8 >& TransferableHelper::getUnoTunnelId()
+{
+ static Sequence< sal_Int8 > aSeq;
+
+ if( !aSeq.getLength() )
+ {
+ static osl::Mutex aCreateMutex;
+ osl::Guard< osl::Mutex > aGuard( aCreateMutex );
+
+ aSeq.realloc( 16 );
+ rtl_createUuid( reinterpret_cast< sal_uInt8* >( aSeq.getArray() ), 0, sal_True );
+ }
+
+
+ return aSeq;
+}
+
+// ---------------------------------
+// - TransferableClipboardNotifier -
+// ---------------------------------
+
+class TransferableClipboardNotifier : public ::cppu::WeakImplHelper1< XClipboardListener >
+{
+private:
+ ::osl::Mutex& mrMutex;
+ Reference< XClipboardNotifier > mxNotifier;
+ TransferableDataHelper* mpListener;
+
+protected:
+ // XClipboardListener
+ virtual void SAL_CALL changedContents( const clipboard::ClipboardEvent& event ) throw (RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
+
+public:
+ TransferableClipboardNotifier( const Reference< XClipboard >& _rxClipboard, TransferableDataHelper& _rListener, ::osl::Mutex& _rMutex );
+
+ /// determines whether we're currently listening
+ inline bool isListening() const { return !isDisposed(); }
+
+ /// determines whether the instance is disposed
+ inline bool isDisposed() const { return mpListener == NULL; }
+
+ /// makes the instance non-functional
+ void dispose();
+};
+
+// -----------------------------------------------------------------------------
+
+TransferableClipboardNotifier::TransferableClipboardNotifier( const Reference< XClipboard >& _rxClipboard, TransferableDataHelper& _rListener, ::osl::Mutex& _rMutex )
+ :mrMutex( _rMutex )
+ ,mxNotifier( _rxClipboard, UNO_QUERY )
+ ,mpListener( &_rListener )
+{
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ if ( mxNotifier.is() )
+ mxNotifier->addClipboardListener( this );
+ else
+ // born dead
+ mpListener = NULL;
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TransferableClipboardNotifier::changedContents( const clipboard::ClipboardEvent& event ) throw (RuntimeException)
+{
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ // the SolarMutex here is necessary, since
+ // - we cannot call mpListener without our own mutex locked
+ // - Rebind respectively InitFormats (called by Rebind) will
+ // try to lock the SolarMutex, too
+ ::osl::MutexGuard aGuard( mrMutex );
+ if( mpListener )
+ mpListener->Rebind( event.Contents );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TransferableClipboardNotifier::disposing( const EventObject& ) throw (RuntimeException)
+{
+ // clipboard is being disposed. Hmm. Okay, become disfunctional myself.
+ dispose();
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferableClipboardNotifier::dispose()
+{
+ ::osl::MutexGuard aGuard( mrMutex );
+
+ Reference< XClipboardListener > xKeepMeAlive( this );
+
+ if ( mxNotifier.is() )
+ mxNotifier->removeClipboardListener( this );
+ mxNotifier.clear();
+
+ mpListener = NULL;
+}
+
+// -------------------------------
+// - TransferableDataHelper_Impl -
+// -------------------------------
+
+struct TransferableDataHelper_Impl
+{
+ ::osl::Mutex maMutex;
+ TransferableClipboardNotifier* mpClipboardListener;
+
+ TransferableDataHelper_Impl()
+ :mpClipboardListener( NULL )
+ {
+ }
+};
+
+// --------------------------
+// - TransferableDataHelper -
+// --------------------------
+
+TransferableDataHelper::TransferableDataHelper() :
+ mpFormats( new DataFlavorExVector ),
+ mpObjDesc( new TransferableObjectDescriptor ),
+ mpImpl( new TransferableDataHelper_Impl )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+TransferableDataHelper::TransferableDataHelper( const Reference< ::com::sun::star::datatransfer::XTransferable >& rxTransferable ) :
+ mxTransfer( rxTransferable ),
+ mpFormats( new DataFlavorExVector ),
+ mpObjDesc( new TransferableObjectDescriptor ),
+ mpImpl( new TransferableDataHelper_Impl )
+{
+ InitFormats();
+}
+
+// -----------------------------------------------------------------------------
+
+TransferableDataHelper::TransferableDataHelper( const TransferableDataHelper& rDataHelper ) :
+ mxTransfer( rDataHelper.mxTransfer ),
+ mxClipboard( rDataHelper.mxClipboard ),
+ mpFormats( new DataFlavorExVector( *rDataHelper.mpFormats ) ),
+ mpObjDesc( new TransferableObjectDescriptor( *rDataHelper.mpObjDesc ) ),
+ mpImpl( new TransferableDataHelper_Impl )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+TransferableDataHelper& TransferableDataHelper::operator=( const TransferableDataHelper& rDataHelper )
+{
+ if ( this != &rDataHelper )
+ {
+ ::osl::MutexGuard aGuard( mpImpl->maMutex );
+
+ bool bWasClipboardListening = ( NULL != mpImpl->mpClipboardListener );
+
+ if ( bWasClipboardListening )
+ StopClipboardListening();
+
+ mxTransfer = rDataHelper.mxTransfer;
+ delete mpFormats, mpFormats = new DataFlavorExVector( *rDataHelper.mpFormats );
+ delete mpObjDesc, mpObjDesc = new TransferableObjectDescriptor( *rDataHelper.mpObjDesc );
+ mxClipboard = rDataHelper.mxClipboard;
+
+ if ( bWasClipboardListening )
+ StartClipboardListening();
+ }
+
+ return *this;
+}
+
+// -----------------------------------------------------------------------------
+
+TransferableDataHelper::~TransferableDataHelper()
+{
+ StopClipboardListening( );
+ {
+ ::osl::MutexGuard aGuard( mpImpl->maMutex );
+ delete mpFormats, mpFormats = NULL;
+ delete mpObjDesc, mpObjDesc = NULL;
+ }
+ delete mpImpl;
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferableDataHelper::FillDataFlavorExVector( const Sequence< DataFlavor >& rDataFlavorSeq,
+ DataFlavorExVector& rDataFlavorExVector )
+{
+ try
+ {
+ Reference< XMultiServiceFactory > xFact( ::comphelper::getProcessServiceFactory() );
+ Reference< XMimeContentTypeFactory > xMimeFact;
+ DataFlavorEx aFlavorEx;
+ const ::rtl::OUString aCharsetStr( ::rtl::OUString::createFromAscii( "charset" ) );
+
+ if( xFact.is() )
+ xMimeFact = Reference< XMimeContentTypeFactory >( xFact->createInstance( ::rtl::OUString::createFromAscii(
+ "com.sun.star.datatransfer.MimeContentTypeFactory" ) ),
+ UNO_QUERY );
+
+ for( sal_Int32 i = 0; i < rDataFlavorSeq.getLength(); i++ )
+ {
+ const DataFlavor& rFlavor = rDataFlavorSeq[ i ];
+ Reference< XMimeContentType > xMimeType;
+
+ try
+ {
+ if( xMimeFact.is() && rFlavor.MimeType.getLength() )
+ xMimeType = xMimeFact->createMimeContentType( rFlavor.MimeType );
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+
+ }
+
+ aFlavorEx.MimeType = rFlavor.MimeType;
+ aFlavorEx.HumanPresentableName = rFlavor.HumanPresentableName;
+ aFlavorEx.DataType = rFlavor.DataType;
+ aFlavorEx.mnSotId = SotExchange::RegisterFormat( rFlavor );
+
+ rDataFlavorExVector.push_back( aFlavorEx );
+
+ // add additional formats for special mime types
+ if( SOT_FORMATSTR_ID_BMP == aFlavorEx.mnSotId )
+ {
+ if( SotExchange::GetFormatDataFlavor( SOT_FORMAT_BITMAP, aFlavorEx ) )
+ {
+ aFlavorEx.mnSotId = SOT_FORMAT_BITMAP;
+ rDataFlavorExVector.push_back( aFlavorEx );
+ }
+ }
+ else if( SOT_FORMATSTR_ID_WMF == aFlavorEx.mnSotId || SOT_FORMATSTR_ID_EMF == aFlavorEx.mnSotId )
+ {
+ if( SotExchange::GetFormatDataFlavor( SOT_FORMAT_GDIMETAFILE, aFlavorEx ) )
+ {
+ aFlavorEx.mnSotId = SOT_FORMAT_GDIMETAFILE;
+ rDataFlavorExVector.push_back( aFlavorEx );
+ }
+ }
+ else if ( SOT_FORMATSTR_ID_HTML_SIMPLE == aFlavorEx.mnSotId )
+ {
+ // #104735# HTML_SIMPLE may also be inserted without comments
+ aFlavorEx.mnSotId = SOT_FORMATSTR_ID_HTML_NO_COMMENT;
+ rDataFlavorExVector.push_back( aFlavorEx );
+ }
+ else if( xMimeType.is() && xMimeType->getFullMediaType().equalsIgnoreAsciiCase( ::rtl::OUString::createFromAscii( "text/plain" ) ) )
+ {
+ // add, if it is a UTF-8 byte buffer
+ if( xMimeType->hasParameter( aCharsetStr ) )
+ {
+ const ::rtl::OUString aCharset( xMimeType->getParameterValue( aCharsetStr ) );
+
+ if( xMimeType->getParameterValue( aCharsetStr ).equalsIgnoreAsciiCase( ::rtl::OUString::createFromAscii( "unicode" ) ) ||
+ xMimeType->getParameterValue( aCharsetStr ).equalsIgnoreAsciiCase( ::rtl::OUString::createFromAscii( "utf-16" ) ) )
+ {
+ rDataFlavorExVector[ rDataFlavorExVector.size() - 1 ].mnSotId = FORMAT_STRING;
+
+ }
+ }
+ }
+ else if( xMimeType.is() && xMimeType->getFullMediaType().equalsIgnoreAsciiCase( ::rtl::OUString::createFromAscii( "text/rtf" ) ) )
+ {
+ rDataFlavorExVector[ rDataFlavorExVector.size() - 1 ].mnSotId = FORMAT_RTF;
+ }
+ else if( xMimeType.is() && xMimeType->getFullMediaType().equalsIgnoreAsciiCase( ::rtl::OUString::createFromAscii( "text/html" ) ) )
+
+ {
+ rDataFlavorExVector[ rDataFlavorExVector.size() - 1 ].mnSotId = SOT_FORMATSTR_ID_HTML;
+ }
+ else if( xMimeType.is() && xMimeType->getFullMediaType().equalsIgnoreAsciiCase( ::rtl::OUString::createFromAscii( "text/uri-list" ) ) )
+ {
+ rDataFlavorExVector[ rDataFlavorExVector.size() - 1 ].mnSotId = SOT_FORMAT_FILE_LIST;
+ }
+ else if( xMimeType.is() && xMimeType->getFullMediaType().equalsIgnoreAsciiCase( ::rtl::OUString::createFromAscii( "application/x-openoffice-objectdescriptor-xml" ) ) )
+ {
+ rDataFlavorExVector[ rDataFlavorExVector.size() - 1 ].mnSotId = SOT_FORMATSTR_ID_OBJECTDESCRIPTOR;
+ }
+ }
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferableDataHelper::InitFormats()
+{
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( mpImpl->maMutex );
+
+ mpFormats->clear();
+ delete mpObjDesc, mpObjDesc = new TransferableObjectDescriptor;
+
+ if( mxTransfer.is() )
+ {
+ TransferableDataHelper::FillDataFlavorExVector( mxTransfer->getTransferDataFlavors(), *mpFormats );
+
+ DataFlavorExVector::iterator aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
+
+ while( aIter != aEnd )
+ {
+ if( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR == aIter->mnSotId )
+ {
+ ImplSetParameterString( *mpObjDesc, *aIter );
+ aIter = aEnd;
+ }
+ else
+ ++aIter;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::HasFormat( SotFormatStringId nFormat ) const
+{
+ ::osl::MutexGuard aGuard( mpImpl->maMutex );
+
+ DataFlavorExVector::iterator aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
+ sal_Bool bRet = sal_False;
+
+ while( aIter != aEnd )
+ {
+ if( nFormat == (*aIter++).mnSotId )
+ {
+ aIter = aEnd;
+ bRet = sal_True;
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::HasFormat( const DataFlavor& rFlavor ) const
+{
+ ::osl::MutexGuard aGuard( mpImpl->maMutex );
+
+ DataFlavorExVector::iterator aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
+ sal_Bool bRet = sal_False;
+
+ while( aIter != aEnd )
+ {
+ if( TransferableDataHelper::IsEqual( rFlavor, *aIter++ ) )
+ {
+ aIter = aEnd;
+ bRet = sal_True;
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_uInt32 TransferableDataHelper::GetFormatCount() const
+{
+ ::osl::MutexGuard aGuard( mpImpl->maMutex );
+ return mpFormats->size();
+}
+
+// -----------------------------------------------------------------------------
+
+
+SotFormatStringId TransferableDataHelper::GetFormat( sal_uInt32 nFormat ) const
+{
+ ::osl::MutexGuard aGuard( mpImpl->maMutex );
+ DBG_ASSERT( nFormat < mpFormats->size(), "TransferableDataHelper::GetFormat: invalid format index" );
+ return( ( nFormat < mpFormats->size() ) ? (*mpFormats)[ nFormat ].mnSotId : 0 );
+}
+
+// -----------------------------------------------------------------------------
+
+DataFlavor TransferableDataHelper::GetFormatDataFlavor( sal_uInt32 nFormat ) const
+{
+ ::osl::MutexGuard aGuard( mpImpl->maMutex );
+ DBG_ASSERT( nFormat < mpFormats->size(), "TransferableDataHelper::GetFormat: invalid format index" );
+
+ DataFlavor aRet;
+
+ if( nFormat < mpFormats->size() )
+ aRet = (*mpFormats)[ nFormat ];
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XTransferable > TransferableDataHelper::GetXTransferable() const
+{
+ Reference< XTransferable > xRet;
+
+ if( mxTransfer.is() )
+ {
+ try
+ {
+ xRet = mxTransfer;
+
+ // do a dummy call to check, if this interface is valid (nasty)
+ Sequence< DataFlavor > aTestSeq( xRet->getTransferDataFlavors() );
+
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ xRet = Reference< XTransferable >();
+ }
+ }
+
+ return xRet;
+}
+
+// -----------------------------------------------------------------------------
+
+Any TransferableDataHelper::GetAny( SotFormatStringId nFormat ) const
+{
+ Any aReturn;
+
+ DataFlavor aFlavor;
+ if ( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) )
+ aReturn = GetAny( aFlavor );
+
+ return aReturn;
+}
+
+
+// -----------------------------------------------------------------------------
+
+Any TransferableDataHelper::GetAny( const DataFlavor& rFlavor ) const
+{
+ ::osl::MutexGuard aGuard( mpImpl->maMutex );
+ Any aRet;
+
+ try
+ {
+ if( mxTransfer.is() )
+ {
+ DataFlavorExVector::iterator aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
+ const SotFormatStringId nRequestFormat = SotExchange::GetFormat( rFlavor );
+
+ if( nRequestFormat )
+ {
+ // try to get alien format first
+ while( aIter != aEnd )
+ {
+ if( ( nRequestFormat == (*aIter).mnSotId ) && !rFlavor.MimeType.equalsIgnoreAsciiCase( (*aIter).MimeType ) )
+ aRet = mxTransfer->getTransferData( *aIter );
+
+ if( aRet.hasValue() )
+ aIter = aEnd;
+ else
+ aIter++;
+ }
+ }
+
+ if( !aRet.hasValue() )
+ aRet = mxTransfer->getTransferData( rFlavor );
+ }
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetString( SotFormatStringId nFormat, String& rStr )
+{
+ ::rtl::OUString aOUString;
+ sal_Bool bRet = GetString( nFormat, aOUString );
+
+ rStr = aOUString;
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetString( const DataFlavor& rFlavor, String& rStr )
+{
+ ::rtl::OUString aOUString;
+ sal_Bool bRet = GetString( rFlavor, aOUString );
+
+ rStr = aOUString;
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetString( SotFormatStringId nFormat, ::rtl::OUString& rStr )
+{
+ DataFlavor aFlavor;
+ return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetString( aFlavor, rStr ) );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetString( const DataFlavor& rFlavor, ::rtl::OUString& rStr )
+{
+ Any aAny( GetAny( rFlavor ) );
+ sal_Bool bRet = sal_False;
+
+ if( aAny.hasValue() )
+ {
+ ::rtl::OUString aOUString;
+ Sequence< sal_Int8 > aSeq;
+
+ if( aAny >>= aOUString )
+ {
+ rStr = aOUString;
+ bRet = sal_True;
+ }
+ else if( aAny >>= aSeq )
+ {
+
+ const sal_Char* pChars = reinterpret_cast< const sal_Char* >( aSeq.getConstArray() );
+ sal_Int32 nLen = aSeq.getLength();
+
+ //JP 10.10.2001: 92930 - don't copy the last zero characterinto the string.
+ //DVO 2002-05-27: strip _all_ trailing zeros
+ while( nLen && ( 0 == *( pChars + nLen - 1 ) ) )
+ --nLen;
+
+ rStr = ::rtl::OUString( pChars, nLen, gsl_getSystemTextEncoding() );
+ bRet = sal_True;
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetBitmap( SotFormatStringId nFormat, Bitmap& rBmp )
+{
+ DataFlavor aFlavor;
+ return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetBitmap( aFlavor, rBmp ) );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetBitmap( const DataFlavor& rFlavor, Bitmap& rBmp )
+{
+ SotStorageStreamRef xStm;
+ DataFlavor aSubstFlavor;
+ sal_Bool bRet = GetSotStorageStream( rFlavor, xStm );
+
+ if( bRet )
+ {
+ *xStm >> rBmp;
+ bRet = ( xStm->GetError() == ERRCODE_NONE );
+
+ /* SJ: #110748# At the moment we are having problems with DDB inserted as DIB. The
+ problem is, that some graphics are inserted much too big because the nXPelsPerMeter
+ and nYPelsPerMeter of the bitmap fileheader isn't including the correct value.
+ Due to this reason the following code assumes that bitmaps with a logical size
+ greater than 50 cm aren't having the correct mapmode set.
+
+ The following code should be removed if DDBs and DIBs are supported via clipboard
+ properly.
+ */
+ if ( bRet )
+ {
+ MapMode aMapMode = rBmp.GetPrefMapMode();
+ if ( aMapMode.GetMapUnit() != MAP_PIXEL )
+ {
+ Size aSize = OutputDevice::LogicToLogic( rBmp.GetPrefSize(), aMapMode, MAP_100TH_MM );
+ if ( ( aSize.Width() > 5000 ) || ( aSize.Height() > 5000 ) )
+ rBmp.SetPrefMapMode( MAP_PIXEL );
+ }
+ }
+ }
+
+ if( !bRet &&
+ HasFormat( SOT_FORMATSTR_ID_BMP ) &&
+ SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_BMP, aSubstFlavor ) &&
+ GetSotStorageStream( aSubstFlavor, xStm ) )
+ {
+ xStm->ResetError();
+ *xStm >> rBmp;
+ bRet = ( xStm->GetError() == ERRCODE_NONE );
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetGDIMetaFile( SotFormatStringId nFormat, GDIMetaFile& rMtf )
+{
+ DataFlavor aFlavor;
+ return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetGDIMetaFile( aFlavor, rMtf ) );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetGDIMetaFile( const DataFlavor& rFlavor, GDIMetaFile& rMtf )
+{
+ SotStorageStreamRef xStm;
+ DataFlavor aSubstFlavor;
+ sal_Bool bRet = sal_False;
+
+ if( GetSotStorageStream( rFlavor, xStm ) )
+ {
+ *xStm >> rMtf;
+ bRet = ( xStm->GetError() == ERRCODE_NONE );
+ }
+
+ if( !bRet &&
+ HasFormat( SOT_FORMATSTR_ID_EMF ) &&
+ SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_EMF, aSubstFlavor ) &&
+ GetSotStorageStream( aSubstFlavor, xStm ) )
+ {
+ Graphic aGraphic;
+
+ if( GraphicConverter::Import( *xStm, aGraphic ) == ERRCODE_NONE )
+ {
+ rMtf = aGraphic.GetGDIMetaFile();
+ bRet = TRUE;
+ }
+ }
+
+ if( !bRet &&
+ HasFormat( SOT_FORMATSTR_ID_WMF ) &&
+ SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_WMF, aSubstFlavor ) &&
+ GetSotStorageStream( aSubstFlavor, xStm ) )
+ {
+ Graphic aGraphic;
+
+ if( GraphicConverter::Import( *xStm, aGraphic ) == ERRCODE_NONE )
+ {
+ rMtf = aGraphic.GetGDIMetaFile();
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetGraphic( SotFormatStringId nFormat, Graphic& rGraphic )
+{
+ DataFlavor aFlavor;
+ return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetGraphic( aFlavor, rGraphic ) );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetGraphic( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, Graphic& rGraphic )
+{
+ DataFlavor aFlavor;
+ sal_Bool bRet = sal_False;
+
+ if( SotExchange::GetFormatDataFlavor( SOT_FORMAT_BITMAP, aFlavor ) &&
+ TransferableDataHelper::IsEqual( aFlavor, rFlavor ) )
+ {
+ Bitmap aBmp;
+
+ if( ( bRet = GetBitmap( aFlavor, aBmp ) ) == sal_True )
+ rGraphic = aBmp;
+ }
+ else if( SotExchange::GetFormatDataFlavor( SOT_FORMAT_GDIMETAFILE, aFlavor ) &&
+ TransferableDataHelper::IsEqual( aFlavor, rFlavor ) )
+ {
+ GDIMetaFile aMtf;
+
+ if( ( bRet = GetGDIMetaFile( aFlavor, aMtf ) ) == sal_True )
+ rGraphic = aMtf;
+ }
+ else
+ {
+ SotStorageStreamRef xStm;
+
+ if( GetSotStorageStream( rFlavor, xStm ) )
+ {
+ *xStm >> rGraphic;
+ bRet = ( xStm->GetError() == ERRCODE_NONE );
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetImageMap( SotFormatStringId nFormat, ImageMap& rIMap )
+{
+ DataFlavor aFlavor;
+ return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetImageMap( aFlavor, rIMap ) );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetImageMap( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, ImageMap& rIMap )
+{
+ SotStorageStreamRef xStm;
+ sal_Bool bRet = GetSotStorageStream( rFlavor, xStm );
+
+ if( bRet )
+ {
+ rIMap.Read( *xStm, String() );
+ bRet = ( xStm->GetError() == ERRCODE_NONE );
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetTransferableObjectDescriptor( SotFormatStringId nFormat, TransferableObjectDescriptor& rDesc )
+{
+ DataFlavor aFlavor;
+ return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetTransferableObjectDescriptor( aFlavor, rDesc ) );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetTransferableObjectDescriptor( const ::com::sun::star::datatransfer::DataFlavor&, TransferableObjectDescriptor& rDesc )
+{
+ rDesc = *mpObjDesc;
+ return true;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetINetBookmark( SotFormatStringId nFormat, INetBookmark& rBmk )
+{
+ DataFlavor aFlavor;
+ return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetINetBookmark( aFlavor, rBmk ) );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetINetBookmark( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, INetBookmark& rBmk )
+{
+ sal_Bool bRet = sal_False;
+ if( HasFormat( rFlavor ))
+ {
+ const SotFormatStringId nFormat = SotExchange::GetFormat( rFlavor );
+ switch( nFormat )
+ {
+ case( SOT_FORMATSTR_ID_SOLK ):
+ case( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ):
+ {
+ String aString;
+ if( GetString( rFlavor, aString ) )
+ {
+ if( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR == nFormat )
+ {
+ rBmk = INetBookmark( aString, aString );
+ bRet = sal_True;
+ }
+ else
+ {
+ String aURL, aDesc;
+ sal_uInt16 nStart = aString.Search( '@' ), nLen = (sal_uInt16) aString.ToInt32();
+
+ if( !nLen && aString.GetChar( 0 ) != '0' )
+ {
+ DBG_WARNING( "SOLK: 1. len=0" );
+ }
+ if( nStart == STRING_NOTFOUND || nLen > aString.Len() - nStart - 3 )
+ {
+ DBG_WARNING( "SOLK: 1. illegal start or wrong len" );
+ }
+ aURL = aString.Copy( nStart + 1, nLen );
+
+ aString.Erase( 0, nStart + 1 + nLen );
+ nStart = aString.Search( '@' );
+ nLen = (sal_uInt16) aString.ToInt32();
+
+ if( !nLen && aString.GetChar( 0 ) != '0' )
+ {
+ DBG_WARNING( "SOLK: 2. len=0" );
+ }
+ if( nStart == STRING_NOTFOUND || nLen > aString.Len() - nStart - 1 )
+ {
+ DBG_WARNING( "SOLK: 2. illegal start or wrong len" );
+ }
+ aDesc = aString.Copy( nStart+1, nLen );
+
+ rBmk = INetBookmark( aURL, aDesc );
+ bRet = sal_True;
+ }
+ }
+ }
+ break;
+
+ case( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ):
+ {
+ Sequence< sal_Int8 > aSeq;
+
+ if( GetSequence( rFlavor, aSeq ) && ( 2048 == aSeq.getLength() ) )
+ {
+ rBmk = INetBookmark( String( reinterpret_cast< const sal_Char* >( aSeq.getConstArray() ), gsl_getSystemTextEncoding() ),
+ String( reinterpret_cast< const sal_Char* >( aSeq.getConstArray() ) + 1024, gsl_getSystemTextEncoding() ) );
+ bRet = sal_True;
+ }
+ }
+ break;
+
+#ifdef WNT
+ case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR:
+ {
+ Sequence< sal_Int8 > aSeq;
+
+ if( GetSequence( rFlavor, aSeq ) && aSeq.getLength() )
+ {
+ FILEGROUPDESCRIPTOR* pFDesc = (FILEGROUPDESCRIPTOR*) aSeq.getConstArray();
+
+ if( pFDesc->cItems )
+ {
+ ByteString aDesc( pFDesc->fgd[ 0 ].cFileName );
+ rtl_TextEncoding eTextEncoding = gsl_getSystemTextEncoding();
+
+ if( ( aDesc.Len() > 4 ) && aDesc.Copy( aDesc.Len() - 4 ).EqualsIgnoreCaseAscii( ".URL" ) )
+ {
+ SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( INetURLObject( String( aDesc, eTextEncoding ) ).GetMainURL( INetURLObject::NO_DECODE ),
+ STREAM_STD_READ );
+
+ if( !pStream || pStream->GetError() )
+ {
+ DataFlavor aFileContentFlavor;
+
+ aSeq.realloc( 0 );
+ delete pStream;
+
+ if( SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_FILECONTENT, aFileContentFlavor ) &&
+ GetSequence( aFileContentFlavor, aSeq ) && aSeq.getLength() )
+ {
+ pStream = new SvMemoryStream( (sal_Char*) aSeq.getConstArray(), aSeq.getLength(), STREAM_STD_READ );
+ }
+ else
+ pStream = NULL;
+ }
+
+ if( pStream )
+ {
+ ByteString aLine;
+ sal_Bool bSttFnd = sal_False;
+
+ while( pStream->ReadLine( aLine ) )
+ {
+ if( aLine.EqualsIgnoreCaseAscii( "[InternetShortcut]" ) )
+ bSttFnd = sal_True;
+ else if( bSttFnd && aLine.Copy( 0, 4 ).EqualsIgnoreCaseAscii( "URL=" ) )
+ {
+ rBmk = INetBookmark( String( aLine.Erase( 0, 4 ), eTextEncoding ),
+ String( aDesc.Erase( aDesc.Len() - 4 ), eTextEncoding ) );
+ bRet = sal_True;
+ break;
+ }
+ }
+
+ delete pStream;
+ }
+ }
+ }
+ }
+ }
+ break;
+#endif
+
+ }
+ }
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetINetImage( SotFormatStringId nFormat,
+ INetImage& rINtImg )
+{
+ DataFlavor aFlavor;
+ return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetINetImage( aFlavor, rINtImg ) );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetINetImage(
+ const ::com::sun::star::datatransfer::DataFlavor& rFlavor,
+ INetImage& rINtImg )
+{
+ SotStorageStreamRef xStm;
+ sal_Bool bRet = GetSotStorageStream( rFlavor, xStm );
+
+ if( bRet )
+ bRet = rINtImg.Read( *xStm, SotExchange::GetFormat( rFlavor ) );
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetFileList( SotFormatStringId nFormat,
+ FileList& rFileList )
+{
+ DataFlavor aFlavor;
+ return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetFileList( aFlavor, rFileList ) );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetFileList(
+ const ::com::sun::star::datatransfer::DataFlavor&,
+ FileList& rFileList )
+{
+ SotStorageStreamRef xStm;
+ sal_Bool bRet = sal_False;
+
+ for( sal_uInt32 i = 0, nFormatCount = GetFormatCount(); ( i < nFormatCount ) && !bRet; ++i )
+ {
+ if( SOT_FORMAT_FILE_LIST == GetFormat( i ) )
+ {
+ const DataFlavor aFlavor( GetFormatDataFlavor( i ) );
+
+ if( GetSotStorageStream( aFlavor, xStm ) )
+ {
+ if( aFlavor.MimeType.indexOf( ::rtl::OUString::createFromAscii( "text/uri-list" ) ) > -1 )
+ {
+ ByteString aByteString;
+
+ while( xStm->ReadLine( aByteString ) )
+ if( aByteString.Len() && aByteString.GetChar( 0 ) != '#' )
+ rFileList.AppendFile( String( aByteString, RTL_TEXTENCODING_UTF8 ) );
+
+ bRet = sal_True;
+ }
+ else
+ bRet = ( ( *xStm >> rFileList ).GetError() == ERRCODE_NONE );
+ }
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetSequence( SotFormatStringId nFormat, Sequence< sal_Int8 >& rSeq )
+{
+ DataFlavor aFlavor;
+ return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetSequence( aFlavor, rSeq ) );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetSequence( const DataFlavor& rFlavor, Sequence< sal_Int8 >& rSeq )
+{
+#ifdef DEBUG
+ fprintf( stderr, "TransferableDataHelper requests sequence of data\n" );
+#endif
+
+ const Any aAny( GetAny( rFlavor ) );
+ return( aAny.hasValue() && ( aAny >>= rSeq ) );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetSotStorageStream( SotFormatStringId nFormat, SotStorageStreamRef& rxStream )
+{
+ DataFlavor aFlavor;
+ return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetSotStorageStream( aFlavor, rxStream ) );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetSotStorageStream( const DataFlavor& rFlavor, SotStorageStreamRef& rxStream )
+{
+ Sequence< sal_Int8 > aSeq;
+ sal_Bool bRet = GetSequence( rFlavor, aSeq );
+
+ if( bRet )
+ {
+ rxStream = new SotStorageStream( String() );
+ rxStream->Write( aSeq.getConstArray(), aSeq.getLength() );
+ rxStream->Seek( 0 );
+ }
+
+ return bRet;
+}
+
+sal_Bool TransferableDataHelper::GetInputStream( SotFormatStringId nFormat, Reference < XInputStream >& rxStream )
+{
+ DataFlavor aFlavor;
+ return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetInputStream( aFlavor, rxStream ) );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetInputStream( const DataFlavor& rFlavor, Reference < XInputStream >& rxStream )
+{
+ Sequence< sal_Int8 > aSeq;
+ sal_Bool bRet = GetSequence( rFlavor, aSeq );
+
+ if( bRet )
+ rxStream = new ::comphelper::SequenceInputStream( aSeq );
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+
+sal_Bool TransferableDataHelper::GetInterface( SotFormatStringId nFormat, Reference< XInterface >& rIf )
+{
+ DataFlavor aFlavor;
+ return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetInterface( aFlavor, rIf ) );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::GetInterface( const DataFlavor& rFlavor, Reference< XInterface >& rIf )
+{
+ const Any aAny( GetAny( rFlavor ) );
+ return( aAny.hasValue() && ( aAny >>= rIf ) );
+}
+
+// -----------------------------------------------------------------------------
+void TransferableDataHelper::Rebind( const Reference< XTransferable >& _rxNewContent )
+{
+ mxTransfer = _rxNewContent;
+ InitFormats();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferableDataHelper::StartClipboardListening( )
+{
+ ::osl::MutexGuard aGuard( mpImpl->maMutex );
+
+ StopClipboardListening( );
+
+ mpImpl->mpClipboardListener = new TransferableClipboardNotifier( mxClipboard, *this, mpImpl->maMutex );
+ mpImpl->mpClipboardListener->acquire();
+
+ return mpImpl->mpClipboardListener->isListening();
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferableDataHelper::StopClipboardListening( )
+{
+ ::osl::MutexGuard aGuard( mpImpl->maMutex );
+
+ if ( mpImpl->mpClipboardListener )
+ {
+ mpImpl->mpClipboardListener->dispose();
+ mpImpl->mpClipboardListener->release();
+ mpImpl->mpClipboardListener = NULL;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+TransferableDataHelper TransferableDataHelper::CreateFromSystemClipboard( Window * pWindow )
+{
+ DBG_ASSERT( pWindow, "Window pointer is NULL" );
+
+ Reference< XClipboard > xClipboard;
+ TransferableDataHelper aRet;
+
+ if( pWindow )
+ xClipboard = pWindow->GetClipboard();
+
+ if( xClipboard.is() )
+ {
+ try
+
+ {
+ Reference< XTransferable > xTransferable( xClipboard->getContents() );
+
+ if( xTransferable.is() )
+ {
+ aRet = TransferableDataHelper( xTransferable );
+ aRet.mxClipboard = xClipboard;
+ // also copy the clipboard - 99030 - 23.05.2002 - fs@openoffice.org
+ }
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+ }
+
+ return aRet;
+}
+
+
+// -----------------------------------------------------------------------------
+
+TransferableDataHelper TransferableDataHelper::CreateFromSelection( Window* pWindow )
+{
+ DBG_ASSERT( pWindow, "Window pointer is NULL" );
+
+ Reference< XClipboard > xSelection;
+ TransferableDataHelper aRet;
+
+ if( pWindow )
+ xSelection = pWindow->GetPrimarySelection();
+
+ if( xSelection.is() )
+ {
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+
+ try
+ {
+ Reference< XTransferable > xTransferable( xSelection->getContents() );
+
+ if( xTransferable.is() )
+ {
+ aRet = TransferableDataHelper( xTransferable );
+ aRet.mxClipboard = xSelection;
+ }
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+
+ Application::AcquireSolarMutex( nRef );
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool TransferableDataHelper::IsEqual( const ::com::sun::star::datatransfer::DataFlavor& rInternalFlavor,
+ const ::com::sun::star::datatransfer::DataFlavor& rRequestFlavor,
+ sal_Bool )
+{
+ Reference< XMultiServiceFactory > xFact( ::comphelper::getProcessServiceFactory() );
+ Reference< XMimeContentTypeFactory > xMimeFact;
+ sal_Bool bRet = sal_False;
+
+ try
+ {
+ if( xFact.is() )
+ xMimeFact = Reference< XMimeContentTypeFactory >( xFact->createInstance( ::rtl::OUString::createFromAscii(
+ "com.sun.star.datatransfer.MimeContentTypeFactory" ) ),
+ UNO_QUERY );
+
+ if( xMimeFact.is() )
+ {
+ Reference< XMimeContentType > xRequestType1( xMimeFact->createMimeContentType( rInternalFlavor.MimeType ) );
+ Reference< XMimeContentType > xRequestType2( xMimeFact->createMimeContentType( rRequestFlavor.MimeType ) );
+
+ if( xRequestType1.is() && xRequestType2.is() )
+ {
+ if( xRequestType1->getFullMediaType().equalsIgnoreAsciiCase( xRequestType2->getFullMediaType() ) )
+ {
+ if( xRequestType1->getFullMediaType().equalsIgnoreAsciiCase( ::rtl::OUString::createFromAscii( "text/plain" ) ) )
+ {
+ // special handling for text/plain media types
+ const ::rtl::OUString aCharsetString( ::rtl::OUString::createFromAscii( "charset" ) );
+
+ if( !xRequestType2->hasParameter( aCharsetString ) ||
+ xRequestType2->getParameterValue( aCharsetString ).equalsIgnoreAsciiCase( ::rtl::OUString::createFromAscii( "utf-16" ) ) ||
+ xRequestType2->getParameterValue( aCharsetString ).equalsIgnoreAsciiCase( ::rtl::OUString::createFromAscii( "unicode" ) ) )
+ {
+ bRet = sal_True;
+ }
+ }
+ else if( xRequestType1->getFullMediaType().equalsIgnoreAsciiCase( ::rtl::OUString::createFromAscii( "application/x-openoffice" ) ) )
+ {
+ // special handling for application/x-openoffice media types
+ const ::rtl::OUString aFormatString( ::rtl::OUString::createFromAscii( "windows_formatname" ) );
+
+ if( xRequestType1->hasParameter( aFormatString ) &&
+ xRequestType2->hasParameter( aFormatString ) &&
+ xRequestType1->getParameterValue( aFormatString ).equalsIgnoreAsciiCase( xRequestType2->getParameterValue( aFormatString ) ) )
+ {
+ bRet = sal_True;
+ }
+ }
+ else
+ bRet = sal_True;
+ }
+ }
+ }
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ bRet = rInternalFlavor.MimeType.equalsIgnoreAsciiCase( rRequestFlavor.MimeType );
+ }
+
+ return bRet;
+}
diff --git a/svtools/source/misc/transfer2.cxx b/svtools/source/misc/transfer2.cxx
new file mode 100644
index 000000000000..dcd0f81b2758
--- /dev/null
+++ b/svtools/source/misc/transfer2.cxx
@@ -0,0 +1,635 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <vos/mutex.hxx>
+#ifndef DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#include <unotools/ucbstreamhelper.hxx>
+#include <sot/exchange.hxx>
+#include <sot/storage.hxx>
+#include <vcl/bitmap.hxx>
+#include <vcl/gdimtf.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+#include <comphelper/processfactory.hxx>
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_DROPTARGETDRAGCONTEXT_HPP_
+#include <com/sun/star/datatransfer/dnd/XDropTargetDragContext.hpp>
+#endif
+
+#include "svl/urlbmk.hxx"
+#include "inetimg.hxx"
+#include <svtools/imap.hxx>
+#include <svtools/transfer.hxx>
+
+// --------------
+// - Namespaces -
+// --------------
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::datatransfer::clipboard;
+using namespace ::com::sun::star::datatransfer::dnd;
+
+// -----------------------------------------
+// - DragSourceHelper::DragGestureListener -
+// -----------------------------------------
+
+DragSourceHelper::DragGestureListener::DragGestureListener( DragSourceHelper& rDragSourceHelper ) :
+ mrParent( rDragSourceHelper )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+DragSourceHelper::DragGestureListener::~DragGestureListener()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DragSourceHelper::DragGestureListener::disposing( const EventObject& ) throw( RuntimeException )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DragSourceHelper::DragGestureListener::dragGestureRecognized( const DragGestureEvent& rDGE ) throw( RuntimeException )
+{
+ const ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ const Point aPtPixel( rDGE.DragOriginX, rDGE.DragOriginY );
+ mrParent.StartDrag( rDGE.DragAction, aPtPixel );
+}
+
+// --------------------
+// - DragSourceHelper -
+// --------------------
+
+DragSourceHelper::DragSourceHelper( Window* pWindow ) :
+ mxDragGestureRecognizer( pWindow->GetDragGestureRecognizer() )
+{
+ if( mxDragGestureRecognizer.is() )
+ {
+ mxDragGestureListener = new DragSourceHelper::DragGestureListener( *this );
+ mxDragGestureRecognizer->addDragGestureListener( mxDragGestureListener );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+DragSourceHelper::~DragSourceHelper()
+{
+ if( mxDragGestureRecognizer.is() )
+ mxDragGestureRecognizer->removeDragGestureListener( mxDragGestureListener );
+}
+
+// -----------------------------------------------------------------------------
+
+void DragSourceHelper::StartDrag( sal_Int8, const Point& )
+{
+}
+
+// ----------------------------------------
+// - DropTargetHelper::DropTargetListener -
+// ----------------------------------------
+
+DropTargetHelper::DropTargetListener::DropTargetListener( DropTargetHelper& rDropTargetHelper ) :
+ mrParent( rDropTargetHelper ),
+ mpLastDragOverEvent( NULL )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+DropTargetHelper::DropTargetListener::~DropTargetListener()
+{
+ delete mpLastDragOverEvent;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DropTargetHelper::DropTargetListener::disposing( const EventObject& ) throw( RuntimeException )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DropTargetHelper::DropTargetListener::drop( const DropTargetDropEvent& rDTDE ) throw( RuntimeException )
+{
+ const ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ try
+ {
+ AcceptDropEvent aAcceptEvent;
+ ExecuteDropEvent aExecuteEvt( rDTDE.DropAction & ~DNDConstants::ACTION_DEFAULT, Point( rDTDE.LocationX, rDTDE.LocationY ), rDTDE );
+ sal_Int8 nRet = DNDConstants::ACTION_NONE;
+
+ aExecuteEvt.mbDefault = ( ( rDTDE.DropAction & DNDConstants::ACTION_DEFAULT ) != 0 );
+
+ // in case of a default action, call ::AcceptDrop first and use the returned
+ // accepted action as the execute action in the call to ::ExecuteDrop
+ aAcceptEvent.mnAction = aExecuteEvt.mnAction;
+ aAcceptEvent.maPosPixel = aExecuteEvt.maPosPixel;
+ (DropTargetEvent&)( aAcceptEvent.maDragEvent ) = (DropTargetEvent&) rDTDE;
+ ( (DropTargetDragEvent&)( aAcceptEvent.maDragEvent ) ).DropAction = rDTDE.DropAction;
+ ( (DropTargetDragEvent&)( aAcceptEvent.maDragEvent ) ).LocationX = rDTDE.LocationX;
+ ( (DropTargetDragEvent&)( aAcceptEvent.maDragEvent ) ).LocationY = rDTDE.LocationY;
+ ( (DropTargetDragEvent&)( aAcceptEvent.maDragEvent ) ).SourceActions = rDTDE.SourceActions;
+ aAcceptEvent.mbLeaving = sal_False;
+ aAcceptEvent.mbDefault = aExecuteEvt.mbDefault;
+
+ nRet = mrParent.AcceptDrop( aAcceptEvent );
+
+ if( DNDConstants::ACTION_NONE != nRet )
+ {
+ rDTDE.Context->acceptDrop( nRet );
+
+ if( aExecuteEvt.mbDefault )
+ aExecuteEvt.mnAction = nRet;
+
+ nRet = mrParent.ExecuteDrop( aExecuteEvt );
+ }
+
+ rDTDE.Context->dropComplete( DNDConstants::ACTION_NONE != nRet );
+
+ if( mpLastDragOverEvent )
+ {
+ delete mpLastDragOverEvent;
+ mpLastDragOverEvent = NULL;
+ }
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DropTargetHelper::DropTargetListener::dragEnter( const DropTargetDragEnterEvent& rDTDEE ) throw( RuntimeException )
+{
+ const ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ try
+ {
+ mrParent.ImplBeginDrag( rDTDEE.SupportedDataFlavors );
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+
+ dragOver( rDTDEE );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DropTargetHelper::DropTargetListener::dragOver( const DropTargetDragEvent& rDTDE ) throw( RuntimeException )
+{
+ const ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ try
+ {
+ if( mpLastDragOverEvent )
+ delete mpLastDragOverEvent;
+
+ mpLastDragOverEvent = new AcceptDropEvent( rDTDE.DropAction & ~DNDConstants::ACTION_DEFAULT, Point( rDTDE.LocationX, rDTDE.LocationY ), rDTDE );
+ mpLastDragOverEvent->mbDefault = ( ( rDTDE.DropAction & DNDConstants::ACTION_DEFAULT ) != 0 );
+
+ const sal_Int8 nRet = mrParent.AcceptDrop( *mpLastDragOverEvent );
+
+ if( DNDConstants::ACTION_NONE == nRet )
+ rDTDE.Context->rejectDrag();
+ else
+ rDTDE.Context->acceptDrag( nRet );
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DropTargetHelper::DropTargetListener::dragExit( const DropTargetEvent& ) throw( RuntimeException )
+{
+ const ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ try
+ {
+ if( mpLastDragOverEvent )
+ {
+ mpLastDragOverEvent->mbLeaving = sal_True;
+ mrParent.AcceptDrop( *mpLastDragOverEvent );
+ delete mpLastDragOverEvent;
+ mpLastDragOverEvent = NULL;
+ }
+
+ mrParent.ImplEndDrag();
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+}
+
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DropTargetHelper::DropTargetListener::dropActionChanged( const DropTargetDragEvent& ) throw( RuntimeException )
+{
+}
+
+// --------------------
+// - DropTargetHelper -
+// --------------------
+
+DropTargetHelper::DropTargetHelper( Window* pWindow ) :
+ mxDropTarget( pWindow->GetDropTarget() ),
+ mpFormats( new DataFlavorExVector )
+{
+ ImplConstruct();
+}
+
+// -----------------------------------------------------------------------------
+
+DropTargetHelper::DropTargetHelper( const Reference< XDropTarget >& rxDropTarget ) :
+ mxDropTarget( rxDropTarget ),
+ mpFormats( new DataFlavorExVector )
+{
+ ImplConstruct();
+}
+
+// -----------------------------------------------------------------------------
+
+DropTargetHelper::~DropTargetHelper()
+{
+ if( mxDropTarget.is() )
+ mxDropTarget->removeDropTargetListener( mxDropTargetListener );
+
+ delete mpFormats;
+}
+
+// -----------------------------------------------------------------------------
+
+void DropTargetHelper::ImplConstruct()
+{
+ if( mxDropTarget.is() )
+ {
+ mxDropTargetListener = new DropTargetHelper::DropTargetListener( *this );
+ mxDropTarget->addDropTargetListener( mxDropTargetListener );
+ mxDropTarget->setActive( sal_True );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void DropTargetHelper::ImplBeginDrag( const Sequence< DataFlavor >& rSupportedDataFlavors )
+{
+ mpFormats->clear();
+ TransferableDataHelper::FillDataFlavorExVector( rSupportedDataFlavors, *mpFormats );
+}
+
+// -----------------------------------------------------------------------------
+
+void DropTargetHelper::ImplEndDrag()
+{
+ mpFormats->clear();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int8 DropTargetHelper::AcceptDrop( const AcceptDropEvent& )
+{
+ return( DNDConstants::ACTION_NONE );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int8 DropTargetHelper::ExecuteDrop( const ExecuteDropEvent& )
+{
+ return( DNDConstants::ACTION_NONE );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool DropTargetHelper::IsDropFormatSupported( SotFormatStringId nFormat )
+{
+ DataFlavorExVector::iterator aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
+ sal_Bool bRet = sal_False;
+
+ while( aIter != aEnd )
+ {
+ if( nFormat == (*aIter++).mnSotId )
+ {
+ bRet = sal_True;
+ aIter = aEnd;
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool DropTargetHelper::IsDropFormatSupported( const DataFlavor& rFlavor )
+{
+ DataFlavorExVector::iterator aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
+ sal_Bool bRet = sal_False;
+
+ while( aIter != aEnd )
+ {
+ if( TransferableDataHelper::IsEqual( rFlavor, *aIter++ ) )
+ {
+ bRet = sal_True;
+ aIter = aEnd;
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+// TransferDataContainer
+// -----------------------------------------------------------------------------
+
+struct TDataCntnrEntry_Impl
+{
+ ::com::sun::star::uno::Any aAny;
+ SotFormatStringId nId;
+};
+
+// -----------------------------------------------------------------------------
+
+typedef ::std::list< TDataCntnrEntry_Impl > TDataCntnrEntryList;
+
+// -----------------------------------------------------------------------------
+
+struct TransferDataContainer_Impl
+{
+ TDataCntnrEntryList aFmtList;
+ Link aFinshedLnk;
+ INetBookmark* pBookmk;
+ Graphic* pGrf;
+
+ TransferDataContainer_Impl()
+ : pBookmk( 0 ), pGrf( 0 )
+ {
+ }
+
+ ~TransferDataContainer_Impl()
+ {
+ delete pBookmk;
+ delete pGrf;
+ }
+};
+
+// -----------------------------------------------------------------------------
+
+TransferDataContainer::TransferDataContainer()
+ : pImpl( new TransferDataContainer_Impl )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+TransferDataContainer::~TransferDataContainer()
+{
+ delete pImpl;
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferDataContainer::AddSupportedFormats()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferDataContainer::GetData( const
+ ::com::sun::star::datatransfer::DataFlavor& rFlavor )
+{
+ TDataCntnrEntryList::iterator aIter( pImpl->aFmtList.begin() ),
+ aEnd( pImpl->aFmtList.end() );
+ sal_Bool bFnd = sal_False;
+ ULONG nFmtId = SotExchange::GetFormat( rFlavor );
+
+ // test first the list
+ for( ; aIter != aEnd; ++aIter )
+ {
+ TDataCntnrEntry_Impl& rEntry = (TDataCntnrEntry_Impl&)*aIter;
+ if( nFmtId == rEntry.nId )
+ {
+ bFnd = SetAny( rEntry.aAny, rFlavor );
+ break;
+ }
+ }
+
+ // test second the bookmark pointer
+ if( !bFnd )
+ switch( nFmtId )
+ {
+ case SOT_FORMAT_STRING:
+ case SOT_FORMATSTR_ID_SOLK:
+ case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
+ case SOT_FORMATSTR_ID_FILECONTENT:
+ case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR:
+ case SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR:
+ if( pImpl->pBookmk )
+ bFnd = SetINetBookmark( *pImpl->pBookmk, rFlavor );
+ break;
+
+ case SOT_FORMATSTR_ID_SVXB:
+ case SOT_FORMAT_BITMAP:
+ case SOT_FORMAT_GDIMETAFILE:
+ if( pImpl->pGrf )
+ bFnd = SetGraphic( *pImpl->pGrf, rFlavor );
+ break;
+ }
+
+ return bFnd;
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferDataContainer::ClearData()
+{
+ delete pImpl;
+ pImpl = new TransferDataContainer_Impl;
+ ClearFormats();
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferDataContainer::CopyINetBookmark( const INetBookmark& rBkmk )
+{
+ if( !pImpl->pBookmk )
+ pImpl->pBookmk = new INetBookmark( rBkmk );
+ else
+ *pImpl->pBookmk = rBkmk;
+
+ AddFormat( SOT_FORMAT_STRING );
+ AddFormat( SOT_FORMATSTR_ID_SOLK );
+ AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
+ AddFormat( SOT_FORMATSTR_ID_FILECONTENT );
+ AddFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR );
+ AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR );
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferDataContainer::CopyAnyData( ULONG nFormatId,
+ const sal_Char* pData, ULONG nLen )
+{
+ if( nLen )
+ {
+ TDataCntnrEntry_Impl aEntry;
+ aEntry.nId = nFormatId;
+
+ Sequence< sal_Int8 > aSeq( nLen );
+ memcpy( aSeq.getArray(), pData, nLen );
+ aEntry.aAny <<= aSeq;
+ pImpl->aFmtList.push_back( aEntry );
+ AddFormat( nFormatId );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferDataContainer::CopyByteString( ULONG nFormatId,
+ const ByteString& rStr )
+{
+ CopyAnyData( nFormatId, rStr.GetBuffer(), rStr.Len() );
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferDataContainer::CopyINetImage( const INetImage& rINtImg )
+{
+ SvMemoryStream aMemStm( 1024, 1024 );
+ aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
+ rINtImg.Write( aMemStm, SOT_FORMATSTR_ID_INET_IMAGE );
+ CopyAnyData( SOT_FORMATSTR_ID_INET_IMAGE, (sal_Char*)aMemStm.GetData(),
+ aMemStm.Seek( STREAM_SEEK_TO_END ) );
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferDataContainer::CopyImageMap( const ImageMap& rImgMap )
+{
+ SvMemoryStream aMemStm( 8192, 8192 );
+ aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
+ rImgMap.Write( aMemStm, String() );
+ CopyAnyData( SOT_FORMATSTR_ID_SVIM, (sal_Char*)aMemStm.GetData(),
+ aMemStm.Seek( STREAM_SEEK_TO_END ) );
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferDataContainer::CopyGraphic( const Graphic& rGrf )
+{
+ GraphicType nType = rGrf.GetType();
+ if( GRAPHIC_NONE != nType )
+ {
+ if( !pImpl->pGrf )
+ pImpl->pGrf = new Graphic( rGrf );
+ else
+ *pImpl->pGrf = rGrf;
+
+ AddFormat( SOT_FORMATSTR_ID_SVXB );
+ if( GRAPHIC_BITMAP == nType )
+ AddFormat( SOT_FORMAT_BITMAP );
+ else if( GRAPHIC_GDIMETAFILE == nType )
+ AddFormat( SOT_FORMAT_GDIMETAFILE );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferDataContainer::CopyString( USHORT nFmt, const String& rStr )
+{
+ if( rStr.Len() )
+ {
+ TDataCntnrEntry_Impl aEntry;
+ aEntry.nId = nFmt;
+ rtl::OUString aStr( rStr );
+ aEntry.aAny <<= aStr;
+ pImpl->aFmtList.push_back( aEntry );
+ AddFormat( aEntry.nId );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferDataContainer::CopyString( const String& rStr )
+{
+ CopyString( SOT_FORMAT_STRING, rStr );
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferDataContainer::CopyAny( USHORT nFmt,
+ const ::com::sun::star::uno::Any& rAny )
+{
+ TDataCntnrEntry_Impl aEntry;
+ aEntry.nId = nFmt;
+ aEntry.aAny = rAny;
+ pImpl->aFmtList.push_back( aEntry );
+ AddFormat( aEntry.nId );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TransferDataContainer::HasAnyData() const
+{
+ return pImpl->aFmtList.begin() != pImpl->aFmtList.end() ||
+ 0 != pImpl->pBookmk;
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferDataContainer::StartDrag(
+ Window* pWindow, sal_Int8 nDragSourceActions,
+ const Link& rLnk, sal_Int32 nDragPointer, sal_Int32 nDragImage )
+{
+ pImpl->aFinshedLnk = rLnk;
+ TransferableHelper::StartDrag( pWindow, nDragSourceActions,
+ nDragPointer, nDragImage );
+}
+
+// -----------------------------------------------------------------------------
+
+void TransferDataContainer::DragFinished( sal_Int8 nDropAction )
+{
+ if( pImpl->aFinshedLnk.IsSet() )
+ pImpl->aFinshedLnk.Call( &nDropAction );
+}
diff --git a/svtools/source/misc/unitconv.cxx b/svtools/source/misc/unitconv.cxx
new file mode 100644
index 000000000000..612bcb4f0221
--- /dev/null
+++ b/svtools/source/misc/unitconv.cxx
@@ -0,0 +1,763 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dlgutil.cxx,v $
+ * $Revision: 1.17 $
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+// include ---------------------------------------------------------------
+
+#include <svtools/unitconv.hxx>
+
+// -----------------------------------------------------------------------
+
+void SetFieldUnit( MetricField& rField, FieldUnit eUnit, BOOL bAll )
+{
+ sal_Int64 nFirst = rField.Denormalize( rField.GetFirst( FUNIT_TWIP ) );
+ sal_Int64 nLast = rField.Denormalize( rField.GetLast( FUNIT_TWIP ) );
+ sal_Int64 nMin = rField.Denormalize( rField.GetMin( FUNIT_TWIP ) );
+ sal_Int64 nMax = rField.Denormalize( rField.GetMax( FUNIT_TWIP ) );
+
+ if ( !bAll )
+ {
+ switch ( eUnit )
+ {
+ case FUNIT_M:
+ case FUNIT_KM:
+ eUnit = FUNIT_CM;
+ break;
+
+ case FUNIT_FOOT:
+ case FUNIT_MILE:
+ eUnit = FUNIT_INCH;
+ break;
+ default: ;//prevent warning
+ }
+ }
+ rField.SetUnit( eUnit );
+ switch( eUnit )
+ {
+ case FUNIT_MM:
+ rField.SetSpinSize( 50 );
+ break;
+
+ case FUNIT_INCH:
+ rField.SetSpinSize( 2 );
+ break;
+
+ default:
+ rField.SetSpinSize( 10 );
+ }
+
+ if ( FUNIT_POINT == eUnit )
+ {
+ if( rField.GetDecimalDigits() > 1 )
+ rField.SetDecimalDigits( 1 );
+ }
+ else
+ rField.SetDecimalDigits( 2 );
+
+ if ( !bAll )
+ {
+ rField.SetFirst( rField.Normalize( nFirst ), FUNIT_TWIP );
+ rField.SetLast( rField.Normalize( nLast ), FUNIT_TWIP );
+ rField.SetMin( rField.Normalize( nMin ), FUNIT_TWIP );
+ rField.SetMax( rField.Normalize( nMax ), FUNIT_TWIP );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SetFieldUnit( MetricBox& rBox, FieldUnit eUnit, BOOL bAll )
+{
+ sal_Int64 nMin = rBox.Denormalize( rBox.GetMin( FUNIT_TWIP ) );
+ sal_Int64 nMax = rBox.Denormalize( rBox.GetMax( FUNIT_TWIP ) );
+
+ if ( !bAll )
+ {
+ switch ( eUnit )
+ {
+ case FUNIT_M:
+ case FUNIT_KM:
+ eUnit = FUNIT_CM;
+ break;
+
+ case FUNIT_FOOT:
+ case FUNIT_MILE:
+ eUnit = FUNIT_INCH;
+ break;
+ default: ;//prevent warning
+ }
+ }
+ rBox.SetUnit( eUnit );
+
+ if ( FUNIT_POINT == eUnit && rBox.GetDecimalDigits() > 1 )
+ rBox.SetDecimalDigits( 1 );
+ else
+ rBox.SetDecimalDigits( 2 );
+
+ if ( !bAll )
+ {
+ rBox.SetMin( rBox.Normalize( nMin ), FUNIT_TWIP );
+ rBox.SetMax( rBox.Normalize( nMax ), FUNIT_TWIP );
+ }
+}
+
+// -----------------------------------------------------------------------
+void SetMetricValue( MetricField& rField, long nCoreValue, SfxMapUnit eUnit )
+{
+ sal_Int64 nVal = OutputDevice::LogicToLogic( nCoreValue, (MapUnit)eUnit, MAP_100TH_MM );
+ nVal = rField.Normalize( nVal );
+ rField.SetValue( nVal, FUNIT_100TH_MM );
+
+}
+
+// -----------------------------------------------------------------------
+
+long GetCoreValue( const MetricField& rField, SfxMapUnit eUnit )
+{
+ sal_Int64 nVal = rField.GetValue( FUNIT_100TH_MM );
+ // avoid rounding issues
+ const sal_Int64 nSizeMask = 0xffffffffff000000LL;
+ bool bRoundBefore = true;
+ if( nVal >= 0 )
+ {
+ if( (nVal & nSizeMask) == 0 )
+ bRoundBefore = false;
+ }
+ else
+ {
+ if( ((-nVal) & nSizeMask ) == 0 )
+ bRoundBefore = false;
+ }
+ if( bRoundBefore )
+ nVal = rField.Denormalize( nVal );
+ sal_Int64 nUnitVal = OutputDevice::LogicToLogic( static_cast<long>(nVal), MAP_100TH_MM, (MapUnit)eUnit );
+ if( ! bRoundBefore )
+ nUnitVal = rField.Denormalize( nUnitVal );
+ return static_cast<long>(nUnitVal);
+}
+
+// -----------------------------------------------------------------------
+
+long CalcToUnit( float nIn, SfxMapUnit eUnit )
+{
+ // nIn ist in Points
+
+ DBG_ASSERT( eUnit == SFX_MAPUNIT_TWIP ||
+ eUnit == SFX_MAPUNIT_100TH_MM ||
+ eUnit == SFX_MAPUNIT_10TH_MM ||
+ eUnit == SFX_MAPUNIT_MM ||
+ eUnit == SFX_MAPUNIT_CM, "this unit is not implemented" );
+
+ float nTmp = nIn;
+
+ if ( SFX_MAPUNIT_TWIP != eUnit )
+ nTmp = nIn * 10 / 567;
+
+ switch ( eUnit )
+ {
+ case SFX_MAPUNIT_100TH_MM: nTmp *= 100; break;
+ case SFX_MAPUNIT_10TH_MM: nTmp *= 10; break;
+ case SFX_MAPUNIT_MM: break;
+ case SFX_MAPUNIT_CM: nTmp /= 10; break;
+ default: ;//prevent warning
+ }
+
+ nTmp *= 20;
+ long nRet = (long)nTmp;
+ return nRet;
+//! return (long)(nTmp * 20);
+}
+
+// -----------------------------------------------------------------------
+
+long ItemToControl( long nIn, SfxMapUnit eItem, SfxFieldUnit eCtrl )
+{
+ long nOut = 0;
+
+ switch ( eItem )
+ {
+ case SFX_MAPUNIT_100TH_MM:
+ case SFX_MAPUNIT_10TH_MM:
+ case SFX_MAPUNIT_MM:
+ {
+ if ( eItem == SFX_MAPUNIT_10TH_MM )
+ nIn /= 10;
+ else if ( eItem == SFX_MAPUNIT_100TH_MM )
+ nIn /= 100;
+ nOut = TransformMetric( nIn, FUNIT_MM, (FieldUnit)eCtrl );
+ }
+ break;
+
+ case SFX_MAPUNIT_CM:
+ {
+ nOut = TransformMetric( nIn, FUNIT_CM, (FieldUnit)eCtrl );
+ }
+ break;
+
+ case SFX_MAPUNIT_1000TH_INCH:
+ case SFX_MAPUNIT_100TH_INCH:
+ case SFX_MAPUNIT_10TH_INCH:
+ case SFX_MAPUNIT_INCH:
+ {
+ if ( eItem == SFX_MAPUNIT_10TH_INCH )
+ nIn /= 10;
+ else if ( eItem == SFX_MAPUNIT_100TH_INCH )
+ nIn /= 100;
+ else if ( eItem == SFX_MAPUNIT_1000TH_INCH )
+ nIn /= 1000;
+ nOut = TransformMetric( nIn, FUNIT_INCH, (FieldUnit)eCtrl );
+ }
+ break;
+
+ case SFX_MAPUNIT_POINT:
+ {
+ nOut = TransformMetric( nIn, FUNIT_POINT, (FieldUnit)eCtrl );
+ }
+ break;
+
+ case SFX_MAPUNIT_TWIP:
+ {
+ nOut = TransformMetric( nIn, FUNIT_TWIP, (FieldUnit)eCtrl );
+ }
+ break;
+ default: ;//prevent warning
+ }
+ return nOut;
+}
+
+// -----------------------------------------------------------------------
+
+long ControlToItem( long nIn, SfxFieldUnit eCtrl, SfxMapUnit eItem )
+{
+ return ItemToControl( nIn, eItem, eCtrl );
+}
+
+// -----------------------------------------------------------------------
+
+FieldUnit MapToFieldUnit( const SfxMapUnit eUnit )
+{
+ switch ( eUnit )
+ {
+ case SFX_MAPUNIT_100TH_MM:
+ case SFX_MAPUNIT_10TH_MM:
+ case SFX_MAPUNIT_MM:
+ return FUNIT_MM;
+
+ case SFX_MAPUNIT_CM:
+ return FUNIT_CM;
+
+ case SFX_MAPUNIT_1000TH_INCH:
+ case SFX_MAPUNIT_100TH_INCH:
+ case SFX_MAPUNIT_10TH_INCH:
+ case SFX_MAPUNIT_INCH:
+ return FUNIT_INCH;
+
+ case SFX_MAPUNIT_POINT:
+ return FUNIT_POINT;
+
+ case SFX_MAPUNIT_TWIP:
+ return FUNIT_TWIP;
+ default: ;//prevent warning
+ }
+ return FUNIT_NONE;
+}
+
+// -----------------------------------------------------------------------
+
+MapUnit FieldToMapUnit( const SfxFieldUnit /*eUnit*/ )
+{
+ return MAP_APPFONT;
+}
+
+// -----------------------------------------------------------------------
+
+long ConvertValueToMap( long nVal, SfxMapUnit eUnit )
+{
+ long nNew = nVal;
+
+ switch ( eUnit )
+ {
+ case SFX_MAPUNIT_10TH_MM:
+ case SFX_MAPUNIT_10TH_INCH:
+ nNew *= 10;
+ break;
+
+ case SFX_MAPUNIT_100TH_MM:
+ case SFX_MAPUNIT_100TH_INCH:
+ nNew *= 100;
+ break;
+
+ case SFX_MAPUNIT_1000TH_INCH:
+ nNew *= 1000;
+ default: ;//prevent warning
+ }
+ return nNew;
+}
+
+// -----------------------------------------------------------------------
+
+long ConvertValueToUnit( long nVal, SfxMapUnit eUnit )
+{
+ long nNew = nVal;
+
+ switch ( eUnit )
+ {
+ case SFX_MAPUNIT_10TH_MM:
+ case SFX_MAPUNIT_10TH_INCH:
+ nNew /= 10;
+ break;
+
+ case SFX_MAPUNIT_100TH_MM:
+ case SFX_MAPUNIT_100TH_INCH:
+ nNew /= 100;
+ break;
+
+ case SFX_MAPUNIT_1000TH_INCH:
+ nNew /= 1000;
+ break;
+ default: ;//prevent warning
+ }
+ return nNew;
+}
+
+// -----------------------------------------------------------------------
+
+long CalcToPoint( long nIn, SfxMapUnit eUnit, USHORT nFaktor )
+{
+ DBG_ASSERT( eUnit == SFX_MAPUNIT_TWIP ||
+ eUnit == SFX_MAPUNIT_100TH_MM ||
+ eUnit == SFX_MAPUNIT_10TH_MM ||
+ eUnit == SFX_MAPUNIT_MM ||
+ eUnit == SFX_MAPUNIT_CM, "this unit is not implemented" );
+
+ long nRet = 0;
+
+ if ( SFX_MAPUNIT_TWIP == eUnit )
+ nRet = nIn;
+ else
+ nRet = nIn * 567;
+
+ switch ( eUnit )
+ {
+ case SFX_MAPUNIT_100TH_MM: nRet /= 100; break;
+ case SFX_MAPUNIT_10TH_MM: nRet /= 10; break;
+ case SFX_MAPUNIT_MM: break;
+ case SFX_MAPUNIT_CM: nRet *= 10; break;
+ default: ;//prevent warning
+ }
+
+ // ggf. aufrunden
+ if ( SFX_MAPUNIT_TWIP != eUnit )
+ {
+ long nMod = 10;
+ long nTmp = nRet % nMod;
+
+ if ( nTmp >= 4 )
+ nRet += 10 - nTmp;
+ nRet /= 10;
+ }
+ return nRet * nFaktor / 20;
+}
+
+// -----------------------------------------------------------------------
+
+long CMToTwips( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 567 ) && nIn >= ( LONG_MIN / 567 ) )
+ nRet = nIn * 567;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long MMToTwips( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 567 ) && nIn >= ( LONG_MIN / 567 ) )
+ nRet = nIn * 567 / 10;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long InchToTwips( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 1440 ) && nIn >= ( LONG_MIN / 1440 ) )
+ nRet = nIn * 1440;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long PointToTwips( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 20 ) && nIn >= ( LONG_MIN / 20 ) )
+ nRet = nIn * 20;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long PicaToTwips( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 240 ) && nIn >= ( LONG_MIN / 240 ) )
+ nRet = nIn * 240;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long TwipsToCM( long nIn )
+{
+ long nRet = nIn / 567;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long InchToCM( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 254 ) && nIn >= ( LONG_MIN / 254 ) )
+ nRet = nIn * 254 / 100;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long MMToCM( long nIn )
+{
+ long nRet = nIn / 10;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long PointToCM( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 20 ) && nIn >= ( LONG_MIN / 20 ) )
+ nRet = nIn * 20 / 567;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long PicaToCM( long nIn)
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 12 / 20 ) && nIn >= ( LONG_MIN / 12 / 20 ) )
+ nRet = nIn * 12 * 20 / 567;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long TwipsToMM( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 10 ) && nIn >= ( LONG_MIN / 10 ) )
+ nRet = nIn * 10 / 566;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long CMToMM( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 10 ) && nIn >= ( LONG_MIN / 10 ) )
+ nRet = nIn * 10;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long InchToMM( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 254 ) && nIn >= ( LONG_MIN / 254 ) )
+ nRet = nIn * 254 / 10;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long PointToMM( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 200 ) && nIn >= ( LONG_MIN / 200 ) )
+ nRet = nIn * 200 / 567;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long PicaToMM( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 12 / 200 ) && nIn >= ( LONG_MIN / 12 / 200 ) )
+ nRet = nIn * 12 * 200 / 567;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long TwipsToInch( long nIn )
+{
+ long nRet = nIn / 1440;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long CMToInch( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 100 ) && nIn >= ( LONG_MIN / 100 ) )
+ nRet = nIn * 100 / 254;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long MMToInch( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 10 ) && nIn >= ( LONG_MIN / 10 ) )
+ nRet = nIn * 10 / 254;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long PointToInch( long nIn )
+{
+ long nRet = nIn / 72;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long PicaToInch( long nIn )
+{
+ long nRet = nIn / 6;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long TwipsToPoint( long nIn )
+{
+ long nRet = nIn / 20;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long InchToPoint( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 72 ) && nIn >= ( LONG_MIN / 72 ) )
+ nRet = nIn * 72;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long CMToPoint( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 567 ) && nIn >= ( LONG_MIN / 567 ) )
+ nRet = nIn * 567 / 20;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long MMToPoint( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 567 ) && nIn >= ( LONG_MIN / 567 ) )
+ nRet = nIn * 567 / 200;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long PicaToPoint( long nIn )
+{
+ long nRet = nIn / 12;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long TwipsToPica( long nIn )
+{
+ long nRet = nIn / 240;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long InchToPica( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 6 ) && nIn >= ( LONG_MIN / 6 ) )
+ nRet = nIn * 6;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long PointToPica( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 12 ) && nIn >= ( LONG_MIN / 12 ) )
+ nRet = nIn * 12;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long CMToPica( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 567 ) && nIn >= ( LONG_MIN / 567 ) )
+ nRet = nIn * 567 / 20 / 12;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long MMToPica( long nIn )
+{
+ long nRet = 0;
+
+ if ( nIn <= ( LONG_MAX / 567 ) && nIn >= ( LONG_MIN / 567 ) )
+ nRet = nIn * 567 / 200 / 12;
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long Nothing( long nIn )
+{
+ long nRet = nIn;
+ return nRet;
+}
+
+FUNC_CONVERT ConvertTable[6][6] =
+{
+// CM, MM INCH POINT PICAS=32 TWIPS
+ { Nothing, CMToMM, CMToInch, CMToPoint, CMToPica, CMToTwips },
+ { MMToCM, Nothing, MMToInch, MMToPoint, MMToPica, MMToTwips },
+ { InchToCM, InchToMM, Nothing, InchToPoint, InchToPica, InchToTwips },
+ { PointToCM, PointToMM, PointToInch, Nothing, PointToPica, PointToTwips },
+ { PicaToCM, PicaToMM, PicaToInch, PicaToPoint, Nothing, PicaToTwips },
+ { TwipsToCM, TwipsToMM, TwipsToInch, TwipsToPoint,TwipsToPica, Nothing }
+};
+
+// -----------------------------------------------------------------------
+
+long TransformMetric( long nVal, FieldUnit aOld, FieldUnit aNew )
+{
+ if ( aOld == FUNIT_NONE || aNew == FUNIT_NONE ||
+ aOld == FUNIT_CUSTOM || aNew == FUNIT_CUSTOM )
+ {
+ return nVal;
+ }
+
+ USHORT nOld = 0;
+ USHORT nNew = 0;
+
+ switch ( aOld )
+ {
+ case FUNIT_CM:
+ nOld = 0; break;
+ case FUNIT_MM:
+ nOld = 1; break;
+ case FUNIT_INCH:
+ nOld = 2; break;
+ case FUNIT_POINT:
+ nOld = 3; break;
+ case FUNIT_PICA:
+ nOld = 4; break;
+ case FUNIT_TWIP:
+ nOld = 5; break;
+ default: ;//prevent warning
+ }
+
+ switch ( aNew )
+ {
+ case FUNIT_CM:
+ nNew = 0; break;
+ case FUNIT_MM:
+ nNew = 1; break;
+ case FUNIT_INCH:
+ nNew = 2; break;
+ case FUNIT_POINT:
+ nNew = 3; break;
+ case FUNIT_PICA:
+ nNew = 4; break;
+ case FUNIT_TWIP:
+ nNew = 5; break;
+ default: ;//prevent warning
+ }
+ return ConvertTable[nOld][nNew]( nVal );
+}
+
diff --git a/svtools/source/misc/wallitem.cxx b/svtools/source/misc/wallitem.cxx
new file mode 100644
index 000000000000..505af52c9908
--- /dev/null
+++ b/svtools/source/misc/wallitem.cxx
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <cppuhelper/weak.hxx>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/io/XActiveDataControl.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include <comphelper/processfactory.hxx>
+
+#include <tools/stream.hxx>
+#include <tools/debug.hxx>
+#include <tools/string.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/stream.hxx>
+#include <tools/color.hxx>
+
+#include <vcl/graph.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/gradient.hxx>
+#include <vcl/cvtgrf.hxx>
+
+#include "wallitem.hxx"
+#include <svl/cntwall.hxx>
+
+// -----------------------------------------------------------------------
+
+//static
+void SfxBrushItemLink::Set( SfxBrushItemLink* pLink )
+{
+ SfxBrushItemLink** ppLink = (SfxBrushItemLink**)GetAppData(SHL_BRUSHITEM);
+ if( !*ppLink )
+ *ppLink = pLink;
+ else
+ delete pLink;
+}
+
diff --git a/svtools/source/misc/xwindowitem.cxx b/svtools/source/misc/xwindowitem.cxx
new file mode 100755
index 000000000000..a382d8293617
--- /dev/null
+++ b/svtools/source/misc/xwindowitem.cxx
@@ -0,0 +1,97 @@
+/*************************************************************************
+ *
+ * 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>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include "svtools/xwindowitem.hxx"
+
+#include <vcl/window.hxx>
+
+
+using namespace ::com::sun::star;
+
+//////////////////////////////////////////////////////////////////////
+
+TYPEINIT1_FACTORY( XWindowItem, SfxPoolItem, new XWindowItem );
+
+
+XWindowItem::XWindowItem() :
+ SfxPoolItem()
+{
+}
+
+
+XWindowItem::XWindowItem( USHORT nWhichId, Window * pWin ) :
+ SfxPoolItem( nWhichId )
+{
+ if (pWin)
+ {
+ m_xWin = uno::Reference< awt::XWindow >( pWin->GetComponentInterface(), uno::UNO_QUERY );
+ // the assertion can't possibly fails since VCLXWindow implements XWindow...
+ DBG_ASSERT( m_xWin.is(), "failed to get XWindow" );
+ }
+}
+
+
+XWindowItem::XWindowItem( USHORT nWhichId, uno::Reference< awt::XWindow > & rxWin ) :
+ SfxPoolItem( nWhichId ),
+ m_xWin( rxWin )
+{
+}
+
+
+XWindowItem::XWindowItem( const XWindowItem &rItem ) :
+ SfxPoolItem( Which() ),
+ m_xWin( rItem.m_xWin )
+{
+}
+
+
+XWindowItem::~XWindowItem()
+{
+}
+
+
+SfxPoolItem * XWindowItem::Clone( SfxItemPool* /*pPool*/ ) const
+{
+ return new XWindowItem( *this );
+}
+
+
+int XWindowItem::operator == ( const SfxPoolItem & rAttr ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
+
+ const XWindowItem * pItem = dynamic_cast< const XWindowItem * >(&rAttr);
+ return pItem ? m_xWin == pItem->m_xWin : 0;
+}
+
+
+//////////////////////////////////////////////////////////////////////
+
+