summaryrefslogtreecommitdiff
path: root/binfilter/bf_svtools/source
diff options
context:
space:
mode:
Diffstat (limited to 'binfilter/bf_svtools/source')
-rw-r--r--binfilter/bf_svtools/source/config/itemholder1.hxx99
-rw-r--r--binfilter/bf_svtools/source/config/itemholder2.hxx98
-rw-r--r--binfilter/bf_svtools/source/config/itemholderbase.hxx138
-rw-r--r--binfilter/bf_svtools/source/config/makefile.mk85
-rw-r--r--binfilter/bf_svtools/source/config/svt_addxmltostorageoptions.cxx300
-rw-r--r--binfilter/bf_svtools/source/config/svt_cacheoptions.cxx347
-rw-r--r--binfilter/bf_svtools/source/config/svt_cjkoptions.cxx406
-rw-r--r--binfilter/bf_svtools/source/config/svt_cmdoptions.cxx461
-rw-r--r--binfilter/bf_svtools/source/config/svt_colorcfg.cxx520
-rw-r--r--binfilter/bf_svtools/source/config/svt_compatibility.cxx623
-rw-r--r--binfilter/bf_svtools/source/config/svt_ctloptions.cxx367
-rw-r--r--binfilter/bf_svtools/source/config/svt_defaultoptions.cxx325
-rw-r--r--binfilter/bf_svtools/source/config/svt_dynamicmenuoptions.cxx789
-rw-r--r--binfilter/bf_svtools/source/config/svt_extendedsecurityoptions.cxx430
-rw-r--r--binfilter/bf_svtools/source/config/svt_fontoptions.cxx389
-rw-r--r--binfilter/bf_svtools/source/config/svt_helpopt.cxx576
-rw-r--r--binfilter/bf_svtools/source/config/svt_historyoptions.cxx624
-rw-r--r--binfilter/bf_svtools/source/config/svt_inetoptions.cxx317
-rw-r--r--binfilter/bf_svtools/source/config/svt_internaloptions.cxx515
-rw-r--r--binfilter/bf_svtools/source/config/svt_itemholder1.cxx326
-rw-r--r--binfilter/bf_svtools/source/config/svt_itemholder2.cxx237
-rw-r--r--binfilter/bf_svtools/source/config/svt_languageoptions.cxx121
-rw-r--r--binfilter/bf_svtools/source/config/svt_lingucfg.cxx570
-rw-r--r--binfilter/bf_svtools/source/config/svt_localisationoptions.cxx373
-rw-r--r--binfilter/bf_svtools/source/config/svt_menuoptions.cxx458
-rw-r--r--binfilter/bf_svtools/source/config/svt_misccfg.cxx153
-rw-r--r--binfilter/bf_svtools/source/config/svt_miscopt.cxx651
-rw-r--r--binfilter/bf_svtools/source/config/svt_moduleoptions.cxx982
-rw-r--r--binfilter/bf_svtools/source/config/svt_options.cxx45
-rw-r--r--binfilter/bf_svtools/source/config/svt_options3d.cxx315
-rw-r--r--binfilter/bf_svtools/source/config/svt_optionsdlg.cxx227
-rw-r--r--binfilter/bf_svtools/source/config/svt_pathoptions.cxx923
-rw-r--r--binfilter/bf_svtools/source/config/svt_printoptions.cxx498
-rw-r--r--binfilter/bf_svtools/source/config/svt_printwarningoptions.cxx342
-rw-r--r--binfilter/bf_svtools/source/config/svt_saveopt.cxx653
-rw-r--r--binfilter/bf_svtools/source/config/svt_searchopt.cxx406
-rw-r--r--binfilter/bf_svtools/source/config/svt_securityoptions.cxx850
-rw-r--r--binfilter/bf_svtools/source/config/svt_sourceviewconfig.cxx241
-rw-r--r--binfilter/bf_svtools/source/config/svt_startoptions.cxx376
-rw-r--r--binfilter/bf_svtools/source/config/svt_syslocaleoptions.cxx476
-rw-r--r--binfilter/bf_svtools/source/config/svt_undoopt.cxx209
-rw-r--r--binfilter/bf_svtools/source/config/svt_useroptions.cxx597
-rw-r--r--binfilter/bf_svtools/source/config/svt_viewoptions.cxx559
-rw-r--r--binfilter/bf_svtools/source/config/svt_workingsetoptions.cxx348
-rw-r--r--binfilter/bf_svtools/source/filerec/makefile.mk46
-rw-r--r--binfilter/bf_svtools/source/filerec/svt_filerec.cxx774
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/FilterConfigCache.hxx145
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/makefile.mk68
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/sgf.ini118
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_FilterConfigCache.cxx618
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_FilterConfigItem.cxx383
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_filter.cxx2019
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_filter2.cxx1325
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_fldll.cxx84
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_gradwrap.cxx577
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_sgfbram.cxx658
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvmain.cxx1144
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvspln.cxx902
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvtext.cxx1295
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/igif/decode.hxx74
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/igif/makefile.mk44
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/igif/svt_decode.cxx221
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/igif/svt_gifread.cxx866
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/ixbm/makefile.mk43
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/ixbm/svt_xbmread.cxx405
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/ixpm/makefile.mk42
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/ixpm/rgbtable.hxx702
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/ixpm/svt_xpmread.cxx698
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/jpeg/jpeg.h78
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/jpeg/makefile.mk43
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/jpeg/svt_jpeg.cxx754
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/jpeg/svt_jpegc.c280
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/wmf/emfwr.hxx102
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/wmf/makefile.mk50
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/wmf/svt_emfwr.cxx1292
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/wmf/svt_enhwmf.cxx1300
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/wmf/svt_winmtf.cxx2178
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/wmf/svt_winwmf.cxx1317
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/wmf/svt_wmf.cxx114
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/wmf/svt_wmfwr.cxx1878
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/wmf/winmtf.hxx760
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/wmf/wmfwr.hxx220
-rw-r--r--binfilter/bf_svtools/source/inc/fsfactory.hxx80
-rw-r--r--binfilter/bf_svtools/source/inc/poolio.hxx207
-rw-r--r--binfilter/bf_svtools/source/items/makefile.mk58
-rw-r--r--binfilter/bf_svtools/source/items/svt_aeitem.cxx249
-rw-r--r--binfilter/bf_svtools/source/items/svt_eitem.cxx56
-rw-r--r--binfilter/bf_svtools/source/items/svt_flagitem.cxx149
-rw-r--r--binfilter/bf_svtools/source/items/svt_globalnameitem.cxx114
-rw-r--r--binfilter/bf_svtools/source/items/svt_intitem.cxx308
-rw-r--r--binfilter/bf_svtools/source/items/svt_macitem.cxx275
-rw-r--r--binfilter/bf_svtools/source/items/svt_poolcach.cxx145
-rw-r--r--binfilter/bf_svtools/source/items/svt_ptitem.cxx205
-rw-r--r--binfilter/bf_svtools/source/items/svt_rectitem.cxx201
-rw-r--r--binfilter/bf_svtools/source/items/svt_rngitem.cxx57
-rw-r--r--binfilter/bf_svtools/source/items/svt_rngitem_inc.cxx228
-rw-r--r--binfilter/bf_svtools/source/items/svt_stritem.cxx81
-rw-r--r--binfilter/bf_svtools/source/items/svt_style.cxx1202
-rw-r--r--binfilter/bf_svtools/source/items/svt_szitem.cxx210
-rw-r--r--binfilter/bf_svtools/source/items1/makefile.mk71
-rw-r--r--binfilter/bf_svtools/source/items1/svt_bintitem.cxx168
-rw-r--r--binfilter/bf_svtools/source/items1/svt_cenumitm.cxx302
-rw-r--r--binfilter/bf_svtools/source/items1/svt_cintitem.cxx564
-rw-r--r--binfilter/bf_svtools/source/items1/svt_cntwall.cxx169
-rw-r--r--binfilter/bf_svtools/source/items1/svt_cstitem.cxx160
-rw-r--r--binfilter/bf_svtools/source/items1/svt_ctypeitm.cxx246
-rw-r--r--binfilter/bf_svtools/source/items1/svt_custritm.cxx148
-rw-r--r--binfilter/bf_svtools/source/items1/svt_dateitem.cxx235
-rw-r--r--binfilter/bf_svtools/source/items1/svt_dtritem.cxx240
-rw-r--r--binfilter/bf_svtools/source/items1/svt_frqitem.cxx211
-rw-r--r--binfilter/bf_svtools/source/items1/svt_ilstitem.cxx98
-rw-r--r--binfilter/bf_svtools/source/items1/svt_itemiter.cxx101
-rw-r--r--binfilter/bf_svtools/source/items1/svt_itempool.cxx1085
-rw-r--r--binfilter/bf_svtools/source/items1/svt_itemprop.cxx482
-rw-r--r--binfilter/bf_svtools/source/items1/svt_itemset.cxx2065
-rw-r--r--binfilter/bf_svtools/source/items1/svt_lckbitem.cxx193
-rw-r--r--binfilter/bf_svtools/source/items1/svt_nranges.cxx682
-rw-r--r--binfilter/bf_svtools/source/items1/svt_poolio.cxx1680
-rw-r--r--binfilter/bf_svtools/source/items1/svt_poolitem.cxx413
-rw-r--r--binfilter/bf_svtools/source/items1/svt_sfontitm.cxx148
-rw-r--r--binfilter/bf_svtools/source/items1/svt_sitem.cxx115
-rw-r--r--binfilter/bf_svtools/source/items1/svt_slstitm.cxx343
-rw-r--r--binfilter/bf_svtools/source/items1/svt_stylepool.cxx271
-rw-r--r--binfilter/bf_svtools/source/items1/svt_tfrmitem.cxx166
-rw-r--r--binfilter/bf_svtools/source/items1/svt_tresitem.cxx83
-rw-r--r--binfilter/bf_svtools/source/items1/svt_visitem.cxx153
-rw-r--r--binfilter/bf_svtools/source/items1/svt_whiter.cxx93
-rw-r--r--binfilter/bf_svtools/source/items1/whassert.hxx61
-rw-r--r--binfilter/bf_svtools/source/memtools/makefile.mk46
-rw-r--r--binfilter/bf_svtools/source/memtools/svt_svarray.cxx372
-rw-r--r--binfilter/bf_svtools/source/misc/ctrltool.src144
-rw-r--r--binfilter/bf_svtools/source/misc/errtxt.src506
-rw-r--r--binfilter/bf_svtools/source/misc/makefile.mk64
-rw-r--r--binfilter/bf_svtools/source/misc/svt_asynclink.cxx135
-rw-r--r--binfilter/bf_svtools/source/misc/svt_ctrltool.cxx404
-rw-r--r--binfilter/bf_svtools/source/misc/svt_ehdl.cxx471
-rw-r--r--binfilter/bf_svtools/source/misc/svt_flbytes.cxx112
-rw-r--r--binfilter/bf_svtools/source/misc/svt_imageresourceaccess.cxx199
-rw-r--r--binfilter/bf_svtools/source/misc/svt_imap.cxx1119
-rw-r--r--binfilter/bf_svtools/source/misc/svt_imap2.cxx59
-rw-r--r--binfilter/bf_svtools/source/misc/svt_imap3.cxx104
-rw-r--r--binfilter/bf_svtools/source/misc/svt_inidef.cxx274
-rw-r--r--binfilter/bf_svtools/source/misc/svt_iniprop.cxx51
-rw-r--r--binfilter/bf_svtools/source/misc/svt_ownlist.cxx129
-rw-r--r--binfilter/bf_svtools/source/misc/svt_restrictedpaths.cxx113
-rw-r--r--binfilter/bf_svtools/source/misc/svt_templatefoldercache.cxx138
-rw-r--r--binfilter/bf_svtools/source/misc/svt_urihelper.cxx870
-rw-r--r--binfilter/bf_svtools/source/misc/svt_vcldata.cxx54
-rw-r--r--binfilter/bf_svtools/source/misc1/makefile.mk62
-rw-r--r--binfilter/bf_svtools/source/misc1/svt_PasswordHelper.cxx110
-rw-r--r--binfilter/bf_svtools/source/misc1/svt_adrparse.cxx774
-rw-r--r--binfilter/bf_svtools/source/misc1/svt_docpasswdrequest.cxx141
-rw-r--r--binfilter/bf_svtools/source/misc1/svt_fstathelper.cxx94
-rw-r--r--binfilter/bf_svtools/source/misc1/svt_inethist.cxx517
-rw-r--r--binfilter/bf_svtools/source/misc1/svt_inettype.cxx865
-rw-r--r--binfilter/bf_svtools/source/misc1/svt_loginerr.cxx46
-rw-r--r--binfilter/bf_svtools/source/misc1/svt_strmadpt.cxx920
-rw-r--r--binfilter/bf_svtools/source/misc1/svt_svtdata.cxx64
-rw-r--r--binfilter/bf_svtools/source/notify/listenerbase.hxx63
-rw-r--r--binfilter/bf_svtools/source/notify/makefile.mk55
-rw-r--r--binfilter/bf_svtools/source/notify/svt_brdcst.cxx203
-rw-r--r--binfilter/bf_svtools/source/notify/svt_broadcast.cxx123
-rw-r--r--binfilter/bf_svtools/source/notify/svt_cancel.cxx209
-rw-r--r--binfilter/bf_svtools/source/notify/svt_hint.cxx51
-rw-r--r--binfilter/bf_svtools/source/notify/svt_isethint.cxx51
-rw-r--r--binfilter/bf_svtools/source/notify/svt_listener.cxx169
-rw-r--r--binfilter/bf_svtools/source/notify/svt_listenerbase.cxx83
-rw-r--r--binfilter/bf_svtools/source/notify/svt_listeneriter.cxx118
-rw-r--r--binfilter/bf_svtools/source/notify/svt_lstner.cxx182
-rw-r--r--binfilter/bf_svtools/source/notify/svt_smplhint.cxx51
-rw-r--r--binfilter/bf_svtools/source/numbers/makefile.mk71
-rw-r--r--binfilter/bf_svtools/source/numbers/numfmuno.hxx320
-rw-r--r--binfilter/bf_svtools/source/numbers/numhead.hxx113
-rw-r--r--binfilter/bf_svtools/source/numbers/supservs.hxx109
-rw-r--r--binfilter/bf_svtools/source/numbers/svt_nbdll.cxx87
-rw-r--r--binfilter/bf_svtools/source/numbers/svt_numfmuno.cxx1145
-rw-r--r--binfilter/bf_svtools/source/numbers/svt_numhead.cxx254
-rw-r--r--binfilter/bf_svtools/source/numbers/svt_numuno.cxx166
-rw-r--r--binfilter/bf_svtools/source/numbers/svt_supservs.cxx234
-rw-r--r--binfilter/bf_svtools/source/numbers/svt_zforfind.cxx2794
-rw-r--r--binfilter/bf_svtools/source/numbers/svt_zforlist.cxx4004
-rw-r--r--binfilter/bf_svtools/source/numbers/svt_zformat.cxx4071
-rw-r--r--binfilter/bf_svtools/source/numbers/svt_zforscan.cxx2778
-rw-r--r--binfilter/bf_svtools/source/numbers/zforscan.hxx276
-rw-r--r--binfilter/bf_svtools/source/svdde/ddeimp.hxx186
-rw-r--r--binfilter/bf_svtools/source/svdde/ddemldeb.hxx73
-rw-r--r--binfilter/bf_svtools/source/svdde/ddemlimp.hxx438
-rw-r--r--binfilter/bf_svtools/source/svdde/ddemlos2.h381
-rw-r--r--binfilter/bf_svtools/source/svdde/ddewrap.hxx32
-rw-r--r--binfilter/bf_svtools/source/svdde/makefile.mk59
-rw-r--r--binfilter/bf_svtools/source/svdde/svt_ddecli.cxx479
-rw-r--r--binfilter/bf_svtools/source/svdde/svt_ddedata.cxx236
-rw-r--r--binfilter/bf_svtools/source/svdde/svt_ddedll.cxx70
-rw-r--r--binfilter/bf_svtools/source/svdde/svt_ddedummy.cxx144
-rw-r--r--binfilter/bf_svtools/source/svdde/svt_ddeinf.cxx61
-rw-r--r--binfilter/bf_svtools/source/svdde/svt_ddeml1.cxx2662
-rw-r--r--binfilter/bf_svtools/source/svdde/svt_ddeml2.cxx1017
-rw-r--r--binfilter/bf_svtools/source/svdde/svt_ddemldeb.cxx283
-rw-r--r--binfilter/bf_svtools/source/svdde/svt_ddestrg.cxx85
-rw-r--r--binfilter/bf_svtools/source/svdde/svt_ddesvr.cxx1083
-rw-r--r--binfilter/bf_svtools/source/svdde/svt_ddewrap.cxx107
-rw-r--r--binfilter/bf_svtools/source/syslocale/makefile.mk44
-rw-r--r--binfilter/bf_svtools/source/syslocale/svt_syslocale.cxx170
-rw-r--r--binfilter/bf_svtools/source/undo/makefile.mk46
-rw-r--r--binfilter/bf_svtools/source/undo/svt_undo.cxx611
-rw-r--r--binfilter/bf_svtools/source/uno/makefile.mk48
-rw-r--r--binfilter/bf_svtools/source/uno/svt_registerservices.cxx143
-rw-r--r--binfilter/bf_svtools/source/uno/svt_unoevent.cxx595
-rw-r--r--binfilter/bf_svtools/source/uno/svt_unoimap.cxx826
209 files changed, 93149 insertions, 0 deletions
diff --git a/binfilter/bf_svtools/source/config/itemholder1.hxx b/binfilter/bf_svtools/source/config/itemholder1.hxx
new file mode 100644
index 000000000000..1b7e05c73d99
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/itemholder1.hxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 INCLUDED_SVTOOLS_ITEMHOLDER1_HXX_
+#define INCLUDED_SVTOOLS_ITEMHOLDER1_HXX_
+
+//-----------------------------------------------
+// includes
+
+#include "itemholderbase.hxx"
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <com/sun/star/lang/XEventListener.hpp>
+
+//-----------------------------------------------
+// namespaces
+
+#ifdef css
+#error "Cant use css as namespace alias."
+#else
+#define css ::com::sun::star
+#endif
+
+namespace binfilter
+{
+
+//-----------------------------------------------
+// definitions
+
+class ItemHolder1 : private ItemHolderMutexBase
+ , public ::cppu::WeakImplHelper1< css::lang::XEventListener >
+{
+ //...........................................
+ // member
+ private:
+
+ TItems m_lItems;
+
+ //...........................................
+ // c++ interface
+ public:
+
+ ItemHolder1();
+ virtual ~ItemHolder1();
+ static void holdConfigItem(EItem eItem);
+
+ //...........................................
+ // uno interface
+ public:
+
+ virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
+ throw(css::uno::RuntimeException);
+
+ //...........................................
+ // helper
+ private:
+
+ void impl_addItem(EItem eItem);
+ void impl_releaseAllItems();
+ void impl_newItem(TItemInfo& rItem);
+ void impl_deleteItem(TItemInfo& rItem);
+};
+
+//-----------------------------------------------
+// namespaces
+
+#undef css
+
+}
+
+#endif // INCLUDED_SVTOOLS_ITEMHOLDER1_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/itemholder2.hxx b/binfilter/bf_svtools/source/config/itemholder2.hxx
new file mode 100644
index 000000000000..781939f84953
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/itemholder2.hxx
@@ -0,0 +1,98 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 INCLUDED_SVTOOLS_ITEMHOLDER2_HXX_
+#define INCLUDED_SVTOOLS_ITEMHOLDER2_HXX_
+
+//-----------------------------------------------
+// includes
+
+#include "itemholderbase.hxx"
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <com/sun/star/lang/XEventListener.hpp>
+
+//-----------------------------------------------
+// namespaces
+
+#ifdef css
+#error "Cant use css as namespace alias."
+#else
+#define css ::com::sun::star
+#endif
+
+namespace binfilter
+{
+
+//-----------------------------------------------
+// definitions
+
+class ItemHolder2 : private ItemHolderMutexBase
+ , public ::cppu::WeakImplHelper1< css::lang::XEventListener >
+{
+ //...........................................
+ // member
+ private:
+
+ TItems m_lItems;
+
+ //...........................................
+ // c++ interface
+ public:
+
+ ItemHolder2();
+ virtual ~ItemHolder2();
+ static void holdConfigItem(EItem eItem);
+
+ //...........................................
+ // uno interface
+ public:
+
+ virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
+ throw(css::uno::RuntimeException);
+
+ //...........................................
+ // helper
+ private:
+
+ void impl_addItem(EItem eItem);
+ void impl_releaseAllItems();
+ void impl_newItem(TItemInfo& rItem);
+ void impl_deleteItem(TItemInfo& rItem);
+};
+
+//-----------------------------------------------
+// namespaces
+
+#undef css
+
+}
+#endif // INCLUDED_SVTOOLS_ITEMHOLDER2_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/itemholderbase.hxx b/binfilter/bf_svtools/source/config/itemholderbase.hxx
new file mode 100644
index 000000000000..0a6477960242
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/itemholderbase.hxx
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 INCLUDED_SVTOOLS_ITEMHOLDERBASE_HXX_
+#define INCLUDED_SVTOOLS_ITEMHOLDERBASE_HXX_
+
+//-----------------------------------------------
+// includes
+
+#include <vector>
+
+#include <osl/mutex.hxx>
+
+namespace binfilter
+{
+
+class Options;
+
+//-----------------------------------------------
+// definitions
+
+struct ItemHolderMutexBase
+{
+ ::osl::Mutex m_aLock;
+};
+
+enum EItem
+{
+ E_ACCELCFG , //
+ E_ACCESSIBILITYOPTIONS , // 2
+ E_ADDXMLTOSTORAGEOPTIONS , //
+ E_APEARCFG , // 2
+
+ E_CJKOPTIONS , // 2
+ E_CMDOPTIONS , //
+ E_COLORCFG , // 2
+ E_COMPATIBILITY , //
+ E_CTLOPTIONS , // 2
+
+ E_DEFAULTOPTIONS , //
+ E_DYNAMICMENUOPTIONS , //
+
+ E_EVENTCFG , //
+ E_EXTENDEDSECURITYOPTIONS , //
+
+ E_FLTRCFG , //
+ E_FONTOPTIONS , //
+ E_FONTSUBSTCONFIG , // 2
+
+ E_HELPOPTIONS , // 2
+ E_HISTORYOPTIONS , //
+
+ E_INETOPTIONS , //
+ E_INTERNALOPTIONS , //
+
+ E_JAVAOPTIONS , //
+
+ E_LANGUAGEOPTIONS , // 2
+ E_LINGUCFG , //
+ E_LOCALISATIONOPTIONS , //
+
+ E_MENUOPTIONS , //
+ E_MISCCFG , // 2
+ E_MISCOPTIONS , //
+ E_MODULEOPTIONS , //
+
+ E_OPTIONSDLGOPTIONS , //
+ E_OPTIONS3D , //
+
+ E_PATHOPTIONS , //
+ E_PRINTOPTIONS , // 2
+ E_PRINTFILEOPTIONS , // 2
+ E_PRINTWARNINGOPTIONS , //
+
+ E_REGOPTIONS , //
+
+ E_SAVEOPTIONS , //
+ E_SEARCHOPT , //
+ E_SECURITYOPTIONS , //
+ E_SOURCEVIEWCONFIG , //
+ E_STARTOPTIONS , //
+ E_SYSLOCALEOPTIONS , // 2
+
+ E_UNDOOPTIONS , // 2
+ E_USEROPTIONS , // 2
+
+ E_VIEWOPTIONS_DIALOG , //
+ E_VIEWOPTIONS_TABDIALOG , //
+ E_VIEWOPTIONS_TABPAGE , //
+ E_VIEWOPTIONS_WINDOW , //
+
+ E_WORKINGSETOPTIONS , //
+
+ E_XMLACCELCFG //
+};
+
+struct TItemInfo
+{
+ TItemInfo()
+ : pItem(0)
+ {}
+
+ Options * pItem;
+ EItem eItem;
+};
+
+typedef ::std::vector< TItemInfo > TItems;
+
+}
+
+#endif // INCLUDED_SVTOOLS_ITEMHOLDERBASE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/makefile.mk b/binfilter/bf_svtools/source/config/makefile.mk
new file mode 100644
index 000000000000..dcf6d8a4e137
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/makefile.mk
@@ -0,0 +1,85 @@
+#*************************************************************************
+#
+# DO NOT ALTER 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=binfilter
+TARGET=config
+ENABLE_EXCEPTIONS := TRUE
+
+# --- Settings -----------------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/svt_moduleoptions.obj \
+ $(SLO)$/svt_pathoptions.obj \
+ $(SLO)$/svt_saveopt.obj \
+ $(SLO)$/svt_lingucfg.obj \
+ $(SLO)$/svt_securityoptions.obj \
+ $(SLO)$/svt_localisationoptions.obj \
+ $(SLO)$/svt_workingsetoptions.obj \
+ $(SLO)$/svt_viewoptions.obj \
+ $(SLO)$/svt_internaloptions.obj \
+ $(SLO)$/svt_startoptions.obj \
+ $(SLO)$/svt_historyoptions.obj \
+ $(SLO)$/svt_inetoptions.obj \
+ $(SLO)$/svt_menuoptions.obj \
+ $(SLO)$/svt_dynamicmenuoptions.obj \
+ $(SLO)$/svt_options3d.obj \
+ $(SLO)$/svt_fontoptions.obj \
+ $(SLO)$/svt_addxmltostorageoptions.obj \
+ $(SLO)$/svt_defaultoptions.obj \
+ $(SLO)$/svt_searchopt.obj \
+ $(SLO)$/svt_printwarningoptions.obj \
+ $(SLO)$/svt_cacheoptions.obj \
+ $(SLO)$/svt_cmdoptions.obj \
+ $(SLO)$/svt_extendedsecurityoptions.obj \
+ $(SLO)$/svt_sourceviewconfig.obj \
+ $(SLO)$/svt_compatibility.obj \
+ $(SLO)$/svt_optionsdlg.obj \
+ $(SLO)$/svt_itemholder1.obj \
+ $(SLO)$/svt_options.obj \
+ $(SLO)$/svt_misccfg.obj \
+ $(SLO)$/svt_helpopt.obj \
+ $(SLO)$/svt_printoptions.obj \
+ $(SLO)$/svt_languageoptions.obj \
+ $(SLO)$/svt_ctloptions.obj \
+ $(SLO)$/svt_cjkoptions.obj \
+ $(SLO)$/svt_colorcfg.obj \
+ $(SLO)$/svt_undoopt.obj \
+ $(SLO)$/svt_useroptions.obj \
+ $(SLO)$/svt_syslocaleoptions.obj \
+ $(SLO)$/svt_itemholder2.obj \
+ $(SLO)$/svt_miscopt.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/binfilter/bf_svtools/source/config/svt_addxmltostorageoptions.cxx b/binfilter/bf_svtools/source/config/svt_addxmltostorageoptions.cxx
new file mode 100644
index 000000000000..1daf3b3b9573
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_addxmltostorageoptions.cxx
@@ -0,0 +1,300 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+//_________________________________________________________________________________________________________________
+// includes
+//_________________________________________________________________________________________________________________
+
+#include <bf_svtools/addxmltostorageoptions.hxx>
+
+#include <unotools/configmgr.hxx>
+#include <unotools/configitem.hxx>
+#include <tools/debug.hxx>
+#include <tools/string.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <rtl/logfile.hxx>
+#include <sal/macros.h>
+#include "itemholder1.hxx"
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+using namespace ::utl;
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::com::sun::star::uno;
+
+namespace binfilter
+{
+
+//*****************************************************************************************************************
+// initialize static member
+// DON'T DO IT IN YOUR HEADER!
+// see definition for further informations
+//*****************************************************************************************************************
+SvtAddXMLToStorageOptions_Impl* SvtAddXMLToStorageOptions::m_pDataContainer = 0;
+sal_Int32 SvtAddXMLToStorageOptions::m_nRefCount = 0;
+
+
+//_________________________________________________________________________________________________________________
+// private declarations!
+//_________________________________________________________________________________________________________________
+
+class SvtAddXMLToStorageOptions_Impl : public ConfigItem
+{
+ //-------------------------------------------------------------------------------------------------------------
+ // public methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ public:
+
+ //---------------------------------------------------------------------------------------------------------
+ // constructor / destructor
+ //---------------------------------------------------------------------------------------------------------
+
+ SvtAddXMLToStorageOptions_Impl();
+
+ //---------------------------------------------------------------------------------------------------------
+ // overloaded methods of baseclass
+ //---------------------------------------------------------------------------------------------------------
+ void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& );
+ void Commit();
+
+ //---------------------------------------------------------------------------------------------------------
+ // public interface
+ //---------------------------------------------------------------------------------------------------------
+
+ /*-****************************************************************************************************//**
+ @short access method to get internal values
+ @descr These method give us a chance to regulate acces to ouer internal values.
+ It's not used in the moment - but it's possible for the feature!
+
+ @seealso -
+
+ @param -
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ sal_Bool IsWriter_Add_XML_to_Storage() const { return bAddXmlToStg_Writer; }
+ sal_Bool IsCalc_Add_XML_to_Storage() const { return bAddXmlToStg_Calc; }
+ sal_Bool IsImpress_Add_XML_to_Storage() const { return bAddXmlToStg_Impress; }
+ sal_Bool IsDraw_Add_XML_to_Storage() const { return bAddXmlToStg_Draw; }
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ /*-****************************************************************************************************//**
+ @short return list of key names of ouer configuration management which represent oue module tree
+ @descr These methods return a static const list of key names. We need it to get needed values from our
+ configuration management.
+
+ @seealso -
+
+ @param -
+ @return A list of needed configuration keys is returned.
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ static Sequence< OUString > GetPropertyNames();
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private member
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ sal_Bool bAddXmlToStg_Writer,
+ bAddXmlToStg_Calc,
+ bAddXmlToStg_Impress,
+ bAddXmlToStg_Draw;
+};
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtAddXMLToStorageOptions_Impl::SvtAddXMLToStorageOptions_Impl()
+ // Init baseclasses first
+ : ConfigItem( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM(
+ "Office.Common/AddXMLToStorage"))),
+ // Init member then.
+ bAddXmlToStg_Writer( FALSE ),
+ bAddXmlToStg_Calc( FALSE ),
+ bAddXmlToStg_Impress( FALSE ),
+ bAddXmlToStg_Draw( FALSE )
+{
+ // Use our static list of configuration keys to get his values.
+ Sequence< OUString > seqNames = GetPropertyNames();
+ Sequence< Any > seqValues = GetProperties( seqNames );
+
+ // Copy values from list in right order to ouer internal member.
+ sal_Int32 nPropertyCount = seqValues.getLength();
+ const Any* pValue = seqValues.getConstArray();
+ for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty, ++pValue )
+ if( pValue->hasValue() )
+
+ switch( nProperty )
+ {
+ case 0:
+ *pValue >>= bAddXmlToStg_Writer;
+ break;
+ case 1:
+ *pValue >>= bAddXmlToStg_Calc;
+ break;
+ case 2:
+ *pValue >>= bAddXmlToStg_Impress;
+ break;
+ case 3:
+ *pValue >>= bAddXmlToStg_Draw;
+ break;
+ }
+}
+
+ void SvtAddXMLToStorageOptions_Impl::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
+ void SvtAddXMLToStorageOptions_Impl::Commit() {}
+
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Sequence< OUString > SvtAddXMLToStorageOptions_Impl::GetPropertyNames()
+{
+ // Build static list of configuration key names.
+ static const sal_Char* pProperties[] =
+ {
+ "Writer",
+ "Calc",
+ "Impress",
+ "Draw"
+ };
+
+ const sal_uInt16 nCnt = SAL_N_ELEMENTS(pProperties);
+ Sequence<OUString> aNames( nCnt );
+ OUString* pNames = aNames.getArray();
+ for( sal_uInt16 n = 0; n < nCnt; ++n )
+ pNames[ n ] = OUString::createFromAscii( pProperties[ n ] );
+ return aNames;
+}
+
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtAddXMLToStorageOptions::SvtAddXMLToStorageOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already exist!
+ if( !m_pDataContainer )
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "bf_svtools( ??? ) ::SvtAddXMLToStorageOptions_Impl::ctor()");
+ m_pDataContainer = new SvtAddXMLToStorageOptions_Impl;
+
+ ItemHolder1::holdConfigItem(E_ADDXMLTOSTORAGEOPTIONS);
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtAddXMLToStorageOptions::~SvtAddXMLToStorageOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Decrease ouer refcount.
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( !--m_nRefCount )
+ delete m_pDataContainer, m_pDataContainer = 0;
+}
+
+sal_Bool SvtAddXMLToStorageOptions::IsWriter_Add_XML_to_Storage() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pDataContainer->IsWriter_Add_XML_to_Storage();
+}
+sal_Bool SvtAddXMLToStorageOptions::IsCalc_Add_XML_to_Storage() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pDataContainer->IsCalc_Add_XML_to_Storage();
+}
+sal_Bool SvtAddXMLToStorageOptions::IsImpress_Add_XML_to_Storage() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pDataContainer->IsImpress_Add_XML_to_Storage();
+}
+sal_Bool SvtAddXMLToStorageOptions::IsDraw_Add_XML_to_Storage() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pDataContainer->IsDraw_Add_XML_to_Storage();
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Mutex& SvtAddXMLToStorageOptions::GetOwnStaticMutex()
+{
+ // Initialize static mutex only for one time!
+ static Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_cacheoptions.cxx b/binfilter/bf_svtools/source/config/svt_cacheoptions.cxx
new file mode 100644
index 000000000000..50a4935eed98
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_cacheoptions.cxx
@@ -0,0 +1,347 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+//_________________________________________________________________________________________________________________
+// includes
+//_________________________________________________________________________________________________________________
+
+#include "cacheoptions.hxx"
+
+#include <unotools/configmgr.hxx>
+#include <unotools/configitem.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+using namespace ::utl;
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::com::sun::star::uno;
+
+namespace binfilter
+{
+
+//_________________________________________________________________________________________________________________
+// const
+//_________________________________________________________________________________________________________________
+
+#define ROOTNODE_START OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Cache" ))
+#define DEFAULT_WRITEROLE 20
+#define DEFAULT_DRAWINGOLE 20
+#define DEFAULT_GRFMGR_TOTALSIZE 10000000
+#define DEFAULT_GRFMGR_OBJECTSIZE 2400000
+#define DEFAULT_GRFMGR_OBJECTRELEASE 600
+
+#define PROPERTYNAME_WRITEROLE OUString(RTL_CONSTASCII_USTRINGPARAM("Writer/OLE_Objects"))
+#define PROPERTYNAME_DRAWINGOLE OUString(RTL_CONSTASCII_USTRINGPARAM("DrawingEngine/OLE_Objects"))
+#define PROPERTYNAME_GRFMGR_TOTALSIZE OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicManager/TotalCacheSize"))
+#define PROPERTYNAME_GRFMGR_OBJECTSIZE OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicManager/ObjectCacheSize"))
+#define PROPERTYNAME_GRFMGR_OBJECTRELEASE OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicManager/ObjectReleaseTime"))
+
+#define PROPERTYHANDLE_WRITEROLE 0
+#define PROPERTYHANDLE_DRAWINGOLE 1
+#define PROPERTYHANDLE_GRFMGR_TOTALSIZE 2
+#define PROPERTYHANDLE_GRFMGR_OBJECTSIZE 3
+#define PROPERTYHANDLE_GRFMGR_OBJECTRELEASE 4
+
+#define PROPERTYCOUNT 5
+
+class SvtCacheOptions_Impl : public ConfigItem
+{
+public:
+
+//---------------------------------------------------------------------------------------------------------
+// constructor / destructor
+//---------------------------------------------------------------------------------------------------------
+
+ SvtCacheOptions_Impl();
+ ~SvtCacheOptions_Impl();
+
+//---------------------------------------------------------------------------------------------------------
+// overloaded methods of baseclass
+//---------------------------------------------------------------------------------------------------------
+
+ virtual void Commit();
+ void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& );
+
+//---------------------------------------------------------------------------------------------------------
+// public interface
+//---------------------------------------------------------------------------------------------------------
+
+ sal_Int32 GetDrawingEngineOLE_Objects() const;
+
+//-------------------------------------------------------------------------------------------------------------
+// private methods
+//-------------------------------------------------------------------------------------------------------------
+
+private:
+
+ static Sequence< OUString > impl_GetPropertyNames();
+
+//-------------------------------------------------------------------------------------------------------------
+// private member
+//-------------------------------------------------------------------------------------------------------------
+
+private:
+
+ sal_Int32 mnWriterOLE;
+ sal_Int32 mnDrawingOLE;
+ sal_Int32 mnGrfMgrTotalSize;
+ sal_Int32 mnGrfMgrObjectSize;
+ sal_Int32 mnGrfMgrObjectRelease;
+};
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtCacheOptions_Impl::SvtCacheOptions_Impl() :
+ ConfigItem( ROOTNODE_START ),
+ mnWriterOLE( DEFAULT_WRITEROLE ),
+ mnDrawingOLE( DEFAULT_DRAWINGOLE ),
+ mnGrfMgrTotalSize( DEFAULT_GRFMGR_TOTALSIZE ),
+ mnGrfMgrObjectSize( DEFAULT_GRFMGR_OBJECTSIZE ),
+ mnGrfMgrObjectRelease( DEFAULT_GRFMGR_OBJECTRELEASE )
+{
+ Sequence< OUString > seqNames( impl_GetPropertyNames() );
+ Sequence< Any > seqValues = GetProperties( seqNames ) ;
+
+ DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtCacheOptions_Impl::SvtCacheOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to ouer internal member.
+ sal_Int32 nPropertyCount = seqValues.getLength();
+ sal_Int32 nProperty = 0;
+
+ for( nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ if( seqValues[ nProperty ].hasValue() )
+ {
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_WRITEROLE:
+ {
+ if( seqValues[ nProperty ].getValueTypeClass() == TypeClass_LONG )
+ seqValues[nProperty] >>= mnWriterOLE;
+ }
+ break;
+
+ case PROPERTYHANDLE_DRAWINGOLE:
+ {
+ if( seqValues[ nProperty ].getValueTypeClass() == TypeClass_LONG )
+ seqValues[nProperty] >>= mnDrawingOLE;
+ }
+ break;
+
+ case PROPERTYHANDLE_GRFMGR_TOTALSIZE:
+ {
+ if( seqValues[ nProperty ].getValueTypeClass() == TypeClass_LONG )
+ seqValues[nProperty] >>= mnGrfMgrTotalSize;
+ }
+ break;
+
+ case PROPERTYHANDLE_GRFMGR_OBJECTSIZE:
+ {
+ if( seqValues[ nProperty ].getValueTypeClass() == TypeClass_LONG )
+ seqValues[nProperty] >>= mnGrfMgrObjectSize;
+ }
+ break;
+
+ case PROPERTYHANDLE_GRFMGR_OBJECTRELEASE:
+ {
+ if( seqValues[ nProperty ].getValueTypeClass() == TypeClass_LONG )
+ seqValues[nProperty] >>= mnGrfMgrObjectRelease;
+ }
+ break;
+ }
+ }
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtCacheOptions_Impl::~SvtCacheOptions_Impl()
+{
+ if( IsModified() )
+ Commit();
+}
+
+//*****************************************************************************************************************
+// Commit
+//*****************************************************************************************************************
+void SvtCacheOptions_Impl::Commit()
+{
+ Sequence< OUString > aSeqNames( impl_GetPropertyNames() );
+ Sequence< Any > aSeqValues( aSeqNames.getLength() );
+
+ for( sal_Int32 nProperty = 0, nCount = aSeqNames.getLength(); nProperty < nCount; ++nProperty )
+ {
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_WRITEROLE:
+ aSeqValues[nProperty] <<= mnWriterOLE;
+ break;
+
+ case PROPERTYHANDLE_DRAWINGOLE:
+ aSeqValues[nProperty] <<= mnDrawingOLE;
+ break;
+
+ case PROPERTYHANDLE_GRFMGR_TOTALSIZE:
+ aSeqValues[nProperty] <<= mnGrfMgrTotalSize;
+ break;
+
+ case PROPERTYHANDLE_GRFMGR_OBJECTSIZE:
+ aSeqValues[nProperty] <<= mnGrfMgrObjectSize;
+ break;
+
+ case PROPERTYHANDLE_GRFMGR_OBJECTRELEASE:
+ aSeqValues[nProperty] <<= mnGrfMgrObjectRelease;
+ break;
+ }
+ }
+
+ PutProperties( aSeqNames, aSeqValues );
+}
+
+ void SvtCacheOptions_Impl::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+sal_Int32 SvtCacheOptions_Impl::GetDrawingEngineOLE_Objects() const
+{
+ return mnDrawingOLE;
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Sequence< OUString > SvtCacheOptions_Impl::impl_GetPropertyNames()
+{
+ // Build static list of configuration key names.
+ static const OUString pProperties[] =
+ {
+ PROPERTYNAME_WRITEROLE,
+ PROPERTYNAME_DRAWINGOLE,
+ PROPERTYNAME_GRFMGR_TOTALSIZE,
+ PROPERTYNAME_GRFMGR_OBJECTSIZE,
+ PROPERTYNAME_GRFMGR_OBJECTRELEASE
+ };
+ // Initialize return sequence with these list ...
+ static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
+ // ... and return it.
+ return seqPropertyNames;
+}
+
+//*****************************************************************************************************************
+// initialize static member
+// DON'T DO IT IN YOUR HEADER!
+// see definition for further informations
+//*****************************************************************************************************************
+SvtCacheOptions_Impl* SvtCacheOptions::m_pDataContainer = NULL;
+sal_Int32 SvtCacheOptions::m_nRefCount = 0;
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtCacheOptions::SvtCacheOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already!
+ if( m_pDataContainer == NULL )
+ {
+ m_pDataContainer = new SvtCacheOptions_Impl();
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtCacheOptions::~SvtCacheOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Decrease ouer refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pDataContainer;
+ m_pDataContainer = NULL;
+ }
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+sal_Int32 SvtCacheOptions::GetDrawingEngineOLE_Objects() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pDataContainer->GetDrawingEngineOLE_Objects();
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Mutex& SvtCacheOptions::GetOwnStaticMutex()
+{
+ // Initialize static mutex only for one time!
+ static Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_cjkoptions.cxx b/binfilter/bf_svtools/source/config/svt_cjkoptions.cxx
new file mode 100644
index 000000000000..986396dba59d
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_cjkoptions.cxx
@@ -0,0 +1,406 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/cjkoptions.hxx>
+
+#include <bf_svtools/languageoptions.hxx>
+
+#include <i18npool/lang.h>
+
+#include <unotools/configitem.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/uno/Any.h>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/instance.hxx>
+
+#include <itemholder2.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::rtl;
+
+namespace binfilter
+{
+
+#define C2U(cChar) OUString::createFromAscii(cChar)
+#define CFG_READONLY_DEFAULT sal_False
+/* -----------------------------10.04.01 12:39--------------------------------
+
+ ---------------------------------------------------------------------------*/
+class SvtCJKOptions_Impl : public utl::ConfigItem
+{
+ sal_Bool bIsLoaded;
+ sal_Bool bCJKFont;
+ sal_Bool bVerticalText;
+ sal_Bool bAsianTypography;
+ sal_Bool bJapaneseFind;
+ sal_Bool bRuby;
+ sal_Bool bChangeCaseMap;
+ sal_Bool bDoubleLines;
+ sal_Bool bEmphasisMarks;
+ sal_Bool bVerticalCallOut;
+
+ sal_Bool bROCJKFont;
+ sal_Bool bROVerticalText;
+ sal_Bool bROAsianTypography;
+ sal_Bool bROJapaneseFind;
+ sal_Bool bRORuby;
+ sal_Bool bROChangeCaseMap;
+ sal_Bool bRODoubleLines;
+ sal_Bool bROEmphasisMarks;
+ sal_Bool bROVerticalCallOut;
+
+public:
+ SvtCJKOptions_Impl();
+ ~SvtCJKOptions_Impl();
+
+ virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& rPropertyNames );
+ virtual void Commit();
+ void Load();
+
+ sal_Bool IsLoaded() { return bIsLoaded; }
+
+ sal_Bool IsCJKFontEnabled() const { return bCJKFont; }
+ sal_Bool IsVerticalTextEnabled() const { return bVerticalText; }
+ sal_Bool IsAsianTypographyEnabled() const { return bAsianTypography; }
+ sal_Bool IsJapaneseFindEnabled() const { return bJapaneseFind; }
+ sal_Bool IsRubyEnabled() const { return bRuby; }
+ sal_Bool IsChangeCaseMapEnabled() const { return bChangeCaseMap; }
+ sal_Bool IsDoubleLinesEnabled() const { return bDoubleLines; }
+ sal_Bool IsEmphasisMarksEnabled() const { return bEmphasisMarks; }
+ sal_Bool IsVerticalCallOutEnabled() const { return bVerticalCallOut; }
+
+ sal_Bool IsAnyEnabled() const {
+ return bCJKFont||bVerticalText||bAsianTypography||bJapaneseFind||
+ bRuby||bChangeCaseMap||bDoubleLines||bEmphasisMarks||bVerticalCallOut; }
+ void SetAll(sal_Bool bSet);
+};
+/*-- 10.04.01 12:41:57---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+namespace
+{
+ struct PropertyNames
+ : public rtl::Static< Sequence<OUString>, PropertyNames > {};
+}
+
+SvtCJKOptions_Impl::SvtCJKOptions_Impl() :
+ utl::ConfigItem(C2U("Office.Common/I18N/CJK")),
+ bIsLoaded(sal_False),
+ bCJKFont(sal_True),
+ bVerticalText(sal_True),
+ bAsianTypography(sal_True),
+ bJapaneseFind(sal_True),
+ bRuby(sal_True),
+ bChangeCaseMap(sal_True),
+ bDoubleLines(sal_True),
+ bEmphasisMarks(sal_True),
+ bVerticalCallOut(sal_True),
+ bROCJKFont(CFG_READONLY_DEFAULT),
+ bROVerticalText(CFG_READONLY_DEFAULT),
+ bROAsianTypography(CFG_READONLY_DEFAULT),
+ bROJapaneseFind(CFG_READONLY_DEFAULT),
+ bRORuby(CFG_READONLY_DEFAULT),
+ bROChangeCaseMap(CFG_READONLY_DEFAULT),
+ bRODoubleLines(CFG_READONLY_DEFAULT),
+ bROEmphasisMarks(CFG_READONLY_DEFAULT),
+ bROVerticalCallOut(CFG_READONLY_DEFAULT)
+{
+}
+/*-- 10.04.01 12:41:57---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SvtCJKOptions_Impl::~SvtCJKOptions_Impl()
+{
+}
+/* -----------------------------20.04.01 14:34--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvtCJKOptions_Impl::SetAll(sal_Bool bSet)
+{
+ if (
+ !bROCJKFont &&
+ !bROVerticalText &&
+ !bROAsianTypography &&
+ !bROJapaneseFind &&
+ !bRORuby &&
+ !bROChangeCaseMap &&
+ !bRODoubleLines &&
+ !bROEmphasisMarks &&
+ !bROVerticalCallOut
+ )
+ {
+ bCJKFont=bSet;
+ bVerticalText=bSet;
+ bAsianTypography=bSet;
+ bJapaneseFind=bSet;
+ bRuby=bSet;
+ bChangeCaseMap=bSet;
+ bDoubleLines=bSet;
+ bEmphasisMarks=bSet;
+ bVerticalCallOut=bSet;
+
+ SetModified();
+ Commit();
+ }
+}
+/*-- 10.04.01 12:41:56---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SvtCJKOptions_Impl::Load()
+{
+ Sequence<OUString> &rPropertyNames = PropertyNames::get();
+ if(!rPropertyNames.getLength())
+ {
+ rPropertyNames.realloc(9);
+ OUString* pNames = rPropertyNames.getArray();
+
+ pNames[0] = C2U("CJKFont");
+ pNames[1] = C2U("VerticalText");
+ pNames[2] = C2U("AsianTypography");
+ pNames[3] = C2U("JapaneseFind");
+ pNames[4] = C2U("Ruby");
+ pNames[5] = C2U("ChangeCaseMap");
+ pNames[6] = C2U("DoubleLines");
+ pNames[7] = C2U("EmphasisMarks");
+ pNames[8] = C2U("VerticalCallOut");
+
+ EnableNotification( rPropertyNames );
+ }
+ Sequence< Any > aValues = GetProperties(rPropertyNames);
+ Sequence< sal_Bool > aROStates = GetReadOnlyStates(rPropertyNames);
+ const Any* pValues = aValues.getConstArray();
+ const sal_Bool* pROStates = aROStates.getConstArray();
+ DBG_ASSERT( aValues.getLength() == rPropertyNames.getLength(), "GetProperties failed" );
+ DBG_ASSERT( aROStates.getLength() == rPropertyNames.getLength(), "GetReadOnlyStates failed" );
+ if ( aValues.getLength() == rPropertyNames.getLength() && aROStates.getLength() == rPropertyNames.getLength() )
+ {
+ for ( int nProp = 0; nProp < rPropertyNames.getLength(); nProp++ )
+ {
+ if( pValues[nProp].hasValue() )
+ {
+ sal_Bool bValue = *(sal_Bool*)pValues[nProp].getValue();
+ switch ( nProp )
+ {
+ case 0: { bCJKFont = bValue; bROCJKFont = pROStates[nProp]; } break;
+ case 1: { bVerticalText = bValue; bROVerticalText = pROStates[nProp]; } break;
+ case 2: { bAsianTypography = bValue; bROAsianTypography = pROStates[nProp]; } break;
+ case 3: { bJapaneseFind = bValue; bROJapaneseFind = pROStates[nProp]; } break;
+ case 4: { bRuby = bValue; bRORuby = pROStates[nProp]; } break;
+ case 5: { bChangeCaseMap = bValue; bROChangeCaseMap = pROStates[nProp]; } break;
+ case 6: { bDoubleLines = bValue; bRODoubleLines = pROStates[nProp]; } break;
+ case 7: { bEmphasisMarks = bValue; bROEmphasisMarks = pROStates[nProp]; } break;
+ case 8: { bVerticalCallOut = bValue; bROVerticalCallOut = pROStates[nProp]; } break;
+ }
+ }
+ }
+ }
+
+ SvtSystemLanguageOptions aSystemLocaleSettings;
+ LanguageType eSystemLanguage = aSystemLocaleSettings.GetWin16SystemLanguage();
+ sal_uInt16 nWinScript = SvtLanguageOptions::GetScriptTypeOfLanguage( eSystemLanguage );
+
+ sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage(LANGUAGE_SYSTEM);
+ if ( !bCJKFont && (( nScriptType & SCRIPTTYPE_ASIAN )||
+ ((eSystemLanguage != LANGUAGE_SYSTEM) && ( nWinScript & SCRIPTTYPE_ASIAN ))))
+ {
+ SetAll(sal_True);
+ }
+ bIsLoaded = sal_True;
+}
+/*-- 10.04.01 12:41:57---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SvtCJKOptions_Impl::Notify( const Sequence< OUString >& )
+{
+ Load();
+}
+/*-- 10.04.01 12:41:57---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SvtCJKOptions_Impl::Commit()
+{
+ Sequence<OUString> &rPropertyNames = PropertyNames::get();
+ OUString* pOrgNames = rPropertyNames.getArray();
+ sal_Int32 nOrgCount = rPropertyNames.getLength();
+
+ Sequence< OUString > aNames(nOrgCount);
+ Sequence< Any > aValues(nOrgCount);
+
+ OUString* pNames = aNames.getArray();
+ Any* pValues = aValues.getArray();
+ sal_Int32 nRealCount = 0;
+
+ const Type& rType = ::getBooleanCppuType();
+ for(int nProp = 0; nProp < nOrgCount; nProp++)
+ {
+ switch(nProp)
+ {
+ case 0:
+ {
+ if (!bROCJKFont)
+ {
+ pNames[nRealCount] = pOrgNames[nProp];
+ pValues[nRealCount].setValue(&bCJKFont, rType);
+ ++nRealCount;
+ }
+ }
+ break;
+
+ case 1:
+ {
+ if (!bROVerticalText)
+ {
+ pNames[nRealCount] = pOrgNames[nProp];
+ pValues[nRealCount].setValue(&bVerticalText, rType);
+ ++nRealCount;
+ }
+ }
+ break;
+
+ case 2:
+ {
+ if (!bROAsianTypography)
+ {
+ pNames[nRealCount] = pOrgNames[nProp];
+ pValues[nRealCount].setValue(&bAsianTypography, rType);
+ ++nRealCount;
+ }
+ }
+ break;
+
+ case 3:
+ {
+ if (!bROJapaneseFind)
+ {
+ pNames[nRealCount] = pOrgNames[nProp];
+ pValues[nRealCount].setValue(&bJapaneseFind, rType);
+ ++nRealCount;
+ }
+ }
+ break;
+
+ case 4:
+ {
+ if (!bRORuby)
+ {
+ pNames[nRealCount] = pOrgNames[nProp];
+ pValues[nRealCount].setValue(&bRuby, rType);
+ ++nRealCount;
+ }
+ }
+ break;
+
+ case 5:
+ {
+ if (!bROChangeCaseMap)
+ {
+ pNames[nRealCount] = pOrgNames[nProp];
+ pValues[nRealCount].setValue(&bChangeCaseMap, rType);
+ ++nRealCount;
+ }
+ }
+ break;
+
+ case 6:
+ {
+ if (!bRODoubleLines)
+ {
+ pNames[nRealCount] = pOrgNames[nProp];
+ pValues[nRealCount].setValue(&bDoubleLines, rType);
+ ++nRealCount;
+ }
+ }
+ break;
+
+ case 7:
+ {
+ if (!bROEmphasisMarks)
+ {
+ pNames[nRealCount] = pOrgNames[nProp];
+ pValues[nRealCount].setValue(&bEmphasisMarks, rType);
+ ++nRealCount;
+ }
+ }
+ break;
+
+ case 8:
+ {
+ if (!bROVerticalCallOut)
+ {
+ pNames[nRealCount] = pOrgNames[nProp];
+ pValues[nRealCount].setValue(&bVerticalCallOut, rType);
+ ++nRealCount;
+ }
+ }
+ break;
+ }
+ }
+ aNames.realloc(nRealCount);
+ aValues.realloc(nRealCount);
+ PutProperties(aNames, aValues);
+}
+
+// global ----------------------------------------------------------------
+
+static SvtCJKOptions_Impl* pCJKOptions = NULL;
+static sal_Int32 nCJKRefCount = 0;
+namespace { struct CJKMutex : public rtl::Static< ::osl::Mutex , CJKMutex >{}; }
+
+
+// class SvtCJKOptions --------------------------------------------------
+
+SvtCJKOptions::SvtCJKOptions(sal_Bool bDontLoad)
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( CJKMutex::get() );
+ if ( !pCJKOptions )
+ {
+ pCJKOptions = new SvtCJKOptions_Impl;
+ ItemHolder2::holdConfigItem(E_CJKOPTIONS);
+ }
+ if( !bDontLoad && !pCJKOptions->IsLoaded())
+ pCJKOptions->Load();
+
+ ++nCJKRefCount;
+ pImp = pCJKOptions;
+}
+
+// -----------------------------------------------------------------------
+
+SvtCJKOptions::~SvtCJKOptions()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( CJKMutex::get() );
+ if ( !--nCJKRefCount )
+ DELETEZ( pCJKOptions );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_cmdoptions.cxx b/binfilter/bf_svtools/source/config/svt_cmdoptions.cxx
new file mode 100644
index 000000000000..f2c90dc6a877
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_cmdoptions.cxx
@@ -0,0 +1,461 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+//_________________________________________________________________________________________________________________
+// includes
+//_________________________________________________________________________________________________________________
+
+#include <bf_svtools/cmdoptions.hxx>
+
+#include <unotools/configmgr.hxx>
+
+#include <unotools/configitem.hxx>
+
+#include <tools/debug.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppuhelper/weakref.hxx>
+
+#include <tools/urlobj.hxx>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <itemholder1.hxx>
+
+#include <algorithm>
+#include <hash_map>
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+using namespace ::std ;
+using namespace ::utl ;
+using namespace ::rtl ;
+using namespace ::osl ;
+using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star::beans ;
+
+namespace binfilter
+{
+
+//_________________________________________________________________________________________________________________
+// const
+//_________________________________________________________________________________________________________________
+
+#define ROOTNODE_CMDOPTIONS OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Commands/Execute" ))
+#define PATHDELIMITER OUString(RTL_CONSTASCII_USTRINGPARAM("/" ))
+
+#define SETNODE_DISABLED OUString(RTL_CONSTASCII_USTRINGPARAM("Disabled" ))
+
+#define PROPERTYNAME_CMD OUString(RTL_CONSTASCII_USTRINGPARAM("Command" ))
+
+#define PROPERTYCOUNT 1
+
+#define OFFSET_CMD 0
+
+//_________________________________________________________________________________________________________________
+// private declarations!
+//_________________________________________________________________________________________________________________
+
+// Method to retrieve a hash code from a string. May be we have to change it to decrease collisions in the hash map
+struct OUStringHashCode
+{
+ size_t operator()( const ::rtl::OUString& sString ) const
+ {
+ return sString.hashCode();
+ }
+};
+
+/*-****************************************************************************************************************
+ @descr support simple command option structures and operations on it
+****************************************************************************************************************-*/
+class SvtCmdOptions
+{
+ public:
+ //---------------------------------------------------------------------------------------------------------
+ // the only way to free memory!
+ void Clear()
+ {
+ m_aCommandHashMap.clear();
+ }
+
+ sal_Bool HasEntries() const
+ {
+ return ( m_aCommandHashMap.size() > 0 );
+ }
+
+ void SetContainerSize( sal_Int32 nSize )
+ {
+ m_aCommandHashMap.resize( nSize );
+ }
+
+ sal_Bool Lookup( const OUString& aCmd ) const
+ {
+ CommandHashMap::const_iterator pEntry = m_aCommandHashMap.find( aCmd );
+ return ( pEntry != m_aCommandHashMap.end() );
+ }
+
+ void AddCommand( const OUString& aCmd )
+ {
+ m_aCommandHashMap.insert( CommandHashMap::value_type( aCmd, 0 ) );
+ }
+
+ //---------------------------------------------------------------------------------------------------------
+ // convert internal list to external format
+ // for using it on right menus realy
+ // Notice: We build a property list with 4 entries and set it on result list then.
+ // The while-loop starts with pointer on internal member list lSetupEntries, change to
+ // lUserEntries then and stop after that with NULL!
+ // Separator entries will be packed in another way then normal entries! We define
+ // special strings "sEmpty" and "sSeperator" to perform too ...
+ Sequence< OUString > GetList() const
+ {
+ sal_Int32 nCount = (sal_Int32)m_aCommandHashMap.size();
+ sal_Int32 nIndex = 0;
+ Sequence< OUString > aList( nCount );
+
+ CommandHashMap::const_iterator pEntry = m_aCommandHashMap.begin();
+ while ( pEntry != m_aCommandHashMap.end() )
+ aList[nIndex++] = pEntry->first;
+
+ return aList;
+ }
+
+ private:
+ class CommandHashMap : public ::std::hash_map< ::rtl::OUString ,
+ sal_Int32 ,
+ OUStringHashCode ,
+ ::std::equal_to< ::rtl::OUString > >
+ {
+ public:
+ inline void free()
+ {
+ CommandHashMap().swap( *this );
+ }
+ };
+
+ CommandHashMap m_aCommandHashMap;
+};
+
+typedef ::std::vector< ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XFrame > > SvtFrameVector;
+
+class SvtCommandOptions_Impl : public ConfigItem
+{
+ //-------------------------------------------------------------------------------------------------------------
+ // public methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ public:
+
+ //---------------------------------------------------------------------------------------------------------
+ // constructor / destructor
+ //---------------------------------------------------------------------------------------------------------
+
+ SvtCommandOptions_Impl();
+ ~SvtCommandOptions_Impl();
+
+ //---------------------------------------------------------------------------------------------------------
+ // overloaded methods of baseclass
+ //---------------------------------------------------------------------------------------------------------
+
+ /*-****************************************************************************************************//**
+ @short called for notify of configmanager
+ @descr These method is called from the ConfigManager before application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. You must update your
+ internal values.
+
+ @seealso baseclass ConfigItem
+
+ @param "lPropertyNames" is the list of properties which should be updated.
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Notify( const Sequence< OUString >& lPropertyNames );
+
+ /*-****************************************************************************************************//**
+ @short write changes to configuration
+ @descr These method writes the changed values into the sub tree
+ and should always called in our destructor to guarantee consistency of config data.
+
+ @seealso baseclass ConfigItem
+
+ @param -
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Commit();
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ /*-****************************************************************************************************//**
+ @short return list of key names of our configuration management which represent oue module tree
+ @descr These methods return the current list of key names! We need it to get needed values from our
+ configuration management and support dynamical menu item lists!
+
+ @seealso -
+
+ @param "nDisabledCount" , returns count of menu entries for "new"
+ @return A list of configuration key names is returned.
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ Sequence< OUString > impl_GetPropertyNames();
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private member
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+ SvtCmdOptions m_aDisabledCommands;
+ SvtFrameVector m_lFrames;
+};
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtCommandOptions_Impl::SvtCommandOptions_Impl()
+ // Init baseclasses first
+ : ConfigItem( ROOTNODE_CMDOPTIONS )
+ // Init member then...
+{
+ // Get names and values of all accessable menu entries and fill internal structures.
+ // See impl_GetPropertyNames() for further informations.
+ Sequence< OUString > lNames = impl_GetPropertyNames ();
+ Sequence< Any > lValues = GetProperties ( lNames );
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !(lNames.getLength()!=lValues.getLength()), "SvtCommandOptions_Impl::SvtCommandOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to ouer internal member.
+ // Attention: List for names and values have an internal construction pattern!
+ sal_Int32 nItem = 0 ;
+ OUString sCmd ;
+
+ // Set size of hash_map reach a used size of approx. 60%
+ m_aDisabledCommands.SetContainerSize( lNames.getLength() * 10 / 6 );
+
+ // Get names/values for disabled commands.
+ for( nItem=0; nItem < lNames.getLength(); ++nItem )
+ {
+ // Currently only one value
+ lValues[nItem] >>= sCmd;
+ m_aDisabledCommands.AddCommand( sCmd );
+ }
+
+/*TODO: Not used in the moment! see Notify() ...
+ // Enable notification mechanism of ouer baseclass.
+ // We need it to get information about changes outside these class on ouer used configuration keys! */
+ Sequence< OUString > aNotifySeq( 1 );
+ aNotifySeq[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "Disabled" ));
+ EnableNotification( aNotifySeq, sal_True );
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtCommandOptions_Impl::~SvtCommandOptions_Impl()
+{
+ // We must save our current values .. if user forget it!
+ if( IsModified() == sal_True )
+ {
+ Commit();
+ }
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtCommandOptions_Impl::Notify( const Sequence< OUString >& )
+{
+ MutexGuard aGuard( SvtCommandOptions::GetOwnStaticMutex() );
+
+ Sequence< OUString > lNames = impl_GetPropertyNames ();
+ Sequence< Any > lValues = GetProperties ( lNames );
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !(lNames.getLength()!=lValues.getLength()), "SvtCommandOptions_Impl::SvtCommandOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to ouer internal member.
+ // Attention: List for names and values have an internal construction pattern!
+ sal_Int32 nItem = 0 ;
+ OUString sCmd ;
+
+ // Set size of hash_map reach a used size of approx. 60%
+ m_aDisabledCommands.Clear();
+ m_aDisabledCommands.SetContainerSize( lNames.getLength() * 10 / 6 );
+
+ // Get names/values for disabled commands.
+ for( nItem=0; nItem < lNames.getLength(); ++nItem )
+ {
+ // Currently only one value
+ lValues[nItem] >>= sCmd;
+ m_aDisabledCommands.AddCommand( sCmd );
+ }
+
+ // dont forget to update all existing frames and her might cached dispatch objects!
+ // But look for already killed frames. We hold weak references instead of hard ones ...
+ for (SvtFrameVector::const_iterator pIt = m_lFrames.begin();
+ pIt != m_lFrames.end() ;
+ ++pIt )
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame(pIt->get(), ::com::sun::star::uno::UNO_QUERY);
+ if (xFrame.is())
+ xFrame->contextChanged();
+ }
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtCommandOptions_Impl::Commit()
+{
+ DBG_ERROR( "SvtCommandOptions_Impl::Commit()\nNot implemented yet!\n" );
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Sequence< OUString > SvtCommandOptions_Impl::impl_GetPropertyNames()
+{
+ // First get ALL names of current existing list items in configuration!
+ Sequence< OUString > lDisabledItems = GetNodeNames( SETNODE_DISABLED, utl::CONFIG_NAME_LOCAL_PATH );
+
+ OUString aSetNode( SETNODE_DISABLED );
+ aSetNode += PATHDELIMITER;
+
+ OUString aCommandKey( PATHDELIMITER );
+ aCommandKey += PROPERTYNAME_CMD;
+
+ // Expand all keys
+ for (sal_Int32 i=0; i<lDisabledItems.getLength(); ++i )
+ {
+ OUStringBuffer aBuffer( 32 );
+ aBuffer.append( aSetNode );
+ aBuffer.append( lDisabledItems[i] );
+ aBuffer.append( aCommandKey );
+ lDisabledItems[i] = aBuffer.makeStringAndClear();
+ }
+
+ // Return result.
+ return lDisabledItems;
+}
+
+//*****************************************************************************************************************
+// initialize static member
+// DON'T DO IT IN YOUR HEADER!
+// see definition for further informations
+//*****************************************************************************************************************
+SvtCommandOptions_Impl* SvtCommandOptions::m_pDataContainer = NULL ;
+sal_Int32 SvtCommandOptions::m_nRefCount = 0 ;
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtCommandOptions::SvtCommandOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already exist!
+ if( m_pDataContainer == NULL )
+ {
+ m_pDataContainer = new SvtCommandOptions_Impl;
+ ItemHolder1::holdConfigItem(E_CMDOPTIONS);
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtCommandOptions::~SvtCommandOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Decrease ouer refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pDataContainer;
+ m_pDataContainer = NULL;
+ }
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Mutex& SvtCommandOptions::GetOwnStaticMutex()
+{
+ // Initialize static mutex only for one time!
+ static Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_colorcfg.cxx b/binfilter/bf_svtools/source/config/svt_colorcfg.cxx
new file mode 100644
index 000000000000..a2e11e0bf2a6
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_colorcfg.cxx
@@ -0,0 +1,520 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/colorcfg.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <tools/color.hxx>
+#include <tools/debug.hxx>
+#include <unotools/configitem.hxx>
+#include <unotools/configpathes.hxx>
+#include <com/sun/star/uno/Sequence.h>
+#include <bf_svtools/poolitem.hxx> //Any2Bool
+#include <bf_svtools/smplhint.hxx>
+#include <osl/mutex.hxx>
+#include <itemholder2.hxx>
+
+#include <vcl/svapp.hxx>
+#include <vcl/event.hxx>
+#include <rtl/instance.hxx>
+
+//-----------------------------------------------------------------------------
+using namespace utl;
+using namespace rtl;
+using namespace com::sun::star;
+
+namespace binfilter
+{
+
+#define C2U(cChar) OUString::createFromAscii(cChar)
+static const sal_Char cColor[] = "/Color";
+static const sal_Char cColorSchemes[] = "ColorSchemes/";
+sal_Int32 nColorRefCount_Impl = 0;
+namespace
+{
+ struct ColorMutex_Impl
+ : public rtl::Static< ::osl::Mutex, ColorMutex_Impl > {};
+}
+
+ColorConfig_Impl* ColorConfig::m_pImpl = NULL;
+
+/* -----------------------------16.01.01 15:36--------------------------------
+ ---------------------------------------------------------------------------*/
+class ColorConfig_Impl : public utl::ConfigItem, public SfxBroadcaster
+{
+ ColorConfigValue m_aConfigValues[ColorConfigEntryCount];
+ sal_Bool m_bEditMode;
+ rtl::OUString m_sIsVisible;
+ rtl::OUString m_sLoadedScheme;
+ sal_Bool m_bIsBroadcastEnabled;
+ static sal_Bool m_bLockBroadcast;
+ static sal_Bool m_bBroadcastWhenUnlocked;
+
+ uno::Sequence< ::rtl::OUString> GetPropertyNames(const rtl::OUString& rScheme);
+public:
+ ColorConfig_Impl(sal_Bool bEditMode = sal_False);
+ virtual ~ColorConfig_Impl();
+
+ void Load(const rtl::OUString& rScheme);
+ void CommitCurrentSchemeName();
+ //changes the name of the current scheme but doesn't load it!
+ void SetCurrentSchemeName(const rtl::OUString& rSchemeName) {m_sLoadedScheme = rSchemeName;}
+ virtual void Commit();
+ virtual void Notify( const uno::Sequence<rtl::OUString>& aPropertyNames);
+
+ const ColorConfigValue& GetColorConfigValue(ColorConfigEntry eValue)
+ {return m_aConfigValues[eValue];}
+
+ const rtl::OUString& GetLoadedScheme() const {return m_sLoadedScheme;}
+
+ void SetModified(){ConfigItem::SetModified();}
+ void ClearModified(){ConfigItem::ClearModified();}
+ void SettingsChanged();
+
+ // #100822#
+ DECL_LINK( DataChangedEventListener, VclWindowEvent* );
+
+ void ImplUpdateApplicationSettings();
+};
+
+/* -----------------------------16.01.01 15:36--------------------------------
+
+ ---------------------------------------------------------------------------*/
+uno::Sequence< OUString> ColorConfig_Impl::GetPropertyNames(const rtl::OUString& rScheme)
+{
+ uno::Sequence<OUString> aNames(2 * ColorConfigEntryCount);
+ OUString* pNames = aNames.getArray();
+ struct ColorConfigEntryData_Impl
+ {
+ const sal_Char* cName;
+ sal_Int32 nLength;
+ rtl_TextEncoding eEncoding;
+ sal_Bool bCanBeVisible;
+ };
+ static const ColorConfigEntryData_Impl cNames[] =
+ {
+ { RTL_CONSTASCII_USTRINGPARAM("/DocColor") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/DocBoundaries") ,sal_True },
+ { RTL_CONSTASCII_USTRINGPARAM("/AppBackground") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/ObjectBoundaries"),sal_True },
+ { RTL_CONSTASCII_USTRINGPARAM("/TableBoundaries") ,sal_True },
+ { RTL_CONSTASCII_USTRINGPARAM("/FontColor") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/Links") ,sal_True },
+ { RTL_CONSTASCII_USTRINGPARAM("/LinksVisited") ,sal_True },
+ { RTL_CONSTASCII_USTRINGPARAM("/Anchor") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/Spell") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/SmartTags") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/WriterTextGrid") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/WriterFieldShadings"),sal_True },
+ { RTL_CONSTASCII_USTRINGPARAM("/WriterIdxShadings") ,sal_True },
+ { RTL_CONSTASCII_USTRINGPARAM("/WriterDirectCursor") ,sal_True },
+ { RTL_CONSTASCII_USTRINGPARAM("/WriterNotesIndicator") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/WriterScriptIndicator") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/WriterSectionBoundaries") ,sal_True },
+ { RTL_CONSTASCII_USTRINGPARAM("/WriterPageBreaks") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/HTMLSGML") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/HTMLComment") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/HTMLKeyword") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/HTMLUnknown") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/CalcGrid") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/CalcPageBreak"), sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/CalcPageBreakManual"), sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/CalcPageBreakAutomatic"), sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/CalcDetective") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/CalcDetectiveError") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/CalcReference") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/CalcNotesBackground") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/DrawGrid") ,sal_True },
+ { RTL_CONSTASCII_USTRINGPARAM("/DrawDrawing") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/DrawFill") ,sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/BASICIdentifier"), sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/BASICComment") , sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/BASICNumber") , sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/BASICString") , sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/BASICOperator") , sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/BASICKeyword") , sal_False },
+ { RTL_CONSTASCII_USTRINGPARAM("/BASICError"), sal_False }
+ };
+ int nIndex = 0;
+ OUString sColor = C2U(cColor);
+ OUString sBase(C2U(cColorSchemes));
+ sBase += utl::wrapConfigurationElementName(rScheme);
+ const int nCount = ColorConfigEntryCount;
+ for(sal_Int32 i = 0; i < 4 * nCount; i+= 4)
+ {
+ rtl::OUString sBaseName(sBase);
+ sal_Int32 nPos = i / 4;
+ sBaseName += OUString(cNames[nPos].cName, cNames[nPos].nLength, cNames[nPos].eEncoding);
+ pNames[nIndex] += sBaseName;
+ pNames[nIndex++] += sColor;
+ if(cNames[nPos].bCanBeVisible)
+ {
+ pNames[nIndex] += sBaseName;
+ pNames[nIndex++] += m_sIsVisible;
+ }
+ }
+ aNames.realloc(nIndex);
+ return aNames;
+}
+/* -----------------------------22.03.2002 14:37------------------------------
+
+ ---------------------------------------------------------------------------*/
+sal_Bool ColorConfig_Impl::m_bLockBroadcast = sal_False;
+sal_Bool ColorConfig_Impl::m_bBroadcastWhenUnlocked = sal_False;
+ColorConfig_Impl::ColorConfig_Impl(sal_Bool bEditMode) :
+ ConfigItem(C2U("Office.UI/ColorScheme")),
+ m_bEditMode(bEditMode),
+ m_sIsVisible(C2U("/IsVisible")),
+ m_bIsBroadcastEnabled(sal_True)
+{
+ if(!m_bEditMode)
+ {
+ //try to register on the root node - if possible
+ uno::Sequence < ::rtl::OUString > aNames(1);
+ EnableNotification( aNames );
+ }
+ Load(::rtl::OUString());
+
+ ImplUpdateApplicationSettings();
+
+ // #100822#
+ ::Application::AddEventListener( LINK(this, ColorConfig_Impl, DataChangedEventListener) );
+
+}
+/* -----------------------------25.03.2002 12:28------------------------------
+
+ ---------------------------------------------------------------------------*/
+ColorConfig_Impl::~ColorConfig_Impl()
+{
+ // #100822#
+ ::Application::RemoveEventListener( LINK(this, ColorConfig_Impl, DataChangedEventListener) );
+}
+/* -----------------------------22.03.2002 14:38------------------------------
+
+ ---------------------------------------------------------------------------*/
+void ColorConfig_Impl::Load(const rtl::OUString& rScheme)
+{
+ rtl::OUString sScheme(rScheme);
+ if(!sScheme.getLength())
+ {
+ //detect current scheme name
+ uno::Sequence < ::rtl::OUString > aCurrent(1);
+ aCurrent.getArray()[0] = C2U("CurrentColorScheme");
+ uno::Sequence< uno::Any > aCurrentVal = GetProperties( aCurrent );
+ aCurrentVal.getConstArray()[0] >>= sScheme;
+ }
+ m_sLoadedScheme = sScheme;
+ //
+ uno::Sequence < ::rtl::OUString > aColorNames = GetPropertyNames(sScheme);
+ uno::Sequence< uno::Any > aColors = GetProperties( aColorNames );
+ const uno::Any* pColors = aColors.getConstArray();
+ const ::rtl::OUString* pColorNames = aColorNames.getConstArray();
+ sal_Int32 nIndex = 0;
+ for(int i = 0; i < 2 * ColorConfigEntryCount && aColors.getLength() > nIndex; i+= 2)
+ {
+ if(pColors[nIndex].hasValue())
+ pColors[nIndex] >>= m_aConfigValues[i / 2].nColor;
+ else
+ m_aConfigValues[i/2].nColor = COL_AUTO;
+ nIndex++;
+ if(nIndex >= aColors.getLength())
+ break;
+ //test for visibility property
+ if(pColorNames[nIndex].match(m_sIsVisible, pColorNames[nIndex].getLength() - m_sIsVisible.getLength()))
+ m_aConfigValues[i / 2].bIsVisible = Any2Bool(pColors[nIndex++]);
+ }
+}
+/* -----------------------------22.03.2002 14:38------------------------------
+
+ ---------------------------------------------------------------------------*/
+void ColorConfig_Impl::Notify( const uno::Sequence<OUString>& )
+{
+ //loading via notification always uses the default setting
+ Load(::rtl::OUString());
+
+ SolarMutexGuard aVclGuard;
+
+ if(m_bLockBroadcast)
+ {
+ m_bBroadcastWhenUnlocked = sal_True;
+ ImplUpdateApplicationSettings();
+ }
+ else
+ Broadcast(SfxSimpleHint(SFX_HINT_COLORS_CHANGED));
+}
+/* -----------------------------22.03.2002 14:38------------------------------
+
+ ---------------------------------------------------------------------------*/
+void ColorConfig_Impl::Commit()
+{
+ uno::Sequence < ::rtl::OUString > aColorNames = GetPropertyNames(m_sLoadedScheme);
+ uno::Sequence < beans::PropertyValue > aPropValues(aColorNames.getLength());
+ beans::PropertyValue* pPropValues = aPropValues.getArray();
+ const ::rtl::OUString* pColorNames = aColorNames.getConstArray();
+ sal_Int32 nIndex = 0;
+ const uno::Type& rBoolType = ::getBooleanCppuType();
+ for(int i = 0; i < 2 * ColorConfigEntryCount && aColorNames.getLength() > nIndex; i+= 2)
+ {
+ pPropValues[nIndex].Name = pColorNames[nIndex];
+ //save automatic colors as void value
+ if(COL_AUTO != sal::static_int_cast<ColorData>(m_aConfigValues[i/2].nColor))
+ pPropValues[nIndex].Value <<= m_aConfigValues[i/2].nColor;
+
+ nIndex++;
+ if(nIndex >= aColorNames.getLength())
+ break;
+ //test for visibility property
+ if(pColorNames[nIndex].match(m_sIsVisible, pColorNames[nIndex].getLength() - m_sIsVisible.getLength()))
+ {
+ pPropValues[nIndex].Name = pColorNames[nIndex];
+ pPropValues[nIndex].Value.setValue(&m_aConfigValues[i/2].bIsVisible, rBoolType);
+ nIndex++;
+ }
+ }
+ rtl::OUString sNode(C2U("ColorSchemes"));
+ SetSetProperties(sNode, aPropValues);
+
+ CommitCurrentSchemeName();
+}
+/* -----------------11.12.2002 10:42-----------------
+ *
+ * --------------------------------------------------*/
+void ColorConfig_Impl::CommitCurrentSchemeName()
+{
+ //save current scheme name
+ uno::Sequence < ::rtl::OUString > aCurrent(1);
+ aCurrent.getArray()[0] = C2U("CurrentColorScheme");
+ uno::Sequence< uno::Any > aCurrentVal(1);
+ aCurrentVal.getArray()[0] <<= m_sLoadedScheme;
+ PutProperties(aCurrent, aCurrentVal);
+}
+/* -----------------------------2002/06/20 13:03------------------------------
+
+ ---------------------------------------------------------------------------*/
+void ColorConfig_Impl::SettingsChanged()
+{
+ SolarMutexGuard aVclGuard;
+
+ ImplUpdateApplicationSettings();
+
+ Broadcast( SfxSimpleHint( SFX_HINT_COLORS_CHANGED ) );
+}
+/* -----------------------------2002/08/16 12:07 -----------------------------
+ #100822#
+ --------------------------------------------------------------------------- */
+IMPL_LINK( ColorConfig_Impl, DataChangedEventListener, VclWindowEvent*, pEvent )
+{
+ if ( pEvent->GetId() == VCLEVENT_APPLICATION_DATACHANGED )
+ {
+ DataChangedEvent* pData = (DataChangedEvent*)(pEvent->GetData());
+ if ( (pData->GetType() == DATACHANGED_SETTINGS) &&
+ (pData->GetFlags() & SETTINGS_STYLE) )
+ {
+ SettingsChanged();
+ return 1L;
+ } else
+ return 0L;
+ } else
+ return 0L;
+}
+
+// ---------------------------------------------------------------------------
+
+/** updates the font color in the vcl window settings */
+void ColorConfig_Impl::ImplUpdateApplicationSettings()
+{
+ Application* pApp = GetpApp();
+ if( pApp )
+ {
+ AllSettings aSettings = pApp->GetSettings();
+ StyleSettings aStyleSettings( aSettings.GetStyleSettings() );
+
+ ColorConfigValue aRet = GetColorConfigValue(FONTCOLOR);
+ if(COL_AUTO == sal::static_int_cast<ColorData>(aRet.nColor))
+ aRet.nColor = ColorConfig::GetDefaultColor(FONTCOLOR).GetColor();
+
+ Color aFontColor(aRet.nColor);
+
+ if( aStyleSettings.GetFontColor() != aFontColor )
+ {
+ aStyleSettings.SetFontColor( aFontColor );
+
+ aSettings.SetStyleSettings( aStyleSettings );
+ pApp->SetSettings( aSettings );
+ }
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+ColorConfig::ColorConfig()
+{
+ ::osl::MutexGuard aGuard( ColorMutex_Impl::get() );
+ if ( !m_pImpl )
+ {
+ m_pImpl = new ColorConfig_Impl;
+ ItemHolder2::holdConfigItem(E_COLORCFG);
+ }
+ ++nColorRefCount_Impl;
+ StartListening( *m_pImpl);
+}
+/* -----------------------------16.01.01 15:36--------------------------------
+
+ ---------------------------------------------------------------------------*/
+ColorConfig::~ColorConfig()
+{
+ ::osl::MutexGuard aGuard( ColorMutex_Impl::get() );
+ EndListening( *m_pImpl);
+ if(!--nColorRefCount_Impl)
+ {
+ delete m_pImpl;
+ m_pImpl = 0;
+ }
+}
+/* -----------------------------11.04.2002 11:49------------------------------
+
+ ---------------------------------------------------------------------------*/
+Color ColorConfig::GetDefaultColor(ColorConfigEntry eEntry)
+{
+ static const sal_Int32 aAutoColors[] =
+ {
+ 0, // DOCCOLOR
+ 0xc0c0c0, // DOCBOUNDARIES
+ 0x808080, // APPBACKGROUND
+ 0xc0c0c0, // OBJECTBOUNDARIES
+ 0xc0c0c0, // TABLEBOUNDARIES
+ 0, // FONTCOLOR
+ 0xcc, // LINKS
+ 0x80, // LINKSVISITED
+ 0, // ANCHOR
+ 0xff0000, // SPELL
+ COL_LIGHTMAGENTA,// SMARTTAGS
+ 0xc0c0c0, // WRITERTEXTGRID
+ 0xc0c0c0, // WRITERFIELDSHADIN
+ 0xc0c0c0, // WRITERIDXSHADINGS
+ 0, // WRITERDIRECTCURSOR
+ COL_YELLOW, //WRITERNOTESINDICATOR
+ COL_GREEN, //WRITERSCRIPTINDICATOR
+ 0xc0c0c0, //WRITERSECTIONBOUNDARIES
+ COL_BLUE, //WRITERPAGEBREAKS,
+ COL_LIGHTBLUE, // HTMLSGML
+ COL_LIGHTGREEN, // HTMLCOMMENT
+ COL_LIGHTRED, // HTMLKEYWORD
+ COL_GRAY, // HTMLUNKNOWN
+ COL_LIGHTGRAY, // CALCGRID
+ COL_BLUE, //CALCPAGEBREAK
+ 0x2300dc, //CALCPAGEBREAKMANUAL
+ COL_GRAY, //CALCPAGEBREAKAUTOMATIC
+ COL_LIGHTBLUE, // CALCDETECTIVE
+ COL_LIGHTRED, // CALCDETECTIVEERROR
+ COL_LIGHTRED, // CALCREFERENCE
+ 0xffffc0, // CALCNOTESBACKGROUND
+ 0xc0c0c0, // DRAWGRID
+ 0, // DRAWDRAWING
+ 0xb8ff, // DRAWFILL
+ COL_GREEN, // BASICIDENTIFIER,
+ COL_GRAY,// BASICCOMMENT ,
+ COL_LIGHTRED,// BASICNUMBER ,
+ COL_LIGHTRED,// BASICSTRING ,
+ COL_BLUE, // BASICOPERATOR ,
+ COL_BLUE, // BASICKEYWORD ,
+ COL_RED, //BASICERROR
+ };
+ Color aRet;
+ switch(eEntry)
+ {
+ case DOCCOLOR :
+ aRet = Application::GetSettings().GetStyleSettings().GetWindowColor();
+ break;
+
+ case APPBACKGROUND :
+ aRet = Application::GetSettings().GetStyleSettings().GetWorkspaceColor();
+ break;
+
+ case SPELL :
+ case DRAWDRAWING :
+ case SMARTTAGS :
+ {
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ aRet = rStyleSettings.GetHighContrastMode() ?
+ rStyleSettings.GetDialogTextColor().GetColor() : aAutoColors[eEntry];
+ }
+ break;
+
+ case DRAWFILL :
+ aRet = /*rStyleSettings.GetHighContrastMode() ?
+ rStyleSettings.OutlineMode??? : */ aAutoColors[eEntry];
+ break;
+
+ case FONTCOLOR :
+ aRet = Application::GetSettings().GetStyleSettings().GetWindowTextColor();
+ break;
+
+ default:
+ aRet = aAutoColors[eEntry];
+ }
+ return aRet;
+}
+/* -----------------------------11.04.2002 11:49------------------------------
+
+ ---------------------------------------------------------------------------*/
+ColorConfigValue ColorConfig::GetColorValue(ColorConfigEntry eEntry, sal_Bool bSmart)const
+{
+ ColorConfigValue aRet = m_pImpl->GetColorConfigValue(eEntry);
+ if(bSmart)
+ {
+ if(COL_AUTO == sal::static_int_cast<ColorData>(aRet.nColor))
+ aRet.nColor = ColorConfig::GetDefaultColor(eEntry).GetColor();
+ //#103495# don't allow grey between 40% and 60% as application background
+ const UINT8 nRed = COLORDATA_RED( aRet.nColor);
+ if(eEntry == APPBACKGROUND &&
+ (nRed == COLORDATA_GREEN( aRet.nColor)) &&
+ (nRed == COLORDATA_BLUE( aRet.nColor)) &&
+ nRed > 102 && nRed < 153 )
+ {
+ aRet.nColor = RGB_COLORDATA(153, 153, 153);
+ }
+ }
+
+ return aRet;
+}
+/* -----------------------------12.04.2002 09:25------------------------------
+
+ ---------------------------------------------------------------------------*/
+void ColorConfig::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ SolarMutexGuard aVclGuard;
+
+ Broadcast( rHint );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_compatibility.cxx b/binfilter/bf_svtools/source/config/svt_compatibility.cxx
new file mode 100644
index 000000000000..217c01e6f0c2
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_compatibility.cxx
@@ -0,0 +1,623 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+//_________________________________________________________________________________________________________________
+// includes
+//_________________________________________________________________________________________________________________
+
+#include <bf_svtools/compatibility.hxx>
+
+#include <unotools/configmgr.hxx>
+
+#include <unotools/configitem.hxx>
+
+#include <tools/debug.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#ifndef __SGI_STL_VECTOR
+#include <vector>
+#endif
+
+#include <itemholder1.hxx>
+
+#include <algorithm>
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+using namespace ::std;
+using namespace ::utl;
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+
+namespace binfilter
+{
+
+//_________________________________________________________________________________________________________________
+// const
+//_________________________________________________________________________________________________________________
+
+#define ROOTNODE_OPTIONS OUString( RTL_CONSTASCII_USTRINGPARAM( "Office.Compatibility/" ) )
+#define PATHDELIMITER OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) )
+#define SETNODE_ALLFILEFORMATS OUString( RTL_CONSTASCII_USTRINGPARAM( "AllFileFormats" ) )
+
+#define PROPERTYNAME_NAME COMPATIBILITY_PROPERTYNAME_NAME
+#define PROPERTYNAME_MODULE COMPATIBILITY_PROPERTYNAME_MODULE
+#define PROPERTYNAME_USEPRTMETRICS COMPATIBILITY_PROPERTYNAME_USEPRTMETRICS
+#define PROPERTYNAME_ADDSPACING COMPATIBILITY_PROPERTYNAME_ADDSPACING
+#define PROPERTYNAME_ADDSPACINGATPAGES COMPATIBILITY_PROPERTYNAME_ADDSPACINGATPAGES
+#define PROPERTYNAME_USEOURTABSTOPS COMPATIBILITY_PROPERTYNAME_USEOURTABSTOPS
+#define PROPERTYNAME_NOEXTLEADING COMPATIBILITY_PROPERTYNAME_NOEXTLEADING
+#define PROPERTYNAME_USELINESPACING COMPATIBILITY_PROPERTYNAME_USELINESPACING
+#define PROPERTYNAME_ADDTABLESPACING COMPATIBILITY_PROPERTYNAME_ADDTABLESPACING
+#define PROPERTYNAME_USEOBJPOS COMPATIBILITY_PROPERTYNAME_USEOBJECTPOSITIONING
+#define PROPERTYNAME_USEOURTEXTWRAP COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING
+#define PROPERTYNAME_CONSIDERWRAPSTYLE COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE
+#define PROPERTYNAME_EXPANDWORDSPACE COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE
+
+#define PROPERTYCOUNT 13
+
+#define OFFSET_NAME 0
+#define OFFSET_MODULE 1
+#define OFFSET_USEPRTMETRICS 2
+#define OFFSET_ADDSPACING 3
+#define OFFSET_ADDSPACINGATPAGES 4
+#define OFFSET_USEOURTABSTOPS 5
+#define OFFSET_NOEXTLEADING 6
+#define OFFSET_USELINESPACING 7
+#define OFFSET_ADDTABLESPACING 8
+#define OFFSET_USEOBJPOS 9
+#define OFFSET_USEOURTEXTWRAPPING 10
+#define OFFSET_CONSIDERWRAPPINGSTYLE 11
+#define OFFSET_EXPANDWORDSPACE 12
+
+//_________________________________________________________________________________________________________________
+// private declarations!
+//_________________________________________________________________________________________________________________
+
+/*-****************************************************************************************************************
+ @descr struct to hold information about one compatibility entry
+****************************************************************************************************************-*/
+struct SvtCompatibilityEntry
+{
+ public:
+ SvtCompatibilityEntry() :
+ bUsePrtMetrics( false ), bAddSpacing( false ),
+ bAddSpacingAtPages( false ), bUseOurTabStops( false ),
+ bNoExtLeading( false ), bUseLineSpacing( false ),
+ bAddTableSpacing( false ), bUseObjPos( false ),
+ bUseOurTextWrapping( false ), bConsiderWrappingStyle( false ),
+ bExpandWordSpace( true ) {}
+ SvtCompatibilityEntry(
+ const OUString& _rName, const OUString& _rNewModule ) :
+ sName( _rName ), sModule( _rNewModule ),
+ bUsePrtMetrics( false ), bAddSpacing( false ),
+ bAddSpacingAtPages( false ), bUseOurTabStops( false ),
+ bNoExtLeading( false ), bUseLineSpacing( false ),
+ bAddTableSpacing( false ), bUseObjPos( false ),
+ bUseOurTextWrapping( false ), bConsiderWrappingStyle( false ),
+ bExpandWordSpace( true ) {}
+
+ inline void SetUsePrtMetrics( bool _bSet ) { bUsePrtMetrics = _bSet; }
+ inline void SetAddSpacing( bool _bSet ) { bAddSpacing = _bSet; }
+ inline void SetAddSpacingAtPages( bool _bSet ) { bAddSpacingAtPages = _bSet; }
+ inline void SetUseOurTabStops( bool _bSet ) { bUseOurTabStops = _bSet; }
+ inline void SetNoExtLeading( bool _bSet ) { bNoExtLeading = _bSet; }
+ inline void SetUseLineSpacing( bool _bSet ) { bUseLineSpacing = _bSet; }
+ inline void SetAddTableSpacing( bool _bSet ) { bAddTableSpacing = _bSet; }
+ inline void SetUseObjPos( bool _bSet ) { bUseObjPos = _bSet; }
+ inline void SetUseOurTextWrapping( bool _bSet ) { bUseOurTextWrapping = _bSet; }
+ inline void SetConsiderWrappingStyle( bool _bSet ) { bConsiderWrappingStyle = _bSet; }
+ inline void SetExpandWordSpace( bool _bSet ) { bExpandWordSpace = _bSet; }
+
+ public:
+ OUString sName;
+ OUString sModule;
+ bool bUsePrtMetrics;
+ bool bAddSpacing;
+ bool bAddSpacingAtPages;
+ bool bUseOurTabStops;
+ bool bNoExtLeading;
+ bool bUseLineSpacing;
+ bool bAddTableSpacing;
+ bool bUseObjPos;
+ bool bUseOurTextWrapping;
+ bool bConsiderWrappingStyle;
+ bool bExpandWordSpace;
+};
+
+/*-****************************************************************************************************************
+ @descr support simple menu structures and operations on it
+****************************************************************************************************************-*/
+class SvtCompatibility
+{
+ public:
+ //---------------------------------------------------------------------------------------------------------
+ // append one entry
+ void AppendEntry( const SvtCompatibilityEntry& rEntry )
+ {
+ lEntries.push_back( rEntry );
+ }
+
+ //---------------------------------------------------------------------------------------------------------
+ // the only way to free memory!
+ void Clear()
+ {
+ lEntries.clear();
+ }
+
+ //---------------------------------------------------------------------------------------------------------
+ // convert internal list to external format
+ Sequence< Sequence< PropertyValue > > GetList() const
+ {
+ sal_Int32 nCount = (sal_Int32)lEntries.size();
+ sal_Int32 nStep = 0;
+ Sequence< PropertyValue > lProperties( PROPERTYCOUNT );
+ Sequence< Sequence< PropertyValue > > lResult( nCount );
+ const vector< SvtCompatibilityEntry >* pList = &lEntries;
+
+ lProperties[ OFFSET_NAME ].Name = PROPERTYNAME_NAME;
+ lProperties[ OFFSET_MODULE ].Name = PROPERTYNAME_MODULE;
+ lProperties[ OFFSET_USEPRTMETRICS ].Name = PROPERTYNAME_USEPRTMETRICS;
+ lProperties[ OFFSET_ADDSPACING ].Name = PROPERTYNAME_ADDSPACING;
+ lProperties[ OFFSET_ADDSPACINGATPAGES ].Name = PROPERTYNAME_ADDSPACINGATPAGES;
+ lProperties[ OFFSET_USEOURTABSTOPS ].Name = PROPERTYNAME_USEOURTABSTOPS;
+ lProperties[ OFFSET_NOEXTLEADING ].Name = PROPERTYNAME_NOEXTLEADING;
+ lProperties[ OFFSET_USELINESPACING ].Name = PROPERTYNAME_USELINESPACING;
+ lProperties[ OFFSET_ADDTABLESPACING ].Name = PROPERTYNAME_ADDTABLESPACING;
+ lProperties[ OFFSET_USEOBJPOS ].Name = PROPERTYNAME_USEOBJPOS;
+ lProperties[ OFFSET_USEOURTEXTWRAPPING ].Name = PROPERTYNAME_USEOURTEXTWRAP;
+ lProperties[ OFFSET_CONSIDERWRAPPINGSTYLE ].Name = PROPERTYNAME_CONSIDERWRAPSTYLE;
+ lProperties[ OFFSET_EXPANDWORDSPACE ].Name = PROPERTYNAME_EXPANDWORDSPACE;
+
+ for ( vector< SvtCompatibilityEntry >::const_iterator pItem = pList->begin();
+ pItem != pList->end(); ++pItem )
+ {
+ lProperties[ OFFSET_NAME ].Value <<= pItem->sName;
+ lProperties[ OFFSET_MODULE ].Value <<= pItem->sModule;
+ lProperties[ OFFSET_USEPRTMETRICS ].Value <<= pItem->bUsePrtMetrics;
+ lProperties[ OFFSET_ADDSPACING ].Value <<= pItem->bAddSpacing;
+ lProperties[ OFFSET_ADDSPACINGATPAGES ].Value <<= pItem->bAddSpacingAtPages;
+ lProperties[ OFFSET_USEOURTABSTOPS ].Value <<= pItem->bUseOurTabStops;
+ lProperties[ OFFSET_NOEXTLEADING ].Value <<= pItem->bNoExtLeading;
+ lProperties[ OFFSET_USELINESPACING ].Value <<= pItem->bUseLineSpacing;
+ lProperties[ OFFSET_ADDTABLESPACING ].Value <<= pItem->bAddTableSpacing;
+ lProperties[ OFFSET_USEOBJPOS ].Value <<= pItem->bUseObjPos;
+ lProperties[ OFFSET_USEOURTEXTWRAPPING ].Value <<= pItem->bUseOurTextWrapping;
+ lProperties[ OFFSET_CONSIDERWRAPPINGSTYLE ].Value <<= pItem->bConsiderWrappingStyle;
+ lProperties[ OFFSET_EXPANDWORDSPACE ].Value <<= pItem->bExpandWordSpace;
+ lResult[ nStep ] = lProperties;
+ ++nStep;
+ }
+
+ return lResult;
+ }
+
+ int size() const
+ {
+ return lEntries.size();
+ }
+
+ const SvtCompatibilityEntry& operator[]( int i )
+ {
+ return lEntries[i];
+ }
+
+ private:
+ vector< SvtCompatibilityEntry > lEntries;
+};
+
+class SvtCompatibilityOptions_Impl : public ConfigItem
+{
+ //-------------------------------------------------------------------------------------------------------------
+ // public methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ public:
+
+ //---------------------------------------------------------------------------------------------------------
+ // constructor / destructor
+ //---------------------------------------------------------------------------------------------------------
+
+ SvtCompatibilityOptions_Impl();
+ ~SvtCompatibilityOptions_Impl();
+
+ //---------------------------------------------------------------------------------------------------------
+ // overloaded methods of baseclass
+ //---------------------------------------------------------------------------------------------------------
+
+ /*-****************************************************************************************************//**
+ @short called for notify of configmanager
+ @descr These method is called from the ConfigManager before application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. You must update your
+ internal values.
+
+ @seealso baseclass ConfigItem
+
+ @param "lPropertyNames" is the list of properties which should be updated.
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Notify( const Sequence< OUString >& lPropertyNames );
+
+ /*-****************************************************************************************************//**
+ @short write changes to configuration
+ @descr These method writes the changed values into the sub tree
+ and should always called in our destructor to guarantee consistency of config data.
+
+ @seealso baseclass ConfigItem
+
+ @param -
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Commit();
+
+ //---------------------------------------------------------------------------------------------------------
+ // public interface
+ //---------------------------------------------------------------------------------------------------------
+
+ inline bool IsUsePrtDevice() const { return m_aDefOptions.bUsePrtMetrics; }
+ inline bool IsAddSpacing() const { return m_aDefOptions.bAddSpacing; }
+ inline bool IsAddSpacingAtPages() const { return m_aDefOptions.bAddSpacingAtPages; }
+ inline bool IsUseOurTabStops() const { return m_aDefOptions.bUseOurTabStops; }
+ inline bool IsNoExtLeading() const { return m_aDefOptions.bNoExtLeading; }
+ inline bool IsUseLineSpacing() const { return m_aDefOptions.bUseLineSpacing; }
+ inline bool IsAddTableSpacing() const { return m_aDefOptions.bAddTableSpacing; }
+ inline bool IsUseObjPos() const { return m_aDefOptions.bUseObjPos; }
+ inline bool IsUseOurTextWrapping() const { return m_aDefOptions.bUseOurTextWrapping; }
+ inline bool IsConsiderWrappingStyle() const { return m_aDefOptions.bConsiderWrappingStyle; }
+ inline bool IsExpandWordSpace() const { return m_aDefOptions.bExpandWordSpace; }
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ /*-****************************************************************************************************//**
+ @short return list of key names of our configuration management which represent one module tree
+ @descr These methods return the current list of key names! We need it to get needed values from our
+ configuration management and support dynamical menu item lists!
+
+ @seealso -
+
+ @param -
+ @return A list of configuration key names is returned.
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ Sequence< OUString > impl_GetPropertyNames( Sequence< OUString >& rItems );
+
+ /*-****************************************************************************************************//**
+ @short expand the list for all well known properties to destination
+ @descr -
+ @attention -
+
+ @seealso method impl_GetPropertyNames()
+
+ @param "lSource" , original list
+ @param "lDestination" , destination of operation
+ @return A list of configuration key names is returned.
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ void impl_ExpandPropertyNames( const Sequence< OUString >& lSource,
+ Sequence< OUString >& lDestination );
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private member
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ SvtCompatibility m_aOptions;
+ SvtCompatibilityEntry m_aDefOptions;
+};
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtCompatibilityOptions_Impl::SvtCompatibilityOptions_Impl()
+ // Init baseclasses first
+ : ConfigItem( ROOTNODE_OPTIONS )
+ // Init member then...
+{
+ // Get names and values of all accessable menu entries and fill internal structures.
+ // See impl_GetPropertyNames() for further informations.
+ Sequence< OUString > lNodes;
+ Sequence< OUString > lNames = impl_GetPropertyNames( lNodes );
+ sal_uInt32 nCount = lNodes.getLength();
+ Sequence< Any > lValues = GetProperties( lNames );
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !( lNames.getLength()!=lValues.getLength() ), "SvtCompatibilityOptions_Impl::SvtCompatibilityOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ SvtCompatibilityEntry aItem;
+ sal_uInt32 nItem = 0;
+ sal_uInt32 nPosition = 0;
+
+ // Get names/values for new menu.
+ // 4 subkeys for every item!
+ bool bDefaultFound = false;
+ for( nItem = 0; nItem < nCount; ++nItem )
+ {
+ aItem.sName = lNodes[ nItem ];
+ lValues[ nPosition++ ] >>= aItem.sModule;
+ lValues[ nPosition++ ] >>= aItem.bUsePrtMetrics;
+ lValues[ nPosition++ ] >>= aItem.bAddSpacing;
+ lValues[ nPosition++ ] >>= aItem.bAddSpacingAtPages;
+ lValues[ nPosition++ ] >>= aItem.bUseOurTabStops;
+ lValues[ nPosition++ ] >>= aItem.bNoExtLeading;
+ lValues[ nPosition++ ] >>= aItem.bUseLineSpacing;
+ lValues[ nPosition++ ] >>= aItem.bAddTableSpacing;
+ lValues[ nPosition++ ] >>= aItem.bUseObjPos;
+ lValues[ nPosition++ ] >>= aItem.bUseOurTextWrapping;
+ lValues[ nPosition++ ] >>= aItem.bConsiderWrappingStyle;
+ lValues[ nPosition++ ] >>= aItem.bExpandWordSpace;
+ m_aOptions.AppendEntry( aItem );
+
+ if ( !bDefaultFound && aItem.sName.equals( COMPATIBILITY_DEFAULT_NAME ) != sal_False )
+ {
+ m_aDefOptions = aItem;
+ bDefaultFound = true;
+ }
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtCompatibilityOptions_Impl::~SvtCompatibilityOptions_Impl()
+{
+ // We must save our current values .. if user forget it!
+ if( IsModified() == sal_True )
+ {
+ Commit();
+ }
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtCompatibilityOptions_Impl::Notify( const Sequence< OUString >& )
+{
+ DBG_ASSERT( sal_False, "SvtCompatibilityOptions_Impl::Notify()\nNot implemented yet! I don't know how I can handle a dynamical list of unknown properties ...\n" );
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtCompatibilityOptions_Impl::Commit()
+{
+ // Write all properties!
+ // Delete complete set first.
+ ClearNodeSet( SETNODE_ALLFILEFORMATS );
+
+ SvtCompatibilityEntry aItem;
+ OUString sNode;
+ Sequence< PropertyValue > lPropertyValues( PROPERTYCOUNT - 1 );
+ sal_uInt32 nItem = 0;
+ sal_uInt32 nNewCount = m_aOptions.size();
+ for( nItem = 0; nItem < nNewCount; ++nItem )
+ {
+ aItem = m_aOptions[ nItem ];
+ sNode = SETNODE_ALLFILEFORMATS + PATHDELIMITER + aItem.sName + PATHDELIMITER;
+
+ lPropertyValues[ OFFSET_MODULE - 1 ].Name = sNode + PROPERTYNAME_MODULE;
+ lPropertyValues[ OFFSET_USEPRTMETRICS - 1 ].Name = sNode + PROPERTYNAME_USEPRTMETRICS;
+ lPropertyValues[ OFFSET_ADDSPACING - 1 ].Name = sNode + PROPERTYNAME_ADDSPACING;
+ lPropertyValues[ OFFSET_ADDSPACINGATPAGES - 1 ].Name = sNode + PROPERTYNAME_ADDSPACINGATPAGES;
+ lPropertyValues[ OFFSET_USEOURTABSTOPS - 1 ].Name = sNode + PROPERTYNAME_USEOURTABSTOPS;
+ lPropertyValues[ OFFSET_NOEXTLEADING - 1 ].Name = sNode + PROPERTYNAME_NOEXTLEADING;
+ lPropertyValues[ OFFSET_USELINESPACING - 1 ].Name = sNode + PROPERTYNAME_USELINESPACING;
+ lPropertyValues[ OFFSET_ADDTABLESPACING - 1 ].Name = sNode + PROPERTYNAME_ADDTABLESPACING;
+ lPropertyValues[ OFFSET_USEOBJPOS - 1 ].Name = sNode + PROPERTYNAME_USEOBJPOS;
+ lPropertyValues[ OFFSET_USEOURTEXTWRAPPING - 1 ].Name = sNode + PROPERTYNAME_USEOURTEXTWRAP;
+ lPropertyValues[ OFFSET_CONSIDERWRAPPINGSTYLE - 1 ].Name = sNode + PROPERTYNAME_CONSIDERWRAPSTYLE;
+ lPropertyValues[ OFFSET_EXPANDWORDSPACE - 1 ].Name = sNode + PROPERTYNAME_EXPANDWORDSPACE;
+
+ lPropertyValues[ OFFSET_MODULE - 1 ].Value <<= aItem.sModule;
+ lPropertyValues[ OFFSET_USEPRTMETRICS - 1 ].Value <<= aItem.bUsePrtMetrics;
+ lPropertyValues[ OFFSET_ADDSPACING - 1 ].Value <<= aItem.bAddSpacing;
+ lPropertyValues[ OFFSET_ADDSPACINGATPAGES - 1 ].Value <<= aItem.bAddSpacingAtPages;
+ lPropertyValues[ OFFSET_USEOURTABSTOPS - 1 ].Value <<= aItem.bUseOurTabStops;
+ lPropertyValues[ OFFSET_NOEXTLEADING - 1 ].Value <<= aItem.bNoExtLeading;
+ lPropertyValues[ OFFSET_USELINESPACING - 1 ].Value <<= aItem.bUseLineSpacing;
+ lPropertyValues[ OFFSET_ADDTABLESPACING - 1 ].Value <<= aItem.bAddTableSpacing;
+ lPropertyValues[ OFFSET_USEOBJPOS - 1 ].Value <<= aItem.bUseObjPos;
+ lPropertyValues[ OFFSET_USEOURTEXTWRAPPING - 1 ].Value <<= aItem.bUseOurTextWrapping;
+ lPropertyValues[ OFFSET_CONSIDERWRAPPINGSTYLE - 1 ].Value <<= aItem.bConsiderWrappingStyle;
+ lPropertyValues[ OFFSET_EXPANDWORDSPACE - 1 ].Value <<= aItem.bExpandWordSpace;
+
+ SetSetProperties( SETNODE_ALLFILEFORMATS, lPropertyValues );
+ }
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Sequence< OUString > SvtCompatibilityOptions_Impl::impl_GetPropertyNames( Sequence< OUString >& rItems )
+{
+ // First get ALL names of current existing list items in configuration!
+ rItems = GetNodeNames( SETNODE_ALLFILEFORMATS );
+ // expand list to result list ...
+ Sequence< OUString > lProperties( rItems.getLength() * ( PROPERTYCOUNT - 1 ) );
+ impl_ExpandPropertyNames( rItems, lProperties );
+ // Return result.
+ return lProperties;
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+void SvtCompatibilityOptions_Impl::impl_ExpandPropertyNames(
+ const Sequence< OUString >& lSource, Sequence< OUString >& lDestination )
+{
+ OUString sFixPath;
+ sal_Int32 nDestStep = 0;
+ sal_Int32 nSourceCount = lSource.getLength();
+ // Copy entries to destination and expand every item with 2 supported sub properties.
+ for( sal_Int32 nSourceStep = 0; nSourceStep < nSourceCount; ++nSourceStep )
+ {
+ sFixPath = SETNODE_ALLFILEFORMATS;
+ sFixPath += PATHDELIMITER;
+ sFixPath += lSource[ nSourceStep ];
+ sFixPath += PATHDELIMITER;
+
+ lDestination[nDestStep] = sFixPath;
+ lDestination[nDestStep] += PROPERTYNAME_MODULE;
+ ++nDestStep;
+ lDestination[nDestStep] = sFixPath;
+ lDestination[nDestStep] += PROPERTYNAME_USEPRTMETRICS;
+ ++nDestStep;
+ lDestination[nDestStep] = sFixPath;
+ lDestination[nDestStep] += PROPERTYNAME_ADDSPACING;
+ ++nDestStep;
+ lDestination[nDestStep] = sFixPath;
+ lDestination[nDestStep] += PROPERTYNAME_ADDSPACINGATPAGES;
+ ++nDestStep;
+ lDestination[nDestStep] = sFixPath;
+ lDestination[nDestStep] += PROPERTYNAME_USEOURTABSTOPS;
+ ++nDestStep;
+ lDestination[nDestStep] = sFixPath;
+ lDestination[nDestStep] += PROPERTYNAME_NOEXTLEADING;
+ ++nDestStep;
+ lDestination[nDestStep] = sFixPath;
+ lDestination[nDestStep] += PROPERTYNAME_USELINESPACING;
+ ++nDestStep;
+ lDestination[nDestStep] = sFixPath;
+ lDestination[nDestStep] += PROPERTYNAME_ADDTABLESPACING;
+ ++nDestStep;
+ lDestination[nDestStep] = sFixPath;
+ lDestination[nDestStep] += PROPERTYNAME_USEOBJPOS;
+ ++nDestStep;
+ lDestination[nDestStep] = sFixPath;
+ lDestination[nDestStep] += PROPERTYNAME_USEOURTEXTWRAP;
+ ++nDestStep;
+ lDestination[nDestStep] = sFixPath;
+ lDestination[nDestStep] += PROPERTYNAME_CONSIDERWRAPSTYLE;
+ ++nDestStep;
+ lDestination[nDestStep] = sFixPath;
+ lDestination[nDestStep] += PROPERTYNAME_EXPANDWORDSPACE;
+ ++nDestStep;
+ }
+}
+
+//*****************************************************************************************************************
+// initialize static member
+// DON'T DO IT IN YOUR HEADER!
+// see definition for further informations
+//*****************************************************************************************************************
+SvtCompatibilityOptions_Impl* SvtCompatibilityOptions::m_pDataContainer = NULL;
+sal_Int32 SvtCompatibilityOptions::m_nRefCount = 0;
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtCompatibilityOptions::SvtCompatibilityOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already exist!
+ if( m_pDataContainer == NULL )
+ {
+ m_pDataContainer = new SvtCompatibilityOptions_Impl;
+ ItemHolder1::holdConfigItem(E_COMPATIBILITY);
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtCompatibilityOptions::~SvtCompatibilityOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Decrease ouer refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pDataContainer;
+ m_pDataContainer = NULL;
+ }
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Mutex& SvtCompatibilityOptions::GetOwnStaticMutex()
+{
+ // Initialize static mutex only for one time!
+ static Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_ctloptions.cxx b/binfilter/bf_svtools/source/config/svt_ctloptions.cxx
new file mode 100644
index 000000000000..c599f1e937bf
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_ctloptions.cxx
@@ -0,0 +1,367 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/ctloptions.hxx>
+
+#include <bf_svtools/languageoptions.hxx>
+
+#include <i18npool/lang.h>
+#include <unotools/configitem.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/uno/Any.h>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <osl/mutex.hxx>
+#include <osl/mutex.hxx>
+#include <bf_svtools/smplhint.hxx>
+#include <vcl/svapp.hxx>
+#include <rtl/instance.hxx>
+
+#include <itemholder2.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+namespace binfilter
+{
+
+#define ASCII_STR(s) rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(s) )
+#define CFG_READONLY_DEFAULT sal_False
+
+// SvtCJKOptions_Impl ----------------------------------------------------------
+
+class SvtCTLOptions_Impl : public utl::ConfigItem, public SfxBroadcaster
+{
+private:
+ sal_Bool m_bIsLoaded;
+ sal_Bool m_bCTLFontEnabled;
+ sal_Bool m_bCTLSequenceChecking;
+ sal_Bool m_bCTLRestricted;
+ sal_Bool m_bCTLTypeAndReplace;
+ SvtCTLOptions::CursorMovement m_eCTLCursorMovement;
+ SvtCTLOptions::TextNumerals m_eCTLTextNumerals;
+
+ sal_Bool m_bROCTLFontEnabled;
+ sal_Bool m_bROCTLSequenceChecking;
+ sal_Bool m_bROCTLRestricted;
+ sal_Bool m_bROCTLTypeAndReplace;
+ sal_Bool m_bROCTLCursorMovement;
+ sal_Bool m_bROCTLTextNumerals;
+
+public:
+ SvtCTLOptions_Impl();
+ ~SvtCTLOptions_Impl();
+
+ virtual void Notify( const Sequence< rtl::OUString >& _aPropertyNames );
+ virtual void Commit();
+ void Load();
+
+ sal_Bool IsLoaded() { return m_bIsLoaded; }
+ sal_Bool IsCTLFontEnabled() const { return m_bCTLFontEnabled; }
+
+ sal_Bool IsCTLSequenceChecking() const { return m_bCTLSequenceChecking;}
+
+ sal_Bool IsCTLSequenceCheckingRestricted( void ) const { return m_bCTLRestricted; }
+
+ sal_Bool IsCTLSequenceCheckingTypeAndReplace() const { return m_bCTLTypeAndReplace; }
+
+ SvtCTLOptions::CursorMovement
+ GetCTLCursorMovement() const { return m_eCTLCursorMovement; }
+
+ SvtCTLOptions::TextNumerals
+ GetCTLTextNumerals() const { return m_eCTLTextNumerals; }
+
+};
+//------------------------------------------------------------------------------
+namespace
+{
+ struct PropertyNames
+ : public rtl::Static< Sequence< rtl::OUString >, PropertyNames > {};
+}
+//------------------------------------------------------------------------------
+SvtCTLOptions_Impl::SvtCTLOptions_Impl() :
+
+ utl::ConfigItem( ASCII_STR("Office.Common/I18N/CTL") ),
+
+ m_bIsLoaded ( sal_False ),
+ m_bCTLFontEnabled ( sal_False ),
+ m_bCTLSequenceChecking ( sal_False ),
+ m_bCTLRestricted ( sal_False ),
+ m_eCTLCursorMovement ( SvtCTLOptions::MOVEMENT_LOGICAL ),
+ m_eCTLTextNumerals ( SvtCTLOptions::NUMERALS_ARABIC ),
+
+ m_bROCTLFontEnabled ( CFG_READONLY_DEFAULT ),
+ m_bROCTLSequenceChecking( CFG_READONLY_DEFAULT ),
+ m_bROCTLRestricted ( CFG_READONLY_DEFAULT ),
+ m_bROCTLCursorMovement ( CFG_READONLY_DEFAULT ),
+ m_bROCTLTextNumerals ( CFG_READONLY_DEFAULT )
+{
+}
+//------------------------------------------------------------------------------
+SvtCTLOptions_Impl::~SvtCTLOptions_Impl()
+{
+ if ( IsModified() == sal_True )
+ Commit();
+}
+// -----------------------------------------------------------------------------
+void SvtCTLOptions_Impl::Notify( const Sequence< rtl::OUString >& )
+{
+ Load();
+ Broadcast(SfxSimpleHint(SFX_HINT_CTL_SETTINGS_CHANGED));
+}
+// -----------------------------------------------------------------------------
+void SvtCTLOptions_Impl::Commit()
+{
+ Sequence< rtl::OUString > &rPropertyNames = PropertyNames::get();
+ rtl::OUString* pOrgNames = rPropertyNames.getArray();
+ sal_Int32 nOrgCount = rPropertyNames.getLength();
+
+ Sequence< rtl::OUString > aNames( nOrgCount );
+ Sequence< Any > aValues( nOrgCount );
+
+ rtl::OUString* pNames = aNames.getArray();
+ Any* pValues = aValues.getArray();
+ sal_Int32 nRealCount = 0;
+
+ const uno::Type& rType = ::getBooleanCppuType();
+
+ for ( int nProp = 0; nProp < nOrgCount; nProp++ )
+ {
+ switch ( nProp )
+ {
+ case 0:
+ {
+ if (!m_bROCTLFontEnabled)
+ {
+ pNames[nRealCount] = pOrgNames[nProp];
+ pValues[nRealCount].setValue( &m_bCTLFontEnabled, rType );
+ ++nRealCount;
+ }
+ }
+ break;
+
+ case 1:
+ {
+ if (!m_bROCTLSequenceChecking)
+ {
+ pNames[nRealCount] = pOrgNames[nProp];
+ pValues[nRealCount].setValue( &m_bCTLSequenceChecking, rType );
+ ++nRealCount;
+ }
+ }
+ break;
+
+ case 2:
+ {
+ if (!m_bROCTLCursorMovement)
+ {
+ pNames[nRealCount] = pOrgNames[nProp];
+ pValues[nRealCount] <<= (sal_Int32)m_eCTLCursorMovement;
+ ++nRealCount;
+ }
+ }
+ break;
+
+ case 3:
+ {
+ if (!m_bROCTLTextNumerals)
+ {
+ pNames[nRealCount] = pOrgNames[nProp];
+ pValues[nRealCount] <<= (sal_Int32)m_eCTLTextNumerals;
+ ++nRealCount;
+ }
+ }
+ break;
+
+ case 4:
+ {
+ if (!m_bROCTLRestricted)
+ {
+ pNames[nRealCount] = pOrgNames[nProp];
+ pValues[nRealCount].setValue( &m_bCTLRestricted, rType );
+ ++nRealCount;
+ }
+ }
+ break;
+ case 5:
+ {
+ if(!m_bROCTLTypeAndReplace)
+ {
+ pNames[nRealCount] = pOrgNames[nProp];
+ pValues[nRealCount].setValue( &m_bCTLTypeAndReplace, rType );
+ ++nRealCount;
+ }
+ }
+ break;
+ }
+ }
+ aNames.realloc(nRealCount);
+ aValues.realloc(nRealCount);
+ PutProperties( aNames, aValues );
+ //broadcast changes
+ Broadcast(SfxSimpleHint(SFX_HINT_CTL_SETTINGS_CHANGED));
+}
+// -----------------------------------------------------------------------------
+void SvtCTLOptions_Impl::Load()
+{
+ Sequence< rtl::OUString >& rPropertyNames = PropertyNames::get();
+ if ( !rPropertyNames.getLength() )
+ {
+ rPropertyNames.realloc(6);
+ rtl::OUString* pNames = rPropertyNames.getArray();
+ pNames[0] = ASCII_STR("CTLFont");
+ pNames[1] = ASCII_STR("CTLSequenceChecking");
+ pNames[2] = ASCII_STR("CTLCursorMovement");
+ pNames[3] = ASCII_STR("CTLTextNumerals");
+ pNames[4] = ASCII_STR("CTLSequenceCheckingRestricted");
+ pNames[5] = ASCII_STR("CTLSequenceCheckingTypeAndReplace");
+ EnableNotification( rPropertyNames );
+ }
+ Sequence< Any > aValues = GetProperties( rPropertyNames );
+ Sequence< sal_Bool > aROStates = GetReadOnlyStates( rPropertyNames );
+ const Any* pValues = aValues.getConstArray();
+ const sal_Bool* pROStates = aROStates.getConstArray();
+ DBG_ASSERT( aValues.getLength() == rPropertyNames.getLength(), "GetProperties failed" );
+ DBG_ASSERT( aROStates.getLength() == rPropertyNames.getLength(), "GetReadOnlyStates failed" );
+ if ( aValues.getLength() == rPropertyNames.getLength() && aROStates.getLength() == rPropertyNames.getLength() )
+ {
+ sal_Bool bValue = sal_False;
+ sal_Int32 nValue = 0;
+
+ for ( int nProp = 0; nProp < rPropertyNames.getLength(); nProp++ )
+ {
+ if ( pValues[nProp].hasValue() )
+ {
+ if ( pValues[nProp] >>= bValue )
+ {
+ switch ( nProp )
+ {
+ case 0: { m_bCTLFontEnabled = bValue; m_bROCTLFontEnabled = pROStates[nProp]; } break;
+ case 1: { m_bCTLSequenceChecking = bValue; m_bROCTLSequenceChecking = pROStates[nProp]; } break;
+ case 4: { m_bCTLRestricted = bValue; m_bROCTLRestricted = pROStates[nProp]; } break;
+ case 5: { m_bCTLTypeAndReplace = bValue; m_bROCTLTypeAndReplace = pROStates[nProp]; } break;
+ }
+ }
+ else if ( pValues[nProp] >>= nValue )
+ {
+ switch ( nProp )
+ {
+ case 2: { m_eCTLCursorMovement = (SvtCTLOptions::CursorMovement)nValue; m_bROCTLCursorMovement = pROStates[nProp]; } break;
+ case 3: { m_eCTLTextNumerals = (SvtCTLOptions::TextNumerals)nValue; m_bROCTLTextNumerals = pROStates[nProp]; } break;
+ }
+ }
+ }
+ }
+ }
+ sal_uInt16 nType = SvtLanguageOptions::GetScriptTypeOfLanguage(LANGUAGE_SYSTEM);
+ SvtSystemLanguageOptions aSystemLocaleSettings;
+ LanguageType eSystemLanguage = aSystemLocaleSettings.GetWin16SystemLanguage();
+ sal_uInt16 nWinScript = SvtLanguageOptions::GetScriptTypeOfLanguage( eSystemLanguage );
+ if( !m_bCTLFontEnabled && (( nType & SCRIPTTYPE_COMPLEX ) ||
+ ((eSystemLanguage != LANGUAGE_SYSTEM) && ( nWinScript & SCRIPTTYPE_COMPLEX ))) )
+ {
+ m_bCTLFontEnabled = sal_True;
+ sal_uInt16 nLanguage = Application::GetSettings().GetLanguage();
+ //enable sequence checking for the appropriate languages
+ m_bCTLSequenceChecking = m_bCTLRestricted = m_bCTLTypeAndReplace =
+ ( LANGUAGE_KHMER == nLanguage || LANGUAGE_KHMER == eSystemLanguage ||
+ LANGUAGE_THAI == nLanguage || LANGUAGE_THAI == eSystemLanguage ||
+ LANGUAGE_VIETNAMESE == nLanguage || LANGUAGE_VIETNAMESE == eSystemLanguage ||
+ LANGUAGE_LAO == nLanguage || LANGUAGE_LAO == eSystemLanguage );
+ Commit();
+ }
+ m_bIsLoaded = sal_True;
+}
+
+// global ----------------------------------------------------------------
+
+static SvtCTLOptions_Impl* pCTLOptions = NULL;
+static sal_Int32 nCTLRefCount = 0;
+namespace { struct CTLMutex : public rtl::Static< osl::Mutex, CTLMutex > {}; }
+
+// class SvtCTLOptions --------------------------------------------------
+
+SvtCTLOptions::SvtCTLOptions( sal_Bool bDontLoad )
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( CTLMutex::get() );
+ if ( !pCTLOptions )
+ {
+ pCTLOptions = new SvtCTLOptions_Impl;
+ ItemHolder2::holdConfigItem(E_CTLOPTIONS);
+ }
+ if( !bDontLoad && !pCTLOptions->IsLoaded() )
+ pCTLOptions->Load();
+
+ ++nCTLRefCount;
+ m_pImp = pCTLOptions;
+ StartListening( *m_pImp);
+}
+
+// -----------------------------------------------------------------------
+
+SvtCTLOptions::~SvtCTLOptions()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( CTLMutex::get() );
+
+ if ( !--nCTLRefCount )
+ DELETEZ( pCTLOptions );
+}
+// -----------------------------------------------------------------------------
+sal_Bool SvtCTLOptions::IsCTLFontEnabled() const
+{
+ DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
+ return pCTLOptions->IsCTLFontEnabled();
+}
+// -----------------------------------------------------------------------------
+sal_Bool SvtCTLOptions::IsCTLSequenceChecking() const
+{
+ DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
+ return pCTLOptions->IsCTLSequenceChecking();
+}
+// -----------------------------------------------------------------------------
+SvtCTLOptions::TextNumerals SvtCTLOptions::GetCTLTextNumerals() const
+{
+ DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
+ return pCTLOptions->GetCTLTextNumerals();
+}
+/* -----------------30.04.2003 10:40-----------------
+
+ --------------------------------------------------*/
+void SvtCTLOptions::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ SolarMutexGuard aVclGuard;
+ Broadcast( rHint );
+}
+
+// -----------------------------------------------------------------------------
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_defaultoptions.cxx b/binfilter/bf_svtools/source/config/svt_defaultoptions.cxx
new file mode 100644
index 000000000000..8103e73c0358
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_defaultoptions.cxx
@@ -0,0 +1,325 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/defaultoptions.hxx>
+#include <bf_svtools/pathoptions.hxx>
+
+#include <unotools/configitem.hxx>
+#include <unotools/configmgr.hxx>
+#include <tools/debug.hxx>
+#include <tools/resmgr.hxx>
+#include <tools/urlobj.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <osl/mutex.hxx>
+
+#include <unotools/localfilehelper.hxx>
+#include <rtl/instance.hxx>
+
+#include <itemholder1.hxx>
+
+using namespace osl;
+using namespace utl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+namespace binfilter
+{
+
+// define ----------------------------------------------------------------
+
+#define ASCII_STR(s) OUString( RTL_CONSTASCII_USTRINGPARAM(s) )
+
+#define DEFAULTPATH__ADDIN 0
+#define DEFAULTPATH__AUTOCORRECT 1
+#define DEFAULTPATH__AUTOTEXT 2
+#define DEFAULTPATH__BACKUP 3
+#define DEFAULTPATH__BASIC 4
+#define DEFAULTPATH__BITMAP 5
+#define DEFAULTPATH__CONFIG 6
+#define DEFAULTPATH__DICTIONARY 7
+#define DEFAULTPATH__FAVORITES 8
+#define DEFAULTPATH__FILTER 9
+#define DEFAULTPATH__GALLERY 10
+#define DEFAULTPATH__GRAPHIC 11
+#define DEFAULTPATH__HELP 12
+#define DEFAULTPATH__LINGUISTIC 13
+#define DEFAULTPATH__MODULE 14
+#define DEFAULTPATH__PALETTE 15
+#define DEFAULTPATH__PLUGIN 16
+#define DEFAULTPATH__TEMP 17
+#define DEFAULTPATH__TEMPLATE 18
+#define DEFAULTPATH__USERCONFIG 19
+#define DEFAULTPATH__USERDICTIONARY 20
+#define DEFAULTPATH__WORK 21
+
+// class SvtDefaultOptions_Impl ------------------------------------------
+
+class SvtDefaultOptions_Impl : public utl::ConfigItem
+{
+public:
+ String m_aAddinPath;
+ String m_aAutoCorrectPath;
+ String m_aAutoTextPath;
+ String m_aBackupPath;
+ String m_aBasicPath;
+ String m_aBitmapPath;
+ String m_aConfigPath;
+ String m_aDictionaryPath;
+ String m_aFavoritesPath;
+ String m_aFilterPath;
+ String m_aGalleryPath;
+ String m_aGraphicPath;
+ String m_aHelpPath;
+ String m_aLinguisticPath;
+ String m_aModulePath;
+ String m_aPalettePath;
+ String m_aPluginPath;
+ String m_aTempPath;
+ String m_aTemplatePath;
+ String m_aUserConfigPath;
+ String m_aUserDictionaryPath;
+ String m_aWorkPath;
+
+ SvtDefaultOptions_Impl();
+ void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& );
+ void Commit();
+};
+
+ void SvtDefaultOptions_Impl::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
+ void SvtDefaultOptions_Impl::Commit() {}
+
+// global ----------------------------------------------------------------
+
+static SvtDefaultOptions_Impl* pOptions = NULL;
+static sal_Int32 nRefCount = 0;
+
+typedef String SvtDefaultOptions_Impl:: *PathStrPtr;
+
+struct PathToDefaultMapping_Impl
+{
+ SvtPathOptions::Pathes _ePath;
+ PathStrPtr _pDefaultPath;
+};
+
+static PathToDefaultMapping_Impl __READONLY_DATA PathMap_Impl[] =
+{
+ { SvtPathOptions::PATH_ADDIN, &SvtDefaultOptions_Impl::m_aAddinPath },
+ { SvtPathOptions::PATH_AUTOCORRECT, &SvtDefaultOptions_Impl::m_aAutoCorrectPath },
+ { SvtPathOptions::PATH_AUTOTEXT, &SvtDefaultOptions_Impl::m_aAutoTextPath },
+ { SvtPathOptions::PATH_BACKUP, &SvtDefaultOptions_Impl::m_aBackupPath },
+ { SvtPathOptions::PATH_BASIC, &SvtDefaultOptions_Impl::m_aBasicPath },
+ { SvtPathOptions::PATH_BITMAP, &SvtDefaultOptions_Impl::m_aBitmapPath },
+ { SvtPathOptions::PATH_CONFIG, &SvtDefaultOptions_Impl::m_aConfigPath },
+ { SvtPathOptions::PATH_DICTIONARY, &SvtDefaultOptions_Impl::m_aDictionaryPath },
+ { SvtPathOptions::PATH_FAVORITES, &SvtDefaultOptions_Impl::m_aFavoritesPath },
+ { SvtPathOptions::PATH_FILTER, &SvtDefaultOptions_Impl::m_aFilterPath },
+ { SvtPathOptions::PATH_GALLERY, &SvtDefaultOptions_Impl::m_aGalleryPath },
+ { SvtPathOptions::PATH_GRAPHIC, &SvtDefaultOptions_Impl::m_aGraphicPath },
+ { SvtPathOptions::PATH_HELP, &SvtDefaultOptions_Impl::m_aHelpPath },
+ { SvtPathOptions::PATH_LINGUISTIC, &SvtDefaultOptions_Impl::m_aLinguisticPath },
+ { SvtPathOptions::PATH_MODULE, &SvtDefaultOptions_Impl::m_aModulePath },
+ { SvtPathOptions::PATH_PALETTE, &SvtDefaultOptions_Impl::m_aPalettePath },
+ { SvtPathOptions::PATH_PLUGIN, &SvtDefaultOptions_Impl::m_aPluginPath },
+ { SvtPathOptions::PATH_TEMP, &SvtDefaultOptions_Impl::m_aTempPath },
+ { SvtPathOptions::PATH_TEMPLATE, &SvtDefaultOptions_Impl::m_aTemplatePath },
+ { SvtPathOptions::PATH_USERCONFIG, &SvtDefaultOptions_Impl::m_aUserConfigPath },
+ { SvtPathOptions::PATH_USERDICTIONARY,&SvtDefaultOptions_Impl::m_aUserDictionaryPath },
+ { SvtPathOptions::PATH_WORK, &SvtDefaultOptions_Impl::m_aWorkPath }
+};
+
+// functions -------------------------------------------------------------
+
+Sequence< OUString > GetDefaultPropertyNames()
+{
+ static const char* aPropNames[] =
+ {
+ "Addin", // PATH_ADDIN
+ "AutoCorrect", // PATH_AUTOCORRECT
+ "AutoText", // PATH_AUTOTEXT
+ "Backup", // PATH_BACKUP
+ "Basic", // PATH_BASIC
+ "Bitmap", // PATH_BITMAP
+ "Config", // PATH_CONFIG
+ "Dictionary", // PATH_DICTIONARY
+ "Favorite", // PATH_FAVORITES
+ "Filter", // PATH_FILTER
+ "Gallery", // PATH_GALLERY
+ "Graphic", // PATH_GRAPHIC
+ "Help", // PATH_HELP
+ "Linguistic", // PATH_LINGUISTIC
+ "Module", // PATH_MODULE
+ "Palette", // PATH_PALETTE
+ "Plugin", // PATH_PLUGIN
+ "Temp", // PATH_TEMP
+ "Template", // PATH_TEMPLATE
+ "UserConfig", // PATH_USERCONFIG
+ "UserDictionary", // PATH_USERDICTIONARY
+ "Work" // PATH_WORK
+ };
+
+ const int nCount = sizeof( aPropNames ) / sizeof( const char* );
+ Sequence< OUString > aNames( nCount );
+ OUString* pNames = aNames.getArray();
+ for ( int i = 0; i < nCount; i++ )
+ pNames[i] = OUString::createFromAscii( aPropNames[i] );
+
+ return aNames;
+}
+
+// -----------------------------------------------------------------------
+
+SvtDefaultOptions_Impl::SvtDefaultOptions_Impl() : ConfigItem( ASCII_STR("Office.Common/Path/Default") )
+{
+ /*ConfigManager* pCfgMgr =*/ ConfigManager::GetConfigManager();
+ Sequence< OUString > aNames = GetDefaultPropertyNames();
+ Sequence< Any > aValues = GetProperties( aNames );
+ EnableNotification( aNames );
+ const Any* pValues = aValues.getConstArray();
+ DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
+ if ( aValues.getLength() == aNames.getLength() )
+ {
+ SvtPathOptions aPathOpt;
+ OUString aTempStr, aFullPath;
+
+ for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
+ {
+ if ( pValues[nProp].hasValue() )
+ {
+ switch ( pValues[nProp].getValueTypeClass() )
+ {
+ case ::com::sun::star::uno::TypeClass_STRING :
+ {
+ // multi pathes
+ if ( pValues[nProp] >>= aTempStr )
+ aFullPath = aPathOpt.SubstituteVariable( aTempStr );
+ else
+ {
+ DBG_ERRORFILE( "any operator >>= failed" );
+ }
+ break;
+ }
+
+ case ::com::sun::star::uno::TypeClass_SEQUENCE :
+ {
+ // single pathes
+ aFullPath = OUString();
+ Sequence < OUString > aList;
+ if ( pValues[nProp] >>= aList )
+ {
+ sal_Int32 nCount = aList.getLength();
+ for ( sal_Int32 nPosition = 0; nPosition < nCount; ++nPosition )
+ {
+ aTempStr = aPathOpt.SubstituteVariable( aList[ nPosition ] );
+ aFullPath += aTempStr;
+ if ( nPosition < nCount-1 )
+ aFullPath += OUString( RTL_CONSTASCII_USTRINGPARAM(";") );
+ }
+ }
+ else
+ {
+ DBG_ERRORFILE( "any operator >>= failed" );
+ }
+ break;
+ }
+
+ default:
+ {
+ DBG_ERRORFILE( "Wrong any type" );
+ }
+ }
+
+ switch ( nProp )
+ {
+ case DEFAULTPATH__ADDIN: m_aAddinPath = String( aFullPath ); break;
+ case DEFAULTPATH__AUTOCORRECT: m_aAutoCorrectPath = String( aFullPath ); break;
+ case DEFAULTPATH__AUTOTEXT: m_aAutoTextPath = String( aFullPath ); break;
+ case DEFAULTPATH__BACKUP: m_aBackupPath = String( aFullPath ); break;
+ case DEFAULTPATH__BASIC: m_aBasicPath = String( aFullPath ); break;
+ case DEFAULTPATH__BITMAP: m_aBitmapPath = String( aFullPath ); break;
+ case DEFAULTPATH__CONFIG: m_aConfigPath = String( aFullPath ); break;
+ case DEFAULTPATH__DICTIONARY: m_aDictionaryPath = String( aFullPath ); break;
+ case DEFAULTPATH__FAVORITES: m_aFavoritesPath = String( aFullPath ); break;
+ case DEFAULTPATH__FILTER: m_aFilterPath = String( aFullPath ); break;
+ case DEFAULTPATH__GALLERY: m_aGalleryPath = String( aFullPath ); break;
+ case DEFAULTPATH__GRAPHIC: m_aGraphicPath = String( aFullPath ); break;
+ case DEFAULTPATH__HELP: m_aHelpPath = String( aFullPath ); break;
+ case DEFAULTPATH__LINGUISTIC: m_aLinguisticPath = String( aFullPath ); break;
+ case DEFAULTPATH__MODULE: m_aModulePath = String( aFullPath ); break;
+ case DEFAULTPATH__PALETTE: m_aPalettePath = String( aFullPath ); break;
+ case DEFAULTPATH__PLUGIN: m_aPluginPath = String( aFullPath ); break;
+ case DEFAULTPATH__TEMP: m_aTempPath = String( aFullPath ); break;
+ case DEFAULTPATH__TEMPLATE: m_aTemplatePath = String( aFullPath ); break;
+ case DEFAULTPATH__USERCONFIG: m_aUserConfigPath = String( aFullPath ); break;
+ case DEFAULTPATH__USERDICTIONARY: m_aUserDictionaryPath = String( aFullPath );break;
+ case DEFAULTPATH__WORK: m_aWorkPath = String( aFullPath ); break;
+
+ default:
+ DBG_ERRORFILE( "invalid index to load a default path" );
+ }
+ }
+ }
+ }
+}
+
+// class SvtDefaultOptions -----------------------------------------------
+namespace { struct lclMutex : public rtl::Static< ::osl::Mutex, lclMutex > {}; }
+
+SvtDefaultOptions::SvtDefaultOptions()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( lclMutex::get() );
+ if ( !pOptions )
+ {
+ pOptions = new SvtDefaultOptions_Impl;
+ ItemHolder1::holdConfigItem(E_DEFAULTOPTIONS);
+ }
+ ++nRefCount;
+ pImp = pOptions;
+}
+
+// -----------------------------------------------------------------------
+
+SvtDefaultOptions::~SvtDefaultOptions()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( lclMutex::get() );
+ if ( !--nRefCount )
+ {
+ if ( pOptions->IsModified() )
+ pOptions->Commit();
+ DELETEZ( pOptions );
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_dynamicmenuoptions.cxx b/binfilter/bf_svtools/source/config/svt_dynamicmenuoptions.cxx
new file mode 100644
index 000000000000..f0e50807ebc7
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_dynamicmenuoptions.cxx
@@ -0,0 +1,789 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+//_________________________________________________________________________________________________________________
+// includes
+//_________________________________________________________________________________________________________________
+
+#include <bf_svtools/dynamicmenuoptions.hxx>
+
+#include <bf_svtools/moduleoptions.hxx>
+
+#include <unotools/configmgr.hxx>
+
+#include <unotools/configitem.hxx>
+
+#include <tools/debug.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#ifndef __SGI_STL_VECTOR
+#include <vector>
+#endif
+
+#include <itemholder1.hxx>
+
+#include <algorithm>
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+using namespace ::std ;
+using namespace ::utl ;
+using namespace ::rtl ;
+using namespace ::osl ;
+using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star::beans ;
+
+namespace binfilter
+{
+
+//_________________________________________________________________________________________________________________
+// const
+//_________________________________________________________________________________________________________________
+
+#define ROOTNODE_MENUS OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Menus/" ))
+#define PATHDELIMITER OUString(RTL_CONSTASCII_USTRINGPARAM("/" ))
+
+#define SETNODE_NEWMENU OUString(RTL_CONSTASCII_USTRINGPARAM("New" ))
+#define SETNODE_WIZARDMENU OUString(RTL_CONSTASCII_USTRINGPARAM("Wizard" ))
+#define SETNODE_HELPBOOKMARKS OUString(RTL_CONSTASCII_USTRINGPARAM("HelpBookmarks" ))
+
+#define PROPERTYNAME_URL DYNAMICMENU_PROPERTYNAME_URL
+#define PROPERTYNAME_TITLE DYNAMICMENU_PROPERTYNAME_TITLE
+#define PROPERTYNAME_IMAGEIDENTIFIER DYNAMICMENU_PROPERTYNAME_IMAGEIDENTIFIER
+#define PROPERTYNAME_TARGETNAME DYNAMICMENU_PROPERTYNAME_TARGETNAME
+
+#define PROPERTYCOUNT 4
+
+#define OFFSET_URL 0
+#define OFFSET_TITLE 1
+#define OFFSET_IMAGEIDENTIFIER 2
+#define OFFSET_TARGETNAME 3
+
+#define PATHPREFIX_SETUP OUString(RTL_CONSTASCII_USTRINGPARAM("m" ))
+#define PATHPREFIX_USER OUString(RTL_CONSTASCII_USTRINGPARAM("u" ))
+
+//_________________________________________________________________________________________________________________
+// private declarations!
+//_________________________________________________________________________________________________________________
+
+/*-****************************************************************************************************************
+ @descr struct to hold information about one menu entry.
+****************************************************************************************************************-*/
+struct SvtDynMenuEntry
+{
+ public:
+ SvtDynMenuEntry() {};
+
+ SvtDynMenuEntry( const OUString& sNewURL ,
+ const OUString& sNewTitle ,
+ const OUString& sNewImageIdentifier ,
+ const OUString& sNewTargetName )
+ {
+ sURL = sNewURL ;
+ sTitle = sNewTitle ;
+ sImageIdentifier = sNewImageIdentifier ;
+ sTargetName = sNewTargetName ;
+ }
+
+ public:
+ OUString sName ;
+ OUString sURL ;
+ OUString sTitle ;
+ OUString sImageIdentifier ;
+ OUString sTargetName ;
+};
+
+/*-****************************************************************************************************************
+ @descr support simple menu structures and operations on it
+****************************************************************************************************************-*/
+class SvtDynMenu
+{
+ public:
+ //---------------------------------------------------------------------------------------------------------
+ // append setup written menu entry
+ // Don't touch name of entry. It was defined by setup and must be the same everytime!
+ // Look for double menu entries here too ... may be some seperator items are supeflous ...
+ void AppendSetupEntry( const SvtDynMenuEntry& rEntry )
+ {
+ if(
+ ( lSetupEntries.size() < 1 ) ||
+ ( lSetupEntries.rbegin()->sURL != rEntry.sURL )
+ )
+ {
+ lSetupEntries.push_back( rEntry );
+ }
+ }
+
+ //---------------------------------------------------------------------------------------------------------
+ // append user specific menu entry
+ // We must find unique name for it by using special prefix
+ // and next count of user setted entries!
+ // Look for double menu entries here too ... may be some seperator items are supeflous ...
+ void AppendUserEntry( SvtDynMenuEntry& rEntry )
+ {
+ if(
+ ( lUserEntries.size() < 1 ) ||
+ ( lUserEntries.rbegin()->sURL != rEntry.sURL )
+ )
+ {
+ rEntry.sName = PATHPREFIX_USER;
+ rEntry.sName += OUString::valueOf( (sal_Int32)impl_getNextUserEntryNr() );
+ lUserEntries.push_back( rEntry );
+ }
+ }
+
+ //---------------------------------------------------------------------------------------------------------
+ // the only way to free memory!
+ void Clear()
+ {
+ lSetupEntries.clear();
+ lUserEntries.clear();
+ }
+
+ //---------------------------------------------------------------------------------------------------------
+ // convert internal list to external format
+ // for using it on right menus realy
+ // Notice: We build a property list with 4 entries and set it on result list then.
+ // The while-loop starts with pointer on internal member list lSetupEntries, change to
+ // lUserEntries then and stop after that with NULL!
+ // Separator entries will be packed in another way then normal entries! We define
+ // special strings "sEmpty" and "sSeperator" to perform too ...
+ Sequence< Sequence< PropertyValue > > GetList() const
+ {
+ sal_Int32 nSetupCount = (sal_Int32)lSetupEntries.size();
+ sal_Int32 nUserCount = (sal_Int32)lUserEntries.size();
+ sal_Int32 nStep = 0;
+ Sequence< PropertyValue > lProperties ( PROPERTYCOUNT );
+ Sequence< Sequence< PropertyValue > > lResult ( nSetupCount+nUserCount );
+ OUString sSeperator ( RTL_CONSTASCII_USTRINGPARAM("private:separator") );
+ OUString sEmpty ;
+ const vector< SvtDynMenuEntry >* pList = &lSetupEntries;
+
+ lProperties[OFFSET_URL ].Name = PROPERTYNAME_URL ;
+ lProperties[OFFSET_TITLE ].Name = PROPERTYNAME_TITLE ;
+ lProperties[OFFSET_IMAGEIDENTIFIER].Name = PROPERTYNAME_IMAGEIDENTIFIER ;
+ lProperties[OFFSET_TARGETNAME ].Name = PROPERTYNAME_TARGETNAME ;
+
+ while( pList != NULL )
+ {
+ for( vector< SvtDynMenuEntry >::const_iterator pItem =pList->begin();
+ pItem!=pList->end() ;
+ ++pItem )
+ {
+ if( pItem->sURL == sSeperator )
+ {
+ lProperties[OFFSET_URL ].Value <<= sSeperator ;
+ lProperties[OFFSET_TITLE ].Value <<= sEmpty ;
+ lProperties[OFFSET_IMAGEIDENTIFIER ].Value <<= sEmpty ;
+ lProperties[OFFSET_TARGETNAME ].Value <<= sEmpty ;
+ }
+ else
+ {
+ lProperties[OFFSET_URL ].Value <<= pItem->sURL ;
+ lProperties[OFFSET_TITLE ].Value <<= pItem->sTitle ;
+ lProperties[OFFSET_IMAGEIDENTIFIER ].Value <<= pItem->sImageIdentifier;
+ lProperties[OFFSET_TARGETNAME ].Value <<= pItem->sTargetName ;
+ }
+ lResult[nStep] = lProperties;
+ ++nStep;
+ }
+ if( pList == &lSetupEntries )
+ pList = &lUserEntries;
+ else
+ pList = NULL;
+ }
+ return lResult;
+ }
+
+ private:
+ //---------------------------------------------------------------------------------------------------------
+ // search for an entry named "ux" with x=[0..i] inside our menu
+ // which has set highest number x. So we can add another user entry.
+ sal_Int32 impl_getNextUserEntryNr() const
+ {
+ sal_Int32 nNr = 0;
+ for( vector< SvtDynMenuEntry >::const_iterator pItem =lUserEntries.begin();
+ pItem!=lUserEntries.end() ;
+ ++pItem )
+ {
+ if( pItem->sName.compareTo( PATHPREFIX_USER, 1 ) == 0 )
+ {
+ OUString sNr = pItem->sName.copy( 1, pItem->sName.getLength()-1 );
+ sal_Int32 nCheckNr = sNr.toInt32();
+ if( nCheckNr > nNr )
+ nNr = nCheckNr;
+ }
+ }
+ // Attention: Code isn't prepared for recyling of unused fragmented numbers!
+ // If we reach end of sal_Int32 range ... we must stop further working ...
+ // But I think nobody expand a menu to more then 1000 ... 100000 ... entries ... or?
+ DBG_ASSERT( !(nNr>0x7fffffff), "Menu::impl_getNextUserEntryNr()\nUser count can be out of range next time ...\n" );
+ return nNr;
+ }
+
+ private:
+ vector< SvtDynMenuEntry > lSetupEntries;
+ vector< SvtDynMenuEntry > lUserEntries ;
+};
+
+class SvtDynamicMenuOptions_Impl : public ConfigItem
+{
+ //-------------------------------------------------------------------------------------------------------------
+ // public methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ public:
+
+ //---------------------------------------------------------------------------------------------------------
+ // constructor / destructor
+ //---------------------------------------------------------------------------------------------------------
+
+ SvtDynamicMenuOptions_Impl();
+ ~SvtDynamicMenuOptions_Impl();
+
+ //---------------------------------------------------------------------------------------------------------
+ // overloaded methods of baseclass
+ //---------------------------------------------------------------------------------------------------------
+
+ /*-****************************************************************************************************//**
+ @short called for notify of configmanager
+ @descr These method is called from the ConfigManager before application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. You must update your
+ internal values.
+
+ @seealso baseclass ConfigItem
+
+ @param "lPropertyNames" is the list of properties which should be updated.
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Notify( const Sequence< OUString >& lPropertyNames );
+
+ /*-****************************************************************************************************//**
+ @short write changes to configuration
+ @descr These method writes the changed values into the sub tree
+ and should always called in our destructor to guarantee consistency of config data.
+
+ @seealso baseclass ConfigItem
+
+ @param -
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Commit();
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ /*-****************************************************************************************************//**
+ @short return list of key names of our configuration management which represent oue module tree
+ @descr These methods return the current list of key names! We need it to get needed values from our
+ configuration management and support dynamical menu item lists!
+
+ @seealso -
+
+ @param "nNewCount" , returns count of menu entries for "new"
+ @param "nWizardCount" , returns count of menu entries for "wizard"
+ @return A list of configuration key names is returned.
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ Sequence< OUString > impl_GetPropertyNames( sal_uInt32& nNewCount, sal_uInt32& nWizardCount, sal_uInt32& nHelpBookmarksCount );
+
+ /*-****************************************************************************************************//**
+ @short sort given source list and expand it for all well known properties to destination
+ @descr We must support sets of entries with count inside the name .. but some of them could be missing!
+ e.g. s1-s2-s3-s0-u1-s6-u5-u7
+ Then we must sort it by name and expand it to the follow one:
+ sSetNode/s0/URL
+ sSetNode/s0/Title
+ sSetNode/s0/...
+ sSetNode/s1/URL
+ sSetNode/s1/Title
+ sSetNode/s1/...
+ ...
+ sSetNode/s6/URL
+ sSetNode/s6/Title
+ sSetNode/s6/...
+ sSetNode/u1/URL
+ sSetNode/u1/Title
+ sSetNode/u1/...
+ ...
+ sSetNode/u7/URL
+ sSetNode/u7/Title
+ sSetNode/u7/...
+ Rules: We start with all setup written entries names "sx" and x=[0..n].
+ Then we handle all "ux" items. Inside these blocks we sort it ascending by number.
+
+ @attention We add these expanded list to the end of given "lDestination" list!
+ So we must start on "lDestination.getLength()".
+ Reallocation of memory of destination list is done by us!
+
+ @seealso method impl_GetPropertyNames()
+
+ @param "lSource" , original list (e.g. [m1-m2-m3-m6-m0] )
+ @param "lDestination" , destination of operation
+ @param "sSetNode" , name of configuration set to build complete path
+ @return A list of configuration key names is returned.
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ void impl_SortAndExpandPropertyNames( const Sequence< OUString >& lSource ,
+ Sequence< OUString >& lDestination ,
+ const OUString& sSetNode );
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private member
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ SvtDynMenu m_aNewMenu ;
+ SvtDynMenu m_aWizardMenu ;
+ SvtDynMenu m_aHelpBookmarksMenu ;
+};
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtDynamicMenuOptions_Impl::SvtDynamicMenuOptions_Impl()
+ // Init baseclasses first
+ : ConfigItem( ROOTNODE_MENUS )
+ // Init member then...
+{
+ // Get names and values of all accessable menu entries and fill internal structures.
+ // See impl_GetPropertyNames() for further informations.
+ sal_uInt32 nNewCount = 0;
+ sal_uInt32 nWizardCount = 0;
+ sal_uInt32 nHelpBookmarksCount = 0;
+ Sequence< OUString > lNames = impl_GetPropertyNames ( nNewCount ,
+ nWizardCount ,
+ nHelpBookmarksCount );
+ Sequence< Any > lValues = GetProperties ( lNames );
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !(lNames.getLength()!=lValues.getLength()), "SvtDynamicMenuOptions_Impl::SvtDynamicMenuOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to ouer internal member.
+ // Attention: List for names and values have an internal construction pattern!
+ //
+ // first "New" menu ...
+ // Name Value
+ // /New/1/URL "private:factory/swriter"
+ // /New/1/Title "Neues Writer Dokument"
+ // /New/1/ImageIdentifier "icon_writer"
+ // /New/1/TargetName "_blank"
+ //
+ // /New/2/URL "private:factory/scalc"
+ // /New/2/Title "Neues Calc Dokument"
+ // /New/2/ImageIdentifier "icon_calc"
+ // /New/2/TargetName "_blank"
+ //
+ // second "Wizard" menu ...
+ // /Wizard/1/URL "file://b"
+ // /Wizard/1/Title "MalWas"
+ // /Wizard/1/ImageIdentifier "icon_?"
+ // /Wizard/1/TargetName "_self"
+ //
+ // ... and so on ...
+
+ sal_uInt32 nItem = 0 ;
+ sal_uInt32 nPosition = 0 ;
+ OUString sName ;
+
+ // We must use these one instance object(!) to get information about installed modules.
+ // These information are used to filter menu entries wich need not installed modules ...
+ // Such entries shouldnt be available then!
+ // see impl_IsEntrySupported() too
+ SvtModuleOptions aModuleOptions;
+
+ // Get names/values for new menu.
+ // 4 subkeys for every item!
+ for( nItem=0; nItem<nNewCount; ++nItem )
+ {
+ SvtDynMenuEntry aItem ;
+ lValues[nPosition] >>= aItem.sURL ;
+ ++nPosition;
+ lValues[nPosition] >>= aItem.sTitle ;
+ ++nPosition;
+ lValues[nPosition] >>= aItem.sImageIdentifier ;
+ ++nPosition;
+ lValues[nPosition] >>= aItem.sTargetName ;
+ ++nPosition;
+ m_aNewMenu.AppendSetupEntry( aItem );
+ }
+
+ // Attention: Don't reset nPosition here!
+
+ // Get names/values for wizard menu.
+ // 4 subkeys for every item!
+ for( nItem=0; nItem<nWizardCount; ++nItem )
+ {
+ SvtDynMenuEntry aItem ;
+ lValues[nPosition] >>= aItem.sURL ;
+ ++nPosition;
+ lValues[nPosition] >>= aItem.sTitle ;
+ ++nPosition;
+ lValues[nPosition] >>= aItem.sImageIdentifier ;
+ ++nPosition;
+ lValues[nPosition] >>= aItem.sTargetName ;
+ ++nPosition;
+ m_aWizardMenu.AppendSetupEntry( aItem );
+ }
+
+ // Attention: Don't reset nPosition here!
+
+ // Get names/values for wizard menu.
+ // 4 subkeys for every item!
+ for( nItem=0; nItem<nHelpBookmarksCount; ++nItem )
+ {
+ SvtDynMenuEntry aItem ;
+ lValues[nPosition] >>= aItem.sURL ;
+ ++nPosition;
+ lValues[nPosition] >>= aItem.sTitle ;
+ ++nPosition;
+ lValues[nPosition] >>= aItem.sImageIdentifier ;
+ ++nPosition;
+ lValues[nPosition] >>= aItem.sTargetName ;
+ ++nPosition;
+ m_aHelpBookmarksMenu.AppendSetupEntry( aItem );
+ }
+
+/*TODO: Not used in the moment! see Notify() ...
+ // Enable notification mechanism of ouer baseclass.
+ // We need it to get information about changes outside these class on ouer used configuration keys!
+ EnableNotification( lNames );
+*/
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtDynamicMenuOptions_Impl::~SvtDynamicMenuOptions_Impl()
+{
+ // We must save our current values .. if user forget it!
+ if( IsModified() == sal_True )
+ {
+ Commit();
+ }
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtDynamicMenuOptions_Impl::Notify( const Sequence< OUString >& )
+{
+ DBG_ASSERT( sal_False, "SvtDynamicMenuOptions_Impl::Notify()\nNot implemented yet! I don't know how I can handle a dynamical list of unknown properties ...\n" );
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtDynamicMenuOptions_Impl::Commit()
+{
+ DBG_ERROR( "SvtDynamicMenuOptions_Impl::Commit()\nNot implemented yet!\n" );
+ /*
+ // Write all properties!
+ // Delete complete sets first.
+ ClearNodeSet( SETNODE_NEWMENU );
+ ClearNodeSet( SETNODE_WIZARDMENU );
+ ClearNodeSet( SETNODE_HELPBOOKMARKS );
+
+ MenuEntry aItem ;
+ OUString sNode ;
+ Sequence< PropertyValue > lPropertyValues( PROPERTYCOUNT );
+ sal_uInt32 nItem = 0 ;
+
+ // Copy "new" menu entries to save-list!
+ sal_uInt32 nNewCount = m_aNewMenu.size();
+ for( nItem=0; nItem<nNewCount; ++nItem )
+ {
+ aItem = m_aNewMenu[nItem];
+ // Format: "New/1/URL"
+ // "New/1/Title"
+ // ...
+ sNode = SETNODE_NEWMENU + PATHDELIMITER + PATHPREFIX + OUString::valueOf( (sal_Int32)nItem ) + PATHDELIMITER;
+
+ lPropertyValues[OFFSET_URL ].Name = sNode + PROPERTYNAME_URL ;
+ lPropertyValues[OFFSET_TITLE ].Name = sNode + PROPERTYNAME_TITLE ;
+ lPropertyValues[OFFSET_IMAGEIDENTIFIER ].Name = sNode + PROPERTYNAME_IMAGEIDENTIFIER ;
+ lPropertyValues[OFFSET_TARGETNAME ].Name = sNode + PROPERTYNAME_TARGETNAME ;
+
+ lPropertyValues[OFFSET_URL ].Value <<= aItem.sURL ;
+ lPropertyValues[OFFSET_TITLE ].Value <<= aItem.sTitle ;
+ lPropertyValues[OFFSET_IMAGEIDENTIFIER ].Value <<= aItem.sImageIdentifier ;
+ lPropertyValues[OFFSET_TARGETNAME ].Value <<= aItem.sTargetName ;
+
+ SetSetProperties( SETNODE_NEWMENU, lPropertyValues );
+ }
+
+ // Copy "wizard" menu entries to save-list!
+ sal_uInt32 nWizardCount = m_aWizardMenu.size();
+ for( nItem=0; nItem<nWizardCount; ++nItem )
+ {
+ aItem = m_aWizardMenu[nItem];
+ // Format: "Wizard/1/URL"
+ // "Wizard/1/Title"
+ // ...
+ sNode = SETNODE_WIZARDMENU + PATHDELIMITER + PATHPREFIX + OUString::valueOf( (sal_Int32)nItem ) + PATHDELIMITER;
+
+ lPropertyValues[OFFSET_URL ].Name = sNode + PROPERTYNAME_URL ;
+ lPropertyValues[OFFSET_TITLE ].Name = sNode + PROPERTYNAME_TITLE ;
+ lPropertyValues[OFFSET_IMAGEIDENTIFIER ].Name = sNode + PROPERTYNAME_IMAGEIDENTIFIER ;
+ lPropertyValues[OFFSET_TARGETNAME ].Name = sNode + PROPERTYNAME_TARGETNAME ;
+
+ lPropertyValues[OFFSET_URL ].Value <<= aItem.sURL ;
+ lPropertyValues[OFFSET_TITLE ].Value <<= aItem.sTitle ;
+ lPropertyValues[OFFSET_IMAGEIDENTIFIER ].Value <<= aItem.sImageIdentifier ;
+ lPropertyValues[OFFSET_TARGETNAME ].Value <<= aItem.sTargetName ;
+
+ SetSetProperties( SETNODE_WIZARDMENU, lPropertyValues );
+ }
+
+ // Copy help bookmarks entries to save-list!
+ sal_uInt32 nHelpBookmarksCount = m_aHelpBookmarksMenu.size();
+ for( nItem=0; nItem<nHelpBookmarksCount; ++nItem )
+ {
+ aItem = m_aHelpBookmarksMenu[nItem];
+ // Format: "HelpBookmarks/1/URL"
+ // "HelpBookmarks/1/Title"
+ // ...
+ sNode = SETNODE_HELPBOOKMARKS + PATHDELIMITER + PATHPREFIX + OUString::valueOf( (sal_Int32)nItem ) + PATHDELIMITER;
+
+ lPropertyValues[OFFSET_URL ].Name = sNode + PROPERTYNAME_URL ;
+ lPropertyValues[OFFSET_TITLE ].Name = sNode + PROPERTYNAME_TITLE ;
+ lPropertyValues[OFFSET_IMAGEIDENTIFIER ].Name = sNode + PROPERTYNAME_IMAGEIDENTIFIER ;
+ lPropertyValues[OFFSET_TARGETNAME ].Name = sNode + PROPERTYNAME_TARGETNAME ;
+
+ lPropertyValues[OFFSET_URL ].Value <<= aItem.sURL ;
+ lPropertyValues[OFFSET_TITLE ].Value <<= aItem.sTitle ;
+ lPropertyValues[OFFSET_IMAGEIDENTIFIER ].Value <<= aItem.sImageIdentifier ;
+ lPropertyValues[OFFSET_TARGETNAME ].Value <<= aItem.sTargetName ;
+
+ SetSetProperties( SETNODE_HELPBOOKMARKS, lPropertyValues );
+ }
+ */
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Sequence< OUString > SvtDynamicMenuOptions_Impl::impl_GetPropertyNames( sal_uInt32& nNewCount, sal_uInt32& nWizardCount, sal_uInt32& nHelpBookmarksCount )
+{
+ // First get ALL names of current existing list items in configuration!
+ Sequence< OUString > lNewItems = GetNodeNames( SETNODE_NEWMENU );
+ Sequence< OUString > lWizardItems = GetNodeNames( SETNODE_WIZARDMENU );
+ Sequence< OUString > lHelpBookmarksItems = GetNodeNames( SETNODE_HELPBOOKMARKS );
+
+ // Get information about list counts ...
+ nNewCount = lNewItems.getLength ();
+ nWizardCount = lWizardItems.getLength ();
+ nHelpBookmarksCount = lHelpBookmarksItems.getLength();
+
+ // Sort and expand all three list to result list ...
+ Sequence< OUString > lProperties;
+ impl_SortAndExpandPropertyNames( lNewItems , lProperties, SETNODE_NEWMENU );
+ impl_SortAndExpandPropertyNames( lWizardItems , lProperties, SETNODE_WIZARDMENU );
+ impl_SortAndExpandPropertyNames( lHelpBookmarksItems, lProperties, SETNODE_HELPBOOKMARKS );
+
+ // Return result.
+ return lProperties;
+}
+
+//*****************************************************************************************************************
+// private helper
+//*****************************************************************************************************************
+class CountWithPrefixSort
+{
+ public:
+ int operator() ( const OUString& s1 ,
+ const OUString& s2 ) const
+ {
+ // Get order numbers from entry name without prefix.
+ // e.g. "m10" => 10
+ // "m5" => 5
+ sal_Int32 n1 = s1.copy( 1, s1.getLength()-1 ).toInt32();
+ sal_Int32 n2 = s2.copy( 1, s2.getLength()-1 ).toInt32();
+ // MUST be in [0,1] ... because it's a difference between
+ // insert-positions of given entries in sorted list!
+ return( n1<n2 );
+ }
+};
+
+class SelectByPrefix
+{
+ public:
+ bool operator() ( const OUString& s ) const
+ {
+ // Prefer setup written entries by check first letter of given string. It must be a "s".
+ return( s.indexOf( PATHPREFIX_SETUP ) == 0 );
+ }
+};
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+void SvtDynamicMenuOptions_Impl::impl_SortAndExpandPropertyNames( const Sequence< OUString >& lSource ,
+ Sequence< OUString >& lDestination ,
+ const OUString& sSetNode )
+{
+ OUString sFixPath ;
+ vector< OUString > lTemp ;
+ sal_Int32 nSourceCount = lSource.getLength() ;
+ sal_Int32 nDestinationStep = lDestination.getLength() ; // start on end of current list ...!
+
+ lDestination.realloc( (nSourceCount*PROPERTYCOUNT)+nDestinationStep ); // get enough memory for copy operations after nDestination ...
+
+ // Copy all items to temp. vector to use fast sort operations :-)
+ for( sal_Int32 nSourceStep=0; nSourceStep<nSourceCount; ++nSourceStep )
+ lTemp.push_back( lSource[nSourceStep] );
+
+ // Sort all entries by number ...
+ stable_sort( lTemp.begin(), lTemp.end(), CountWithPrefixSort() );
+ // and split into setup & user written entries!
+ stable_partition( lTemp.begin(), lTemp.end(), SelectByPrefix() );
+
+ // Copy sorted entries to destination and expand every item with
+ // 4 supported sub properties.
+ for( vector< OUString >::const_iterator pItem =lTemp.begin() ;
+ pItem!=lTemp.end() ;
+ ++pItem )
+ {
+ sFixPath = sSetNode ;
+ sFixPath += PATHDELIMITER ;
+ sFixPath += *pItem ;
+ sFixPath += PATHDELIMITER ;
+
+ lDestination[nDestinationStep] = sFixPath ;
+ lDestination[nDestinationStep] += PROPERTYNAME_URL ;
+ ++nDestinationStep;
+ lDestination[nDestinationStep] = sFixPath ;
+ lDestination[nDestinationStep] += PROPERTYNAME_TITLE ;
+ ++nDestinationStep;
+ lDestination[nDestinationStep] = sFixPath ;
+ lDestination[nDestinationStep] += PROPERTYNAME_IMAGEIDENTIFIER ;
+ ++nDestinationStep;
+ lDestination[nDestinationStep] = sFixPath ;
+ lDestination[nDestinationStep] += PROPERTYNAME_TARGETNAME ;
+ ++nDestinationStep;
+ }
+}
+
+//*****************************************************************************************************************
+// initialize static member
+// DON'T DO IT IN YOUR HEADER!
+// see definition for further informations
+//*****************************************************************************************************************
+SvtDynamicMenuOptions_Impl* SvtDynamicMenuOptions::m_pDataContainer = NULL ;
+sal_Int32 SvtDynamicMenuOptions::m_nRefCount = 0 ;
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtDynamicMenuOptions::SvtDynamicMenuOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already exist!
+ if( m_pDataContainer == NULL )
+ {
+ m_pDataContainer = new SvtDynamicMenuOptions_Impl;
+ ItemHolder1::holdConfigItem(E_DYNAMICMENUOPTIONS);
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtDynamicMenuOptions::~SvtDynamicMenuOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Decrease ouer refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pDataContainer;
+ m_pDataContainer = NULL;
+ }
+}
+
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Mutex& SvtDynamicMenuOptions::GetOwnStaticMutex()
+{
+ // Initialize static mutex only for one time!
+ static Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_extendedsecurityoptions.cxx b/binfilter/bf_svtools/source/config/svt_extendedsecurityoptions.cxx
new file mode 100644
index 000000000000..d0f40f0f26c0
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_extendedsecurityoptions.cxx
@@ -0,0 +1,430 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+//_________________________________________________________________________________________________________________
+// includes
+//_________________________________________________________________________________________________________________
+
+#include <bf_svtools/extendedsecurityoptions.hxx>
+
+#include <unotools/configmgr.hxx>
+
+#include <unotools/configitem.hxx>
+
+#include <tools/debug.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <tools/urlobj.hxx>
+
+#include <tools/wldcrd.hxx>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <bf_svtools/pathoptions.hxx>
+
+#include <hash_map>
+
+#include <rtl/logfile.hxx>
+#include "itemholder1.hxx"
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+using namespace ::utl ;
+using namespace ::rtl ;
+using namespace ::osl ;
+using namespace ::com::sun::star::uno ;
+
+namespace binfilter
+{
+
+//_________________________________________________________________________________________________________________
+// const
+//_________________________________________________________________________________________________________________
+
+#define ROOTNODE_SECURITY OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Security"))
+
+#define SECURE_EXTENSIONS_SET OUString(RTL_CONSTASCII_USTRINGPARAM("SecureExtensions"))
+#define EXTENSION_PROPNAME OUString(RTL_CONSTASCII_USTRINGPARAM("/Extension"))
+
+#define PROPERTYNAME_HYPERLINKS_OPEN OUString(RTL_CONSTASCII_USTRINGPARAM("Hyperlinks/Open"))
+
+#define PROPERTYHANDLE_HYPERLINKS_OPEN 0
+
+#define PROPERTYCOUNT 1
+
+//_________________________________________________________________________________________________________________
+// private declarations!
+//_________________________________________________________________________________________________________________
+
+struct OUStringHashCode
+{
+ size_t operator()( const ::rtl::OUString& sString ) const
+ {
+ return sString.hashCode();
+ }
+};
+
+class ExtensionHashMap : public ::std::hash_map< ::rtl::OUString,
+ sal_Int32,
+ OUStringHashCode,
+ ::std::equal_to< ::rtl::OUString > >
+{
+ public:
+ inline void free()
+ {
+ ExtensionHashMap().swap( *this );
+ }
+};
+
+class SvtExtendedSecurityOptions_Impl : public ConfigItem
+{
+ //-------------------------------------------------------------------------------------------------------------
+ // public methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ public:
+
+ //---------------------------------------------------------------------------------------------------------
+ // constructor / destructor
+ //---------------------------------------------------------------------------------------------------------
+
+ SvtExtendedSecurityOptions_Impl();
+ ~SvtExtendedSecurityOptions_Impl();
+
+ //---------------------------------------------------------------------------------------------------------
+ // overloaded methods of baseclass
+ //---------------------------------------------------------------------------------------------------------
+
+ /*-****************************************************************************************************//**
+ @short called for notify of configmanager
+ @descr These method is called from the ConfigManager before application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. You must update your
+ internal values.
+
+ @seealso baseclass ConfigItem
+
+ @param "seqPropertyNames" is the list of properties which should be updated.
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Notify( const Sequence< OUString >& seqPropertyNames );
+
+ /*-****************************************************************************************************//**
+ @short write changes to configuration
+ @descr These method writes the changed values into the sub tree
+ and should always called in our destructor to guarantee consistency of config data.
+
+ @seealso baseclass ConfigItem
+
+ @param -
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Commit();
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ /*-****************************************************************************************************//**
+ @short return list of key names of ouer configuration management which represent oue module tree
+ @descr These methods return a static const list of key names. We need it to get needed values from our
+ configuration management.
+
+ @seealso -
+
+ @param -
+ @return A list of needed configuration keys is returned.
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ static Sequence< OUString > GetPropertyNames();
+
+ /*-****************************************************************************************************//**
+ @short Fills the hash map with all extensions known to be secure
+ @descr These methods fills the given hash map object with all extensions known to be secure.
+
+ @seealso -
+
+ @param aHashMap
+ A hash map to be filled with secure extension strings.
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+ void FillExtensionHashMap( ExtensionHashMap& aHashMap );
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private member
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+ OUString m_aSecureExtensionsSetName;
+ OUString m_aExtensionPropName;
+
+ SvtExtendedSecurityOptions::OpenHyperlinkMode m_eOpenHyperlinkMode;
+ sal_Bool m_bROOpenHyperlinkMode;
+ ExtensionHashMap m_aExtensionHashMap;
+};
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtExtendedSecurityOptions_Impl::SvtExtendedSecurityOptions_Impl()
+ // Init baseclasses first
+ : ConfigItem ( ROOTNODE_SECURITY ),
+ m_aSecureExtensionsSetName( SECURE_EXTENSIONS_SET ),
+ m_aExtensionPropName( EXTENSION_PROPNAME ),
+ m_bROOpenHyperlinkMode(sal_False)
+ // Init member then.
+{
+ // Fill the extension hash map with all secure extension strings
+ FillExtensionHashMap( m_aExtensionHashMap );
+
+ Sequence< OUString > seqNames = GetPropertyNames();
+ Sequence< Any > seqValues = GetProperties( seqNames );
+ Sequence< sal_Bool > seqRO = GetReadOnlyStates ( seqNames );
+
+ sal_Int32 nPropertyCount = seqValues.getLength();
+ for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ // Safe impossible cases.
+ // Check any for valid value.
+ DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtExtendedSecurityOptions_Impl::SvtExtendedSecurityOptions_Impl()\nInvalid property value detected!\n" );
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_HYPERLINKS_OPEN:
+ {
+ DBG_ASSERT( ( seqValues[nProperty].getValueTypeClass() == TypeClass_LONG ), "SvtExtendedSecurityOptions_Impl::SvtExtendedSecurityOptions_Impl()\nWho has changed the value type of 'Hyperlink/Open'?" );
+
+ sal_Int32 nMode = SvtExtendedSecurityOptions::OPEN_WITHSECURITYCHECK;
+ if ( seqValues[nProperty] >>= nMode )
+ m_eOpenHyperlinkMode = (SvtExtendedSecurityOptions::OpenHyperlinkMode)nMode;
+ else
+ {
+ DBG_ERROR("Wrong type for Open mode!");
+ }
+ m_bROOpenHyperlinkMode = seqRO[nProperty];
+ }
+ break;
+ }
+ }
+
+ // Enable notification mechanism of our baseclass.
+ // We need it to get information about changes outside these class on ouer used configuration keys!
+ Sequence< OUString > seqNotifyNames( 1 );
+ seqNotifyNames[0] = m_aSecureExtensionsSetName;
+ EnableNotification( seqNotifyNames );
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtExtendedSecurityOptions_Impl::~SvtExtendedSecurityOptions_Impl()
+{
+ // We must save our current values .. if user forget it!
+ if( IsModified() == sal_True )
+ {
+ Commit();
+ }
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtExtendedSecurityOptions_Impl::Notify( const Sequence< OUString >& )
+{
+ // Not implemented
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtExtendedSecurityOptions_Impl::Commit()
+{
+ // Get names of supported properties, create a list for values and copy current values to it.
+ Sequence< OUString > seqNames = GetPropertyNames ();
+ sal_Int32 nCount = seqNames.getLength();
+ Sequence< Any > seqValues ( nCount );
+ for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
+ {
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_HYPERLINKS_OPEN: {
+ seqValues[nProperty] <<= (sal_Int32)m_eOpenHyperlinkMode;
+ }
+ break;
+ }
+ }
+
+ // Set properties in configuration.
+ PutProperties( seqNames, seqValues );
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+void SvtExtendedSecurityOptions_Impl::FillExtensionHashMap( ExtensionHashMap& aHashMap )
+{
+ // Get sequence with secure extensions from configuration
+ Sequence< OUString > seqNodes = GetNodeNames( m_aSecureExtensionsSetName );
+
+ OUString aValue;
+ Sequence< Any > aValues;
+ Sequence< OUString > aPropSeq( 1 );
+ for ( int i = 0; i < seqNodes.getLength(); i++ )
+ {
+ // Create access name for property
+ OUStringBuffer aExtEntryProp( m_aSecureExtensionsSetName );
+ aExtEntryProp.appendAscii( "/" );
+ aExtEntryProp.append( seqNodes[i] );
+ aExtEntryProp.append( m_aExtensionPropName );
+
+ aPropSeq[0] = aExtEntryProp.makeStringAndClear();
+ aValues = GetProperties( aPropSeq );
+ if ( aValues.getLength() == 1 )
+ {
+ // Don't use value if sequence has not the correct length
+ if ( aValues[0] >>= aValue )
+ // Add extension into secure extensions hash map
+ aHashMap.insert( ExtensionHashMap::value_type( aValue.toAsciiLowerCase(), 1 ) );
+ else
+ {
+ DBG_ERRORFILE( "SvtExtendedSecurityOptions_Impl::FillExtensionHashMap(): not string value?" );
+ }
+ }
+ }
+}
+
+//*****************************************************************************************************************
+// private method (currently not used)
+//*****************************************************************************************************************
+Sequence< OUString > SvtExtendedSecurityOptions_Impl::GetPropertyNames()
+{
+ // Build static list of configuration key names.
+ static const OUString pProperties[] =
+ {
+ PROPERTYNAME_HYPERLINKS_OPEN
+ };
+ // Initialize return sequence with these list ...
+ static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
+ // ... and return it.
+ return seqPropertyNames;
+}
+
+//*****************************************************************************************************************
+// initialize static member
+// DON'T DO IT IN YOUR HEADER!
+// see definition for further informations
+//*****************************************************************************************************************
+SvtExtendedSecurityOptions_Impl* SvtExtendedSecurityOptions::m_pDataContainer = NULL ;
+sal_Int32 SvtExtendedSecurityOptions::m_nRefCount = 0 ;
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtExtendedSecurityOptions::SvtExtendedSecurityOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetInitMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already exist!
+ if( m_pDataContainer == NULL )
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "bf_svtools ( ??? ) ::SvtExtendedSecurityOptions_Impl::ctor()");
+ m_pDataContainer = new SvtExtendedSecurityOptions_Impl;
+
+ ItemHolder1::holdConfigItem(E_EXTENDEDSECURITYOPTIONS);
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtExtendedSecurityOptions::~SvtExtendedSecurityOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetInitMutex() );
+ // Decrease ouer refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pDataContainer;
+ m_pDataContainer = NULL;
+ }
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Mutex& SvtExtendedSecurityOptions::GetInitMutex()
+{
+ // Initialize static mutex only for one time!
+ static Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_fontoptions.cxx b/binfilter/bf_svtools/source/config/svt_fontoptions.cxx
new file mode 100644
index 000000000000..6a821a0208ba
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_fontoptions.cxx
@@ -0,0 +1,389 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+//_________________________________________________________________________________________________________________
+// includes
+//_________________________________________________________________________________________________________________
+
+#include <bf_svtools/fontoptions.hxx>
+
+#include <unotools/configmgr.hxx>
+
+#include <unotools/configitem.hxx>
+
+#include <tools/debug.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <rtl/logfile.hxx>
+#include "itemholder1.hxx"
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+using namespace ::utl ;
+using namespace ::rtl ;
+using namespace ::osl ;
+using namespace ::com::sun::star::uno ;
+
+namespace binfilter
+{
+
+//_________________________________________________________________________________________________________________
+// const
+//_________________________________________________________________________________________________________________
+
+#define ROOTNODE_FONT OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Font" ))
+
+#define PROPERTYNAME_REPLACEMENTTABLE OUString(RTL_CONSTASCII_USTRINGPARAM("Substitution/Replacement" ))
+#define PROPERTYNAME_FONTHISTORY OUString(RTL_CONSTASCII_USTRINGPARAM("View/History" ))
+#define PROPERTYNAME_FONTWYSIWYG OUString(RTL_CONSTASCII_USTRINGPARAM("View/ShowFontBoxWYSIWYG" ))
+
+#define PROPERTYHANDLE_REPLACEMENTTABLE 0
+#define PROPERTYHANDLE_FONTHISTORY 1
+#define PROPERTYHANDLE_FONTWYSIWYG 2
+
+#define PROPERTYCOUNT 3
+
+//_________________________________________________________________________________________________________________
+// private declarations!
+//_________________________________________________________________________________________________________________
+
+class SvtFontOptions_Impl : public ConfigItem
+{
+ //-------------------------------------------------------------------------------------------------------------
+ // public methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ public:
+
+ //---------------------------------------------------------------------------------------------------------
+ // constructor / destructor
+ //---------------------------------------------------------------------------------------------------------
+
+ SvtFontOptions_Impl();
+ ~SvtFontOptions_Impl();
+
+ //---------------------------------------------------------------------------------------------------------
+ // overloaded methods of baseclass
+ //---------------------------------------------------------------------------------------------------------
+
+ /*-****************************************************************************************************//**
+ @short called for notify of configmanager
+ @descr These method is called from the ConfigManager before application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. You must update your
+ internal values.
+
+ @seealso baseclass ConfigItem
+
+ @param "seqPropertyNames" is the list of properties which should be updated.
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Notify( const Sequence< OUString >& seqPropertyNames );
+
+ /*-****************************************************************************************************//**
+ @short write changes to configuration
+ @descr These method writes the changed values into the sub tree
+ and should always called in our destructor to guarantee consistency of config data.
+
+ @seealso baseclass ConfigItem
+
+ @param -
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Commit();
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ /*-****************************************************************************************************//**
+ @short return list of key names of ouer configuration management which represent oue module tree
+ @descr These methods return a static const list of key names. We need it to get needed values from our
+ configuration management.
+
+ @seealso -
+
+ @param -
+ @return A list of needed configuration keys is returned.
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ static Sequence< OUString > impl_GetPropertyNames();
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private member
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ sal_Bool m_bReplacementTable ;
+ sal_Bool m_bFontHistory ;
+ sal_Bool m_bFontWYSIWYG ;
+};
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtFontOptions_Impl::SvtFontOptions_Impl()
+ // Init baseclasses first
+ : ConfigItem ( ROOTNODE_FONT )
+ // Init member then.
+ , m_bReplacementTable ( sal_False )
+ , m_bFontHistory ( sal_False )
+ , m_bFontWYSIWYG ( sal_False )
+{
+ // Use our static list of configuration keys to get his values.
+ Sequence< OUString > seqNames = impl_GetPropertyNames ( );
+ Sequence< Any > seqValues = GetProperties ( seqNames );
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtFontOptions_Impl::SvtFontOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to ouer internal member.
+ sal_Int32 nPropertyCount = seqValues.getLength();
+ for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ // Safe impossible cases.
+ // Check any for valid value.
+ DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtFontOptions_Impl::SvtFontOptions_Impl()\nInvalid property value detected!\n" );
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_REPLACEMENTTABLE : {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtFontOptions_Impl::SvtFontOptions_Impl()\nWho has changed the value type of \"Office.Common\\Font\\Substitution\\Replacement\"?" );
+ seqValues[nProperty] >>= m_bReplacementTable;
+ }
+ break;
+ case PROPERTYHANDLE_FONTHISTORY : {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtFontOptions_Impl::SvtFontOptions_Impl()\nWho has changed the value type of \"Office.Common\\Font\\View\\History\"?" );
+ seqValues[nProperty] >>= m_bFontHistory;
+ }
+ break;
+ case PROPERTYHANDLE_FONTWYSIWYG : {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtFontOptions_Impl::SvtFontOptions_Impl()\nWho has changed the value type of \"Office.Common\\Font\\View\\ShowFontBoxWYSIWYG\"?" );
+ seqValues[nProperty] >>= m_bFontWYSIWYG;
+ }
+ break;
+ }
+ }
+
+ // Enable notification mechanism of ouer baseclass.
+ // We need it to get information about changes outside these class on ouer used configuration keys!
+ EnableNotification( seqNames );
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtFontOptions_Impl::~SvtFontOptions_Impl()
+{
+ // We must save our current values .. if user forget it!
+ if( IsModified() == sal_True )
+ {
+ Commit();
+ }
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtFontOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames )
+{
+ // Use given list of updated properties to get his values from configuration directly!
+ Sequence< Any > seqValues = GetProperties( seqPropertyNames );
+ // Safe impossible cases.
+ // We need values from ALL notified configuration keys.
+ DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtFontOptions_Impl::Notify()\nI miss some values of configuration keys!\n" );
+ // Step over list of property names and get right value from coreesponding value list to set it on internal members!
+ sal_Int32 nCount = seqPropertyNames.getLength();
+ for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
+ {
+ if( seqPropertyNames[nProperty] == PROPERTYNAME_REPLACEMENTTABLE )
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtFontOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\Font\\Substitution\\Replacement\"?" );
+ seqValues[nProperty] >>= m_bReplacementTable;
+ }
+ else
+ if( seqPropertyNames[nProperty] == PROPERTYNAME_FONTHISTORY )
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtFontOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\Font\\View\\History\"?" );
+ seqValues[nProperty] >>= m_bFontHistory;
+ }
+ else
+ if( seqPropertyNames[nProperty] == PROPERTYNAME_FONTWYSIWYG )
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtFontOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\Font\\View\\ShowFontBoxWYSIWYG\"?" );
+ seqValues[nProperty] >>= m_bFontWYSIWYG;
+ }
+ #if OSL_DEBUG_LEVEL > 1
+ else DBG_ASSERT( sal_False, "SvtFontOptions_Impl::Notify()\nUnkown property detected ... I can't handle these!\n" );
+ #endif
+ }
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtFontOptions_Impl::Commit()
+{
+ // Get names of supported properties, create a list for values and copy current values to it.
+ Sequence< OUString > seqNames = impl_GetPropertyNames();
+ sal_Int32 nCount = seqNames.getLength();
+ Sequence< Any > seqValues ( nCount );
+ for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
+ {
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_REPLACEMENTTABLE : {
+ seqValues[nProperty] <<= m_bReplacementTable;
+ }
+ break;
+ case PROPERTYHANDLE_FONTHISTORY : {
+ seqValues[nProperty] <<= m_bFontHistory;
+ }
+ break;
+ case PROPERTYHANDLE_FONTWYSIWYG : {
+ seqValues[nProperty] <<= m_bFontWYSIWYG;
+ }
+ break;
+ }
+ }
+ // Set properties in configuration.
+ PutProperties( seqNames, seqValues );
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Sequence< OUString > SvtFontOptions_Impl::impl_GetPropertyNames()
+{
+ // Build static list of configuration key names.
+ static const OUString pProperties[] =
+ {
+ PROPERTYNAME_REPLACEMENTTABLE ,
+ PROPERTYNAME_FONTHISTORY ,
+ PROPERTYNAME_FONTWYSIWYG ,
+ };
+ // Initialize return sequence with these list ...
+ static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
+ // ... and return it.
+ return seqPropertyNames;
+}
+
+//*****************************************************************************************************************
+// initialize static member
+// DON'T DO IT IN YOUR HEADER!
+// see definition for further informations
+//*****************************************************************************************************************
+SvtFontOptions_Impl* SvtFontOptions::m_pDataContainer = NULL ;
+sal_Int32 SvtFontOptions::m_nRefCount = 0 ;
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtFontOptions::SvtFontOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( impl_GetOwnStaticMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already exist!
+ if( m_pDataContainer == NULL )
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtFontOptions_Impl::ctor()");
+ m_pDataContainer = new SvtFontOptions_Impl;
+
+ ItemHolder1::holdConfigItem(E_FONTOPTIONS);
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtFontOptions::~SvtFontOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( impl_GetOwnStaticMutex() );
+ // Decrease ouer refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pDataContainer;
+ m_pDataContainer = NULL;
+ }
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Mutex& SvtFontOptions::impl_GetOwnStaticMutex()
+{
+ // Initialize static mutex only for one time!
+ static Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_helpopt.cxx b/binfilter/bf_svtools/source/config/svt_helpopt.cxx
new file mode 100644
index 000000000000..c52aec6e771d
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_helpopt.cxx
@@ -0,0 +1,576 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/helpopt.hxx>
+
+#include <unotools/configmgr.hxx>
+#include <unotools/configitem.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <vcl/help.hxx>
+
+#include <osl/mutex.hxx>
+#include <comphelper/stl_types.hxx>
+
+#include <rtl/logfile.hxx>
+#include "itemholder2.hxx"
+
+using namespace utl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star;
+
+namespace binfilter
+{
+
+static SvtHelpOptions_Impl* pOptions = NULL;
+static sal_Int32 nRefCount = 0;
+
+#define EXTENDEDHELP 0
+#define HELPTIPS 1
+#define AGENT_ENABLED 2
+#define AGENT_TIMEOUT 3
+#define AGENT_RETRYLIMIT 4
+#define LOCALE 5
+#define SYSTEM 6
+#define STYLESHEET 7
+
+class SvtHelpOptions_Impl : public utl::ConfigItem
+{
+ IdList* pList;
+ sal_Int32 nHelpAgentTimeoutPeriod;
+ sal_Int32 nHelpAgentRetryLimit;
+ sal_Bool bExtendedHelp;
+ sal_Bool bHelpTips;
+ sal_Bool bHelpAgentEnabled;
+ sal_Bool bWelcomeScreen;
+ String aLocale;
+ String aSystem;
+ String sHelpStyleSheet;
+
+ DECLARE_STL_USTRINGACCESS_MAP( sal_Int32, MapString2Int );
+ MapString2Int aURLIgnoreCounters;
+ ::osl::Mutex aIgnoreCounterSafety;
+
+ Sequence< OUString > GetPropertyNames();
+
+public:
+ SvtHelpOptions_Impl();
+
+ virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
+ void Load( const ::com::sun::star::uno::Sequence< ::rtl::OUString>& aPropertyNames);
+ virtual void Commit();
+
+ void SetExtendedHelp( sal_Bool b ) { bExtendedHelp= b; SetModified(); }
+ sal_Bool IsExtendedHelp() const { return bExtendedHelp; }
+ void SetHelpTips( sal_Bool b ) { bHelpTips = b; SetModified(); }
+ sal_Bool IsHelpTips() const { return bHelpTips; }
+
+ void SetHelpAgentEnabled( sal_Bool b ) { bHelpAgentEnabled = b; SetModified(); }
+ sal_Bool IsHelpAgentEnabled() const { return bHelpAgentEnabled; }
+ void SetHelpAgentTimeoutPeriod( sal_Int32 _nSeconds ) { nHelpAgentTimeoutPeriod = _nSeconds; SetModified(); }
+ sal_Int32 GetHelpAgentTimeoutPeriod( ) const { return nHelpAgentTimeoutPeriod; }
+ void SetHelpAgentRetryLimit( sal_Int32 _nTrials ) { nHelpAgentRetryLimit = _nTrials; SetModified(); }
+ sal_Int32 GetHelpAgentRetryLimit( ) const { return nHelpAgentRetryLimit; }
+
+ void SetWelcomeScreen( sal_Bool b ) { bWelcomeScreen = b; SetModified(); }
+ sal_Bool IsWelcomeScreen() const { return bWelcomeScreen; }
+ IdList* GetPIStarterList() { return pList; }
+ void AddToPIStarterList( sal_Int32 nId );
+ void RemoveFromPIStarterList( sal_Int32 nId );
+ String GetLocale() const { return aLocale; }
+ String GetSystem() const { return aSystem; }
+
+ const String& GetHelpStyleSheet()const{return sHelpStyleSheet;}
+ void SetHelpStyleSheet(const String& rStyleSheet){sHelpStyleSheet = rStyleSheet; SetModified();}
+
+ static ::osl::Mutex & getInitMutex();
+
+protected:
+ void implLoadURLCounters();
+ void implSaveURLCounters();
+ // to be called with aIgnoreCounterSafety locked
+ void implGetURLCounters( Sequence< ::rtl::OUString >& _rNodeNames, Sequence< Any >& _rURLs, Sequence< Any >& _rCounter );
+};
+
+Sequence< OUString > SvtHelpOptions_Impl::GetPropertyNames()
+{
+ static const char* aPropNames[] =
+ {
+ "ExtendedTip",
+ "Tip",
+ "HelpAgent/Enabled",
+ "HelpAgent/Timeout",
+ "HelpAgent/RetryLimit",
+ "Locale",
+ "System",
+ "HelpStyleSheet",
+// "HowTo/Show"
+ };
+
+ const int nCount = sizeof( aPropNames ) / sizeof( const char* );
+ Sequence< OUString > aNames( nCount );
+ OUString* pNames = aNames.getArray();
+ for ( int i = 0; i < nCount; i++ )
+ pNames[i] = OUString::createFromAscii( aPropNames[i] );
+
+ return aNames;
+}
+
+::osl::Mutex & SvtHelpOptions_Impl::getInitMutex()
+{
+ static ::osl::Mutex *pMutex = 0;
+
+ if( ! pMutex )
+ {
+ ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
+ if( ! pMutex )
+ {
+ static ::osl::Mutex mutex;
+ pMutex = &mutex;
+ }
+ }
+ return *pMutex;
+}
+
+
+// -----------------------------------------------------------------------
+
+SvtHelpOptions_Impl::SvtHelpOptions_Impl()
+ : ConfigItem( OUString::createFromAscii("Office.Common/Help") )
+ , pList( 0 )
+ , bExtendedHelp( sal_False )
+ , bHelpTips( sal_True )
+ , bHelpAgentEnabled( sal_False )
+ , bWelcomeScreen( sal_False )
+{
+ Sequence< OUString > aNames = GetPropertyNames();
+ Load( aNames );
+ EnableNotification( aNames );
+ implLoadURLCounters();
+}
+
+// -----------------------------------------------------------------------
+static int lcl_MapPropertyName( const ::rtl::OUString rCompare,
+ const uno::Sequence< ::rtl::OUString>& aInternalPropertyNames)
+{
+ for(int nProp = 0; nProp < aInternalPropertyNames.getLength(); ++nProp)
+ {
+ if( aInternalPropertyNames[nProp] == rCompare )
+ return nProp;
+ }
+ return -1;
+}
+
+void SvtHelpOptions_Impl::Load(const uno::Sequence< ::rtl::OUString>& rPropertyNames)
+{
+ const uno::Sequence< ::rtl::OUString> aInternalPropertyNames( GetPropertyNames());
+ Sequence< Any > aValues = GetProperties( rPropertyNames );
+ const Any* pValues = aValues.getConstArray();
+ DBG_ASSERT( aValues.getLength() == rPropertyNames.getLength(), "GetProperties failed" );
+ if ( aValues.getLength() == rPropertyNames.getLength() )
+ {
+ for ( int nProp = 0; nProp < rPropertyNames.getLength(); nProp++ )
+ {
+ DBG_ASSERT( pValues[nProp].hasValue(), "property value missing" );
+ if ( pValues[nProp].hasValue() )
+ {
+ sal_Bool bTmp = sal_Bool();
+ ::rtl::OUString aTmpStr;
+ sal_Int32 nTmpInt = 0;
+ if ( pValues[nProp] >>= bTmp )
+ {
+ switch ( lcl_MapPropertyName(rPropertyNames[nProp], aInternalPropertyNames) )
+ {
+ case EXTENDEDHELP :
+ bExtendedHelp = bTmp;
+ break;
+ case HELPTIPS :
+ bHelpTips = bTmp;
+ break;
+ case AGENT_ENABLED :
+ bHelpAgentEnabled = bTmp;
+ break;
+ default:
+ DBG_ERRORFILE( "Wrong Member!" );
+ break;
+ }
+ }
+ else if ( pValues[nProp] >>= aTmpStr )
+ {
+ switch ( nProp )
+ {
+ case LOCALE:
+ aLocale = aTmpStr;
+ break;
+
+ case SYSTEM:
+ aSystem = aTmpStr;
+ break;
+ case STYLESHEET :
+ sHelpStyleSheet = aTmpStr;
+ break;
+ default:
+ DBG_ERRORFILE( "Wrong Member!" );
+ break;
+ }
+ }
+ else if ( pValues[nProp] >>= nTmpInt )
+ {
+ switch ( nProp )
+ {
+ case AGENT_TIMEOUT:
+ nHelpAgentTimeoutPeriod = nTmpInt;
+ break;
+
+ case AGENT_RETRYLIMIT:
+ nHelpAgentRetryLimit = nTmpInt;
+ break;
+
+ default:
+ DBG_ERRORFILE( "Wrong Member!" );
+ break;
+ }
+ }
+ else
+ {
+ DBG_ERRORFILE( "Wrong Type!" );
+ }
+ }
+ }
+ if ( IsHelpTips() != Help::IsQuickHelpEnabled() )
+ IsHelpTips() ? Help::EnableQuickHelp() : Help::DisableQuickHelp();
+ if ( IsExtendedHelp() != Help::IsBalloonHelpEnabled() )
+ IsExtendedHelp() ? Help::EnableBalloonHelp() : Help::DisableBalloonHelp();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvtHelpOptions_Impl::implGetURLCounters( Sequence< ::rtl::OUString >& _rNodeNames, Sequence< Any >& _rURLs, Sequence< Any >& _rCounters )
+{
+ // the ignore counters for the help agent URLs
+ const ::rtl::OUString sIgnoreListNodePath = ::rtl::OUString::createFromAscii("HelpAgent/IgnoreList");
+ const ::rtl::OUString sPathSeparator = ::rtl::OUString::createFromAscii("/");
+ const ::rtl::OUString sURLLocalPath = ::rtl::OUString::createFromAscii("/Name");
+ const ::rtl::OUString sCounterLocalPath = ::rtl::OUString::createFromAscii("/Counter");
+
+ // get the names of all the nodes containing ignore counters
+ // collect the node names we have to ask
+ // first get the node names of all children of HelpAgent/IgnoreList
+ _rNodeNames = GetNodeNames(sIgnoreListNodePath);
+ const ::rtl::OUString* pIgnoredURLsNodes = _rNodeNames.getConstArray();
+ const ::rtl::OUString* pIgnoredURLsNodesEnd = pIgnoredURLsNodes + _rNodeNames.getLength();
+
+ // then assemble the two lists (of node paths) for the URLs and the counters
+ Sequence< ::rtl::OUString > aIgnoredURLs(_rNodeNames.getLength());
+ Sequence< ::rtl::OUString > aIgnoredURLsCounter(_rNodeNames.getLength());
+ ::rtl::OUString* pIgnoredURLs = aIgnoredURLs.getArray();
+ ::rtl::OUString* pIgnoredURLsCounter = aIgnoredURLsCounter.getArray();
+ for (;pIgnoredURLsNodes != pIgnoredURLsNodesEnd; ++pIgnoredURLsNodes, ++pIgnoredURLs, ++pIgnoredURLsCounter)
+ {
+ ::rtl::OUString sLocalURLAccess = sIgnoreListNodePath;
+ sLocalURLAccess += sPathSeparator;
+ sLocalURLAccess += *pIgnoredURLsNodes;
+
+ // the path to the URL of this specific entry
+ *pIgnoredURLs = sLocalURLAccess;
+ *pIgnoredURLs += sURLLocalPath;
+
+ // the path of the counter for that URL
+ *pIgnoredURLsCounter = sLocalURLAccess;
+ *pIgnoredURLsCounter += sCounterLocalPath;
+ }
+
+ // now collect the values
+ _rURLs = GetProperties(aIgnoredURLs);
+ _rCounters = GetProperties(aIgnoredURLsCounter);
+
+ sal_Int32 nURLs = _rURLs.getLength();
+ sal_Int32 nCounters = _rCounters.getLength();
+ DBG_ASSERT(nURLs == nCounters, "SvtHelpOptions_Impl::implGetURLCounters: inconsistence while retrieving the visited URLs!");
+
+ // normalize in case something went wrong
+ sal_Int32 nKnownURLs = nURLs < nCounters ? nURLs : nCounters;
+ if (nURLs < nCounters)
+ {
+ _rCounters.realloc(nKnownURLs);
+ _rNodeNames.realloc(nKnownURLs);
+ }
+ else if (nURLs > nCounters)
+ {
+ _rURLs.realloc(nKnownURLs);
+ _rNodeNames.realloc(nKnownURLs);
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvtHelpOptions_Impl::implSaveURLCounters()
+{
+ ::osl::MutexGuard aGuard(aIgnoreCounterSafety);
+
+ const ::rtl::OUString sIgnoreListNodePath = ::rtl::OUString::createFromAscii("HelpAgent/IgnoreList");
+ const ::rtl::OUString sPathSeparator = ::rtl::OUString::createFromAscii("/");
+ const ::rtl::OUString sURLLocalPath = ::rtl::OUString::createFromAscii("/Name");
+ const ::rtl::OUString sCounterLocalPath = ::rtl::OUString::createFromAscii("/Counter");
+
+ // get the current URL/counter pairs (as they're persistent at the moment)
+ Sequence< ::rtl::OUString > aNodeNames;
+ Sequence< Any > aURLs;
+ Sequence< Any > aCounters;
+
+ implGetURLCounters(aNodeNames, aURLs, aCounters);
+ sal_Int32 nKnownURLs = aURLs.getLength();
+
+ const ::rtl::OUString* pNodeNames = aNodeNames.getConstArray();
+ const Any* pURLs = aURLs.getConstArray();
+ const Any* pCounters = aCounters.getConstArray();
+
+ // check which of them must be deleted/modified
+ Sequence< ::rtl::OUString > aDeleteFromConfig(nKnownURLs); // names of nodes to be deleted
+ ::rtl::OUString* pDeleteFromConfig = aDeleteFromConfig.getArray();
+ ::std::set< ::rtl::OUString > aAlreadyPresent; // URLs currently persistent
+
+ // for modifying already existent nodes
+ Sequence< ::rtl::OUString > aNewCounterNodePaths(nKnownURLs);
+ Sequence< Any > aNewCounterValues(nKnownURLs);
+ ::rtl::OUString* pNewCounterNodePaths = aNewCounterNodePaths.getArray();
+ Any* pNewCounterValues = aNewCounterValues.getArray();
+
+ // temporaries needed inside the loop
+ ::rtl::OUString sCurrentURL, sCurrentURLNodeName;
+
+ for (sal_Int32 i=0; i<nKnownURLs; ++i, ++pNodeNames, ++pURLs, ++pCounters)
+ {
+ if (!((*pURLs) >>= sCurrentURL))
+ continue;
+
+ ConstMapString2IntIterator aThisURLNewCounter = aURLIgnoreCounters.find(sCurrentURL);
+ if (aURLIgnoreCounters.end() == aThisURLNewCounter)
+ { // we do not know anything about this URL anymore.
+ // -> have to removed it from the configuration later on
+ *pDeleteFromConfig = *pNodeNames;
+ ++pDeleteFromConfig;
+ }
+ else
+ { // we know this URL
+ sCurrentURLNodeName = sIgnoreListNodePath;
+ sCurrentURLNodeName += sPathSeparator;
+ sCurrentURLNodeName += *pNodeNames;
+
+ // -> remember this (so we don't need to add a new node for this URL later on)
+ aAlreadyPresent.insert(sCurrentURL);
+
+ sal_Int32 nThisURLPersistentCounter = 0;
+ (*pCounters) >>= nThisURLPersistentCounter;
+
+ if (aThisURLNewCounter->second != nThisURLPersistentCounter)
+ { // the counter changed
+ // -> remember the path and the new counter for the adjustment below
+ *pNewCounterNodePaths = sCurrentURLNodeName;
+ *pNewCounterNodePaths += sCounterLocalPath;
+ ++pNewCounterNodePaths;
+
+ (*pNewCounterValues) <<= aThisURLNewCounter->second;
+ ++pNewCounterValues;
+ }
+ }
+ }
+
+ // delete the nodes which are flagged so ...
+ aDeleteFromConfig.realloc(pDeleteFromConfig - aDeleteFromConfig.getArray());
+ if (0 != aDeleteFromConfig.getLength())
+ {
+ ClearNodeElements(sIgnoreListNodePath, aDeleteFromConfig);
+ }
+
+ // modify the nodes which need to be
+ aNewCounterNodePaths.realloc(pNewCounterNodePaths - aNewCounterNodePaths.getArray());
+ aNewCounterValues.realloc(pNewCounterValues - aNewCounterValues.getArray());
+ if (0 != aNewCounterNodePaths.getLength())
+ {
+ PutProperties(aNewCounterNodePaths, aNewCounterValues);
+ }
+
+ // and for the new ones ...
+ ::rtl::OUString sNewNodeName;
+ Sequence< ::rtl::OUString > aNewCounterDataNodeNames(2);
+ Sequence< Any > aNewCounterDataValues(2);
+ const ::rtl::OUString sNodeNameBase = ::rtl::OUString::createFromAscii("URL");
+ for ( ConstMapString2IntIterator aCollectNew = aURLIgnoreCounters.begin();
+ aCollectNew != aURLIgnoreCounters.end();
+ ++aCollectNew
+ )
+ {
+ if (aAlreadyPresent.end() == aAlreadyPresent.find(aCollectNew->first))
+ { // this URL is not persistent, yet
+ // -> add a new node
+ sNewNodeName = sNodeNameBase;
+ if (!getUniqueSetElementName(sIgnoreListNodePath, sNewNodeName))
+ {
+ DBG_ERRORFILE( "SvtHelpOptions_Impl::implSaveURLCounters: could not get a free name!" );
+ continue;
+ }
+ AddNode(sIgnoreListNodePath, sNewNodeName);
+
+ // and set the URL/counter pair
+ aNewCounterDataNodeNames[0] = sIgnoreListNodePath;
+ aNewCounterDataNodeNames[0] += sPathSeparator;
+ aNewCounterDataNodeNames[0] += sNewNodeName;
+ aNewCounterDataNodeNames[0] += sURLLocalPath;
+ aNewCounterDataValues[0] <<= aCollectNew->first;
+
+ aNewCounterDataNodeNames[1] = sIgnoreListNodePath;
+ aNewCounterDataNodeNames[1] += sPathSeparator;
+ aNewCounterDataNodeNames[1] += sNewNodeName;
+ aNewCounterDataNodeNames[1] += sCounterLocalPath;
+ aNewCounterDataValues[1] <<= aCollectNew->second;
+
+ PutProperties(aNewCounterDataNodeNames, aNewCounterDataValues);
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvtHelpOptions_Impl::implLoadURLCounters()
+{
+ ::osl::MutexGuard aGuard(aIgnoreCounterSafety);
+
+ Sequence< ::rtl::OUString > aNodeNames;
+ Sequence< Any > aURLs;
+ Sequence< Any > aCounters;
+
+ implGetURLCounters(aNodeNames, aURLs, aCounters);
+ sal_Int32 nKnownURLs = aURLs.getLength();
+
+ const Any* pURLs = aURLs.getConstArray();
+ const Any* pCounters = aCounters.getConstArray();
+
+ ::rtl::OUString sCurrentURL;
+ sal_Int32 nCurrentCounter;
+ for (sal_Int32 i=0; i<nKnownURLs; ++i, ++pURLs, ++pCounters)
+ {
+ (*pURLs) >>= sCurrentURL;
+ nCurrentCounter = 0;
+ (*pCounters) >>= nCurrentCounter;
+ aURLIgnoreCounters[sCurrentURL] = nCurrentCounter;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvtHelpOptions_Impl::Commit()
+{
+ Sequence< OUString > aNames = GetPropertyNames();
+ Sequence< Any > aValues( aNames.getLength() );
+ Any* pValues = aValues.getArray();
+ for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
+ {
+ switch ( nProp )
+ {
+ case EXTENDEDHELP :
+ pValues[nProp] <<= bExtendedHelp;
+ break;
+
+ case HELPTIPS :
+ pValues[nProp] <<= bHelpTips;
+ break;
+
+ case AGENT_ENABLED :
+ pValues[nProp] <<= bHelpAgentEnabled;
+ break;
+
+ case AGENT_TIMEOUT:
+ pValues[nProp] <<= nHelpAgentTimeoutPeriod;
+ break;
+
+ case AGENT_RETRYLIMIT:
+ pValues[nProp] <<= nHelpAgentRetryLimit;
+ break;
+
+ case LOCALE:
+ pValues[nProp] <<= ::rtl::OUString(aLocale);
+ break;
+
+ case SYSTEM:
+ pValues[nProp] <<= ::rtl::OUString(aSystem);
+ break;
+ case STYLESHEET :
+ pValues[nProp] <<= ::rtl::OUString(sHelpStyleSheet);
+ break;
+
+ }
+ }
+
+ PutProperties( aNames, aValues );
+
+ implSaveURLCounters();
+}
+
+// -----------------------------------------------------------------------
+
+void SvtHelpOptions_Impl::Notify( const Sequence<rtl::OUString>& aPropertyNames )
+{
+ Load( aPropertyNames );
+}
+
+SvtHelpOptions::SvtHelpOptions()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( SvtHelpOptions_Impl::getInitMutex() );
+ ++nRefCount;
+ if ( !pOptions )
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtHelpOptions_Impl::ctor()");
+ pOptions = new SvtHelpOptions_Impl;
+
+ ItemHolder2::holdConfigItem(E_HELPOPTIONS);
+ }
+ pImp = pOptions;
+}
+
+// -----------------------------------------------------------------------
+
+SvtHelpOptions::~SvtHelpOptions()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( SvtHelpOptions_Impl::getInitMutex() );
+ if ( !--nRefCount )
+ {
+ if ( pOptions->IsModified() )
+ pOptions->Commit();
+ DELETEZ( pOptions );
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_historyoptions.cxx b/binfilter/bf_svtools/source/config/svt_historyoptions.cxx
new file mode 100644
index 000000000000..743fbc497f7f
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_historyoptions.cxx
@@ -0,0 +1,624 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+//_________________________________________________________________________________________________________________
+// includes
+//_________________________________________________________________________________________________________________
+
+#include <bf_svtools/historyoptions.hxx>
+
+#include <unotools/configmgr.hxx>
+
+#include <unotools/configitem.hxx>
+
+#include <tools/debug.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#ifndef __SGI_STL_DEQUE
+#include <deque>
+#endif
+
+#ifndef __SGI_STL_ALGORITHM
+#include <algorithm>
+#endif
+
+#include <rtl/logfile.hxx>
+#include "itemholder1.hxx"
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+using namespace ::std ;
+using namespace ::utl ;
+using namespace ::rtl ;
+using namespace ::osl ;
+using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star::beans ;
+
+namespace binfilter
+{
+
+//_________________________________________________________________________________________________________________
+// const
+//_________________________________________________________________________________________________________________
+
+#define ROOTNODE_HISTORY OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/History/" ))
+
+#define DEFAULT_PICKLISTSIZE 4
+#define DEFAULT_HISTORYSIZE 10
+#define DEFAULT_HELPBOOKMARKSIZE 100
+
+#define PATHDELIMITER OUString(RTL_CONSTASCII_USTRINGPARAM("/" ))
+
+#define PROPERTYNAME_PICKLISTSIZE OUString(RTL_CONSTASCII_USTRINGPARAM("PickListSize" ))
+#define PROPERTYNAME_HISTORYSIZE OUString(RTL_CONSTASCII_USTRINGPARAM("Size" ))
+#define PROPERTYNAME_HELPBOOKMARKSIZE OUString(RTL_CONSTASCII_USTRINGPARAM("HelpBookmarkSize" ))
+
+#define PROPERTYNAME_PICKLIST OUString(RTL_CONSTASCII_USTRINGPARAM("PickList" ))
+#define PROPERTYNAME_HISTORY OUString(RTL_CONSTASCII_USTRINGPARAM("List" ))
+#define PROPERTYNAME_HELPBOOKMARKS OUString(RTL_CONSTASCII_USTRINGPARAM("HelpBookmarks" ))
+
+#define PROPERTYNAME_HISTORYITEM_URL HISTORY_PROPERTYNAME_URL
+#define PROPERTYNAME_HISTORYITEM_FILTER HISTORY_PROPERTYNAME_FILTER
+#define PROPERTYNAME_HISTORYITEM_TITLE HISTORY_PROPERTYNAME_TITLE
+#define PROPERTYNAME_HISTORYITEM_PASSWORD HISTORY_PROPERTYNAME_PASSWORD
+
+#define OFFSET_URL 0
+#define OFFSET_FILTER 1
+#define OFFSET_TITLE 2
+#define OFFSET_PASSWORD 3
+
+#define PROPERTYHANDLE_PICKLISTSIZE 0
+#define PROPERTYHANDLE_HISTORYSIZE 1
+#define PROPERTYHANDLE_HELPBOOKMARKSIZE 2
+
+#define FIXPROPERTYCOUNT 3 // counts PROPERYHANDLE_PICKLISTSIZE ... PROPERTYHANDLE_HELPBOOKMARKSIZE!
+
+#define FIXP OUString(RTL_CONSTASCII_USTRINGPARAM("p" ))
+#define FIXH OUString(RTL_CONSTASCII_USTRINGPARAM("h" ))
+#define FIXB OUString(RTL_CONSTASCII_USTRINGPARAM("b" ))
+
+//_________________________________________________________________________________________________________________
+// private declarations!
+//_________________________________________________________________________________________________________________
+
+struct IMPL_THistoryItem
+{
+ IMPL_THistoryItem()
+ {
+ }
+
+ IMPL_THistoryItem( const OUString& sNewURL ,
+ const OUString& sNewFilter ,
+ const OUString& sNewTitle ,
+ const OUString& sNewPassword )
+ {
+ sURL = sNewURL ;
+ sFilter = sNewFilter ;
+ sTitle = sNewTitle ;
+ sPassword = sNewPassword ;
+ }
+
+ sal_Bool operator==( const OUString& sSearchedURL )
+ {
+ return( sURL == sSearchedURL );
+ }
+
+ OUString sURL ;
+ OUString sFilter ;
+ OUString sTitle ;
+ OUString sPassword ;
+};
+
+class SvtHistoryOptions_Impl : public ConfigItem
+{
+ //-------------------------------------------------------------------------------------------------------------
+ // public methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ public:
+
+ //---------------------------------------------------------------------------------------------------------
+ // constructor / destructor
+ //---------------------------------------------------------------------------------------------------------
+
+ SvtHistoryOptions_Impl();
+ ~SvtHistoryOptions_Impl();
+
+ //---------------------------------------------------------------------------------------------------------
+ // overloaded methods of baseclass
+ //---------------------------------------------------------------------------------------------------------
+
+ /*-****************************************************************************************************//**
+ @short called for notify of configmanager
+ @descr These method is called from the ConfigManager before application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. You must update your
+ internal values.
+
+ @seealso baseclass ConfigItem
+
+ @param "seqPropertyNames" is the list of properties which should be updated.
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Notify( const Sequence< OUString >& seqPropertyNames );
+
+ /*-****************************************************************************************************//**
+ @short write changes to configuration
+ @descr These method writes the changed values into the sub tree
+ and should always called in our destructor to guarantee consistency of config data.
+
+ @seealso baseclass ConfigItem
+
+ @param -
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Commit();
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ /*-****************************************************************************************************//**
+ @short return list of key names of ouer configuration management which represent oue module tree
+ @descr These methods return the current list of key names! We need it to get needed values from our
+ configuration management and support dynamical history lists!
+
+ @seealso -
+
+ @param -
+ @return A list of configuration key names is returned.
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ Sequence< OUString > impl_GetPropertyNames( sal_uInt32& nPicklistCount ,
+ sal_uInt32& nHistoryCount ,
+ sal_uInt32& nHelpBookmarkCount );
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private member
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ deque< IMPL_THistoryItem > m_aPicklist ;
+ sal_uInt32 m_nPicklistSize ;
+ deque< IMPL_THistoryItem > m_aHistory ;
+ sal_uInt32 m_nHistorySize ;
+ deque< IMPL_THistoryItem > m_aHelpBookmarks ;
+ sal_uInt32 m_nHelpBookmarkSize ;
+};
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtHistoryOptions_Impl::SvtHistoryOptions_Impl()
+ // Init baseclasses first
+ : ConfigItem ( ROOTNODE_HISTORY )
+ // Init member then...
+{
+ // Use our list snapshot of configuration keys to get his values.
+ // See impl_GetPropertyNames() for further informations.
+ sal_uInt32 nPicklistCount = 0;
+ sal_uInt32 nHistoryCount = 0;
+ sal_uInt32 nHelpBookmarkCount = 0;
+ Sequence< OUString > seqNames = impl_GetPropertyNames ( nPicklistCount ,
+ nHistoryCount ,
+ nHelpBookmarkCount );
+ Sequence< Any > seqValues = GetProperties ( seqNames );
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtHistoryOptions_Impl::SvtHistoryOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to ouer internal member.
+ // Attention: List for names and values have an internal construction pattern!
+ // zB:
+ // Name Value
+ // /Picklist/Size 2
+ // /History/Size 3
+ // /Picklist/List/1/URL "file://a"
+ // /Picklist/List/1/Filter "writer-..."
+ // /Picklist/List/1/Title "Test1"
+ // /Picklist/List/1/Password "lysemyf1"
+ // /Picklist/List/2/URL "file://b"
+ // /Picklist/List/2/Filter "calc-..."
+ // /Picklist/List/2/Title "Test2"
+ // /Picklist/List/2/Password "lysemyf2"
+ // /History/List/2/URL "http://blub"
+ // /History/List/2/Filter "html-..."
+ // /History/List/2/Title "blub"
+ // /History/List/2/Password "xxx"
+ // ... and so on ...
+
+ // First we must read sizes of ouer history lists => the first to values.
+ // We need these informations to work correctly with follow keys!
+ seqValues[PROPERTYHANDLE_PICKLISTSIZE ] >>= m_nPicklistSize ;
+ seqValues[PROPERTYHANDLE_HISTORYSIZE ] >>= m_nHistorySize ;
+ seqValues[PROPERTYHANDLE_HELPBOOKMARKSIZE] >>= m_nHelpBookmarkSize ;
+
+ // Safe impossible cases.
+ // I think a size of 0 isn't relay meaningful.
+ if( m_nPicklistSize < 1 )
+ {
+ m_nPicklistSize = DEFAULT_PICKLISTSIZE;
+ DBG_ASSERT( sal_False, "SvtHistoryOptions_Impl::SvtHistoryOptions_Impl()\nI think a picklist size of 0 isn't relay meaningful! Set new value to 4 entries.\n" );
+ }
+ if( m_nHistorySize < 1 )
+ {
+ m_nHistorySize = DEFAULT_HISTORYSIZE;
+ DBG_ASSERT( sal_False, "SvtHistoryOptions_Impl::SvtHistoryOptions_Impl()\nI think a history size of 0 isn't relay meaningful! Set new value to 10 entries.\n" );
+ }
+ if( m_nHelpBookmarkSize < 1 )
+ {
+ m_nHelpBookmarkSize = DEFAULT_HELPBOOKMARKSIZE;
+ DBG_ASSERT( sal_False, "SvtHistoryOptions_Impl::SvtHistoryOptions_Impl()\nI think a help bookmark size of 0 isn't relay meaningful! Set new value to 100 entries.\n" );
+ }
+
+ IMPL_THistoryItem aItem;
+ sal_uInt32 nPosition = FIXPROPERTYCOUNT; // step over first three readed size values! but count begins at 0!
+ // Get names/values for picklist.
+ // 4 subkeys for every item!
+ OUString sName;
+ sal_uInt32 nItem;
+ for( nItem=0; nItem<nPicklistCount; ++nItem )
+ {
+ seqValues[nPosition] >>= aItem.sURL ;
+ ++nPosition;
+ seqValues[nPosition] >>= aItem.sFilter ;
+ ++nPosition;
+ seqValues[nPosition] >>= aItem.sTitle ;
+ ++nPosition;
+ seqValues[nPosition] >>= aItem.sPassword ;
+ ++nPosition;
+ m_aPicklist.push_back( aItem );
+ }
+
+ // Attention: Don't reset nPosition here!
+
+ // Get names/values for picklist.
+ // 4 subkeys for every item!
+ for( nItem=0; nItem<nHistoryCount; ++nItem )
+ {
+ seqValues[nPosition] >>= aItem.sURL ;
+ ++nPosition;
+ seqValues[nPosition] >>= aItem.sFilter ;
+ ++nPosition;
+ seqValues[nPosition] >>= aItem.sTitle ;
+ ++nPosition;
+ seqValues[nPosition] >>= aItem.sPassword ;
+ ++nPosition;
+ m_aHistory.push_back( aItem );
+ }
+
+ // Get names/values for help bookmarks.
+ // 4 subkeys for every item!
+ for( nItem=0; nItem<nHelpBookmarkCount; ++nItem )
+ {
+ seqValues[nPosition] >>= aItem.sURL ;
+ ++nPosition;
+ seqValues[nPosition] >>= aItem.sFilter ;
+ ++nPosition;
+ seqValues[nPosition] >>= aItem.sTitle ;
+ ++nPosition;
+ seqValues[nPosition] >>= aItem.sPassword ;
+ ++nPosition;
+ m_aHelpBookmarks.push_back( aItem );
+ }
+
+/*TODO: Not used in the moment! see Notify() ...
+ // Enable notification mechanism of ouer baseclass.
+ // We need it to get information about changes outside these class on ouer used configuration keys!
+ Sequence< OUString > seqNotifications( seqNames );
+ sal_Int32 nNotifyCount = seqNames.getLength();
+ seqNotifications.realloc( nNotifyCount+PROPERTYCOUNT_LISTNODES );
+ seqNotification[nNotifyCount ] = PROPERTYNAME_PICKLIST;
+ seqNotification[nNotifyCount+1] = PROPERTYNAME_HISTORY ;
+ EnableNotification( seqNotification );
+*/
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtHistoryOptions_Impl::~SvtHistoryOptions_Impl()
+{
+ // We must save our current values .. if user forget it!
+ if( IsModified() == sal_True )
+ {
+ Commit();
+ }
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtHistoryOptions_Impl::Notify( const Sequence< OUString >& )
+{
+ DBG_ASSERT( sal_False, "SvtHistoryOptions_Impl::Notify()\nNot implemented yet! I don't know how I can handle a dynamical list of unknown properties ...\n" );
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtHistoryOptions_Impl::Commit()
+{
+ // First write fix properties.
+ Sequence< OUString > seqFixPropertyNames ( FIXPROPERTYCOUNT );
+ Sequence< Any > seqFixPropertyValues( FIXPROPERTYCOUNT );
+ seqFixPropertyNames [PROPERTYHANDLE_PICKLISTSIZE ] = PROPERTYNAME_PICKLISTSIZE ;
+ seqFixPropertyNames [PROPERTYHANDLE_HISTORYSIZE ] = PROPERTYNAME_HISTORYSIZE ;
+ seqFixPropertyNames [PROPERTYHANDLE_HELPBOOKMARKSIZE] = PROPERTYNAME_HELPBOOKMARKSIZE ;
+ seqFixPropertyValues[PROPERTYHANDLE_PICKLISTSIZE ] <<= m_nPicklistSize ;
+ seqFixPropertyValues[PROPERTYHANDLE_HISTORYSIZE ] <<= m_nHistorySize ;
+ seqFixPropertyValues[PROPERTYHANDLE_HELPBOOKMARKSIZE] <<= m_nHelpBookmarkSize ;
+ PutProperties( seqFixPropertyNames, seqFixPropertyValues );
+
+ // Write set of dynamic properties then.
+ ClearNodeSet( PROPERTYNAME_PICKLIST );
+ ClearNodeSet( PROPERTYNAME_HISTORY );
+ ClearNodeSet( PROPERTYNAME_HELPBOOKMARKS );
+
+ IMPL_THistoryItem aItem ;
+ OUString sNode ;
+ Sequence< PropertyValue > seqPropertyValues( 4 ) ;
+
+ // Copy picklist entries to save-list!
+ sal_uInt32 nPicklistCount = m_aPicklist.size();
+ sal_uInt32 nItem;
+ for( nItem=0; nItem<nPicklistCount; ++nItem )
+ {
+ aItem = m_aPicklist[nItem];
+ sNode = PROPERTYNAME_PICKLIST + PATHDELIMITER + FIXP + OUString::valueOf( (sal_Int32)nItem ) + PATHDELIMITER;
+ seqPropertyValues[OFFSET_URL ].Name = sNode + PROPERTYNAME_HISTORYITEM_URL ;
+ seqPropertyValues[OFFSET_FILTER ].Name = sNode + PROPERTYNAME_HISTORYITEM_FILTER ;
+ seqPropertyValues[OFFSET_TITLE ].Name = sNode + PROPERTYNAME_HISTORYITEM_TITLE ;
+ seqPropertyValues[OFFSET_PASSWORD ].Name = sNode + PROPERTYNAME_HISTORYITEM_PASSWORD ;
+ seqPropertyValues[OFFSET_URL ].Value <<= aItem.sURL ;
+ seqPropertyValues[OFFSET_FILTER ].Value <<= aItem.sFilter ;
+ seqPropertyValues[OFFSET_TITLE ].Value <<= aItem.sTitle ;
+ seqPropertyValues[OFFSET_PASSWORD ].Value <<= aItem.sPassword ;
+
+ SetSetProperties( PROPERTYNAME_PICKLIST, seqPropertyValues );
+ }
+
+ // Copy URL-list entries to save-list!
+ sal_uInt32 nHistoryCount = m_aHistory.size();
+ for( nItem=0; nItem<nHistoryCount; ++nItem )
+ {
+ aItem = m_aHistory[nItem];
+ sNode = PROPERTYNAME_HISTORY + PATHDELIMITER + FIXH + OUString::valueOf( (sal_Int32)nItem ) + PATHDELIMITER;
+ seqPropertyValues[OFFSET_URL ].Name = sNode + PROPERTYNAME_HISTORYITEM_URL ;
+ seqPropertyValues[OFFSET_FILTER ].Name = sNode + PROPERTYNAME_HISTORYITEM_FILTER ;
+ seqPropertyValues[OFFSET_TITLE ].Name = sNode + PROPERTYNAME_HISTORYITEM_TITLE ;
+ seqPropertyValues[OFFSET_PASSWORD ].Name = sNode + PROPERTYNAME_HISTORYITEM_PASSWORD ;
+ seqPropertyValues[OFFSET_URL ].Value <<= aItem.sURL ;
+ seqPropertyValues[OFFSET_FILTER ].Value <<= aItem.sFilter ;
+ seqPropertyValues[OFFSET_TITLE ].Value <<= aItem.sTitle ;
+ seqPropertyValues[OFFSET_PASSWORD ].Value <<= aItem.sPassword ;
+
+ SetSetProperties( PROPERTYNAME_HISTORY, seqPropertyValues );
+ }
+
+ // Copy HelpBookmark-list entries to save-list!
+ sal_uInt32 nHelpBookmarkCount = m_aHelpBookmarks.size();
+ for( nItem=0; nItem<nHelpBookmarkCount; ++nItem )
+ {
+ aItem = m_aHelpBookmarks[nItem];
+ sNode = PROPERTYNAME_HELPBOOKMARKS + PATHDELIMITER + FIXB + OUString::valueOf( (sal_Int32)nItem ) + PATHDELIMITER;
+ seqPropertyValues[OFFSET_URL ].Name = sNode + PROPERTYNAME_HISTORYITEM_URL ;
+ seqPropertyValues[OFFSET_FILTER ].Name = sNode + PROPERTYNAME_HISTORYITEM_FILTER ;
+ seqPropertyValues[OFFSET_TITLE ].Name = sNode + PROPERTYNAME_HISTORYITEM_TITLE ;
+ seqPropertyValues[OFFSET_PASSWORD ].Name = sNode + PROPERTYNAME_HISTORYITEM_PASSWORD ;
+ seqPropertyValues[OFFSET_URL ].Value <<= aItem.sURL ;
+ seqPropertyValues[OFFSET_FILTER ].Value <<= aItem.sFilter ;
+ seqPropertyValues[OFFSET_TITLE ].Value <<= aItem.sTitle ;
+ seqPropertyValues[OFFSET_PASSWORD ].Value <<= aItem.sPassword ;
+
+ SetSetProperties( PROPERTYNAME_HELPBOOKMARKS, seqPropertyValues );
+ }
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Sequence< OUString > SvtHistoryOptions_Impl::impl_GetPropertyNames( sal_uInt32& nPicklistCount ,
+ sal_uInt32& nHistoryCount ,
+ sal_uInt32& nHelpBookmarkCount )
+{
+ /* TODO
+ Index basiert einf�gen !!! => p0 => 0 p1 => 1 ...
+ */
+
+ // First get ALL names of current existing list items in configuration!
+ Sequence< OUString > seqPicklistItems = GetNodeNames( PROPERTYNAME_PICKLIST );
+ Sequence< OUString > seqHistoryItems = GetNodeNames( PROPERTYNAME_HISTORY );
+ Sequence< OUString > seqHelpBookmarkItems = GetNodeNames( PROPERTYNAME_HELPBOOKMARKS );
+
+ // Get information about list counts ...
+ nPicklistCount = seqPicklistItems.getLength ();
+ nHistoryCount = seqHistoryItems.getLength ();
+ nHelpBookmarkCount = seqHelpBookmarkItems.getLength();
+ // ... and create a property list with right size! (+2...see fix properties below!)
+ Sequence< OUString > seqProperties( FIXPROPERTYCOUNT +
+ (nPicklistCount *4) +
+ (nHistoryCount *4) +
+ (nHelpBookmarkCount*4) );
+
+ // Add names of fix properties to list.
+ seqProperties[PROPERTYHANDLE_PICKLISTSIZE ] = PROPERTYNAME_PICKLISTSIZE ;
+ seqProperties[PROPERTYHANDLE_HISTORYSIZE ] = PROPERTYNAME_HISTORYSIZE ;
+ seqProperties[PROPERTYHANDLE_HELPBOOKMARKSIZE] = PROPERTYNAME_HELPBOOKMARKSIZE ;
+
+ sal_uInt32 nPosition = FIXPROPERTYCOUNT; // step over three fix properties for sizes! but count begins at 0!
+ // Add names for picklist to list.
+ // 4 subkeys for every item!
+ // nPosition is the start point of an history item, nItem an index into right list of node names!
+ sal_uInt32 nItem;
+ for( nItem=0; nItem<nPicklistCount; ++nItem )
+ {
+ seqProperties[nPosition] = PROPERTYNAME_PICKLIST + PATHDELIMITER + seqPicklistItems[nItem] + PATHDELIMITER + PROPERTYNAME_HISTORYITEM_URL ;
+ ++nPosition;
+ seqProperties[nPosition] = PROPERTYNAME_PICKLIST + PATHDELIMITER + seqPicklistItems[nItem] + PATHDELIMITER + PROPERTYNAME_HISTORYITEM_FILTER ;
+ ++nPosition;
+ seqProperties[nPosition] = PROPERTYNAME_PICKLIST + PATHDELIMITER + seqPicklistItems[nItem] + PATHDELIMITER + PROPERTYNAME_HISTORYITEM_TITLE ;
+ ++nPosition;
+ seqProperties[nPosition] = PROPERTYNAME_PICKLIST + PATHDELIMITER + seqPicklistItems[nItem] + PATHDELIMITER + PROPERTYNAME_HISTORYITEM_PASSWORD ;
+ ++nPosition;
+ }
+
+ // Attention: Don't reset nPosition here!
+
+ // Add names for URL-list to list.
+ // 4 subkeys for every item!
+ // nPosition is the start point of an history item, nItem an index into right list of node names!
+ for( nItem=0; nItem<nHistoryCount; ++nItem )
+ {
+ seqProperties[nPosition] = PROPERTYNAME_HISTORY + PATHDELIMITER + seqHistoryItems[nItem] + PATHDELIMITER + PROPERTYNAME_HISTORYITEM_URL ;
+ ++nPosition;
+ seqProperties[nPosition] = PROPERTYNAME_HISTORY + PATHDELIMITER + seqHistoryItems[nItem] + PATHDELIMITER + PROPERTYNAME_HISTORYITEM_FILTER ;
+ ++nPosition;
+ seqProperties[nPosition] = PROPERTYNAME_HISTORY + PATHDELIMITER + seqHistoryItems[nItem] + PATHDELIMITER + PROPERTYNAME_HISTORYITEM_TITLE ;
+ ++nPosition;
+ seqProperties[nPosition] = PROPERTYNAME_HISTORY + PATHDELIMITER + seqHistoryItems[nItem] + PATHDELIMITER + PROPERTYNAME_HISTORYITEM_PASSWORD ;
+ ++nPosition;
+ }
+
+ // Attention: Don't reset nPosition here!
+
+ // Add names for HelpBookmark-list to list.
+ // 4 subkeys for every item!
+ // nPosition is the start point of an bokmark item, nItem an index into right list of node names!
+ for( nItem=0; nItem<nHelpBookmarkCount; ++nItem )
+ {
+ seqProperties[nPosition] = PROPERTYNAME_HELPBOOKMARKS + PATHDELIMITER + seqHelpBookmarkItems[nItem] + PATHDELIMITER + PROPERTYNAME_HISTORYITEM_URL ;
+ ++nPosition;
+ seqProperties[nPosition] = PROPERTYNAME_HELPBOOKMARKS + PATHDELIMITER + seqHelpBookmarkItems[nItem] + PATHDELIMITER + PROPERTYNAME_HISTORYITEM_FILTER ;
+ ++nPosition;
+ seqProperties[nPosition] = PROPERTYNAME_HELPBOOKMARKS + PATHDELIMITER + seqHelpBookmarkItems[nItem] + PATHDELIMITER + PROPERTYNAME_HISTORYITEM_TITLE ;
+ ++nPosition;
+ seqProperties[nPosition] = PROPERTYNAME_HELPBOOKMARKS + PATHDELIMITER + seqHelpBookmarkItems[nItem] + PATHDELIMITER + PROPERTYNAME_HISTORYITEM_PASSWORD ;
+ ++nPosition;
+ }
+
+ // Return result.
+ return seqProperties;
+}
+
+//*****************************************************************************************************************
+// initialize static member
+// DON'T DO IT IN YOUR HEADER!
+// see definition for further informations
+//*****************************************************************************************************************
+SvtHistoryOptions_Impl* SvtHistoryOptions::m_pDataContainer = NULL ;
+sal_Int32 SvtHistoryOptions::m_nRefCount = 0 ;
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtHistoryOptions::SvtHistoryOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already exist!
+ if( m_pDataContainer == NULL )
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtHistoryOptions_Impl::ctor()");
+ m_pDataContainer = new SvtHistoryOptions_Impl;
+
+ ItemHolder1::holdConfigItem(E_HISTORYOPTIONS);
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtHistoryOptions::~SvtHistoryOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Decrease ouer refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pDataContainer;
+ m_pDataContainer = NULL;
+ }
+}
+
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Mutex& SvtHistoryOptions::GetOwnStaticMutex()
+{
+ // Initialize static mutex only for one time!
+ static Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_inetoptions.cxx b/binfilter/bf_svtools/source/config/svt_inetoptions.cxx
new file mode 100644
index 000000000000..a02de3b00820
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_inetoptions.cxx
@@ -0,0 +1,317 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/inetoptions.hxx>
+
+#include "rtl/instance.hxx"
+
+#include <tools/urlobj.hxx>
+#include <tools/wldcrd.hxx>
+
+#include <algorithm>
+#include <map>
+#include <set>
+#include <vector>
+#include <utility>
+
+#include <com/sun/star/beans/PropertyChangeEvent.hpp>
+#include <com/sun/star/beans/XPropertiesChangeListener.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/system/XProxySettings.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <osl/mutex.hxx>
+#include <rtl/ustring.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <unotools/configitem.hxx>
+#include <unotools/processfactory.hxx>
+#include <osl/diagnose.h>
+#include <salhelper/refobj.hxx>
+#include <rtl/logfile.hxx>
+#include "itemholder1.hxx"
+
+using namespace com::sun;
+
+//============================================================================
+//
+// takeAny
+//
+//============================================================================
+
+namespace {
+
+template< typename T > inline T takeAny(star::uno::Any const & rAny)
+{
+ T aValue = T();
+ rAny >>= aValue;
+ return aValue;
+}
+
+}
+
+namespace binfilter
+{
+
+//============================================================================
+//
+// SvtInetOptions::Impl
+//
+//============================================================================
+
+class SvtInetOptions::Impl: public salhelper::ReferenceObject,
+ public utl::ConfigItem
+{
+public:
+ enum Index
+ {
+ INDEX_NO_PROXY,
+ INDEX_PROXY_TYPE,
+ INDEX_FTP_PROXY_NAME,
+ INDEX_FTP_PROXY_PORT,
+ INDEX_HTTP_PROXY_NAME,
+ INDEX_HTTP_PROXY_PORT
+ };
+
+ Impl();
+
+ inline void flush() { Commit(); }
+
+private:
+ enum { ENTRY_COUNT = INDEX_HTTP_PROXY_PORT + 1 };
+
+ struct Entry
+ {
+ enum State { UNKNOWN, KNOWN, MODIFIED };
+
+ inline Entry(): m_eState(UNKNOWN) {}
+
+ rtl::OUString m_aName;
+ star::uno::Any m_aValue;
+ State m_eState;
+ };
+
+ // MSVC has problems with the below Map type when
+ // star::uno::Reference< star::beans::XPropertiesChangeListener > is not
+ // wrapped in class Listener:
+ class Listener:
+ public star::uno::Reference< star::beans::XPropertiesChangeListener >
+ {
+ public:
+ Listener(star::uno::Reference<
+ star::beans::XPropertiesChangeListener > const &
+ rListener):
+ star::uno::Reference< star::beans::XPropertiesChangeListener >(
+ rListener)
+ {}
+ };
+
+ typedef std::map< Listener, std::set< rtl::OUString > > Map;
+
+ osl::Mutex m_aMutex;
+ Entry m_aEntries[ENTRY_COUNT];
+ Map m_aListeners;
+
+ virtual inline ~Impl() { Commit(); }
+
+ virtual void Notify(star::uno::Sequence< rtl::OUString > const & rKeys);
+
+ virtual void Commit();
+
+ void notifyListeners(star::uno::Sequence< rtl::OUString > const & rKeys);
+};
+
+//============================================================================
+// virtual
+void
+SvtInetOptions::Impl::Notify(star::uno::Sequence< rtl::OUString > const &
+ rKeys)
+{
+ {
+ osl::MutexGuard aGuard(m_aMutex);
+ for (sal_Int32 i = 0; i < rKeys.getLength(); ++i)
+ for (sal_Int32 j = 0; j < ENTRY_COUNT; ++j)
+ if (rKeys[i] == m_aEntries[j].m_aName)
+ {
+ m_aEntries[j].m_eState = Entry::UNKNOWN;
+ break;
+ }
+ }
+ notifyListeners(rKeys);
+}
+
+//============================================================================
+// virtual
+void SvtInetOptions::Impl::Commit()
+{
+ star::uno::Sequence< rtl::OUString > aKeys(ENTRY_COUNT);
+ star::uno::Sequence< star::uno::Any > aValues(ENTRY_COUNT);
+ sal_Int32 nCount = 0;
+ {
+ osl::MutexGuard aGuard(m_aMutex);
+ for (sal_Int32 i = 0; i < ENTRY_COUNT; ++i)
+ if (m_aEntries[i].m_eState == Entry::MODIFIED)
+ {
+ aKeys[nCount] = m_aEntries[i].m_aName;
+ aValues[nCount] = m_aEntries[i].m_aValue;
+ ++nCount;
+ m_aEntries[i].m_eState = Entry::KNOWN;
+ }
+ }
+ if (nCount > 0)
+ {
+ aKeys.realloc(nCount);
+ aValues.realloc(nCount);
+ PutProperties(aKeys, aValues);
+ }
+}
+
+//============================================================================
+void
+SvtInetOptions::Impl::notifyListeners(
+ star::uno::Sequence< rtl::OUString > const & rKeys)
+{
+ typedef
+ std::vector< std::pair< star::uno::Reference<
+ star::beans::XPropertiesChangeListener >,
+ star::uno::Sequence<
+ star::beans::PropertyChangeEvent > > >
+ List;
+ List aNotifications;
+ {
+ osl::MutexGuard aGuard(m_aMutex);
+ aNotifications.reserve(m_aListeners.size());
+ Map::const_iterator aMapEnd(m_aListeners.end());
+ for (Map::const_iterator aIt(m_aListeners.begin()); aIt != aMapEnd;
+ ++aIt)
+ {
+ const Map::mapped_type &rSet = aIt->second;
+ Map::mapped_type::const_iterator aSetEnd(rSet.end());
+ star::uno::Sequence< star::beans::PropertyChangeEvent >
+ aEvents(rKeys.getLength());
+ sal_Int32 nCount = 0;
+ for (sal_Int32 i = 0; i < rKeys.getLength(); ++i)
+ {
+ rtl::OUString
+ aTheKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "Inet/")));
+ aTheKey += rKeys[i];
+ if (rSet.find(aTheKey) != aSetEnd)
+ {
+ aEvents[nCount].PropertyName = aTheKey;
+ aEvents[nCount].PropertyHandle = -1;
+ ++nCount;
+ }
+ }
+ if (nCount > 0)
+ {
+ aEvents.realloc(nCount);
+ aNotifications.
+ push_back(std::make_pair< List::value_type::first_type,
+ List::value_type::second_type >(
+ aIt->first, aEvents));
+ }
+ }
+ }
+ for (List::size_type i = 0; i < aNotifications.size(); ++i)
+ if (aNotifications[i].first.is())
+ aNotifications[i].first->
+ propertiesChange(aNotifications[i].second);
+}
+
+//============================================================================
+SvtInetOptions::Impl::Impl():
+ ConfigItem(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Inet/Settings")))
+{
+ m_aEntries[INDEX_NO_PROXY].m_aName
+ = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetNoProxy"));
+ m_aEntries[INDEX_PROXY_TYPE].m_aName
+ = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetProxyType"));
+ m_aEntries[INDEX_FTP_PROXY_NAME].m_aName
+ = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetFTPProxyName"));
+ m_aEntries[INDEX_FTP_PROXY_PORT].m_aName
+ = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetFTPProxyPort"));
+ m_aEntries[INDEX_HTTP_PROXY_NAME].m_aName
+ = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPProxyName"));
+ m_aEntries[INDEX_HTTP_PROXY_PORT].m_aName
+ = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPProxyPort"));
+
+ star::uno::Sequence< rtl::OUString > aKeys(ENTRY_COUNT);
+ for (sal_Int32 i = 0; i < ENTRY_COUNT; ++i)
+ aKeys[i] = m_aEntries[i].m_aName;
+ if (!EnableNotification(aKeys))
+ OSL_ENSURE(false,
+ "SvtInetOptions::Impl::Impl(): Bad EnableNotifications()");
+}
+
+//============================================================================
+//
+// SvtInetOptions
+//
+//============================================================================
+
+namespace
+{
+ class LocalSingleton : public rtl::Static< osl::Mutex, LocalSingleton >
+ {
+ };
+}
+
+// static
+SvtInetOptions::Impl * SvtInetOptions::m_pImpl = 0;
+
+//============================================================================
+SvtInetOptions::SvtInetOptions()
+{
+ osl::MutexGuard aGuard(LocalSingleton::get());
+ if (!m_pImpl)
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtInetOptions_Impl::ctor()");
+ m_pImpl = new Impl;
+
+ ItemHolder1::holdConfigItem(E_INETOPTIONS);
+ }
+ m_pImpl->acquire();
+}
+
+//============================================================================
+SvtInetOptions::~SvtInetOptions()
+{
+ osl::MutexGuard aGuard(LocalSingleton::get());
+ if (m_pImpl->release() == 0)
+ m_pImpl = 0;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_internaloptions.cxx b/binfilter/bf_svtools/source/config/svt_internaloptions.cxx
new file mode 100644
index 000000000000..50d0f25a4b3f
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_internaloptions.cxx
@@ -0,0 +1,515 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+//_________________________________________________________________________________________________________________
+// includes
+//_________________________________________________________________________________________________________________
+
+#include <deque>
+
+#include <bf_svtools/internaloptions.hxx>
+
+#include <unotools/configmgr.hxx>
+
+#include <unotools/configitem.hxx>
+
+#include <tools/debug.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+#include <rtl/logfile.hxx>
+#include "itemholder1.hxx"
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+using namespace ::utl ;
+using namespace ::rtl ;
+using namespace ::osl ;
+using namespace ::std ;
+using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star::beans ;
+
+namespace binfilter
+{
+
+//_________________________________________________________________________________________________________________
+// const
+//_________________________________________________________________________________________________________________
+
+#define ROOTNODE_INTERNAL OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Internal" ))
+#define DEFAULT_SLOTCFG sal_False
+#define DEFAULT_SENDCRASHMAIL sal_False
+#define DEFAULT_USEMAILUI sal_True
+#define DEFAULT_CURRENTTEMPURL OUString(RTL_CONSTASCII_USTRINGPARAM(""))
+
+#define FIXPROPERTYNAME_SLOTCFG OUString(RTL_CONSTASCII_USTRINGPARAM("Slot" ))
+#define FIXPROPERTYNAME_SENDCRASHMAIL OUString(RTL_CONSTASCII_USTRINGPARAM("SendCrashMail" ))
+#define FIXPROPERTYNAME_USEMAILUI OUString(RTL_CONSTASCII_USTRINGPARAM("UseMailUI" ))
+#define FIXPROPERTYNAME_CURRENTTEMPURL OUString(RTL_CONSTASCII_USTRINGPARAM("CurrentTempURL" ))
+//#define FIXPROPERTYNAME_REMOVEMENUENTRYCLOSE OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryClose"))
+//#define FIXPROPERTYNAME_REMOVEMENUENTRYBACKTOWEBTOP OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryBackToWebtop"))
+//#define FIXPROPERTYNAME_REMOVEMENUENTRYNEWWEBTOP OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryNewWebtop"))
+//#define FIXPROPERTYNAME_REMOVEMENUENTRYLOGOUT OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryLogout"))
+
+#define FIXPROPERTYHANDLE_SLOTCFG 0
+#define FIXPROPERTYHANDLE_SENDCRASHMAIL 1
+#define FIXPROPERTYHANDLE_USEMAILUI 2
+#define FIXPROPERTYHANDLE_CURRENTTEMPURL 3
+//#define FIXPROPERTYHANDLE_REMOVEMENUENTRYCLOSE 3
+//#define FIXPROPERTYHANDLE_REMOVEMENUENTRYBACKTOWEBTOP 4
+//#define FIXPROPERTYHANDLE_REMOVEMENUENTRYNEWWEBTOP 5
+//#define FIXPROPERTYHANDLE_REMOVEMENUENTRYLOGOUT 6
+
+#define FIXPROPERTYCOUNT 4
+/*
+#define PROPERTYNAME_RECOVERYLIST OUString(RTL_CONSTASCII_USTRINGPARAM("RecoveryList" ))
+#define PROPERTYNAME_URL OUString(RTL_CONSTASCII_USTRINGPARAM("OrgURL" ))
+#define PROPERTYNAME_FILTER OUString(RTL_CONSTASCII_USTRINGPARAM("FilterName" ))
+#define PROPERTYNAME_TEMPNAME OUString(RTL_CONSTASCII_USTRINGPARAM("TempURL" ))
+
+#define OFFSET_URL 0
+#define OFFSET_FILTER 1
+#define OFFSET_TEMPNAME 2
+*/
+#define PATHDELIMITER OUString(RTL_CONSTASCII_USTRINGPARAM("/" ))
+#define FIXR OUString(RTL_CONSTASCII_USTRINGPARAM("r" ))
+
+//_________________________________________________________________________________________________________________
+// private declarations!
+//_________________________________________________________________________________________________________________
+/*
+struct tIMPL_RecoveryEntry
+{
+ OUString sURL ;
+ OUString sFilter ;
+ OUString sTempName ;
+
+ tIMPL_RecoveryEntry()
+ {
+ sURL = OUString();
+ sFilter = OUString();
+ sTempName = OUString();
+ }
+
+ tIMPL_RecoveryEntry( const OUString& sNewURL ,
+ const OUString& sNewFilter ,
+ const OUString& sNewTempName )
+ {
+ sURL = sNewURL ;
+ sFilter = sNewFilter ;
+ sTempName = sNewTempName ;
+ }
+};
+
+typedef deque< tIMPL_RecoveryEntry > tIMPL_RecoveryStack;
+*/
+class SvtInternalOptions_Impl : public ConfigItem
+{
+ //-------------------------------------------------------------------------------------------------------------
+ // private member
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ sal_Bool m_bRemoveMenuEntryClose;
+ sal_Bool m_bRemoveMenuEntryBackToWebtop;
+ sal_Bool m_bRemoveMenuEntryNewWebtop;
+ sal_Bool m_bRemoveMenuEntryLogout;
+ sal_Bool m_bSlotCFG ; /// cache "Slot" of Internal section
+ sal_Bool m_bSendCrashMail ; /// cache "SendCrashMail" of Internal section
+ sal_Bool m_bUseMailUI;
+ OUString m_aCurrentTempURL ;
+ // tIMPL_RecoveryStack m_aRecoveryList ; /// cache "RecoveryList" of Internal section
+ //-------------------------------------------------------------------------------------------------------------
+ // public methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ public:
+
+ //---------------------------------------------------------------------------------------------------------
+ // constructor / destructor
+ //---------------------------------------------------------------------------------------------------------
+
+ SvtInternalOptions_Impl();
+ ~SvtInternalOptions_Impl();
+
+ //---------------------------------------------------------------------------------------------------------
+ // overloaded methods of baseclass
+ //---------------------------------------------------------------------------------------------------------
+
+ /*-****************************************************************************************************//**
+ @short called for notify of configmanager
+ @descr These method is called from the ConfigManager before application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. You must update your
+ internal values.
+
+ @seealso baseclass ConfigItem
+
+ @param "seqPropertyNames" is the list of properties which should be updated.
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Notify( const Sequence< OUString >& )
+ {
+ DBG_ASSERT( sal_False, "SvtInternalOptions::Notify()\nNot used yet ... but called!?\n" );
+ }
+
+ /*-****************************************************************************************************//**
+ @short write changes to configuration
+ @descr These method writes the changed values into the sub tree
+ and should always called in our destructor to guarantee consistency of config data.
+
+ @seealso baseclass ConfigItem
+
+ @param -
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Commit();
+
+ //---------------------------------------------------------------------------------------------------------
+ // public interface
+ //---------------------------------------------------------------------------------------------------------
+
+ /*-****************************************************************************************************//**
+ @short access method to get internal values
+ @descr These method give us a chance to regulate acces to ouer internal values.
+ It's not used in the moment - but it's possible for the feature!
+
+ @seealso -
+
+ @param -
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ sal_Bool IsRemoveMenuEntryClose() const { return m_bRemoveMenuEntryClose; }
+ sal_Bool IsRemoveMenuEntryBackToWebtop() const { return m_bRemoveMenuEntryBackToWebtop; }
+ sal_Bool IsRemoveMenuEntryNewWebtop() const { return m_bRemoveMenuEntryNewWebtop; }
+ sal_Bool IsRemoveMenuEntryLogout() const { return m_bRemoveMenuEntryLogout; }
+ sal_Bool SlotCFGEnabled () const { return m_bSlotCFG; }
+ sal_Bool CrashMailEnabled () const { return m_bSendCrashMail; }
+ sal_Bool MailUIEnabled () const { return m_bUseMailUI; }
+
+ OUString GetCurrentTempURL() const { return m_aCurrentTempURL; }
+ //-------------------------------------------------------------------------------------------------------------
+ // private methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ /*-****************************************************************************************************//**
+ @short return list of fix key names of ouer configuration management which represent oue module tree
+ @descr These methods return a static const list of key names. We need it to get needed values from our
+ configuration management. We return well known key names only - because the "UserData" node
+ is handled in a special way!
+
+ @seealso -
+
+ @param -
+ @return A list of needed configuration keys is returned.
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ Sequence< OUString > impl_GetPropertyNames();
+};
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtInternalOptions_Impl::SvtInternalOptions_Impl()
+ // Init baseclasses first
+ : ConfigItem ( ROOTNODE_INTERNAL, CONFIG_MODE_IMMEDIATE_UPDATE )
+ // Init member then.
+ , m_bRemoveMenuEntryClose ( sal_False )
+ , m_bRemoveMenuEntryBackToWebtop ( sal_False )
+ , m_bRemoveMenuEntryNewWebtop ( sal_False )
+ , m_bRemoveMenuEntryLogout ( sal_False )
+ , m_bSlotCFG ( DEFAULT_SLOTCFG )
+ , m_bSendCrashMail ( DEFAULT_SENDCRASHMAIL )
+ , m_bUseMailUI ( DEFAULT_USEMAILUI )
+ , m_aCurrentTempURL ( DEFAULT_CURRENTTEMPURL )
+{
+ // Use our list of configuration keys to get his values.
+ // structure of internal section: (first 2 entries are fixed - all other are member of a set!)
+ // "Slot"
+ // "SendCrashMail"
+ // "RecoveryList/r1/URL"
+ // "RecoveryList/r1/Filter"
+ // "RecoveryList/r1/TempName"
+ // "RecoveryList/r2/URL"
+ // "RecoveryList/r2/Filter"
+ // "RecoveryList/r2/TempName"
+ // "RecoveryList/.."
+ Sequence< OUString > seqNames = impl_GetPropertyNames() ;
+ Sequence< Any > seqValues = GetProperties( seqNames ) ;
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtInternalOptions_Impl::SvtInternalOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Read fixed values first!
+ DBG_ASSERT(!(seqValues[FIXPROPERTYHANDLE_SLOTCFG].getValueTypeClass()!=TypeClass_BOOLEAN) , "SvtInternalOptions_Impl::SvtInternalOptions_Impl()\nWho has changed the value type of \"Office.Common\\Internal\\Slot\"?" );
+ DBG_ASSERT(!(seqValues[FIXPROPERTYHANDLE_SENDCRASHMAIL].getValueTypeClass()!=TypeClass_BOOLEAN) , "SvtInternalOptions_Impl::SvtInternalOptions_Impl()\nWho has changed the value type of \"Office.Common\\Internal\\SendCrashMail\"?" );
+ seqValues[FIXPROPERTYHANDLE_SLOTCFG ] >>= m_bSlotCFG ;
+ seqValues[FIXPROPERTYHANDLE_SENDCRASHMAIL ] >>= m_bSendCrashMail ;
+ seqValues[FIXPROPERTYHANDLE_USEMAILUI ] >>= m_bUseMailUI ;
+ seqValues[FIXPROPERTYHANDLE_CURRENTTEMPURL ] >>= m_aCurrentTempURL ;
+// seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYCLOSE ] >>= m_bRemoveMenuEntryClose ;
+// seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYBACKTOWEBTOP ] >>= m_bRemoveMenuEntryBackToWebtop ;
+// seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYNEWWEBTOP ] >>= m_bRemoveMenuEntryNewWebtop ;
+// seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYLOGOUT ] >>= m_bRemoveMenuEntryLogout ;
+/*
+ // Read dynamical set "RecoveryList" then.
+ // 3 subkeys for every item!
+ // Attention: Start at next element after last fixed entry! We must ignore "Slot" and "SendCrashMail" ...
+ tIMPL_RecoveryEntry aEntry;
+ sal_uInt32 nCount = seqValues.getLength() ;
+ sal_uInt32 nPosition = FIXPROPERTYCOUNT ;
+
+ while( nPosition<nCount )
+ {
+ seqValues[nPosition] >>= aEntry.sURL ;
+ ++nPosition;
+ seqValues[nPosition] >>= aEntry.sFilter ;
+ ++nPosition;
+ seqValues[nPosition] >>= aEntry.sTempName ;
+ ++nPosition;
+ m_aRecoveryList.push_front( aEntry );
+ }
+*/
+ // We don't need any notifications here.
+ // "Slot" and "SendCrashMail" are readonly(!) and our recovery list should not modified during runtime - it's used
+ // by our crash guard only ... otherwise we have a big problem.
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtInternalOptions_Impl::~SvtInternalOptions_Impl()
+{
+ if( IsModified() == sal_True )
+ {
+ Commit();
+ }
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtInternalOptions_Impl::Commit()
+{
+ // We have to write our current temp URL
+ Sequence< OUString > aNames( 1 );
+ OUString* pNames = aNames.getArray();
+ Sequence< Any > aValues( 1 );
+ Any* pValues = aValues.getArray();
+
+ pNames[0] = FIXPROPERTYNAME_CURRENTTEMPURL;
+ pValues[0] <<= m_aCurrentTempURL;
+
+ PutProperties( aNames, aValues );
+
+/*
+ // Write set of dynamic properties then.
+ ClearNodeSet( PROPERTYNAME_RECOVERYLIST );
+
+ tIMPL_RecoveryEntry aItem ;
+ OUString sNode ;
+ Sequence< PropertyValue > seqPropertyValues( 3 ) ; // Every node in set has 3 sub-nodes!( url, filter, tempname )
+
+ // Copy list entries to save-list and write it to configuration.
+
+ sal_uInt32 nCount = m_aRecoveryList.size();
+ for( sal_uInt32 nItem=0; nItem<nCount; ++nItem )
+ {
+ aItem = m_aRecoveryList.top();
+ m_aRecoveryList.pop();
+ sNode = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + FIXR + OUString::valueOf( (sal_Int32)nItem ) + PATHDELIMITER;
+ seqPropertyValues[OFFSET_URL ].Name = sNode + PROPERTYNAME_URL ;
+ seqPropertyValues[OFFSET_FILTER ].Name = sNode + PROPERTYNAME_FILTER ;
+ seqPropertyValues[OFFSET_TEMPNAME ].Name = sNode + PROPERTYNAME_TEMPNAME ;
+ seqPropertyValues[OFFSET_URL ].Value <<= aItem.sURL ;
+ seqPropertyValues[OFFSET_FILTER ].Value <<= aItem.sFilter ;
+ seqPropertyValues[OFFSET_TEMPNAME ].Value <<= aItem.sTempName ;
+
+ SetSetProperties( PROPERTYNAME_RECOVERYLIST, seqPropertyValues );
+ }
+
+ tIMPL_RecoveryStack::iterator iRecovery = m_aRecoveryList.begin();
+ for ( sal_uInt32 nItem=0; iRecovery != m_aRecoveryList.end(); ++nItem, ++iRecovery)
+ {
+ aItem = *iRecovery;
+ sNode = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + FIXR +
+ OUString::valueOf( (sal_Int32)nItem ) + PATHDELIMITER;
+ seqPropertyValues[OFFSET_URL ].Name = sNode + PROPERTYNAME_URL ;
+ seqPropertyValues[OFFSET_FILTER ].Name = sNode + PROPERTYNAME_FILTER ;
+ seqPropertyValues[OFFSET_TEMPNAME ].Name = sNode + PROPERTYNAME_TEMPNAME ;
+ seqPropertyValues[OFFSET_URL ].Value <<= iRecovery->sURL ;
+ seqPropertyValues[OFFSET_FILTER ].Value <<= iRecovery->sFilter ;
+ seqPropertyValues[OFFSET_TEMPNAME ].Value <<= iRecovery->sTempName ;
+ SetSetProperties( PROPERTYNAME_RECOVERYLIST, seqPropertyValues );
+ }
+
+ */
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Sequence< OUString > SvtInternalOptions_Impl::impl_GetPropertyNames()
+{
+ /*
+ // First get ALL names of current existing list items in configuration!
+ Sequence< OUString > seqRecoveryItems = GetNodeNames( PROPERTYNAME_RECOVERYLIST );
+ // Get information about list counts ...
+ sal_Int32 nRecoveryCount = seqRecoveryItems.getLength();
+ // ... and create a property list with right size! (+2...for fix properties!) (*3 ... = sub nodes for every set node!)
+ Sequence< OUString > seqProperties( FIXPROPERTYCOUNT + (nRecoveryCount*3) );
+ */
+ Sequence< OUString > seqProperties(4);
+
+ // Add names of fix properties to list.
+ seqProperties[FIXPROPERTYHANDLE_SLOTCFG ] = FIXPROPERTYNAME_SLOTCFG ;
+ seqProperties[FIXPROPERTYHANDLE_SENDCRASHMAIL ] = FIXPROPERTYNAME_SENDCRASHMAIL ;
+ seqProperties[FIXPROPERTYHANDLE_USEMAILUI ] = FIXPROPERTYNAME_USEMAILUI ;
+ seqProperties[FIXPROPERTYHANDLE_CURRENTTEMPURL ] = FIXPROPERTYNAME_CURRENTTEMPURL ;
+// seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYCLOSE ] = FIXPROPERTYNAME_REMOVEMENUENTRYCLOSE;
+// seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYBACKTOWEBTOP ] = FIXPROPERTYNAME_REMOVEMENUENTRYBACKTOWEBTOP;
+// seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYNEWWEBTOP ] = FIXPROPERTYNAME_REMOVEMENUENTRYNEWWEBTOP;
+// seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYLOGOUT ] = FIXPROPERTYNAME_REMOVEMENUENTRYLOGOUT;
+/*
+ sal_uInt32 nPosition = FIXPROPERTYCOUNT;
+ // Add names for recovery list to list.
+ // 3 subkeys for every item!
+ // nPosition is the start point of an list item, nItem an index into right list of node names!
+ for( sal_Int32 nItem=0; nItem<nRecoveryCount; ++nItem )
+ {
+ seqProperties[nPosition] = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + seqRecoveryItems[nItem] + PATHDELIMITER + PROPERTYNAME_URL ;
+ ++nPosition;
+ seqProperties[nPosition] = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + seqRecoveryItems[nItem] + PATHDELIMITER + PROPERTYNAME_FILTER ;
+ ++nPosition;
+ seqProperties[nPosition] = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + seqRecoveryItems[nItem] + PATHDELIMITER + PROPERTYNAME_TEMPNAME ;
+ ++nPosition;
+ }
+*/
+ // Return result.
+ return seqProperties;
+}
+
+//*****************************************************************************************************************
+// initialize static member
+// DON'T DO IT IN YOUR HEADER!
+// see definition for further informations
+//*****************************************************************************************************************
+SvtInternalOptions_Impl* SvtInternalOptions::m_pDataContainer = NULL ;
+sal_Int32 SvtInternalOptions::m_nRefCount = 0 ;
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtInternalOptions::SvtInternalOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already!
+ if( m_pDataContainer == NULL )
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtInternalOptions_Impl::ctor()");
+ m_pDataContainer = new SvtInternalOptions_Impl();
+
+ ItemHolder1::holdConfigItem(E_INTERNALOPTIONS);
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtInternalOptions::~SvtInternalOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Decrease ouer refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pDataContainer;
+ m_pDataContainer = NULL;
+ }
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Mutex& SvtInternalOptions::GetOwnStaticMutex()
+{
+ // Initialize static mutex only for one time!
+ static Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_itemholder1.cxx b/binfilter/bf_svtools/source/config/svt_itemholder1.cxx
new file mode 100644
index 000000000000..63504c93bb4d
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_itemholder1.cxx
@@ -0,0 +1,326 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 "itemholder1.hxx"
+
+//-----------------------------------------------
+// includes
+
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/lang/XComponent.hpp>
+
+#include <bf_svtools/addxmltostorageoptions.hxx>
+#include <cacheoptions.hxx>
+#include <bf_svtools/cmdoptions.hxx>
+#include <bf_svtools/compatibility.hxx>
+#include <bf_svtools/defaultoptions.hxx>
+#include <bf_svtools/dynamicmenuoptions.hxx>
+#include <bf_svtools/extendedsecurityoptions.hxx>
+#include <fltrcfg.hxx>
+#include <bf_svtools/fontoptions.hxx>
+#include <bf_svtools/historyoptions.hxx>
+#include <bf_svtools/inetoptions.hxx>
+#include <bf_svtools/internaloptions.hxx>
+#include <javaoptions.hxx>
+#include <bf_svtools/lingucfg.hxx>
+#include <bf_svtools/localisationoptions.hxx>
+#include <bf_svtools/menuoptions.hxx>
+#include <bf_svtools/moduleoptions.hxx>
+#include <bf_svtools/options3d.hxx>
+#include <bf_svtools/pathoptions.hxx>
+#include <bf_svtools/printwarningoptions.hxx>
+#include <regoptions.hxx>
+#include <bf_svtools/optionsdlg.hxx>
+#include <bf_svtools/saveopt.hxx>
+#include <searchopt.hxx>
+#include <bf_svtools/securityoptions.hxx>
+#include <bf_svtools/sourceviewconfig.hxx>
+#include <bf_svtools/startoptions.hxx>
+#include <bf_svtools/viewoptions.hxx>
+#include <bf_svtools/workingsetoptions.hxx>
+#include <bf_svtools/options.hxx>
+
+//-----------------------------------------------
+// namespaces
+
+namespace css = ::com::sun::star;
+
+namespace binfilter
+{
+
+//-----------------------------------------------
+// declarations
+
+//-----------------------------------------------
+ItemHolder1::ItemHolder1()
+ : ItemHolderMutexBase()
+{
+ try
+ {
+ css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
+ css::uno::Reference< css::lang::XComponent > xCfg(
+ xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")),
+ css::uno::UNO_QUERY);
+ if (xCfg.is())
+ xCfg->addEventListener(static_cast< css::lang::XEventListener* >(this));
+ }
+// #i37892 got errorhandling from ConfigManager::GetConfigurationProvider()
+#ifdef DBG_UTIL
+ catch(css::uno::Exception& rEx)
+ {
+ static sal_Bool bMessage = sal_True;
+ if(bMessage)
+ {
+ bMessage = sal_False;
+ ::rtl::OString sMsg("CreateInstance with arguments exception: ");
+ sMsg += ::rtl::OString(rEx.Message.getStr(),
+ rEx.Message.getLength(),
+ RTL_TEXTENCODING_ASCII_US);
+ OSL_ENSURE(sal_False, sMsg.getStr());
+ }
+ }
+#else
+ catch(css::uno::Exception&){}
+#endif
+}
+
+//-----------------------------------------------
+ItemHolder1::~ItemHolder1()
+{
+ impl_releaseAllItems();
+}
+
+//-----------------------------------------------
+void ItemHolder1::holdConfigItem(EItem eItem)
+{
+ static ItemHolder1* pHolder = new ItemHolder1();
+ pHolder->impl_addItem(eItem);
+}
+
+//-----------------------------------------------
+void SAL_CALL ItemHolder1::disposing(const css::lang::EventObject&)
+ throw(css::uno::RuntimeException)
+{
+ css::uno::Reference< css::uno::XInterface > xSelfHold(static_cast< css::lang::XEventListener* >(this), css::uno::UNO_QUERY);
+ impl_releaseAllItems();
+}
+
+//-----------------------------------------------
+void ItemHolder1::impl_addItem(EItem eItem)
+{
+ ::osl::ResettableMutexGuard aLock(m_aLock);
+
+ TItems::const_iterator pIt;
+ for ( pIt = m_lItems.begin();
+ pIt != m_lItems.end() ;
+ ++pIt )
+ {
+ const TItemInfo& rInfo = *pIt;
+ if (rInfo.eItem == eItem)
+ return;
+ }
+
+ TItemInfo aNewItem;
+ aNewItem.eItem = eItem;
+ impl_newItem(aNewItem);
+ if (aNewItem.pItem)
+ m_lItems.push_back(aNewItem);
+}
+
+//-----------------------------------------------
+void ItemHolder1::impl_releaseAllItems()
+{
+ ::osl::ResettableMutexGuard aLock(m_aLock);
+
+ TItems::iterator pIt;
+ for ( pIt = m_lItems.begin();
+ pIt != m_lItems.end() ;
+ ++pIt )
+ {
+ TItemInfo& rInfo = *pIt;
+ impl_deleteItem(rInfo);
+ }
+ m_lItems.clear();
+}
+
+//-----------------------------------------------
+void ItemHolder1::impl_newItem(TItemInfo& rItem)
+{
+ switch(rItem.eItem)
+ {
+ case E_ADDXMLTOSTORAGEOPTIONS :
+ rItem.pItem = new SvtAddXMLToStorageOptions();
+ break;
+
+ case E_CMDOPTIONS :
+ rItem.pItem = new SvtCommandOptions();
+ break;
+
+ case E_COMPATIBILITY :
+ rItem.pItem = new SvtCompatibilityOptions();
+ break;
+
+ case E_DEFAULTOPTIONS :
+ rItem.pItem = new SvtDefaultOptions();
+ break;
+
+ case E_DYNAMICMENUOPTIONS :
+ rItem.pItem = new SvtDynamicMenuOptions();
+ break;
+
+ case E_EVENTCFG :
+ break;
+
+ case E_EXTENDEDSECURITYOPTIONS :
+ rItem.pItem = new SvtExtendedSecurityOptions();
+ break;
+
+ case E_FLTRCFG :
+ break;
+
+ case E_FONTOPTIONS :
+ rItem.pItem = new SvtFontOptions();
+ break;
+
+ case E_HISTORYOPTIONS :
+ rItem.pItem = new SvtHistoryOptions();
+ break;
+
+ case E_INETOPTIONS :
+ rItem.pItem = new SvtInetOptions();
+ break;
+
+ case E_INTERNALOPTIONS :
+ rItem.pItem = new SvtInternalOptions();
+ break;
+
+ case E_JAVAOPTIONS :
+ break;
+
+ case E_LINGUCFG :
+ rItem.pItem = new SvtLinguConfig();
+ break;
+
+ case E_LOCALISATIONOPTIONS :
+ rItem.pItem = new SvtLocalisationOptions();
+ break;
+
+ case E_MENUOPTIONS :
+ rItem.pItem = new SvtMenuOptions();
+ break;
+
+ case E_MODULEOPTIONS :
+ rItem.pItem = new SvtModuleOptions();
+ break;
+
+ case E_OPTIONSDLGOPTIONS :
+ rItem.pItem = new SvtOptionsDialogOptions();
+ break;
+
+ case E_OPTIONS3D :
+ rItem.pItem = new SvtOptions3D();
+ break;
+
+ case E_PATHOPTIONS :
+ rItem.pItem = new SvtPathOptions();
+ break;
+
+ case E_PRINTWARNINGOPTIONS :
+ rItem.pItem = new SvtPrintWarningOptions();
+ break;
+
+ case E_REGOPTIONS :
+// no ref count rItem.pItem = new ::svt::RegOptions();
+ break;
+
+ case E_SAVEOPTIONS :
+ rItem.pItem = new SvtSaveOptions();
+ break;
+
+ case E_SEARCHOPT :
+// no ref count rItem.pItem = new SvtSearchOptions();
+ break;
+
+ case E_SECURITYOPTIONS :
+ rItem.pItem = new SvtSecurityOptions();
+ break;
+
+ case E_SOURCEVIEWCONFIG :
+ rItem.pItem = new SourceViewConfig();
+ break;
+
+ case E_STARTOPTIONS :
+ rItem.pItem = new SvtStartOptions();
+ break;
+
+ case E_VIEWOPTIONS_DIALOG :
+ rItem.pItem = new SvtViewOptions(E_DIALOG, ::rtl::OUString());
+ break;
+
+ case E_VIEWOPTIONS_TABDIALOG :
+ rItem.pItem = new SvtViewOptions(E_TABDIALOG, ::rtl::OUString());
+ break;
+
+ case E_VIEWOPTIONS_TABPAGE :
+ rItem.pItem = new SvtViewOptions(E_TABPAGE, ::rtl::OUString());
+ break;
+
+ case E_VIEWOPTIONS_WINDOW :
+ rItem.pItem = new SvtViewOptions(E_WINDOW, ::rtl::OUString());
+ break;
+
+ case E_WORKINGSETOPTIONS :
+ rItem.pItem = new SvtWorkingSetOptions();
+ break;
+
+ case E_XMLACCELCFG :
+ // ??? TODO
+ break;
+ default:
+ OSL_ASSERT( "unknown item type" );
+ break;
+ }
+}
+
+//-----------------------------------------------
+void ItemHolder1::impl_deleteItem(TItemInfo& rItem)
+{
+ if (rItem.pItem)
+ {
+ delete rItem.pItem;
+ rItem.pItem = 0;
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_itemholder2.cxx b/binfilter/bf_svtools/source/config/svt_itemholder2.cxx
new file mode 100644
index 000000000000..3e11f9833278
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_itemholder2.cxx
@@ -0,0 +1,237 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 "itemholder2.hxx"
+
+//-----------------------------------------------
+// includes
+
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/lang/XComponent.hpp>
+
+#include <apearcfg.hxx>
+#include <bf_svtools/cjkoptions.hxx>
+#include <bf_svtools/colorcfg.hxx>
+#include <bf_svtools/ctloptions.hxx>
+#include <fontsubstconfig.hxx>
+#include <bf_svtools/helpopt.hxx>
+#include <bf_svtools/languageoptions.hxx>
+#include <misccfg.hxx>
+#include <bf_svtools/printoptions.hxx>
+#include <bf_svtools/syslocaleoptions.hxx>
+#include <bf_svtools/undoopt.hxx>
+#include <bf_svtools/useroptions.hxx>
+#include <bf_svtools/options.hxx>
+#include <bf_svtools/miscopt.hxx>
+
+
+#include <tools/debug.hxx>
+
+//-----------------------------------------------
+// namespaces
+
+namespace css = ::com::sun::star;
+
+namespace binfilter
+{
+
+//-----------------------------------------------
+// declarations
+
+//-----------------------------------------------
+ItemHolder2::ItemHolder2()
+ : ItemHolderMutexBase()
+{
+ try
+ {
+ css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
+ css::uno::Reference< css::lang::XComponent > xCfg(
+ xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")),
+ css::uno::UNO_QUERY);
+ if (xCfg.is())
+ xCfg->addEventListener(static_cast< css::lang::XEventListener* >(this));
+ }
+// #i37892 got errorhandling from ConfigManager::GetConfigurationProvider()
+ catch(css::uno::RuntimeException& rREx)
+ {
+ throw rREx;
+ }
+#ifdef DBG_UTIL
+ catch(css::uno::Exception& rEx)
+ {
+ static sal_Bool bMessage = sal_True;
+ if(bMessage)
+ {
+ bMessage = sal_False;
+ ::rtl::OString sMsg("CreateInstance with arguments exception: ");
+ sMsg += ::rtl::OString(rEx.Message.getStr(),
+ rEx.Message.getLength(),
+ RTL_TEXTENCODING_ASCII_US);
+ DBG_ERROR(sMsg.getStr());
+ }
+ }
+#else
+ catch(css::uno::Exception&){}
+#endif
+}
+
+//-----------------------------------------------
+ItemHolder2::~ItemHolder2()
+{
+ impl_releaseAllItems();
+}
+
+//-----------------------------------------------
+void ItemHolder2::holdConfigItem(EItem eItem)
+{
+ static ItemHolder2* pHolder = new ItemHolder2();
+ pHolder->impl_addItem(eItem);
+}
+
+//-----------------------------------------------
+void SAL_CALL ItemHolder2::disposing(const css::lang::EventObject&)
+ throw(css::uno::RuntimeException)
+{
+ impl_releaseAllItems();
+}
+
+//-----------------------------------------------
+void ItemHolder2::impl_addItem(EItem eItem)
+{
+ ::osl::ResettableMutexGuard aLock(m_aLock);
+
+ TItems::const_iterator pIt;
+ for ( pIt = m_lItems.begin();
+ pIt != m_lItems.end() ;
+ ++pIt )
+ {
+ const TItemInfo& rInfo = *pIt;
+ if (rInfo.eItem == eItem)
+ return;
+ }
+
+ TItemInfo aNewItem;
+ aNewItem.eItem = eItem;
+ impl_newItem(aNewItem);
+ if (aNewItem.pItem)
+ m_lItems.push_back(aNewItem);
+}
+
+//-----------------------------------------------
+void ItemHolder2::impl_releaseAllItems()
+{
+ ::osl::ResettableMutexGuard aLock(m_aLock);
+
+ TItems::iterator pIt;
+ for ( pIt = m_lItems.begin();
+ pIt != m_lItems.end() ;
+ ++pIt )
+ {
+ TItemInfo& rInfo = *pIt;
+ impl_deleteItem(rInfo);
+ }
+ m_lItems.clear();
+}
+
+//-----------------------------------------------
+void ItemHolder2::impl_newItem(TItemInfo& rItem)
+{
+ switch(rItem.eItem)
+ {
+ case E_APEARCFG :
+ break;
+
+ case E_CJKOPTIONS :
+ rItem.pItem = new SvtCJKOptions();
+ break;
+
+ case E_COLORCFG :
+ rItem.pItem = new ColorConfig();
+ break;
+
+ case E_CTLOPTIONS :
+ rItem.pItem = new SvtCTLOptions();
+ break;
+
+ case E_FONTSUBSTCONFIG :
+ break;
+
+ case E_HELPOPTIONS :
+ rItem.pItem = new SvtHelpOptions();
+ break;
+
+ case E_LANGUAGEOPTIONS :
+// capsulate CTL and CJL options ! rItem.pItem = new SvtLanguageOptions();
+ break;
+
+ case E_MISCCFG :
+// no ref count rItem.pItem = new SfxMiscCfg();
+ break;
+
+ case E_PRINTOPTIONS :
+ rItem.pItem = new SvtPrinterOptions();
+ break;
+
+ case E_PRINTFILEOPTIONS :
+ rItem.pItem = new SvtPrintFileOptions();
+ break;
+
+ case E_SYSLOCALEOPTIONS :
+ rItem.pItem = new SvtSysLocaleOptions();
+ break;
+
+ case E_UNDOOPTIONS :
+ rItem.pItem = new SvtUndoOptions();
+ break;
+
+ case E_USEROPTIONS :
+ rItem.pItem = new SvtUserOptions();
+ break;
+ case E_MISCOPTIONS :
+ rItem.pItem = new SvtMiscOptions();
+ break;
+
+ default:
+ OSL_ASSERT(false);
+ break;
+ }
+}
+
+//-----------------------------------------------
+void ItemHolder2::impl_deleteItem(TItemInfo& rItem)
+{
+ if (rItem.pItem)
+ {
+ delete rItem.pItem;
+ rItem.pItem = 0;
+ }
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_languageoptions.cxx b/binfilter/bf_svtools/source/config/svt_languageoptions.cxx
new file mode 100644
index 000000000000..02285954548c
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_languageoptions.cxx
@@ -0,0 +1,121 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/languageoptions.hxx>
+
+#include <bf_svtools/cjkoptions.hxx>
+#include <bf_svtools/ctloptions.hxx>
+#include <vcl/svapp.hxx>
+#include <i18npool/mslangid.hxx>
+
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/instance.hxx>
+
+#include <com/sun/star/i18n/ScriptType.hpp>
+
+using namespace ::com::sun::star;
+// global ----------------------------------------------------------------------
+
+namespace { struct ALMutex : public rtl::Static< ::osl::Mutex, ALMutex > {}; }
+
+namespace binfilter
+{
+
+// -----------------------------------------------------------------------------
+// returns for a language the scripttype
+sal_uInt16 SvtLanguageOptions::GetScriptTypeOfLanguage( sal_uInt16 nLang )
+{
+ if( LANGUAGE_DONTKNOW == nLang )
+ nLang = LANGUAGE_ENGLISH_US;
+ else if( LANGUAGE_SYSTEM == nLang )
+ nLang = Application::GetSettings().GetLanguage();
+
+ sal_Int16 nScriptType = MsLangId::getScriptType( nLang );
+ USHORT nScript;
+ switch (nScriptType)
+ {
+ case ::com::sun::star::i18n::ScriptType::ASIAN:
+ nScript = SCRIPTTYPE_ASIAN;
+ break;
+ case ::com::sun::star::i18n::ScriptType::COMPLEX:
+ nScript = SCRIPTTYPE_COMPLEX;
+ break;
+ default:
+ nScript = SCRIPTTYPE_LATIN;
+ }
+ return nScript;
+}
+// -----------------------------------------------------------------------------
+
+
+/*-- 27.10.2005 08:18:01---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SvtSystemLanguageOptions::SvtSystemLanguageOptions() :
+ utl::ConfigItem( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("System/L10N") ))
+{
+ uno::Sequence< rtl::OUString > aPropertyNames(1);
+ rtl::OUString* pNames = aPropertyNames.getArray();
+ pNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SystemLocale"));
+ uno::Sequence< uno::Any > aValues = GetProperties( aPropertyNames );
+
+ if ( aValues.getLength() )
+ {
+ aValues[0]>>= m_sWin16SystemLocale;
+ }
+}
+/*-- 27.10.2005 08:18:01---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SvtSystemLanguageOptions::~SvtSystemLanguageOptions()
+{
+}
+/*-- 27.10.2005 08:18:02---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SvtSystemLanguageOptions::Commit()
+{
+ //does nothing
+}
+/*-- 27.10.2005 08:36:14---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+LanguageType SvtSystemLanguageOptions::GetWin16SystemLanguage()
+{
+ if( m_sWin16SystemLocale.getLength() == 0 )
+ return LANGUAGE_NONE;
+ return MsLangId::convertIsoStringToLanguage( m_sWin16SystemLocale );
+}
+
+ void SvtSystemLanguageOptions::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_lingucfg.cxx b/binfilter/bf_svtools/source/config/svt_lingucfg.cxx
new file mode 100644
index 000000000000..7b73d283564b
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_lingucfg.cxx
@@ -0,0 +1,570 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <com/sun/star/lang/Locale.hpp>
+
+#include <i18npool/mslangid.hxx>
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+#include <sal/macros.h>
+
+#include <bf_svtools/lingucfg.hxx>
+#include <linguprops.hxx>
+
+#include <itemholder1.hxx>
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::lang;
+
+namespace binfilter
+{
+
+#define A2OU(x) ::rtl::OUString::createFromAscii( x )
+
+///////////////////////////////////////////////////////////////////////////
+
+
+static osl::Mutex & GetOwnMutex()
+{
+ static osl::Mutex aMutex;
+ return aMutex;
+}
+
+
+///////////////////////////////////////////////////////////////////////////
+
+
+static inline INT16 lcl_CfgLocaleStrToLanguage( const OUString &rCfgLocaleStr )
+{
+ INT16 nRes = LANGUAGE_NONE;
+ if (0 != rCfgLocaleStr.getLength())
+ nRes = MsLangId::convertIsoStringToLanguage( rCfgLocaleStr );
+ return nRes;
+}
+
+
+static inline const OUString lcl_LanguageToCfgLocaleStr( INT16 nLanguage )
+{
+ OUString aRes;
+ if (LANGUAGE_NONE != nLanguage)
+ aRes = MsLangId::convertLanguageToIsoString( nLanguage );
+ return aRes;
+}
+
+
+static void lcl_CfgAnyToLanguage( const Any &rVal, INT16& rLanguage )
+{
+ OUString aTmp;
+ if ((rVal >>= aTmp) && 0 != aTmp.getLength())
+ rLanguage = MsLangId::convertIsoStringToLanguage( aTmp );
+}
+
+
+//////////////////////////////////////////////////////////////////////
+
+SvtLinguOptions::SvtLinguOptions()
+{
+ nDefaultLanguage = LANGUAGE_NONE;
+
+ nDefaultLanguage_CJK = LANGUAGE_NONE;
+ nDefaultLanguage_CTL = LANGUAGE_NONE;
+
+ // general options
+ bIsGermanPreReform = FALSE;
+ bIsUseDictionaryList =
+ bIsIgnoreControlCharacters = TRUE;
+
+ // spelling options
+ bIsSpellCapitalization =
+ bIsSpellSpecial = TRUE;
+ bIsSpellAuto =
+ bIsSpellInAllLanguages =
+ bIsSpellHideMarkings =
+ bIsSpellReverse =
+ bIsSpellWithDigits =
+ bIsSpellUpperCase = FALSE;
+
+ // text conversion options
+ bIsIgnorePostPositionalWord = TRUE;
+ bIsAutoCloseDialog =
+ bIsShowEntriesRecentlyUsedFirst =
+ bIsAutoReplaceUniqueEntries = FALSE;
+ bIsDirectionToSimplified = TRUE;
+ bIsUseCharacterVariants =
+ bIsTranslateCommonTerms =
+ bIsReverseMapping = FALSE;
+
+ bROIsDirectionToSimplified =
+ bROIsUseCharacterVariants =
+ bROIsTranslateCommonTerms =
+ bROIsReverseMapping = FALSE;
+
+ // hyphenation options
+ bIsHyphSpecial = TRUE;
+ bIsHyphAuto = FALSE;
+ nHyphMinLeading =
+ nHyphMinTrailing = 2;
+ nHyphMinWordLength = 0;
+
+ nDataFilesChangedCheckValue = 0;
+}
+
+
+//////////////////////////////////////////////////////////////////////
+
+
+class SvtLinguConfigItem : public utl::ConfigItem
+{
+ SvtLinguOptions aOpt;
+
+ // disallow copy-constructor and assignment-operator for now
+ SvtLinguConfigItem( const SvtLinguConfigItem & );
+ SvtLinguConfigItem & operator = ( const SvtLinguConfigItem & );
+
+ static BOOL GetHdlByName( INT32 &rnHdl, const OUString &rPropertyName, sal_Bool bFullPropName = sal_False );
+ static const Sequence< OUString > & GetPropertyNames();
+ BOOL LoadOptions( const Sequence< OUString > &rProperyNames );
+ BOOL SaveOptions( const Sequence< OUString > &rProperyNames );
+
+public:
+ SvtLinguConfigItem();
+ virtual ~SvtLinguConfigItem();
+
+ // utl::ConfigItem
+ virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString > &rPropertyNames );
+ virtual void Commit();
+
+ // make some protected functions of utl::ConfigItem public
+ using utl::ConfigItem::GetNodeNames;
+ using utl::ConfigItem::GetProperties;
+ //using utl::ConfigItem::PutProperties;
+ //using utl::ConfigItem::SetSetProperties;
+ using utl::ConfigItem::ReplaceSetProperties;
+ //using utl::ConfigItem::GetReadOnlyStates;
+
+ BOOL GetOptions( SvtLinguOptions &rOptions ) const;
+};
+
+
+SvtLinguConfigItem::SvtLinguConfigItem() :
+ utl::ConfigItem( String::CreateFromAscii( "Office.Linguistic" ) )
+{
+ LoadOptions( GetPropertyNames() );
+ ClearModified();
+
+ // request notify events when properties change
+ EnableNotification( GetPropertyNames() );
+}
+
+
+SvtLinguConfigItem::~SvtLinguConfigItem()
+{
+ //! Commit (SaveOptions) will be called by the d-tor of the base called !
+}
+
+
+void SvtLinguConfigItem::Notify( const Sequence< OUString > &rPropertyNames )
+{
+ LoadOptions( rPropertyNames );
+}
+
+
+void SvtLinguConfigItem::Commit()
+{
+ SaveOptions( GetPropertyNames() );
+}
+
+
+static struct NamesToHdl
+{
+ const char *pFullPropName; // full qualified name as used in configuration
+ const char *pPropName; // property name only (atom) of above
+ INT32 nHdl; // numeric handle representing the property
+}aNamesToHdl[] =
+{
+{/* 0 */ "General/DefaultLocale", UPN_DEFAULT_LOCALE, UPH_DEFAULT_LOCALE},
+{/* 1 */ "General/DictionaryList/ActiveDictionaries", UPN_ACTIVE_DICTIONARIES, UPH_ACTIVE_DICTIONARIES},
+{/* 2 */ "General/DictionaryList/IsUseDictionaryList", UPN_IS_USE_DICTIONARY_LIST, UPH_IS_USE_DICTIONARY_LIST},
+{/* 3 */ "General/IsIgnoreControlCharacters", UPN_IS_IGNORE_CONTROL_CHARACTERS, UPH_IS_IGNORE_CONTROL_CHARACTERS},
+{/* 4 */ "General/IsGermanPreReform", UPN_IS_GERMAN_PRE_REFORM, UPH_IS_GERMAN_PRE_REFORM},
+{/* 5 */ "General/DefaultLocale_CJK", UPN_DEFAULT_LOCALE_CJK, UPH_DEFAULT_LOCALE_CJK},
+{/* 6 */ "General/DefaultLocale_CTL", UPN_DEFAULT_LOCALE_CTL, UPH_DEFAULT_LOCALE_CTL},
+
+{/* 7 */ "SpellChecking/IsSpellUpperCase", UPN_IS_SPELL_UPPER_CASE, UPH_IS_SPELL_UPPER_CASE},
+{/* 8 */ "SpellChecking/IsSpellWithDigits", UPN_IS_SPELL_WITH_DIGITS, UPH_IS_SPELL_WITH_DIGITS},
+{/* 9 */ "SpellChecking/IsSpellCapitalization", UPN_IS_SPELL_CAPITALIZATION, UPH_IS_SPELL_CAPITALIZATION},
+{/* 10 */ "SpellChecking/IsSpellAuto", UPN_IS_SPELL_AUTO, UPH_IS_SPELL_AUTO},
+{/* 11 */ "SpellChecking/IsSpellSpecial", UPN_IS_SPELL_SPECIAL, UPH_IS_SPELL_SPECIAL},
+{/* 12 */ "SpellChecking/IsSpellInAllLocales", UPN_IS_SPELL_IN_ALL_LANGUAGES, UPH_IS_SPELL_IN_ALL_LANGUAGES},
+{/* 13 */ "SpellChecking/IsHideMarkings", UPN_IS_SPELL_HIDE, UPH_IS_SPELL_HIDE},
+{/* 14 */ "SpellChecking/IsReverseDirection", UPN_IS_WRAP_REVERSE, UPH_IS_WRAP_REVERSE},
+
+{/* 15 */ "Hyphenation/MinLeading", UPN_HYPH_MIN_LEADING, UPH_HYPH_MIN_LEADING},
+{/* 16 */ "Hyphenation/MinTrailing", UPN_HYPH_MIN_TRAILING, UPH_HYPH_MIN_TRAILING},
+{/* 17 */ "Hyphenation/MinWordLength", UPN_HYPH_MIN_WORD_LENGTH, UPH_HYPH_MIN_WORD_LENGTH},
+{/* 18 */ "Hyphenation/IsHyphSpecial", UPN_IS_HYPH_SPECIAL, UPH_IS_HYPH_SPECIAL},
+{/* 19 */ "Hyphenation/IsHyphAuto", UPN_IS_HYPH_AUTO, UPH_IS_HYPH_AUTO},
+
+{/* 20 */ "TextConversion/ActiveConversionDictionaries", UPN_ACTIVE_CONVERSION_DICTIONARIES, UPH_ACTIVE_CONVERSION_DICTIONARIES},
+{/* 21 */ "TextConversion/IsIgnorePostPositionalWord", UPN_IS_IGNORE_POST_POSITIONAL_WORD, UPH_IS_IGNORE_POST_POSITIONAL_WORD},
+{/* 22 */ "TextConversion/IsAutoCloseDialog", UPN_IS_AUTO_CLOSE_DIALOG, UPH_IS_AUTO_CLOSE_DIALOG},
+{/* 23 */ "TextConversion/IsShowEntriesRecentlyUsedFirst", UPN_IS_SHOW_ENTRIES_RECENTLY_USED_FIRST, UPH_IS_SHOW_ENTRIES_RECENTLY_USED_FIRST},
+{/* 24 */ "TextConversion/IsAutoReplaceUniqueEntries", UPN_IS_AUTO_REPLACE_UNIQUE_ENTRIES, UPH_IS_AUTO_REPLACE_UNIQUE_ENTRIES},
+{/* 25 */ "TextConversion/IsDirectionToSimplified", UPN_IS_DIRECTION_TO_SIMPLIFIED, UPH_IS_DIRECTION_TO_SIMPLIFIED},
+{/* 26 */ "TextConversion/IsUseCharacterVariants", UPN_IS_USE_CHARACTER_VARIANTS, UPH_IS_USE_CHARACTER_VARIANTS},
+{/* 27 */ "TextConversion/IsTranslateCommonTerms", UPN_IS_TRANSLATE_COMMON_TERMS, UPH_IS_TRANSLATE_COMMON_TERMS},
+{/* 28 */ "TextConversion/IsReverseMapping", UPN_IS_REVERSE_MAPPING, UPH_IS_REVERSE_MAPPING},
+
+{/* 29 */ "ServiceManager/DataFilesChangedCheckValue", UPN_DATA_FILES_CHANGED_CHECK_VALUE, UPH_DATA_FILES_CHANGED_CHECK_VALUE},
+
+ /* similar to entry 0 (thus no own configuration entry) but with different property name and type */
+{ NULL, UPN_DEFAULT_LANGUAGE, UPH_DEFAULT_LANGUAGE},
+
+{ NULL, NULL, -1}
+};
+
+
+const Sequence< OUString > & SvtLinguConfigItem::GetPropertyNames()
+{
+ static Sequence< OUString > aNames;
+ static sal_Bool bInitialized = sal_False;
+
+ if (!bInitialized)
+ {
+ INT32 nMax = SAL_N_ELEMENTS(aNamesToHdl);
+
+ aNames.realloc( nMax );
+ OUString *pNames = aNames.getArray();
+ INT32 nIdx = 0;
+ for (INT32 i = 0; i < nMax; ++i)
+ {
+ const sal_Char *pFullPropName = aNamesToHdl[i].pFullPropName;
+ if (pFullPropName)
+ pNames[ nIdx++ ] = A2OU( pFullPropName );
+ }
+ aNames.realloc( nIdx );
+ bInitialized = sal_True;
+ }
+ return aNames;
+}
+
+
+BOOL SvtLinguConfigItem::GetHdlByName(
+ INT32 &rnHdl,
+ const OUString &rPropertyName,
+ sal_Bool bFullPropName )
+{
+ NamesToHdl *pEntry = &aNamesToHdl[0];
+
+ if (bFullPropName)
+ {
+ while (pEntry && pEntry->pFullPropName != NULL)
+ {
+ if (0 == rPropertyName.compareToAscii( pEntry->pFullPropName ))
+ {
+ rnHdl = pEntry->nHdl;
+ break;
+ }
+ ++pEntry;
+ }
+ return pEntry && pEntry->pFullPropName != NULL;
+ }
+ else
+ {
+ while (pEntry && pEntry->pPropName != NULL)
+ {
+ if (0 == rPropertyName.compareToAscii( pEntry->pPropName ))
+ {
+ rnHdl = pEntry->nHdl;
+ break;
+ }
+ ++pEntry;
+ }
+ return pEntry && pEntry->pPropName != NULL;
+ }
+}
+
+BOOL SvtLinguConfigItem::GetOptions( SvtLinguOptions &rOptions ) const
+{
+ osl::MutexGuard aGuard( GetOwnMutex() );
+
+ rOptions = aOpt;
+ return TRUE;
+}
+
+BOOL SvtLinguConfigItem::LoadOptions( const Sequence< OUString > &rProperyNames )
+{
+ osl::MutexGuard aGuard( GetOwnMutex() );
+
+ BOOL bRes = FALSE;
+
+ const OUString *pProperyNames = rProperyNames.getConstArray();
+ INT32 nProps = rProperyNames.getLength();
+
+ const Sequence< Any > aValues = GetProperties( rProperyNames );
+ const Sequence< sal_Bool > aROStates = GetReadOnlyStates( rProperyNames );
+
+ if (nProps && aValues.getLength() == nProps && aROStates.getLength() == nProps)
+ {
+ SvtLinguOptions &rOpt = aOpt;
+
+ const Any *pValue = aValues.getConstArray();
+ const sal_Bool *pROStates = aROStates.getConstArray();
+ for (INT32 i = 0; i < nProps; ++i)
+ {
+ const Any &rVal = pValue[i];
+ INT32 nPropertyHandle;
+ GetHdlByName( nPropertyHandle, pProperyNames[i], sal_True );
+ switch ( nPropertyHandle )
+ {
+ case UPH_DEFAULT_LOCALE :
+ { rOpt.bRODefaultLanguage = pROStates[i]; lcl_CfgAnyToLanguage( rVal, rOpt.nDefaultLanguage ); } break;
+ case UPH_ACTIVE_DICTIONARIES :
+ { rOpt.bROActiveDics = pROStates[i]; rVal >>= rOpt.aActiveDics; } break;
+ case UPH_IS_USE_DICTIONARY_LIST :
+ { rOpt.bROIsUseDictionaryList = pROStates[i]; rVal >>= rOpt.bIsUseDictionaryList; } break;
+ case UPH_IS_IGNORE_CONTROL_CHARACTERS :
+ { rOpt.bROIsIgnoreControlCharacters = pROStates[i]; rVal >>= rOpt.bIsIgnoreControlCharacters; } break;
+ case UPH_IS_GERMAN_PRE_REFORM :
+ { rOpt.bROIsGermanPreReform = pROStates[i]; rVal >>= rOpt.bIsGermanPreReform; } break;
+ case UPH_DEFAULT_LOCALE_CJK :
+ { rOpt.bRODefaultLanguage_CJK = pROStates[i]; lcl_CfgAnyToLanguage( rVal, rOpt.nDefaultLanguage_CJK ); } break;
+ case UPH_DEFAULT_LOCALE_CTL :
+ { rOpt.bRODefaultLanguage_CTL = pROStates[i]; lcl_CfgAnyToLanguage( rVal, rOpt.nDefaultLanguage_CTL ); } break;
+
+ case UPH_IS_SPELL_UPPER_CASE :
+ { rOpt.bROIsSpellUpperCase = pROStates[i]; rVal >>= rOpt.bIsSpellUpperCase; } break;
+ case UPH_IS_SPELL_WITH_DIGITS :
+ { rOpt.bROIsSpellWithDigits = pROStates[i]; rVal >>= rOpt.bIsSpellWithDigits; } break;
+ case UPH_IS_SPELL_CAPITALIZATION :
+ { rOpt.bROIsSpellCapitalization = pROStates[i]; rVal >>= rOpt.bIsSpellCapitalization; } break;
+ case UPH_IS_SPELL_AUTO :
+ { rOpt.bROIsSpellAuto = pROStates[i]; rVal >>= rOpt.bIsSpellAuto; } break;
+ case UPH_IS_SPELL_SPECIAL :
+ { rOpt.bROIsSpellSpecial = pROStates[i]; rVal >>= rOpt.bIsSpellSpecial; } break;
+ case UPH_IS_SPELL_IN_ALL_LANGUAGES :
+ { rOpt.bROIsSpellInAllLanguages = pROStates[i]; rVal >>= rOpt.bIsSpellInAllLanguages; } break;
+ case UPH_IS_SPELL_HIDE :
+ { rOpt.bROIsSpellHideMarkings = pROStates[i]; rVal >>= rOpt.bIsSpellHideMarkings; } break;
+ case UPH_IS_WRAP_REVERSE :
+ { rOpt.bROIsSpellReverse = pROStates[i]; rVal >>= rOpt.bIsSpellReverse; } break;
+
+ case UPH_HYPH_MIN_LEADING :
+ { rOpt.bROHyphMinLeading = pROStates[i]; rVal >>= rOpt.nHyphMinLeading; } break;
+ case UPH_HYPH_MIN_TRAILING :
+ { rOpt.bROHyphMinTrailing = pROStates[i]; rVal >>= rOpt.nHyphMinTrailing; } break;
+ case UPH_HYPH_MIN_WORD_LENGTH :
+ { rOpt.bROHyphMinWordLength = pROStates[i]; rVal >>= rOpt.nHyphMinWordLength; } break;
+ case UPH_IS_HYPH_SPECIAL :
+ { rOpt.bROIsHyphSpecial = pROStates[i]; rVal >>= rOpt.bIsHyphSpecial; } break;
+ case UPH_IS_HYPH_AUTO :
+ { rOpt.bROIsHyphAuto = pROStates[i]; rVal >>= rOpt.bIsHyphAuto; } break;
+
+ case UPH_ACTIVE_CONVERSION_DICTIONARIES : { rOpt.bROActiveConvDics = pROStates[i]; rVal >>= rOpt.aActiveConvDics; } break;
+
+ case UPH_IS_IGNORE_POST_POSITIONAL_WORD :
+ { rOpt.bROIsIgnorePostPositionalWord = pROStates[i]; rVal >>= rOpt.bIsIgnorePostPositionalWord; } break;
+ case UPH_IS_AUTO_CLOSE_DIALOG :
+ { rOpt.bROIsAutoCloseDialog = pROStates[i]; rVal >>= rOpt.bIsAutoCloseDialog; } break;
+ case UPH_IS_SHOW_ENTRIES_RECENTLY_USED_FIRST :
+ { rOpt.bROIsShowEntriesRecentlyUsedFirst = pROStates[i]; rVal >>= rOpt.bIsShowEntriesRecentlyUsedFirst; } break;
+ case UPH_IS_AUTO_REPLACE_UNIQUE_ENTRIES :
+ { rOpt.bROIsAutoReplaceUniqueEntries = pROStates[i]; rVal >>= rOpt.bIsAutoReplaceUniqueEntries; } break;
+
+ case UPH_IS_DIRECTION_TO_SIMPLIFIED :
+ { rOpt.bROIsDirectionToSimplified = pROStates[i];
+ if( ! (rVal >>= rOpt.bIsDirectionToSimplified) )
+ {
+ //default is locale dependent:
+ if( rOpt.nDefaultLanguage_CJK == LANGUAGE_CHINESE_HONGKONG
+ || rOpt.nDefaultLanguage_CJK == LANGUAGE_CHINESE_MACAU
+ || rOpt.nDefaultLanguage_CJK == LANGUAGE_CHINESE_TRADITIONAL )
+ {
+ rOpt.bIsDirectionToSimplified = FALSE;
+ }
+ else
+ {
+ rOpt.bIsDirectionToSimplified = TRUE;
+ }
+ }
+ } break;
+ case UPH_IS_USE_CHARACTER_VARIANTS :
+ { rOpt.bROIsUseCharacterVariants = pROStates[i]; rVal >>= rOpt.bIsUseCharacterVariants; } break;
+ case UPH_IS_TRANSLATE_COMMON_TERMS :
+ { rOpt.bROIsTranslateCommonTerms = pROStates[i]; rVal >>= rOpt.bIsTranslateCommonTerms; } break;
+ case UPH_IS_REVERSE_MAPPING :
+ { rOpt.bROIsReverseMapping = pROStates[i]; rVal >>= rOpt.bIsReverseMapping; } break;
+
+ case UPH_DATA_FILES_CHANGED_CHECK_VALUE :
+ { rOpt.bRODataFilesChangedCheckValue = pROStates[i]; rVal >>= rOpt.nDataFilesChangedCheckValue; } break;
+ default:
+ DBG_ERROR( "unexpected case" );
+ }
+ }
+
+ bRes = TRUE;
+ }
+ DBG_ASSERT( bRes, "LoadOptions failed" );
+
+ return bRes;
+}
+
+
+BOOL SvtLinguConfigItem::SaveOptions( const Sequence< OUString > &rProperyNames )
+{
+ if (!IsModified())
+ return TRUE;
+
+ osl::MutexGuard aGuard( GetOwnMutex() );
+
+ BOOL bRet = FALSE;
+ const Type &rBOOL = ::getBooleanCppuType();
+ const Type &rINT16 = ::getCppuType( (INT16 *) NULL );
+ const Type &rINT32 = ::getCppuType( (INT32 *) NULL );
+
+ INT32 nProps = rProperyNames.getLength();
+ Sequence< Any > aValues( nProps );
+ Any *pValue = aValues.getArray();
+
+ if (nProps && aValues.getLength() == nProps)
+ {
+ const SvtLinguOptions &rOpt = aOpt;
+
+ OUString aTmp( lcl_LanguageToCfgLocaleStr( rOpt.nDefaultLanguage ) );
+ *pValue++ = makeAny( aTmp ); // 0
+ *pValue++ = makeAny( rOpt.aActiveDics ); // 1
+ pValue++->setValue( &rOpt.bIsUseDictionaryList, rBOOL ); // 2
+ pValue++->setValue( &rOpt.bIsIgnoreControlCharacters, rBOOL ); // 3
+ pValue++->setValue( &rOpt.bIsGermanPreReform, rBOOL ); // 4
+ aTmp = lcl_LanguageToCfgLocaleStr( rOpt.nDefaultLanguage_CJK );
+ *pValue++ = makeAny( aTmp ); // 5
+ aTmp = lcl_LanguageToCfgLocaleStr( rOpt.nDefaultLanguage_CTL );
+ *pValue++ = makeAny( aTmp ); // 6
+
+ pValue++->setValue( &rOpt.bIsSpellUpperCase, rBOOL ); // 7
+ pValue++->setValue( &rOpt.bIsSpellWithDigits, rBOOL ); // 8
+ pValue++->setValue( &rOpt.bIsSpellCapitalization, rBOOL ); // 9
+ pValue++->setValue( &rOpt.bIsSpellAuto, rBOOL ); // 10
+ pValue++->setValue( &rOpt.bIsSpellSpecial, rBOOL ); // 11
+ pValue++->setValue( &rOpt.bIsSpellInAllLanguages, rBOOL ); // 12
+ pValue++->setValue( &rOpt.bIsSpellHideMarkings, rBOOL ); // 13
+ pValue++->setValue( &rOpt.bIsSpellReverse, rBOOL ); // 14
+
+ pValue++->setValue( &rOpt.nHyphMinLeading, rINT16 ); // 15
+ pValue++->setValue( &rOpt.nHyphMinTrailing, rINT16 ); // 16
+ pValue++->setValue( &rOpt.nHyphMinWordLength, rINT16 ); // 17
+ pValue++->setValue( &rOpt.bIsHyphSpecial, rBOOL ); // 18
+ pValue++->setValue( &rOpt.bIsHyphAuto, rBOOL ); // 19
+
+ *pValue++ = makeAny( rOpt.aActiveConvDics ); // 20
+
+ pValue++->setValue( &rOpt.bIsIgnorePostPositionalWord, rBOOL ); // 21
+ pValue++->setValue( &rOpt.bIsAutoCloseDialog, rBOOL ); // 22
+ pValue++->setValue( &rOpt.bIsShowEntriesRecentlyUsedFirst, rBOOL ); // 23
+ pValue++->setValue( &rOpt.bIsAutoReplaceUniqueEntries, rBOOL ); // 24
+
+ pValue++->setValue( &rOpt.bIsDirectionToSimplified, rBOOL ); // 25
+ pValue++->setValue( &rOpt.bIsUseCharacterVariants, rBOOL ); // 26
+ pValue++->setValue( &rOpt.bIsTranslateCommonTerms, rBOOL ); // 27
+ pValue++->setValue( &rOpt.bIsReverseMapping, rBOOL ); // 28
+
+ pValue++->setValue( &rOpt.nDataFilesChangedCheckValue, rINT32 ); // 29
+
+ bRet |= PutProperties( rProperyNames, aValues );
+ }
+
+ if (bRet)
+ ClearModified();
+
+ return bRet;
+}
+
+//////////////////////////////////////////////////////////////////////
+
+static SvtLinguConfigItem *pCfgItem = 0;
+static sal_Int32 nCfgItemRefCount = 0;
+
+
+SvtLinguConfig::SvtLinguConfig()
+{
+ // Global access, must be guarded (multithreading)
+ osl::MutexGuard aGuard( GetOwnMutex() );
+ ++nCfgItemRefCount;
+}
+
+
+SvtLinguConfig::~SvtLinguConfig()
+{
+ osl::MutexGuard aGuard( GetOwnMutex() );
+
+ if (pCfgItem && pCfgItem->IsModified())
+ pCfgItem->Commit();
+
+ if (--nCfgItemRefCount <= 0)
+ {
+ if (pCfgItem)
+ delete pCfgItem;
+ pCfgItem = 0;
+ }
+}
+
+
+SvtLinguConfigItem & SvtLinguConfig::GetConfigItem()
+{
+ // Global access, must be guarded (multithreading)
+ osl::MutexGuard aGuard( GetOwnMutex() );
+ if (!pCfgItem)
+ {
+ pCfgItem = new SvtLinguConfigItem;
+ ItemHolder1::holdConfigItem(E_LINGUCFG);
+ }
+ ++nCfgItemRefCount;
+ return *pCfgItem;
+}
+
+
+Sequence< OUString > SvtLinguConfig::GetNodeNames( const OUString &rNode )
+{
+ return GetConfigItem().GetNodeNames( rNode );
+}
+
+
+BOOL SvtLinguConfig::GetOptions( SvtLinguOptions &rOptions ) const
+{
+ return GetConfigItem().GetOptions( rOptions );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_localisationoptions.cxx b/binfilter/bf_svtools/source/config/svt_localisationoptions.cxx
new file mode 100644
index 000000000000..da702bef9e4d
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_localisationoptions.cxx
@@ -0,0 +1,373 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+//_________________________________________________________________________________________________________________
+// includes
+//_________________________________________________________________________________________________________________
+
+#include <bf_svtools/localisationoptions.hxx>
+
+#include <unotools/configmgr.hxx>
+
+#include <unotools/configitem.hxx>
+
+#include <tools/debug.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <rtl/logfile.hxx>
+#include "itemholder1.hxx"
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+using namespace ::utl ;
+using namespace ::rtl ;
+using namespace ::osl ;
+using namespace ::com::sun::star::uno ;
+
+namespace binfilter
+{
+
+//_________________________________________________________________________________________________________________
+// const
+//_________________________________________________________________________________________________________________
+
+#define ROOTNODE_LOCALISATION OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/View/Localisation"))
+#define DEFAULT_AUTOMNEMONIC sal_False
+#define DEFAULT_DIALOGSCALE 0
+
+#define PROPERTYNAME_AUTOMNEMONIC OUString(RTL_CONSTASCII_USTRINGPARAM("AutoMnemonic" ))
+#define PROPERTYNAME_DIALOGSCALE OUString(RTL_CONSTASCII_USTRINGPARAM("DialogScale" ))
+
+#define PROPERTYHANDLE_AUTOMNEMONIC 0
+#define PROPERTYHANDLE_DIALOGSCALE 1
+
+#define PROPERTYCOUNT 2
+
+//_________________________________________________________________________________________________________________
+// private declarations!
+//_________________________________________________________________________________________________________________
+
+class SvtLocalisationOptions_Impl : public ConfigItem
+{
+ //-------------------------------------------------------------------------------------------------------------
+ // public methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ public:
+
+ //---------------------------------------------------------------------------------------------------------
+ // constructor / destructor
+ //---------------------------------------------------------------------------------------------------------
+
+ SvtLocalisationOptions_Impl();
+ ~SvtLocalisationOptions_Impl();
+
+ //---------------------------------------------------------------------------------------------------------
+ // overloaded methods of baseclass
+ //---------------------------------------------------------------------------------------------------------
+
+ /*-****************************************************************************************************//**
+ @short called for notify of configmanager
+ @descr These method is called from the ConfigManager before application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. You must update your
+ internal values.
+
+ @seealso baseclass ConfigItem
+
+ @param "seqPropertyNames" is the list of properties which should be updated.
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Notify( const Sequence< OUString >& seqPropertyNames );
+
+ /*-****************************************************************************************************//**
+ @short write changes to configuration
+ @descr These method writes the changed values into the sub tree
+ and should always called in our destructor to guarantee consistency of config data.
+
+ @seealso baseclass ConfigItem
+
+ @param -
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Commit();
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ /*-****************************************************************************************************//**
+ @short return list of key names of ouer configuration management which represent oue module tree
+ @descr These methods return a static const list of key names. We need it to get needed values from our
+ configuration management.
+
+ @seealso -
+
+ @param -
+ @return A list of needed configuration keys is returned.
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ static Sequence< OUString > GetPropertyNames();
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private member
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ sal_Bool m_bAutoMnemonic ;
+ sal_Int32 m_nDialogScale ;
+};
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtLocalisationOptions_Impl::SvtLocalisationOptions_Impl()
+ // Init baseclasses first
+ : ConfigItem ( ROOTNODE_LOCALISATION )
+ // Init member then.
+ , m_bAutoMnemonic ( DEFAULT_AUTOMNEMONIC )
+ , m_nDialogScale ( DEFAULT_DIALOGSCALE )
+{
+ // Use our static list of configuration keys to get his values.
+ Sequence< OUString > seqNames = GetPropertyNames ( );
+ Sequence< Any > seqValues = GetProperties ( seqNames );
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtLocalisationOptions_Impl::SvtLocalisationOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to ouer internal member.
+ sal_Int32 nPropertyCount = seqValues.getLength();
+ for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ // Safe impossible cases.
+ // Check any for valid value.
+ DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtLocalisationOptions_Impl::SvtLocalisationOptions_Impl()\nInvalid property value detected!\n" );
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_AUTOMNEMONIC : {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtLocalisationOptions_Impl::SvtLocalisationOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Localisation\\AutoMnemonic\"?" );
+ seqValues[nProperty] >>= m_bAutoMnemonic;
+ }
+ break;
+
+ case PROPERTYHANDLE_DIALOGSCALE : {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtLocalisationOptions_Impl::SvtLocalisationOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Localisation\\DialogScale\"?" );
+ seqValues[nProperty] >>= m_nDialogScale;
+ }
+ break;
+ }
+ }
+
+ // Enable notification mechanism of ouer baseclass.
+ // We need it to get information about changes outside these class on ouer used configuration keys!
+ EnableNotification( seqNames );
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtLocalisationOptions_Impl::~SvtLocalisationOptions_Impl()
+{
+ // We must save our current values .. if user forget it!
+ if( IsModified() == sal_True )
+ {
+ Commit();
+ }
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtLocalisationOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames )
+{
+ // Use given list of updated properties to get his values from configuration directly!
+ Sequence< Any > seqValues = GetProperties( seqPropertyNames );
+ // Safe impossible cases.
+ // We need values from ALL notified configuration keys.
+ DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtLocalisationOptions_Impl::Notify()\nI miss some values of configuration keys!\n" );
+ // Step over list of property names and get right value from coreesponding value list to set it on internal members!
+ sal_Int32 nCount = seqPropertyNames.getLength();
+ for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
+ {
+ if( seqPropertyNames[nProperty] == PROPERTYNAME_AUTOMNEMONIC )
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtLocalisationOptions_Impl::SvtLocalisationOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Localisation\\AutoMnemonic\"?" );
+ seqValues[nProperty] >>= m_bAutoMnemonic;
+ }
+ else
+ if( seqPropertyNames[nProperty] == PROPERTYNAME_DIALOGSCALE )
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtLocalisationOptions_Impl::SvtLocalisationOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Localisation\\DialogScale\"?" );
+ seqValues[nProperty] >>= m_nDialogScale;
+ }
+ #if OSL_DEBUG_LEVEL > 1
+ else DBG_ASSERT( sal_False, "SvtLocalisationOptions_Impl::Notify()\nUnkown property detected ... I can't handle these!\n" );
+ #endif
+ }
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtLocalisationOptions_Impl::Commit()
+{
+ // Get names of supported properties, create a list for values and copy current values to it.
+ Sequence< OUString > seqNames = GetPropertyNames ();
+ sal_Int32 nCount = seqNames.getLength();
+ Sequence< Any > seqValues ( nCount );
+ for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
+ {
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_AUTOMNEMONIC : {
+ seqValues[nProperty] <<= m_bAutoMnemonic;
+ }
+ break;
+
+ case PROPERTYHANDLE_DIALOGSCALE : {
+ seqValues[nProperty] <<= m_nDialogScale;
+ }
+ break;
+ }
+ }
+ // Set properties in configuration.
+ PutProperties( seqNames, seqValues );
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Sequence< OUString > SvtLocalisationOptions_Impl::GetPropertyNames()
+{
+ // Build static list of configuration key names.
+ static const OUString pProperties[] =
+ {
+ PROPERTYNAME_AUTOMNEMONIC ,
+ PROPERTYNAME_DIALOGSCALE ,
+ };
+ // Initialize return sequence with these list ...
+ static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
+ // ... and return it.
+ return seqPropertyNames;
+}
+
+//*****************************************************************************************************************
+// initialize static member
+// DON'T DO IT IN YOUR HEADER!
+// see definition for further informations
+//*****************************************************************************************************************
+SvtLocalisationOptions_Impl* SvtLocalisationOptions::m_pDataContainer = NULL ;
+sal_Int32 SvtLocalisationOptions::m_nRefCount = 0 ;
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtLocalisationOptions::SvtLocalisationOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already exist!
+ if( m_pDataContainer == NULL )
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtLocalisationOptions_Impl::ctor()");
+ m_pDataContainer = new SvtLocalisationOptions_Impl;
+
+ ItemHolder1::holdConfigItem(E_LOCALISATIONOPTIONS);
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtLocalisationOptions::~SvtLocalisationOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Decrease ouer refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pDataContainer;
+ m_pDataContainer = NULL;
+ }
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Mutex& SvtLocalisationOptions::GetOwnStaticMutex()
+{
+ // Initialize static mutex only for one time!
+ static Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_menuoptions.cxx b/binfilter/bf_svtools/source/config/svt_menuoptions.cxx
new file mode 100644
index 000000000000..126a67228023
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_menuoptions.cxx
@@ -0,0 +1,458 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+//_________________________________________________________________________________________________________________
+// includes
+//_________________________________________________________________________________________________________________
+
+#include <bf_svtools/menuoptions.hxx>
+
+#include <unotools/configmgr.hxx>
+
+#include <unotools/configitem.hxx>
+
+#include <tools/debug.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <rtl/logfile.hxx>
+#include "itemholder1.hxx"
+
+#include <tools/link.hxx>
+#include <tools/list.hxx>
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+using namespace ::utl ;
+using namespace ::rtl ;
+using namespace ::osl ;
+using namespace ::com::sun::star::uno ;
+
+namespace binfilter
+{
+
+//_________________________________________________________________________________________________________________
+// const
+//_________________________________________________________________________________________________________________
+
+#define ROOTNODE_MENU OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/View/Menu" ))
+#define DEFAULT_DONTHIDEDISABLEDENTRIES sal_False
+#define DEFAULT_FOLLOWMOUSE sal_True
+#define DEFAULT_MENUICONS sal_True
+
+#define PROPERTYNAME_DONTHIDEDISABLEDENTRIES OUString(RTL_CONSTASCII_USTRINGPARAM("DontHideDisabledEntry" ))
+#define PROPERTYNAME_FOLLOWMOUSE OUString(RTL_CONSTASCII_USTRINGPARAM("FollowMouse" ))
+#define PROPERTYNAME_SHOWICONSINMENUES OUString(RTL_CONSTASCII_USTRINGPARAM("ShowIconsInMenues" ))
+
+#define PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES 0
+#define PROPERTYHANDLE_FOLLOWMOUSE 1
+#define PROPERTYHANDLE_SHOWICONSINMENUES 2
+
+#define PROPERTYCOUNT 3
+
+DECLARE_LIST( LinkList, Link * )
+
+//_________________________________________________________________________________________________________________
+// private declarations!
+//_________________________________________________________________________________________________________________
+
+class SvtMenuOptions_Impl : public ConfigItem
+{
+ //-------------------------------------------------------------------------------------------------------------
+ // private member
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+ LinkList aList;
+ sal_Bool m_bDontHideDisabledEntries ; /// cache "DontHideDisabledEntries" of Menu section
+ sal_Bool m_bFollowMouse ; /// cache "FollowMouse" of Menu section
+ sal_Bool m_bMenuIcons ; /// cache "MenuIcons" of Menu section
+
+ //-------------------------------------------------------------------------------------------------------------
+ // public methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ public:
+
+ //---------------------------------------------------------------------------------------------------------
+ // constructor / destructor
+ //---------------------------------------------------------------------------------------------------------
+
+ SvtMenuOptions_Impl();
+ ~SvtMenuOptions_Impl();
+
+ //---------------------------------------------------------------------------------------------------------
+ // overloaded methods of baseclass
+ //---------------------------------------------------------------------------------------------------------
+
+ /*-****************************************************************************************************//**
+ @short called for notify of configmanager
+ @descr These method is called from the ConfigManager before application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. You must update your
+ internal values.
+
+ @seealso baseclass ConfigItem
+
+ @param "seqPropertyNames" is the list of properties which should be updated.
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Notify( const Sequence< OUString >& seqPropertyNames );
+
+ /*-****************************************************************************************************//**
+ @short write changes to configuration
+ @descr These method writes the changed values into the sub tree
+ and should always called in our destructor to guarantee consistency of config data.
+
+ @seealso baseclass ConfigItem
+
+ @param -
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Commit();
+
+ //---------------------------------------------------------------------------------------------------------
+ // public interface
+ //---------------------------------------------------------------------------------------------------------
+
+ /*-****************************************************************************************************//**
+ @short access method to get internal values
+ @descr These method give us a chance to regulate acces to ouer internal values.
+ It's not used in the moment - but it's possible for the feature!
+
+ @seealso -
+
+ @param -
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ sal_Bool IsEntryHidingEnabled() const
+ { return m_bDontHideDisabledEntries; }
+
+ sal_Bool IsFollowMouseEnabled() const
+ { return m_bFollowMouse; }
+
+ sal_Bool IsMenuIconsEnabled() const
+ { return m_bMenuIcons; }
+
+ void SetEntryHidingState ( sal_Bool bState )
+ {
+ m_bDontHideDisabledEntries = bState;
+ SetModified();
+ for ( USHORT n=0; n<aList.Count(); n++ )
+ aList.GetObject(n)->Call( this );
+ Commit();
+ }
+
+ void SetFollowMouseState ( sal_Bool bState )
+ {
+ m_bFollowMouse = bState;
+ SetModified();
+ for ( USHORT n=0; n<aList.Count(); n++ )
+ aList.GetObject(n)->Call( this );
+ Commit();
+ }
+
+ void SetMenuIconsState ( sal_Bool bState )
+ {
+ m_bMenuIcons = bState;
+ SetModified();
+ for ( USHORT n=0; n<aList.Count(); n++ )
+ aList.GetObject(n)->Call( this );
+ Commit();
+ }
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ /*-****************************************************************************************************//**
+ @short return list of fix key names of ouer configuration management which represent oue module tree
+ @descr These methods return a static const list of key names. We need it to get needed values from our
+ configuration management.
+
+ @seealso -
+
+ @param -
+ @return A list of needed configuration keys is returned.
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ static Sequence< OUString > impl_GetPropertyNames();
+};
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtMenuOptions_Impl::SvtMenuOptions_Impl()
+ // Init baseclasses first
+ : ConfigItem ( ROOTNODE_MENU )
+ // Init member then.
+ , m_bDontHideDisabledEntries ( DEFAULT_DONTHIDEDISABLEDENTRIES )
+ , m_bFollowMouse ( DEFAULT_FOLLOWMOUSE )
+ , m_bMenuIcons ( DEFAULT_MENUICONS )
+{
+ // Use our static list of configuration keys to get his values.
+ Sequence< OUString > seqNames = impl_GetPropertyNames();
+ Sequence< Any > seqValues = GetProperties( seqNames ) ;
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to ouer internal member.
+ sal_Int32 nPropertyCount = seqValues.getLength() ;
+ sal_Int32 nProperty = 0 ;
+ for( nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ // Safe impossible cases.
+ // Check any for valid value.
+ DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nInvalid property value for property detected!\n" );
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES : {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\DontHideDisabledEntry\"?" );
+ seqValues[nProperty] >>= m_bDontHideDisabledEntries;
+ }
+ break;
+
+ case PROPERTYHANDLE_FOLLOWMOUSE : {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\FollowMouse\"?" );
+ seqValues[nProperty] >>= m_bFollowMouse;
+ }
+ break;
+ case PROPERTYHANDLE_SHOWICONSINMENUES : {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\ShowIconsInMenues\"?" );
+ seqValues[nProperty] >>= m_bMenuIcons;
+ }
+ break;
+ }
+ }
+
+ EnableNotification( seqNames );
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtMenuOptions_Impl::~SvtMenuOptions_Impl()
+{
+ // Flush data to configuration!
+ // User has no chance to do that.
+ if( IsModified() == sal_True )
+ {
+ Commit();
+ }
+
+ for ( USHORT n=0; n<aList.Count(); )
+ delete aList.Remove(n);
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtMenuOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames )
+{
+ // Use given list of updated properties to get his values from configuration directly!
+ Sequence< Any > seqValues = GetProperties( seqPropertyNames );
+ // Safe impossible cases.
+ // We need values from ALL notified configuration keys.
+ DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtMenuOptions_Impl::Notify()\nI miss some values of configuration keys!\n" );
+ // Step over list of property names and get right value from coreesponding value list to set it on internal members!
+ sal_Int32 nCount = seqPropertyNames.getLength();
+ for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
+ {
+ if( seqPropertyNames[nProperty] == PROPERTYNAME_DONTHIDEDISABLEDENTRIES )
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\View\\Menu\\DontHideDisabledEntry\"?" );
+ seqValues[nProperty] >>= m_bDontHideDisabledEntries;
+ }
+ else
+ if( seqPropertyNames[nProperty] == PROPERTYNAME_FOLLOWMOUSE )
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\View\\Menu\\FollowMouse\"?" );
+ seqValues[nProperty] >>= m_bFollowMouse;
+ }
+ if( seqPropertyNames[nProperty] == PROPERTYNAME_SHOWICONSINMENUES )
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\ShowIconsInMenues\"?" );
+ seqValues[nProperty] >>= m_bMenuIcons;
+ }
+ #if OSL_DEBUG_LEVEL > 1
+ else DBG_ASSERT( sal_False, "SvtMenuOptions_Impl::Notify()\nUnkown property detected ... I can't handle these!\n" );
+ #endif
+ }
+
+ for ( USHORT n=0; n<aList.Count(); n++ )
+ aList.GetObject(n)->Call( this );
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtMenuOptions_Impl::Commit()
+{
+ // Get names of supported properties, create a list for values and copy current values to it.
+ Sequence< OUString > seqNames = impl_GetPropertyNames();
+ sal_Int32 nCount = seqNames.getLength();
+ Sequence< Any > seqValues ( nCount );
+ for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
+ {
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES : {
+ seqValues[nProperty] <<= m_bDontHideDisabledEntries;
+ }
+ break;
+
+ case PROPERTYHANDLE_FOLLOWMOUSE : {
+ seqValues[nProperty] <<= m_bFollowMouse;
+ }
+ break;
+ case PROPERTYHANDLE_SHOWICONSINMENUES : {
+ seqValues[nProperty] <<= m_bMenuIcons;
+ }
+ break;
+ }
+ }
+ // Set properties in configuration.
+ PutProperties( seqNames, seqValues );
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Sequence< OUString > SvtMenuOptions_Impl::impl_GetPropertyNames()
+{
+ // Build static list of configuration key names.
+ static const OUString pProperties[] =
+ {
+ PROPERTYNAME_DONTHIDEDISABLEDENTRIES ,
+ PROPERTYNAME_FOLLOWMOUSE ,
+ PROPERTYNAME_SHOWICONSINMENUES
+ };
+ // Initialize return sequence with these list ...
+ static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
+ // ... and return it.
+ return seqPropertyNames;
+}
+
+//*****************************************************************************************************************
+// initialize static member
+// DON'T DO IT IN YOUR HEADER!
+// see definition for further informations
+//*****************************************************************************************************************
+SvtMenuOptions_Impl* SvtMenuOptions::m_pDataContainer = NULL ;
+sal_Int32 SvtMenuOptions::m_nRefCount = 0 ;
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtMenuOptions::SvtMenuOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already!
+ if( m_pDataContainer == NULL )
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtMenuOptions_Impl::ctor()");
+ m_pDataContainer = new SvtMenuOptions_Impl();
+
+ ItemHolder1::holdConfigItem(E_MENUOPTIONS);
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtMenuOptions::~SvtMenuOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Decrease ouer refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pDataContainer;
+ m_pDataContainer = NULL;
+ }
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Mutex& SvtMenuOptions::GetOwnStaticMutex()
+{
+ // Initialize static mutex only for one time!
+ static Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_misccfg.cxx b/binfilter/bf_svtools/source/config/svt_misccfg.cxx
new file mode 100644
index 000000000000..0e16d7eba31b
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_misccfg.cxx
@@ -0,0 +1,153 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 "misccfg.hxx"
+
+#include <bf_svtools/zforlist.hxx>
+
+#include <tools/debug.hxx>
+
+#include <rtl/logfile.hxx>
+
+
+#define DEFAULT_TAB 2000
+
+#define DEF_INCH 2540L
+#define DEF_RELTWIP 1440L
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+namespace binfilter
+{
+
+#define C2U(cChar) OUString::createFromAscii(cChar)
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+SfxMiscCfg::SfxMiscCfg() :
+ ConfigItem(C2U("Office.Common") ),
+ bPaperSize(FALSE),
+ bPaperOrientation (FALSE),
+ bNotFound (FALSE),
+ nYear2000( SvNumberFormatter::GetYear2000Default() )
+{
+ RTL_LOGFILE_CONTEXT(aLog, "svtools SfxMiscCfg::SfxMiscCfg()");
+
+ Load();
+}
+/* -----------------------------02.03.01 15:31--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SfxMiscCfg::~SfxMiscCfg()
+{
+}
+
+/* -----------------------------02.03.01 15:31--------------------------------
+
+ ---------------------------------------------------------------------------*/
+const Sequence<OUString>& SfxMiscCfg::GetPropertyNames()
+{
+ static Sequence<OUString> aNames;
+ if(!aNames.getLength())
+ {
+ static const char* aPropNames[] =
+ {
+ "Print/Warning/PaperSize", // 0
+ "Print/Warning/PaperOrientation", // 1
+ "Print/Warning/NotFound", // 2
+ "DateFormat/TwoDigitYear", // 3
+ };
+ const int nCount = 4;
+ aNames.realloc(nCount);
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ }
+ return aNames;
+}
+/* -----------------------------02.03.01 15:31--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SfxMiscCfg::Load()
+{
+ const Sequence<OUString>& aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ EnableNotification(aNames);
+ const Any* pValues = aValues.getConstArray();
+ DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == aNames.getLength())
+ {
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ switch(nProp)
+ {
+ case 0: bPaperSize = *(sal_Bool*)pValues[nProp].getValue(); break; //"Print/Warning/PaperSize",
+ case 1: bPaperOrientation = *(sal_Bool*)pValues[nProp].getValue(); break; //"Print/Warning/PaperOrientation",
+ case 2: bNotFound = *(sal_Bool*)pValues[nProp].getValue() ; break; //"Print/Warning/NotFound",
+ case 3: pValues[nProp] >>= nYear2000;break; //"DateFormat/TwoDigitYear",
+ }
+ }
+ }
+ }
+}
+/* -----------------------------02.03.01 15:31--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SfxMiscCfg::Notify( const com::sun::star::uno::Sequence<rtl::OUString>& )
+{
+ Load();
+}
+/* -----------------------------02.03.01 15:31--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SfxMiscCfg::Commit()
+{
+ const Sequence<OUString>& aNames = GetPropertyNames();
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ const Type& rType = ::getBooleanCppuType();
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ switch(nProp)
+ {
+ case 0: pValues[nProp].setValue(&bPaperSize, rType);break; //"Print/Warning/PaperSize",
+ case 1: pValues[nProp].setValue(&bPaperOrientation, rType);break; //"Print/Warning/PaperOrientation",
+ case 2: pValues[nProp].setValue(&bNotFound, rType);break; //"Print/Warning/NotFound",
+ case 3: pValues[nProp] <<= nYear2000;break; //"DateFormat/TwoDigitYear",
+ }
+ }
+ PutProperties(aNames, aValues);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_miscopt.cxx b/binfilter/bf_svtools/source/config/svt_miscopt.cxx
new file mode 100644
index 000000000000..33c1c2d77542
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_miscopt.cxx
@@ -0,0 +1,651 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/miscopt.hxx>
+
+#include <unotools/configmgr.hxx>
+
+#include <unotools/configitem.hxx>
+
+#include <tools/debug.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <tools/link.hxx>
+#include <tools/list.hxx>
+#include <tools/wldcrd.hxx>
+#include <tools/urlobj.hxx>
+
+#include <rtl/logfile.hxx>
+#include "itemholder2.hxx"
+
+#include <imgdef.hxx>
+#include <vcl/svapp.hxx>
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+using namespace ::utl ;
+using namespace ::rtl ;
+using namespace ::osl ;
+using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star;
+
+namespace binfilter
+{
+
+//_________________________________________________________________________________________________________________
+// const
+//_________________________________________________________________________________________________________________
+
+#define ASCII_STR(s) OUString( RTL_CONSTASCII_USTRINGPARAM(s) )
+#define ROOTNODE_MISC ASCII_STR("Office.Common/Misc")
+#define DEFAULT_PLUGINSENABLED sal_True;
+
+#define PROPERTYNAME_PLUGINSENABLED ASCII_STR("PluginsEnabled")
+#define PROPERTYHANDLE_PLUGINSENABLED 0
+#define PROPERTYNAME_SYMBOLSET ASCII_STR("SymbolSet")
+#define PROPERTYHANDLE_SYMBOLSET 1
+#define PROPERTYNAME_TOOLBOXSTYLE ASCII_STR("ToolboxStyle")
+#define PROPERTYHANDLE_TOOLBOXSTYLE 2
+#define PROPERTYNAME_USESYSTEMFILEDIALOG ASCII_STR("UseSystemFileDialog")
+#define PROPERTYHANDLE_USESYSTEMFILEDIALOG 3
+#define PROPERTYNAME_SYMBOLSTYLE ASCII_STR("SymbolStyle")
+#define PROPERTYHANDLE_SYMBOLSTYLE 4
+
+#define PROPERTYCOUNT 5
+
+#define VCL_TOOLBOX_STYLE_FLAT ((USHORT)0x0004) // from <vcl/toolbox.hxx>
+
+DECLARE_LIST( LinkList, Link * )
+
+//_________________________________________________________________________________________________________________
+// private declarations!
+//_________________________________________________________________________________________________________________
+
+class SvtMiscOptions_Impl : public ConfigItem
+{
+ //-------------------------------------------------------------------------------------------------------------
+ // private member
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+ LinkList aList;
+ sal_Bool m_bUseSystemFileDialog;
+ sal_Bool m_bIsUseSystemFileDialogRO;
+ sal_Bool m_bPluginsEnabled;
+ sal_Bool m_bIsPluginsEnabledRO;
+ sal_Int16 m_nSymbolsSize;
+ sal_Bool m_bIsSymbolsSizeRO;
+ sal_Bool m_bIsSymbolsStyleRO;
+ sal_Int16 m_nToolboxStyle;
+ sal_Bool m_bIsToolboxStyleRO;
+
+ //-------------------------------------------------------------------------------------------------------------
+ // public methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ public:
+
+ //---------------------------------------------------------------------------------------------------------
+ // constructor / destructor
+ //---------------------------------------------------------------------------------------------------------
+
+ SvtMiscOptions_Impl();
+ ~SvtMiscOptions_Impl();
+
+ //---------------------------------------------------------------------------------------------------------
+ // overloaded methods of baseclass
+ //---------------------------------------------------------------------------------------------------------
+
+ /*-****************************************************************************************************//**
+ @short called for notify of configmanager
+ @descr These method is called from the ConfigManager before application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. You must update your
+ internal values.
+
+ @seealso baseclass ConfigItem
+
+ @param "seqPropertyNames" is the list of properties which should be updated.
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Notify( const Sequence< OUString >& seqPropertyNames );
+
+ /** loads required data from the configuration. It's called in the constructor to
+ read all entries and form ::Notify to re-read changed settings
+
+ */
+ void Load( const Sequence< OUString >& rPropertyNames );
+
+ /*-****************************************************************************************************//**
+ @short write changes to configuration
+ @descr These method writes the changed values into the sub tree
+ and should always called in our destructor to guarantee consistency of config data.
+
+ @seealso baseclass ConfigItem
+
+ @param -
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Commit();
+
+ //---------------------------------------------------------------------------------------------------------
+ // public interface
+ //---------------------------------------------------------------------------------------------------------
+
+ inline sal_Bool UseSystemFileDialog() const
+ { return m_bUseSystemFileDialog; }
+
+ inline void SetUseSystemFileDialog( sal_Bool bSet )
+ { m_bUseSystemFileDialog = bSet; SetModified(); }
+
+ inline sal_Bool IsUseSystemFileDialogReadOnly() const
+ { return m_bIsUseSystemFileDialogRO; }
+
+ inline sal_Bool IsPluginsEnabled() const
+ { return m_bPluginsEnabled; }
+
+ inline sal_Bool IsPluginsEnabledReadOnly() const
+ { return m_bIsPluginsEnabledRO; }
+
+ inline sal_Int16 GetSymbolsSize()
+ { return m_nSymbolsSize; }
+
+ inline sal_Bool IsGetSymbolsSizeReadOnly()
+ { return m_bIsSymbolsSizeRO; }
+
+ sal_Int16 GetSymbolsStyle() const;
+ ::rtl::OUString GetSymbolsStyleName() const;
+
+ inline void SetSymbolsStyle( sal_Int16 nSet )
+ { ImplSetSymbolsStyle( true, nSet, ::rtl::OUString() ); }
+
+ inline void SetSymbolsStyleName( ::rtl::OUString &rName )
+ { ImplSetSymbolsStyle( false, 0, rName ); }
+
+ inline sal_Bool IsGetSymbolsStyleReadOnly()
+ { return m_bIsSymbolsStyleRO; }
+
+ // translate to VCL settings ( "0" = 3D, "1" = FLAT )
+ inline sal_Int16 GetToolboxStyle()
+ { return m_nToolboxStyle ? VCL_TOOLBOX_STYLE_FLAT : 0; }
+
+ inline sal_Bool IsGetToolboxStyleReadOnly()
+ { return m_bIsToolboxStyleRO; }
+
+ void CallListeners();
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ /*-****************************************************************************************************//**
+ @short return list of key names of ouer configuration management which represent oue module tree
+ @descr These methods return a static const list of key names. We need it to get needed values from our
+ configuration management.
+
+ @seealso -
+
+ @param -
+ @return A list of needed configuration keys is returned.
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ static Sequence< OUString > GetPropertyNames();
+
+ protected:
+ void ImplSetSymbolsStyle( bool bValue, sal_Int16 nSet, const ::rtl::OUString &rName );
+};
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+static sal_Int16 implSymbolsStyleFromVCL( ULONG nStyle )
+{
+ switch ( nStyle )
+ {
+ case STYLE_SYMBOLS_AUTO: return SFX_SYMBOLS_STYLE_AUTO;
+ case STYLE_SYMBOLS_DEFAULT: return SFX_SYMBOLS_STYLE_DEFAULT;
+ case STYLE_SYMBOLS_HICONTRAST: return SFX_SYMBOLS_STYLE_HICONTRAST;
+ case STYLE_SYMBOLS_INDUSTRIAL: return SFX_SYMBOLS_STYLE_INDUSTRIAL;
+ case STYLE_SYMBOLS_CRYSTAL: return SFX_SYMBOLS_STYLE_CRYSTAL;
+ case STYLE_SYMBOLS_TANGO: return SFX_SYMBOLS_STYLE_TANGO;
+ }
+
+ return SFX_SYMBOLS_STYLE_AUTO;
+}
+
+static ULONG implSymbolsStyleToVCL( sal_Int16 nStyle )
+{
+ switch ( nStyle )
+ {
+ case SFX_SYMBOLS_STYLE_AUTO: return STYLE_SYMBOLS_AUTO;
+ case SFX_SYMBOLS_STYLE_DEFAULT: return STYLE_SYMBOLS_DEFAULT;
+ case SFX_SYMBOLS_STYLE_HICONTRAST: return STYLE_SYMBOLS_HICONTRAST;
+ case SFX_SYMBOLS_STYLE_INDUSTRIAL: return STYLE_SYMBOLS_INDUSTRIAL;
+ case SFX_SYMBOLS_STYLE_CRYSTAL: return STYLE_SYMBOLS_CRYSTAL;
+ case SFX_SYMBOLS_STYLE_TANGO: return STYLE_SYMBOLS_TANGO;
+ }
+
+ return STYLE_SYMBOLS_AUTO;
+}
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtMiscOptions_Impl::SvtMiscOptions_Impl()
+ // Init baseclasses first
+ : ConfigItem( ROOTNODE_MISC )
+
+ , m_bUseSystemFileDialog( sal_False )
+ , m_bIsUseSystemFileDialogRO( sal_False )
+ , m_bPluginsEnabled( sal_False )
+ , m_bIsPluginsEnabledRO( sal_False )
+ , m_nSymbolsSize( 0 )
+ , m_bIsSymbolsSizeRO( sal_False )
+ , m_bIsSymbolsStyleRO( sal_False )
+ , m_nToolboxStyle( 1 )
+ , m_bIsToolboxStyleRO( sal_False )
+
+{
+ // Use our static list of configuration keys to get his values.
+ Sequence< OUString > seqNames = GetPropertyNames ( );
+ Load( seqNames );
+ Sequence< Any > seqValues = GetProperties ( seqNames );
+ Sequence< sal_Bool > seqRO = GetReadOnlyStates ( seqNames );
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtMiscOptions_Impl::SvtMiscOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to ouer internal member.
+ sal_Int32 nPropertyCount = seqValues.getLength();
+ for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ // Safe impossible cases.
+ // Check any for valid value.
+ DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nInvalid property value detected!\n" );
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_PLUGINSENABLED :
+ {
+ if( !(seqValues[nProperty] >>= m_bPluginsEnabled) )
+ {
+ DBG_ERROR("Wrong type of \"Misc\\PluginsEnabled\"!" );
+ }
+ m_bIsPluginsEnabledRO = seqRO[nProperty];
+ break;
+ }
+
+ case PROPERTYHANDLE_SYMBOLSET :
+ {
+ if( !(seqValues[nProperty] >>= m_nSymbolsSize) )
+ {
+ DBG_ERROR("Wrong type of \"Misc\\SymbolSet\"!" );
+ }
+ m_bIsSymbolsSizeRO = seqRO[nProperty];
+ break;
+ }
+
+ case PROPERTYHANDLE_TOOLBOXSTYLE :
+ {
+ if( !(seqValues[nProperty] >>= m_nToolboxStyle) )
+ {
+ DBG_ERROR("Wrong type of \"Misc\\ToolboxStyle\"!" );
+ }
+ m_bIsToolboxStyleRO = seqRO[nProperty];
+ break;
+ }
+
+ case PROPERTYHANDLE_USESYSTEMFILEDIALOG :
+ {
+ if( !(seqValues[nProperty] >>= m_bUseSystemFileDialog) )
+ {
+ DBG_ERROR("Wrong type of \"Misc\\UseSystemFileDialog\"!" );
+ }
+ m_bIsUseSystemFileDialogRO = seqRO[nProperty];
+ break;
+ }
+
+ case PROPERTYHANDLE_SYMBOLSTYLE :
+ {
+ ::rtl::OUString aSymbolsStyle;
+ if( seqValues[nProperty] >>= aSymbolsStyle )
+ SetSymbolsStyleName( aSymbolsStyle );
+ else
+ {
+ DBG_ERROR("Wrong type of \"Misc\\SymbolStyle\"!" );
+ }
+ m_bIsSymbolsStyleRO = seqRO[nProperty];
+ break;
+ }
+ }
+ }
+
+ // Enable notification mechanism of ouer baseclass.
+ // We need it to get information about changes outside these class on ouer used configuration keys!
+ EnableNotification( seqNames );
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtMiscOptions_Impl::~SvtMiscOptions_Impl()
+{
+ // We must save our current values .. if user forget it!
+ if( IsModified() == sal_True )
+ {
+ Commit();
+ }
+
+ for ( USHORT n=0; n<aList.Count(); )
+ delete aList.Remove(n);
+}
+
+/*-- 25.02.2005 13:22:04---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+static int lcl_MapPropertyName( const ::rtl::OUString rCompare,
+ const uno::Sequence< ::rtl::OUString>& aInternalPropertyNames)
+{
+ for(int nProp = 0; nProp < aInternalPropertyNames.getLength(); ++nProp)
+ {
+ if( aInternalPropertyNames[nProp] == rCompare )
+ return nProp;
+ }
+ return -1;
+}
+
+void SvtMiscOptions_Impl::Load( const Sequence< OUString >& rPropertyNames )
+{
+ const uno::Sequence< ::rtl::OUString> aInternalPropertyNames( GetPropertyNames());
+ Sequence< Any > seqValues = GetProperties( rPropertyNames );
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !(rPropertyNames.getLength()!=seqValues.getLength()), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to ouer internal member.
+ sal_Int32 nPropertyCount = seqValues.getLength();
+ for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ // Safe impossible cases.
+ // Check any for valid value.
+ DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nInvalid property value detected!\n" );
+ switch( lcl_MapPropertyName(rPropertyNames[nProperty], aInternalPropertyNames) )
+ {
+ case PROPERTYHANDLE_PLUGINSENABLED : {
+ if( !(seqValues[nProperty] >>= m_bPluginsEnabled) )
+ {
+ DBG_ERROR("Wrong type of \"Misc\\PluginsEnabled\"!" );
+ }
+ }
+ break;
+ case PROPERTYHANDLE_SYMBOLSET : {
+ if( !(seqValues[nProperty] >>= m_nSymbolsSize) )
+ {
+ DBG_ERROR("Wrong type of \"Misc\\SymbolSet\"!" );
+ }
+ }
+ break;
+ case PROPERTYHANDLE_TOOLBOXSTYLE : {
+ if( !(seqValues[nProperty] >>= m_nToolboxStyle) )
+ {
+ DBG_ERROR("Wrong type of \"Misc\\ToolboxStyle\"!" );
+ }
+ }
+ break;
+ case PROPERTYHANDLE_USESYSTEMFILEDIALOG : {
+ if( !(seqValues[nProperty] >>= m_bUseSystemFileDialog) )
+ {
+ DBG_ERROR("Wrong type of \"Misc\\UseSystemFileDialog\"!" );
+ }
+ }
+ break;
+ case PROPERTYHANDLE_SYMBOLSTYLE : {
+ ::rtl::OUString aSymbolsStyle;
+ if( seqValues[nProperty] >>= aSymbolsStyle )
+ SetSymbolsStyleName( aSymbolsStyle );
+ else
+ {
+ DBG_ERROR("Wrong type of \"Misc\\SymbolStyle\"!" );
+ }
+ }
+ break;
+ }
+ }
+}
+
+void SvtMiscOptions_Impl::CallListeners()
+{
+ for ( USHORT n = 0; n < aList.Count(); ++n )
+ aList.GetObject(n)->Call( this );
+}
+
+sal_Int16 SvtMiscOptions_Impl::GetSymbolsStyle() const
+{
+ return implSymbolsStyleFromVCL( Application::GetSettings().GetStyleSettings().GetSymbolsStyle() );
+}
+
+::rtl::OUString SvtMiscOptions_Impl::GetSymbolsStyleName() const
+{
+ return Application::GetSettings().GetStyleSettings().GetSymbolsStyleName();
+}
+
+void SvtMiscOptions_Impl::ImplSetSymbolsStyle( bool bValue, sal_Int16 nSet, const ::rtl::OUString &rName )
+{
+ if ( ( bValue && ( nSet != GetSymbolsStyle() ) ) ||
+ ( !bValue && ( rName != GetSymbolsStyleName() ) ) )
+ {
+ AllSettings aAllSettings = Application::GetSettings();
+ StyleSettings aStyleSettings = aAllSettings.GetStyleSettings();
+
+ if ( bValue )
+ aStyleSettings.SetSymbolsStyle( implSymbolsStyleToVCL( nSet ) );
+ else
+ aStyleSettings.SetSymbolsStyleName( rName );
+
+ aAllSettings.SetStyleSettings(aStyleSettings);
+ Application::MergeSystemSettings( aAllSettings );
+ Application::SetSettings(aAllSettings);
+
+ SetModified();
+ CallListeners();
+ }
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtMiscOptions_Impl::Notify( const Sequence< OUString >& rPropertyNames )
+{
+ Load( rPropertyNames );
+ CallListeners();
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtMiscOptions_Impl::Commit()
+{
+ // Get names of supported properties, create a list for values and copy current values to it.
+ Sequence< OUString > seqNames = GetPropertyNames ();
+ sal_Int32 nCount = seqNames.getLength();
+ Sequence< Any > seqValues ( nCount );
+ for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
+ {
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_PLUGINSENABLED :
+ {
+ if ( !m_bIsPluginsEnabledRO )
+ seqValues[nProperty] <<= m_bPluginsEnabled;
+ break;
+ }
+
+ case PROPERTYHANDLE_SYMBOLSET :
+ {
+ if ( !m_bIsSymbolsSizeRO )
+ seqValues[nProperty] <<= m_nSymbolsSize;
+ break;
+ }
+
+ case PROPERTYHANDLE_TOOLBOXSTYLE :
+ {
+ if ( !m_bIsToolboxStyleRO )
+ seqValues[nProperty] <<= m_nToolboxStyle;
+ break;
+ }
+
+ case PROPERTYHANDLE_USESYSTEMFILEDIALOG :
+ {
+ if ( !m_bIsUseSystemFileDialogRO )
+ seqValues[nProperty] <<= m_bUseSystemFileDialog;
+ break;
+ }
+
+ case PROPERTYHANDLE_SYMBOLSTYLE :
+ {
+ if ( !m_bIsSymbolsStyleRO )
+ seqValues[nProperty] <<= GetSymbolsStyleName();
+ break;
+ }
+ }
+ }
+ // Set properties in configuration.
+ PutProperties( seqNames, seqValues );
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Sequence< OUString > SvtMiscOptions_Impl::GetPropertyNames()
+{
+ // Build static list of configuration key names.
+ static const OUString pProperties[] =
+ {
+ PROPERTYNAME_PLUGINSENABLED,
+ PROPERTYNAME_SYMBOLSET,
+ PROPERTYNAME_TOOLBOXSTYLE,
+ PROPERTYNAME_USESYSTEMFILEDIALOG,
+ PROPERTYNAME_SYMBOLSTYLE
+ };
+
+ // Initialize return sequence with these list ...
+ static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
+ // ... and return it.
+ return seqPropertyNames;
+}
+
+//*****************************************************************************************************************
+// initialize static member
+// DON'T DO IT IN YOUR HEADER!
+// see definition for further informations
+//*****************************************************************************************************************
+SvtMiscOptions_Impl* SvtMiscOptions::m_pDataContainer = NULL ;
+sal_Int32 SvtMiscOptions::m_nRefCount = 0 ;
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtMiscOptions::SvtMiscOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetInitMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already exist!
+ if( m_pDataContainer == NULL )
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtMiscOptions_Impl::ctor()");
+ m_pDataContainer = new SvtMiscOptions_Impl;
+ ItemHolder2::holdConfigItem(E_MISCOPTIONS);
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtMiscOptions::~SvtMiscOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetInitMutex() );
+ // Decrease ouer refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pDataContainer;
+ m_pDataContainer = NULL;
+ }
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Mutex & SvtMiscOptions::GetInitMutex()
+{
+ // Initialize static mutex only for one time!
+ static Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_moduleoptions.cxx b/binfilter/bf_svtools/source/config/svt_moduleoptions.cxx
new file mode 100644
index 000000000000..9fbcf5199e3e
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_moduleoptions.cxx
@@ -0,0 +1,982 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+//_________________________________________________________________________________________________________________
+// includes
+//_________________________________________________________________________________________________________________
+
+#include <bf_svtools/moduleoptions.hxx>
+
+#include <comphelper/sequenceashashmap.hxx>
+
+#include <unotools/configmgr.hxx>
+
+#include <unotools/configitem.hxx>
+
+#include <unotools/processfactory.hxx>
+
+#include <osl/diagnose.h>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <rtl/logfile.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+#include <com/sun/star/container/XNameAccess.hpp>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <com/sun/star/document/XTypeDetection.hpp>
+
+#include <com/sun/star/util/XStringSubstitution.hpp>
+
+#include "itemholder1.hxx"
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+#ifndef css
+namespace css = ::com::sun::star;
+#endif
+
+namespace binfilter
+{
+
+//_________________________________________________________________________________________________________________
+// const
+//_________________________________________________________________________________________________________________
+
+/*-************************************************************************************************************//**
+ @descr These values are used to define neccessary keys from our configuration management to support
+ all functionality of these implementation.
+ It's a fast way to make changes if some keys change his name or location!
+
+ Property handle are neccessary to specify right position in return list of configuration
+ for asked values. We ask it with a list of properties to get his values. The returned list
+ has the same order like our given name list!
+ e.g.:
+ NAMELIST[ PROPERTYHANDLE_xxx ] => VALUELIST[ PROPERTYHANDLE_xxx ]
+*//*-*************************************************************************************************************/
+#define ROOTNODE_FACTORIES ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Setup/Office/Factories" ))
+#define PATHSEPERATOR ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/" ))
+
+// Attention: The property "ooSetupFactoryEmptyDocumentURL" is read from configuration but not used! There is
+// special code that uses hard coded strings to return them.
+#define PROPERTYNAME_SHORTNAME ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryShortName" ))
+#define PROPERTYNAME_TEMPLATEFILE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryTemplateFile" ))
+#define PROPERTYNAME_WINDOWATTRIBUTES ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryWindowAttributes"))
+#define PROPERTYNAME_EMPTYDOCUMENTURL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryEmptyDocumentURL"))
+#define PROPERTYNAME_DEFAULTFILTER ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryDefaultFilter" ))
+#define PROPERTYNAME_ICON ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryIcon" ))
+
+#define PROPERTYHANDLE_SHORTNAME 0
+#define PROPERTYHANDLE_TEMPLATEFILE 1
+#define PROPERTYHANDLE_WINDOWATTRIBUTES 2
+#define PROPERTYHANDLE_EMPTYDOCUMENTURL 3
+#define PROPERTYHANDLE_DEFAULTFILTER 4
+#define PROPERTYHANDLE_ICON 5
+
+#define PROPERTYCOUNT 6
+
+#define FACTORYNAME_WRITER ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument" ))
+#define FACTORYNAME_WRITERWEB ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.WebDocument" ))
+#define FACTORYNAME_WRITERGLOBAL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GlobalDocument" ))
+#define FACTORYNAME_CALC ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDocument" ))
+#define FACTORYNAME_DRAW ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocument" ))
+#define FACTORYNAME_IMPRESS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationDocument"))
+#define FACTORYNAME_MATH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.formula.FormulaProperties" ))
+#define FACTORYNAME_CHART ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.ChartDocument" ))
+#define FACTORYNAME_DATABASE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.OfficeDatabaseDocument" ))
+#define FACTORYNAME_STARTMODULE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.StartModule" ))
+
+#define FACTORYCOUNT 10
+
+/*-************************************************************************************************************//**
+ @descr This struct hold information about one factory. We declare a complete array which can hold infos
+ for all well known factories. Values of enum "EFactory" (see header!) are directly used as index!
+ So we can support a fast access on these informations.
+*//*-*************************************************************************************************************/
+struct FactoryInfo
+{
+ public:
+ //---------------------------------------------------------------------------------------------------------
+ // initialize empty struct
+ FactoryInfo()
+ {
+ free();
+ // @@@ should be supplied from outside!
+ xSMgr = ::utl::getProcessServiceFactory();
+ }
+
+ //---------------------------------------------------------------------------------------------------------
+ // easy way to reset struct member!
+ void free()
+ {
+ bInstalled = sal_False ;
+ sFactory = ::rtl::OUString() ;
+ sShortName = ::rtl::OUString() ;
+ sTemplateFile = ::rtl::OUString() ;
+ sWindowAttributes = ::rtl::OUString() ;
+ sEmptyDocumentURL = ::rtl::OUString() ;
+ sDefaultFilter = ::rtl::OUString() ;
+ nIcon = 0 ;
+ bChangedTemplateFile = sal_False ;
+ bChangedWindowAttributes = sal_False ;
+ bChangedEmptyDocumentURL = sal_False ;
+ bChangedDefaultFilter = sal_False ;
+ bChangedIcon = sal_False ;
+ bDefaultFilterReadonly = sal_False ;
+ }
+
+ //---------------------------------------------------------------------------------------------------------
+ // returns list of properties, which has changed only!
+ // We use given value of sNodeBase to build full qualified pathes ...
+ // Last sign of it must be "/". Beacuse we use it directly, without any additional things!
+ css::uno::Sequence< css::beans::PropertyValue > getChangedProperties( const ::rtl::OUString& sNodeBase )
+ {
+ // a) reserve memory for max. count of changed properties
+ // b) add names and values of changed ones only and count it
+ // c) resize return list by using count
+ css::uno::Sequence< css::beans::PropertyValue > lProperties ( 4 );
+ sal_Int8 nRealyChanged = 0 ;
+
+ if( bChangedTemplateFile == sal_True )
+ {
+ lProperties[nRealyChanged].Name = sNodeBase + PROPERTYNAME_TEMPLATEFILE;
+
+ if ( sTemplateFile.getLength() > 0 )
+ {
+ lProperties[nRealyChanged].Value
+ <<= getStringSubstitution()
+ ->reSubstituteVariables( sTemplateFile );
+ }
+ else
+ {
+ lProperties[nRealyChanged].Value <<= sTemplateFile;
+ }
+
+ ++nRealyChanged;
+ }
+ if( bChangedWindowAttributes == sal_True )
+ {
+ lProperties[nRealyChanged].Name = sNodeBase + PROPERTYNAME_WINDOWATTRIBUTES;
+ lProperties[nRealyChanged].Value <<= sWindowAttributes;
+ ++nRealyChanged;
+ }
+ if( bChangedEmptyDocumentURL == sal_True )
+ {
+ lProperties[nRealyChanged].Name = sNodeBase + PROPERTYNAME_EMPTYDOCUMENTURL;
+ lProperties[nRealyChanged].Value <<= sEmptyDocumentURL;
+ ++nRealyChanged;
+ }
+ if( bChangedDefaultFilter == sal_True )
+ {
+ lProperties[nRealyChanged].Name = sNodeBase + PROPERTYNAME_DEFAULTFILTER;
+ lProperties[nRealyChanged].Value <<= sDefaultFilter;
+ ++nRealyChanged;
+ }
+ if( bChangedIcon == sal_True )
+ {
+ lProperties[nRealyChanged].Name = sNodeBase + PROPERTYNAME_ICON;
+ lProperties[nRealyChanged].Value <<= nIcon;
+ ++nRealyChanged;
+ }
+
+ // Don't forget to reset changed flags! Otherwise we save it again and again and ...
+ bChangedTemplateFile = sal_False ;
+ bChangedWindowAttributes = sal_False ;
+ bChangedEmptyDocumentURL = sal_False ;
+ bChangedDefaultFilter = sal_False ;
+ bChangedIcon = sal_False ;
+
+ lProperties.realloc( nRealyChanged );
+ return lProperties;
+ }
+
+ //---------------------------------------------------------------------------------------------------------
+ // We must support setting AND marking of changed values.
+ // That's why we can't make our member public. We must use get/set/init methods
+ // to control access on it!
+ sal_Bool getInstalled () const { return bInstalled; };
+ ::rtl::OUString getFactory () const { return sFactory; };
+ ::rtl::OUString getShortName () const { return sShortName; };
+ ::rtl::OUString getTemplateFile () const { return sTemplateFile; };
+ ::rtl::OUString getWindowAttributes () const { return sWindowAttributes; };
+ ::rtl::OUString getEmptyDocumentURL () const { return sEmptyDocumentURL; };
+ ::rtl::OUString getDefaultFilter () const { return sDefaultFilter; };
+ sal_Bool isDefaultFilterReadonly() const { return bDefaultFilterReadonly; }
+ sal_Int32 getIcon () const { return nIcon; };
+
+ //---------------------------------------------------------------------------------------------------------
+ // If you call set-methods - we check for changes of valkues and mark it.
+ // But if you whish to set it without that ... you must initialize it!
+ void initInstalled ( sal_Bool bNewInstalled ) { bInstalled = bNewInstalled ; }
+ void initFactory ( const ::rtl::OUString& sNewFactory ) { sFactory = sNewFactory ; }
+ void initShortName ( const ::rtl::OUString& sNewShortName ) { sShortName = sNewShortName ; }
+ void initWindowAttributes ( const ::rtl::OUString& sNewWindowAttributes ) { sWindowAttributes = sNewWindowAttributes ; }
+ void initEmptyDocumentURL ( const ::rtl::OUString& sNewEmptyDocumentURL ) { sEmptyDocumentURL = sNewEmptyDocumentURL ; }
+ void initDefaultFilter ( const ::rtl::OUString& sNewDefaultFilter ) { sDefaultFilter = sNewDefaultFilter ; }
+ void setDefaultFilterReadonly( const sal_Bool bVal){bDefaultFilterReadonly = bVal;}
+ void initIcon ( sal_Int32 nNewIcon ) { nIcon = nNewIcon ; }
+
+ //---------------------------------------------------------------------------------------------------------
+ void initTemplateFile( const ::rtl::OUString& sNewTemplateFile )
+ {
+ if ( sNewTemplateFile.getLength() > 0 )
+ {
+ sTemplateFile
+ = getStringSubstitution()
+ ->substituteVariables( sNewTemplateFile, sal_False );
+ }
+ else
+ {
+ sTemplateFile = sNewTemplateFile;
+ }
+ }
+
+ //---------------------------------------------------------------------------------------------------------
+ void setInstalled( sal_Bool bNewInstalled )
+ {
+ bInstalled = bNewInstalled;
+ };
+
+ //---------------------------------------------------------------------------------------------------------
+ void setFactory( const ::rtl::OUString& sNewFactory )
+ {
+ sFactory = sNewFactory;
+ };
+
+ //---------------------------------------------------------------------------------------------------------
+ void setShortName( const ::rtl::OUString& sNewShortName )
+ {
+ sShortName = sNewShortName;
+ };
+
+ //---------------------------------------------------------------------------------------------------------
+ void setTemplateFile( const ::rtl::OUString& sNewTemplateFile )
+ {
+ if( sTemplateFile != sNewTemplateFile )
+ {
+ sTemplateFile = sNewTemplateFile;
+ bChangedTemplateFile = sal_True ;
+ }
+ };
+
+ //---------------------------------------------------------------------------------------------------------
+ void setWindowAttributes( const ::rtl::OUString& sNewWindowAttributes )
+ {
+ if( sWindowAttributes != sNewWindowAttributes )
+ {
+ sWindowAttributes = sNewWindowAttributes;
+ bChangedWindowAttributes = sal_True ;
+ }
+ };
+
+ //---------------------------------------------------------------------------------------------------------
+ void setEmptyDocumentURL( const ::rtl::OUString& sNewEmptyDocumentURL )
+ {
+ if( sEmptyDocumentURL != sNewEmptyDocumentURL )
+ {
+ sEmptyDocumentURL = sNewEmptyDocumentURL;
+ bChangedEmptyDocumentURL = sal_True ;
+ }
+ };
+
+ //---------------------------------------------------------------------------------------------------------
+ void setDefaultFilter( const ::rtl::OUString& sNewDefaultFilter )
+ {
+ if( sDefaultFilter != sNewDefaultFilter )
+ {
+ sDefaultFilter = sNewDefaultFilter;
+ bChangedDefaultFilter = sal_True ;
+ }
+ };
+
+ //---------------------------------------------------------------------------------------------------------
+ void setIcon( sal_Int32 nNewIcon )
+ {
+ if( nNewIcon != nNewIcon )
+ {
+ nNewIcon = nNewIcon;
+ bChangedIcon = sal_True;
+ }
+ };
+
+ private:
+ css::uno::Reference< css::util::XStringSubstitution > getStringSubstitution()
+ {
+ if ( !xSubstVars.is() )
+ {
+ xSubstVars
+ = css::uno::Reference< css::util::XStringSubstitution >(
+ xSMgr->createInstance(
+ ::rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.util.PathSubstitution" ) ) ),
+ css::uno::UNO_QUERY );
+ if ( !xSubstVars.is() )
+ throw css::uno::RuntimeException(
+ ::rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "Cannot instanciate service "
+ "com.sun.star.util.PathSubstitution" ) ),
+ css::uno::Reference< css::uno::XInterface >() );
+ }
+ return xSubstVars;
+ }
+
+ sal_Bool bInstalled ;
+ ::rtl::OUString sFactory ;
+ ::rtl::OUString sShortName ;
+ ::rtl::OUString sTemplateFile ;
+ ::rtl::OUString sWindowAttributes ;
+ ::rtl::OUString sEmptyDocumentURL ;
+ ::rtl::OUString sDefaultFilter ;
+ sal_Int32 nIcon ;
+
+ sal_Bool bChangedTemplateFile :1 ;
+ sal_Bool bChangedWindowAttributes :1 ;
+ sal_Bool bChangedEmptyDocumentURL :1 ;
+ sal_Bool bChangedDefaultFilter :1 ;
+ sal_Bool bChangedIcon :1 ;
+ sal_Bool bDefaultFilterReadonly :1 ;
+
+ css::uno::Reference< css::lang::XMultiServiceFactory > xSMgr;
+ css::uno::Reference< css::util::XStringSubstitution > xSubstVars;
+};
+
+typedef FactoryInfo FactoryInfoList[FACTORYCOUNT];
+
+/*-************************************************************************************************************//**
+ @short IMPL data container for wrapper class SvtModulOptions!
+ @descr These class is used as a static data container of class SvtModuleOptions. The hold it by using
+ a refcount and make it threadsafe by using an osl mutex. So we don't must do anything for that.
+ We can implement pure functionality to read/write configuration data only.
+
+ @implements -
+ @base ConfigItem
+
+ @devstatus ready to use
+ @threadsafe no
+*//*-*************************************************************************************************************/
+class SvtModuleOptions_Impl : public ::utl::ConfigItem
+{
+ //-------------------------------------------------------------------------------------------------------------
+ // public methods
+ //-------------------------------------------------------------------------------------------------------------
+ public:
+ //---------------------------------------------------------------------------------------------------------
+ // constructor / destructor
+ //---------------------------------------------------------------------------------------------------------
+ SvtModuleOptions_Impl(SvtModuleOptions* pOutsideClass);
+ ~SvtModuleOptions_Impl();
+
+ //---------------------------------------------------------------------------------------------------------
+ // overloaded methods of baseclass
+ //---------------------------------------------------------------------------------------------------------
+ virtual void Notify( const css::uno::Sequence< ::rtl::OUString >& lPropertyNames );
+ virtual void Commit( );
+
+ //---------------------------------------------------------------------------------------------------------
+ // public interface
+ //---------------------------------------------------------------------------------------------------------
+ sal_Bool IsModuleInstalled ( SvtModuleOptions::EModule eModule ) const;
+ static sal_Bool ClassifyFactoryByName ( const ::rtl::OUString& sName ,
+ SvtModuleOptions::EFactory& eFactory );
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private methods
+ //-------------------------------------------------------------------------------------------------------------
+ private:
+ static css::uno::Sequence< ::rtl::OUString > impl_ExpandSetNames ( const css::uno::Sequence< ::rtl::OUString >& lSetNames );
+ void impl_Read ( const css::uno::Sequence< ::rtl::OUString >& lSetNames );
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private types
+ //-------------------------------------------------------------------------------------------------------------
+ private:
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private member
+ //-------------------------------------------------------------------------------------------------------------
+ private:
+ FactoryInfoList m_lFactories;
+ sal_Bool m_bReadOnlyStatesWellKnown;
+ SvtModuleOptions* m_pOutsideClass;
+};
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+/*-************************************************************************************************************//**
+ @short default ctor
+ @descr We open our configuration here and read all neccessary values from it.
+ These values are cached till everyone call Commit(). Then we write changed ones back to cfg.
+
+ @seealso baseclass ConfigItem
+ @seealso method impl_Read()
+
+ @param -
+ @return -
+
+ @onerror -
+ @threadsafe no
+*//*-*************************************************************************************************************/
+SvtModuleOptions_Impl::SvtModuleOptions_Impl(SvtModuleOptions* pOutsideClass)
+ : ::utl::ConfigItem( ROOTNODE_FACTORIES )
+ , m_bReadOnlyStatesWellKnown( sal_False )
+ , m_pOutsideClass( pOutsideClass )
+{
+ // First initialize list of factory infos! Otherwise we couldnt gurantee right working of these class.
+ for( sal_Int32 nFactory=0; nFactory<FACTORYCOUNT; ++nFactory )
+ m_lFactories[nFactory].free();
+
+ // Get name list of all existing set node names in configuration to read her properties in impl_Read().
+ // These list is a list of long names of our factories.
+ const css::uno::Sequence< ::rtl::OUString > lFactories = GetNodeNames( ::rtl::OUString() );
+ impl_Read( lFactories );
+
+ // Enable notification for changes by using configuration directly.
+ // So we can update our internal values immediatly.
+ EnableNotification( lFactories );
+}
+
+/*-************************************************************************************************************//**
+ @short default dtor
+ @descr If any values of our cache was modified we should write it back to configuration.
+
+ @attention Don't forget to call "SetModified()" method of base class ConfigItem if any interface method
+ of this class modify internal member list m_lFactories! Otherwise Commit() will never be called!!!
+
+ @seealso baseclass ConfigItem
+
+ @param -
+ @return -
+
+ @onerror -
+ @threadsafe no
+*//*-*************************************************************************************************************/
+SvtModuleOptions_Impl::~SvtModuleOptions_Impl()
+{
+ if( IsModified() == sal_True )
+ {
+ Commit();
+ }
+}
+
+/*-************************************************************************************************************//**
+ @short called for notify of configmanager
+ @descr These method is called from the ConfigManager before application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. You must update our
+ internal values.
+
+ @attention We are registered for pure set node names only. So we can use our internal method "impl_Read()" to
+ update our info list. Because - these method expand given name list to full qualified property list
+ and use it to read the values. These values are filled into our internal member list m_lFactories
+ at right position.
+
+ @seealso method impl_Read()
+
+ @param "lNames" is the list of set node entries which should be updated.
+ @return -
+
+ @onerror -
+ @threadsafe no
+*//*-*************************************************************************************************************/
+void SvtModuleOptions_Impl::Notify( const css::uno::Sequence< ::rtl::OUString >& )
+{
+ OSL_ENSURE( sal_False, "SvtModuleOptions_Impl::Notify()\nNot implemented yet!\n" );
+}
+
+/*-****************************************************************************************************//**
+ @short write changes to configuration
+ @descr These method writes the changed values into the sub tree
+ and should always called in our destructor to guarantee consistency of config data.
+
+ @attention We clear complete set in configuration first and write it completly new! So we don't must
+ distinguish between existing, added or removed elements. Our internal cached values
+ are the only and right ones.
+
+ @seealso baseclass ConfigItem
+
+ @param -
+ @return -
+
+ @onerror -
+ @threadsafe no
+*//*-*****************************************************************************************************/
+void SvtModuleOptions_Impl::Commit()
+{
+ // Reserve memory for ALL possible factory properties!
+ // Step over all factories and get her realy changed values only.
+ // Build list of these ones and use it for commit.
+ css::uno::Sequence< css::beans::PropertyValue > lCommitProperties( FACTORYCOUNT*PROPERTYCOUNT );
+ FactoryInfo* pInfo = NULL ;
+ sal_Int32 nRealCount = 0 ;
+ ::rtl::OUString sBasePath ;
+ for( sal_Int32 nFactory=0; nFactory<FACTORYCOUNT; ++nFactory )
+ {
+ pInfo = &(m_lFactories[nFactory]);
+
+ // These path is used to build full qualified property names ....
+ // See pInfo->getChangedProperties() for further informations
+ sBasePath = PATHSEPERATOR + pInfo->getFactory() + PATHSEPERATOR;
+
+ const css::uno::Sequence< css::beans::PropertyValue > lChangedProperties = pInfo->getChangedProperties ( sBasePath );
+ const css::beans::PropertyValue* pChangedProperties = lChangedProperties.getConstArray();
+ sal_Int32 nPropertyCount = lChangedProperties.getLength();
+ for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ lCommitProperties[nRealCount] = pChangedProperties[nProperty];
+ ++nRealCount;
+ }
+ }
+ // Resize commit list to real size.
+ // If nothing to do - suppress calling of configuration ...
+ // It could be to expensive :-)
+ if( nRealCount > 0 )
+ {
+ lCommitProperties.realloc( nRealCount );
+ SetSetProperties( ::rtl::OUString(), lCommitProperties );
+ }
+}
+
+/*-****************************************************************************************************//**
+ @short access method to get internal values
+ @descr These methods implement easy access to our internal values.
+ You give us right enum value to specify which module interest you ... we return right information.
+
+ @attention Some poeple use any value as enum ... but we support in header specified values only!
+ We use it directly as index in our internal list. If enum value isn't right - we crash with an
+ "index out of range"!!! Please use me right - otherwise there is no guarantee.
+
+ @seealso -
+
+ @param "eModule" , index in list - specify module
+ @param "eFactory" , index in list - specify factory
+ @param "sTemplate", set new standard template for these factory
+ @return Queried information.
+
+ @onerror We return default values. (mostly "not installed"!)
+ @threadsafe no
+*//*-*****************************************************************************************************/
+sal_Bool SvtModuleOptions_Impl::IsModuleInstalled( SvtModuleOptions::EModule eModule ) const
+{
+ sal_Bool bInstalled = sal_False;
+ switch( eModule )
+ {
+ case SvtModuleOptions::E_SWRITER : bInstalled = m_lFactories[SvtModuleOptions::E_WRITER].getInstalled();
+ break;
+ case SvtModuleOptions::E_SWEB : bInstalled = m_lFactories[SvtModuleOptions::E_WRITERWEB].getInstalled();
+ break;
+ case SvtModuleOptions::E_SGLOBAL : bInstalled = m_lFactories[SvtModuleOptions::E_WRITERGLOBAL].getInstalled();
+ break;
+ case SvtModuleOptions::E_SCALC : bInstalled = m_lFactories[SvtModuleOptions::E_CALC].getInstalled();
+ break;
+ case SvtModuleOptions::E_SDRAW : bInstalled = m_lFactories[SvtModuleOptions::E_DRAW].getInstalled();
+ break;
+ case SvtModuleOptions::E_SIMPRESS : bInstalled = m_lFactories[SvtModuleOptions::E_IMPRESS].getInstalled();
+ break;
+ case SvtModuleOptions::E_SMATH : bInstalled = m_lFactories[SvtModuleOptions::E_MATH].getInstalled();
+ break;
+ case SvtModuleOptions::E_SCHART : bInstalled = m_lFactories[SvtModuleOptions::E_CHART].getInstalled();
+ break;
+ case SvtModuleOptions::E_SSTARTMODULE : bInstalled = m_lFactories[SvtModuleOptions::E_STARTMODULE].getInstalled();
+ break;
+ case SvtModuleOptions::E_SBASIC : bInstalled = sal_True; // Couldn't be deselected by setup yet!
+ break;
+ case SvtModuleOptions::E_SDATABASE : bInstalled = m_lFactories[SvtModuleOptions::E_DATABASE].getInstalled();
+ break;
+ }
+
+ return bInstalled;
+}
+
+/*-************************************************************************************************************//**
+ @short return list of key names of ouer configuration management which represent our module tree
+ @descr You give use a list of current existing set node names .. and we expand it for all
+ well known properties which are neccessary for this implementation.
+ These full expanded list should be used to get values of this properties.
+
+ @seealso ctor
+
+ @param -
+ @return List of all relative addressed properties of given set entry names.
+
+ @onerror List will be empty.
+ @threadsafe no
+*//*-*************************************************************************************************************/
+css::uno::Sequence< ::rtl::OUString > SvtModuleOptions_Impl::impl_ExpandSetNames( const css::uno::Sequence< ::rtl::OUString >& lSetNames )
+{
+ sal_Int32 nCount = lSetNames.getLength() ;
+ css::uno::Sequence< ::rtl::OUString > lPropNames ( nCount*PROPERTYCOUNT );
+ ::rtl::OUString* pPropNames = lPropNames.getArray() ;
+ sal_Int32 nPropStart = 0 ;
+
+ for( sal_Int32 nName=0; nName<nCount; ++nName )
+ {
+ pPropNames[nPropStart+PROPERTYHANDLE_SHORTNAME ] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_SHORTNAME ;
+ pPropNames[nPropStart+PROPERTYHANDLE_TEMPLATEFILE ] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_TEMPLATEFILE ;
+ pPropNames[nPropStart+PROPERTYHANDLE_WINDOWATTRIBUTES] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_WINDOWATTRIBUTES;
+ pPropNames[nPropStart+PROPERTYHANDLE_EMPTYDOCUMENTURL] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_EMPTYDOCUMENTURL;
+ pPropNames[nPropStart+PROPERTYHANDLE_DEFAULTFILTER ] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_DEFAULTFILTER ;
+ pPropNames[nPropStart+PROPERTYHANDLE_ICON ] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_ICON ;
+ nPropStart += PROPERTYCOUNT;
+ }
+
+ return lPropNames;
+}
+
+/*-************************************************************************************************************//**
+ @short helper to classify given factory by name
+ @descr Every factory has his own long and short name. So we can match right enum value for internal using.
+
+ @attention We change in/out parameter "eFactory" in every case! But you should use it only, if return value is TRUE!
+ Algorithm: Set out-parameter to propably value ... and check the longname.
+ If it match with these factory - break operation and return true AND right set parameter.
+ Otherwise try next one and so on. If no factory was found return false. Out parameter eFactory
+ is set to last tried value but shouldn't be used! Because our return value is false!
+
+ @seealso -
+
+ @param "sLongName" , long name of factory, which should be classified
+ @return "eFactory" , right enum value, which match given long name
+ and true for successfully classification, false otherwise
+
+ @onerror We return false.
+ @threadsafe no
+*//*-*************************************************************************************************************/
+sal_Bool SvtModuleOptions_Impl::ClassifyFactoryByName( const ::rtl::OUString& sName, SvtModuleOptions::EFactory& eFactory )
+{
+ sal_Bool bState;
+
+ eFactory = SvtModuleOptions::E_WRITER ;
+ bState = ( sName == FACTORYNAME_WRITER );
+
+ if( bState == sal_False )
+ {
+ eFactory = SvtModuleOptions::E_WRITERWEB ;
+ bState = ( sName == FACTORYNAME_WRITERWEB );
+ }
+ // no else!
+ if( bState == sal_False )
+ {
+ eFactory = SvtModuleOptions::E_WRITERGLOBAL ;
+ bState = ( sName == FACTORYNAME_WRITERGLOBAL );
+ }
+ // no else!
+ if( bState == sal_False )
+ {
+ eFactory = SvtModuleOptions::E_CALC ;
+ bState = ( sName == FACTORYNAME_CALC );
+ }
+ // no else!
+ if( bState == sal_False )
+ {
+ eFactory = SvtModuleOptions::E_DRAW ;
+ bState = ( sName == FACTORYNAME_DRAW );
+ }
+ // no else!
+ if( bState == sal_False )
+ {
+ eFactory = SvtModuleOptions::E_IMPRESS ;
+ bState = ( sName == FACTORYNAME_IMPRESS );
+ }
+ // no else!
+ if( bState == sal_False )
+ {
+ eFactory = SvtModuleOptions::E_MATH ;
+ bState = ( sName == FACTORYNAME_MATH );
+ }
+ // no else!
+ if( bState == sal_False )
+ {
+ eFactory = SvtModuleOptions::E_CHART ;
+ bState = ( sName == FACTORYNAME_CHART );
+ }
+ // no else!
+ if( bState == sal_False )
+ {
+ eFactory = SvtModuleOptions::E_DATABASE ;
+ bState = ( sName == FACTORYNAME_DATABASE );
+ }
+ // no else!
+ if( bState == sal_False )
+ {
+ eFactory = SvtModuleOptions::E_STARTMODULE ;
+ bState = ( sName == FACTORYNAME_STARTMODULE);
+ }
+
+ return bState;
+}
+
+/*-************************************************************************************************************//**
+ @short read factory configuration
+ @descr Give us a list of pure factory names (long names!) which can be used as
+ direct set node names ... and we read her property values and fill internal list.
+ These method can be used by initial reading at ctor and later updating by "Notify()".
+
+ @seealso ctor
+ @seealso method Notify()
+
+ @param "lFactories" is the list of set node entries which should be readed.
+ @return -
+
+ @onerror We do nothing.
+ @threadsafe no
+*//*-*************************************************************************************************************/
+void SvtModuleOptions_Impl::impl_Read( const css::uno::Sequence< ::rtl::OUString >& lFactories )
+{
+ // Expand every set node name in lFactories to full qualified pathes to his properties
+ // and get right values from configuration.
+ const css::uno::Sequence< ::rtl::OUString > lProperties = impl_ExpandSetNames( lFactories );
+ const css::uno::Sequence< css::uno::Any > lValues = GetProperties( lProperties );
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ OSL_ENSURE( !(lProperties.getLength()!=lValues.getLength()), "SvtModuleOptions_Impl::impl_Read()\nI miss some values of configuration keys!\n" );
+
+ // Algorithm: We step over all given factory names and classify it. These enum value can be used as direct index
+ // in our member list m_lFactories! VAriable nPropertyStart marks start position of every factory
+ // and her properties in expanded property/value list. The defines PROPERTHANDLE_xxx are used as offset values
+ // added to nPropertyStart. So we can address every property relative in these lists.
+ // If we found any valid values ... we reset all existing informations for corresponding m_lFactories-entry and
+ // use a pointer to these struct in memory directly to set new values.
+ // But we set it only, if bInstalled is true. Otherwise all other values of a factory can be undeclared .. They
+ // shouldn't be used then.
+ // Attention: If a propertyset of a factory will be ignored we must step to next start position of next factory infos!
+ // see "nPropertyStart += PROPERTYCOUNT" ...
+
+ sal_Int32 nPropertyStart = 0 ;
+ sal_Int32 nNodeCount = lFactories.getLength();
+ FactoryInfo* pInfo = NULL ;
+ SvtModuleOptions::EFactory eFactory ;
+
+ for( sal_Int32 nSetNode=0; nSetNode<nNodeCount; ++nSetNode )
+ {
+ const ::rtl::OUString& sFactoryName = lFactories[nSetNode];
+ if( ClassifyFactoryByName( sFactoryName, eFactory ) == sal_True )
+ {
+ ::rtl::OUString sTemp;
+ sal_Int32 nTemp = 0;
+
+ pInfo = &(m_lFactories[eFactory]);
+ pInfo->free();
+
+ pInfo->initInstalled( sal_True );
+ pInfo->initFactory ( sFactoryName );
+
+ if (lValues[nPropertyStart+PROPERTYHANDLE_SHORTNAME] >>= sTemp)
+ pInfo->initShortName( sTemp );
+ if (lValues[nPropertyStart+PROPERTYHANDLE_TEMPLATEFILE] >>= sTemp)
+ pInfo->initTemplateFile( sTemp );
+ if (lValues[nPropertyStart+PROPERTYHANDLE_WINDOWATTRIBUTES] >>= sTemp)
+ pInfo->initWindowAttributes( sTemp );
+ if (lValues[nPropertyStart+PROPERTYHANDLE_EMPTYDOCUMENTURL] >>= sTemp)
+ pInfo->initEmptyDocumentURL( sTemp );
+ if (lValues[nPropertyStart+PROPERTYHANDLE_DEFAULTFILTER ] >>= sTemp)
+ pInfo->initDefaultFilter( sTemp );
+ if (lValues[nPropertyStart+PROPERTYHANDLE_ICON] >>= nTemp)
+ pInfo->initIcon( nTemp );
+ }
+ nPropertyStart += PROPERTYCOUNT;
+ }
+}
+
+//*****************************************************************************************************************
+// initialize static member
+// DON'T DO IT IN YOUR HEADER!
+// see definition for further informations
+//*****************************************************************************************************************
+SvtModuleOptions_Impl* SvtModuleOptions::m_pDataContainer = NULL ;
+sal_Int32 SvtModuleOptions::m_nRefCount = 0 ;
+
+/*-************************************************************************************************************//**
+ @short standard constructor and destructor
+ @descr This will initialize an instance with default values. We initialize/deinitialize our static data
+ container and create a static mutex, which is used for threadsafe code in further time of this object.
+
+ @seealso method impl_GetOwnStaticMutex()
+
+ @param -
+ @return -
+
+ @onerror -
+ @threadsafe yes
+*//*-*************************************************************************************************************/
+SvtModuleOptions::SvtModuleOptions()
+{
+ ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
+ ++m_nRefCount;
+ if( m_nRefCount == 1 )
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtModuleOptions_Impl::ctor()");
+ m_pDataContainer = new SvtModuleOptions_Impl(this);
+
+ ItemHolder1::holdConfigItem(E_MODULEOPTIONS);
+ }
+}
+
+//*****************************************************************************************************************
+SvtModuleOptions::~SvtModuleOptions()
+{
+ ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
+ --m_nRefCount;
+ if( m_nRefCount == 0 )
+ {
+ delete m_pDataContainer;
+ m_pDataContainer = NULL;
+ }
+}
+
+/*-************************************************************************************************************//**
+ @short access to configuration data
+ @descr This methods allow read/write access to configuration values.
+ They are threadsafe. All calls are forwarded to impl-data-container. See there for further informations!
+
+ @seealso method impl_GetOwnStaticMutex()
+
+ @param -
+ @return -
+
+ @onerror -
+ @threadsafe yes
+*//*-*************************************************************************************************************/
+sal_Bool SvtModuleOptions::IsModuleInstalled( EModule eModule ) const
+{
+ ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
+ return m_pDataContainer->IsModuleInstalled( eModule );
+}
+
+//*****************************************************************************************************************
+sal_Bool SvtModuleOptions::IsChart() const
+{
+ ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
+ return m_pDataContainer->IsModuleInstalled( E_SCHART );
+}
+
+//*****************************************************************************************************************
+//*****************************************************************************************************************
+sal_Bool SvtModuleOptions::IsDraw() const
+{
+ ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
+ return m_pDataContainer->IsModuleInstalled( E_SDRAW );
+}
+
+//*****************************************************************************************************************
+sal_Bool SvtModuleOptions::IsWriter() const
+{
+ ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
+ return m_pDataContainer->IsModuleInstalled( E_SWRITER );
+}
+
+//*****************************************************************************************************************
+sal_Bool SvtModuleOptions::IsImpress() const
+{
+ ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
+ return m_pDataContainer->IsModuleInstalled( E_SIMPRESS );
+}
+
+//*****************************************************************************************************************
+sal_uInt32 SvtModuleOptions::GetFeatures() const
+{
+ ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
+
+ sal_uInt32 nFeature = 0;
+
+ if( m_pDataContainer->IsModuleInstalled( E_SWRITER ) == sal_True )
+ nFeature |= FEATUREFLAG_WRITER;
+ if( m_pDataContainer->IsModuleInstalled( E_SCALC ) == sal_True )
+ nFeature |= FEATUREFLAG_CALC;
+ if( m_pDataContainer->IsModuleInstalled( E_SDRAW ) == sal_True )
+ nFeature |= FEATUREFLAG_DRAW;
+ if( m_pDataContainer->IsModuleInstalled( E_SIMPRESS ) == sal_True )
+ nFeature |= FEATUREFLAG_IMPRESS;
+ if( m_pDataContainer->IsModuleInstalled( E_SCHART ) == sal_True )
+ nFeature |= FEATUREFLAG_CHART;
+ if( m_pDataContainer->IsModuleInstalled( E_SMATH ) == sal_True )
+ nFeature |= FEATUREFLAG_MATH;
+ if( m_pDataContainer->IsModuleInstalled( E_SBASIC ) == sal_True )
+ nFeature |= FEATUREFLAG_BASICIDE;
+ if( m_pDataContainer->IsModuleInstalled( E_SDATABASE ) == sal_True )
+ nFeature |= FEATUREFLAG_INSIGHT;
+
+ return nFeature;
+}
+
+/*-****************************************************************************************************//**
+ @short return a reference to a static mutex
+ @descr These class is threadsafe.
+ We create a static mutex only for one time and use it to protect our refcount and container
+ member!
+
+ @seealso -
+
+ @param -
+ @return A reference to a static mutex member.
+
+ @onerror -
+ @threadsafe yes
+*//*-*****************************************************************************************************/
+::osl::Mutex& SvtModuleOptions::impl_GetOwnStaticMutex()
+{
+ // Initialize static mutex only for one time!
+ static ::osl::Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static ::osl::Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_options.cxx b/binfilter/bf_svtools/source/config/svt_options.cxx
new file mode 100644
index 000000000000..fa4e16ca4d27
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_options.cxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 "sal/config.h"
+
+#include <bf_svtools/options.hxx>
+
+namespace binfilter
+{
+
+Options::Options() {}
+
+Options::~Options() {}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_options3d.cxx b/binfilter/bf_svtools/source/config/svt_options3d.cxx
new file mode 100644
index 000000000000..cc39ed8d0000
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_options3d.cxx
@@ -0,0 +1,315 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+//_________________________________________________________________________________________________________________
+// includes
+//_________________________________________________________________________________________________________________
+
+#include <bf_svtools/options3d.hxx>
+
+#include <unotools/configmgr.hxx>
+
+#include <unotools/configitem.hxx>
+
+#include <tools/debug.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <itemholder1.hxx>
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+using namespace ::utl ;
+using namespace ::rtl ;
+using namespace ::osl ;
+using namespace ::com::sun::star::uno ;
+
+namespace binfilter
+{
+
+//_________________________________________________________________________________________________________________
+// const
+//_________________________________________________________________________________________________________________
+
+#define ROOTNODE_START OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/_3D_Engine" ))
+#define DEFAULT_DITHERING sal_True
+#define DEFAULT_OPENGL sal_True
+#define DEFAULT_OPENGL_FASTER sal_True
+#define DEFAULT_OPENGL_FASTER sal_True
+#define DEFAULT_SHOWFULL sal_False
+
+#define PROPERTYNAME_DITHERING OUString(RTL_CONSTASCII_USTRINGPARAM("Dithering" ))
+#define PROPERTYNAME_OPENGL OUString(RTL_CONSTASCII_USTRINGPARAM("OpenGL" ))
+#define PROPERTYNAME_OPENGL_FASTER OUString(RTL_CONSTASCII_USTRINGPARAM("OpenGL_Faster" ))
+#define PROPERTYNAME_SHOWFULL OUString(RTL_CONSTASCII_USTRINGPARAM("ShowFull" ))
+
+#define PROPERTYHANDLE_DITHERING 0
+#define PROPERTYHANDLE_OPENGL 1
+#define PROPERTYHANDLE_OPENGL_FASTER 2
+#define PROPERTYHANDLE_SHOWFULL 3
+
+#define PROPERTYCOUNT 4
+
+class SvtOptions3D_Impl : public ConfigItem
+{
+public:
+
+//---------------------------------------------------------------------------------------------------------
+// constructor / destructor
+//---------------------------------------------------------------------------------------------------------
+
+ SvtOptions3D_Impl();
+ ~SvtOptions3D_Impl();
+
+//---------------------------------------------------------------------------------------------------------
+// overloaded methods of baseclass
+//---------------------------------------------------------------------------------------------------------
+
+ virtual void Commit();
+ void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& );
+
+//-------------------------------------------------------------------------------------------------------------
+// private methods
+//-------------------------------------------------------------------------------------------------------------
+
+private:
+
+ static Sequence< OUString > impl_GetPropertyNames();
+
+//-------------------------------------------------------------------------------------------------------------
+// private member
+//-------------------------------------------------------------------------------------------------------------
+
+private:
+
+ sal_Bool m_bDithering;
+ sal_Bool m_bOpenGL;
+ sal_Bool m_bOpenGL_Faster;
+ sal_Bool m_bShowFull;
+};
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtOptions3D_Impl::SvtOptions3D_Impl() :
+ ConfigItem( ROOTNODE_START ),
+ m_bDithering( DEFAULT_DITHERING ),
+ m_bOpenGL( DEFAULT_OPENGL ),
+ m_bOpenGL_Faster( DEFAULT_OPENGL_FASTER ),
+ m_bShowFull( DEFAULT_SHOWFULL )
+{
+ Sequence< OUString > seqNames( impl_GetPropertyNames() );
+ Sequence< Any > seqValues = GetProperties( seqNames ) ;
+
+ DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtOptions3D_Impl::SvtOptions3D_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to ouer internal member.
+ sal_Int32 nPropertyCount = seqValues.getLength();
+ sal_Int32 nProperty = 0;
+
+ for( nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtOptions3D_Impl::SvtOptions3D_Impl()\nInvalid property value for property detected!\n" );
+
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_DITHERING:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptions3D_Impl::SvtOptions3D_Impl()\nWho has changed the value type of \"Office.Common\\_3D_Engine\\Dithering\"?" );
+ seqValues[nProperty] >>= m_bDithering;
+ }
+ break;
+
+ case PROPERTYHANDLE_OPENGL:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptions3D_Impl::SvtOptions3D_Impl()\nWho has changed the value type of \"Office.Common\\_3D_Engine\\OpenGL\"?" );
+ seqValues[nProperty] >>= m_bOpenGL;
+ }
+ break;
+
+ case PROPERTYHANDLE_OPENGL_FASTER:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptions3D_Impl::SvtOptions3D_Impl()\nWho has changed the value type of \"Office.Common\\_3D_Engine\\OpenGL_Faster\"?" );
+ seqValues[nProperty] >>= m_bOpenGL_Faster;
+ }
+ break;
+
+ case PROPERTYHANDLE_SHOWFULL:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptions3D_Impl::SvtOptions3D_Impl()\nWho has changed the value type of \"Office.Common\\_3D_Engine\\ShowFull\"?" );
+ seqValues[nProperty] >>= m_bShowFull;
+ }
+ break;
+ }
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtOptions3D_Impl::~SvtOptions3D_Impl()
+{
+ if( IsModified() )
+ Commit();
+}
+
+//*****************************************************************************************************************
+// Commit
+//*****************************************************************************************************************
+void SvtOptions3D_Impl::Commit()
+{
+ Sequence< OUString > aSeqNames( impl_GetPropertyNames() );
+ Sequence< Any > aSeqValues( aSeqNames.getLength() );
+
+ for( sal_Int32 nProperty = 0, nCount = aSeqNames.getLength(); nProperty < nCount; ++nProperty )
+ {
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_DITHERING:
+ aSeqValues[nProperty] <<= m_bDithering;
+ break;
+
+ case PROPERTYHANDLE_OPENGL:
+ aSeqValues[nProperty] <<= m_bOpenGL;
+ break;
+
+ case PROPERTYHANDLE_OPENGL_FASTER:
+ aSeqValues[nProperty] <<= m_bOpenGL_Faster;
+ break;
+
+ case PROPERTYHANDLE_SHOWFULL:
+ aSeqValues[nProperty] <<= m_bShowFull;
+ break;
+ }
+ }
+
+ PutProperties( aSeqNames, aSeqValues );
+}
+
+ void SvtOptions3D_Impl::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Sequence< OUString > SvtOptions3D_Impl::impl_GetPropertyNames()
+{
+ // Build static list of configuration key names.
+ static const OUString pProperties[] =
+ {
+ PROPERTYNAME_DITHERING ,
+ PROPERTYNAME_OPENGL ,
+ PROPERTYNAME_OPENGL_FASTER ,
+ PROPERTYNAME_SHOWFULL
+ };
+ // Initialize return sequence with these list ...
+ static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
+ // ... and return it.
+ return seqPropertyNames;
+}
+
+//*****************************************************************************************************************
+// initialize static member
+// DON'T DO IT IN YOUR HEADER!
+// see definition for further informations
+//*****************************************************************************************************************
+SvtOptions3D_Impl* SvtOptions3D::m_pDataContainer = NULL ;
+sal_Int32 SvtOptions3D::m_nRefCount = 0 ;
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtOptions3D::SvtOptions3D()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already!
+ if( m_pDataContainer == NULL )
+ {
+ m_pDataContainer = new SvtOptions3D_Impl();
+ ItemHolder1::holdConfigItem(E_OPTIONS3D);
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtOptions3D::~SvtOptions3D()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Decrease ouer refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pDataContainer;
+ m_pDataContainer = NULL;
+ }
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Mutex& SvtOptions3D::GetOwnStaticMutex()
+{
+ // Initialize static mutex only for one time!
+ static Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_optionsdlg.cxx b/binfilter/bf_svtools/source/config/svt_optionsdlg.cxx
new file mode 100644
index 000000000000..8a95581b5e6c
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_optionsdlg.cxx
@@ -0,0 +1,227 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/optionsdlg.hxx>
+
+#include <unotools/configmgr.hxx>
+#include <unotools/configitem.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <osl/mutex.hxx>
+#include <comphelper/stl_types.hxx>
+
+#include <hash_map>
+#include "itemholder1.hxx"
+
+using namespace utl;
+using namespace rtl;
+using namespace com::sun::star::beans ;
+using namespace com::sun::star::uno;
+
+namespace binfilter
+{
+
+#define CFG_FILENAME OUString( RTL_CONSTASCII_USTRINGPARAM( "Office.OptionsDialog" ) )
+#define ROOT_NODE OUString( RTL_CONSTASCII_USTRINGPARAM( "OptionsDialogGroups" ) )
+#define PAGES_NODE OUString( RTL_CONSTASCII_USTRINGPARAM( "Pages" ) )
+#define OPTIONS_NODE OUString( RTL_CONSTASCII_USTRINGPARAM( "Options" ) )
+#define PROPERTY_HIDE OUString( RTL_CONSTASCII_USTRINGPARAM( "Hide" ) )
+
+static SvtOptionsDlgOptions_Impl* pOptions = NULL;
+static sal_Int32 nRefCount = 0;
+
+class SvtOptionsDlgOptions_Impl : public utl::ConfigItem
+{
+private:
+ struct OUStringHashCode
+ {
+ size_t operator()( const ::rtl::OUString& sString ) const
+ {
+ return sString.hashCode();
+ }
+ };
+
+ typedef std::hash_map< OUString, sal_Bool, OUStringHashCode, ::std::equal_to< OUString > > OptionNodeList;
+
+ OUString m_sPathDelimiter;
+ OptionNodeList m_aOptionNodeList;
+
+ enum NodeType{ NT_Group, NT_Page, NT_Option };
+ void ReadNode( const OUString& _rNode, NodeType _eType );
+
+public:
+ SvtOptionsDlgOptions_Impl();
+
+ virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
+ virtual void Commit();
+
+ static ::osl::Mutex & getInitMutex();
+};
+
+::osl::Mutex & SvtOptionsDlgOptions_Impl::getInitMutex()
+{
+ static ::osl::Mutex *pMutex = 0;
+
+ if( ! pMutex )
+ {
+ ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
+ if( ! pMutex )
+ {
+ static ::osl::Mutex mutex;
+ pMutex = &mutex;
+ }
+ }
+ return *pMutex;
+}
+
+// -----------------------------------------------------------------------
+
+SvtOptionsDlgOptions_Impl::SvtOptionsDlgOptions_Impl()
+ : ConfigItem( OUString( CFG_FILENAME ) ),
+
+ m_sPathDelimiter( RTL_CONSTASCII_USTRINGPARAM( "/" ) ),
+ m_aOptionNodeList( OptionNodeList() )
+
+{
+ OUString sRootNode( ROOT_NODE );
+ Sequence< OUString > aNodeSeq = GetNodeNames( sRootNode );
+ OUString sNode( sRootNode + m_sPathDelimiter );
+ sal_uInt32 nCount = aNodeSeq.getLength();
+ for ( sal_uInt32 n = 0; n < nCount; n++ )
+ {
+ OUString sSubNode( sNode + aNodeSeq[n] );
+ ReadNode( sSubNode, NT_Group );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvtOptionsDlgOptions_Impl::Commit()
+{
+ // nothing to commit
+}
+
+// -----------------------------------------------------------------------
+
+void SvtOptionsDlgOptions_Impl::Notify( const Sequence< rtl::OUString >& )
+{
+ // nothing to notify
+}
+
+void SvtOptionsDlgOptions_Impl::ReadNode( const OUString& _rNode, NodeType _eType )
+{
+ OUString sNode( _rNode + m_sPathDelimiter );
+ OUString sSet;
+ sal_Int32 nLen = 0;
+ switch ( _eType )
+ {
+ case NT_Group :
+ {
+ sSet = PAGES_NODE;
+ nLen = 2;
+ break;
+ }
+
+ case NT_Page :
+ {
+ sSet = OPTIONS_NODE;
+ nLen = 2;
+ break;
+ }
+
+ case NT_Option :
+ {
+ nLen = 1;
+ break;
+ }
+ }
+
+ Sequence< OUString > lResult( nLen );
+ lResult[0] = OUString( sNode + PROPERTY_HIDE );
+ if ( _eType != NT_Option )
+ lResult[1] = OUString( sNode + sSet );
+
+ Sequence< Any > aValues;
+ aValues = GetProperties( lResult );
+ sal_Bool bHide = sal_False;
+ if ( aValues[0] >>= bHide )
+ m_aOptionNodeList.insert( OptionNodeList::value_type( sNode, bHide ) );
+
+ if ( _eType != NT_Option )
+ {
+ OUString sNodes( sNode + sSet );
+ Sequence< OUString > aNodes = GetNodeNames( sNodes );
+ if ( aNodes.getLength() > 0 )
+ {
+ for ( sal_uInt32 n = 0; n < (sal_uInt32)aNodes.getLength(); ++n )
+ {
+ OUString sSubNodeName( sNodes + m_sPathDelimiter + aNodes[n] );
+ ReadNode( sSubNodeName, _eType == NT_Group ? NT_Page : NT_Option );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+SvtOptionsDialogOptions::SvtOptionsDialogOptions()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( SvtOptionsDlgOptions_Impl::getInitMutex() );
+ ++nRefCount;
+ if ( !pOptions )
+ {
+ pOptions = new SvtOptionsDlgOptions_Impl;
+
+ ItemHolder1::holdConfigItem( E_OPTIONSDLGOPTIONS );
+ }
+ m_pImp = pOptions;
+}
+
+// -----------------------------------------------------------------------
+
+SvtOptionsDialogOptions::~SvtOptionsDialogOptions()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( SvtOptionsDlgOptions_Impl::getInitMutex() );
+ if ( !--nRefCount )
+ {
+ if ( pOptions->IsModified() )
+ pOptions->Commit();
+ DELETEZ( pOptions );
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_pathoptions.cxx b/binfilter/bf_svtools/source/config/svt_pathoptions.cxx
new file mode 100644
index 000000000000..3c6d16f56816
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_pathoptions.cxx
@@ -0,0 +1,923 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <com/sun/star/frame/XConfigManager.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+
+#include <bf_svtools/pathoptions.hxx>
+
+#include <unotools/configitem.hxx>
+#include <unotools/configmgr.hxx>
+#include <tools/debug.hxx>
+#include <tools/resmgr.hxx>
+#include <tools/urlobj.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <osl/mutex.hxx>
+#include <osl/file.hxx>
+#include <unotools/localfilehelper.hxx>
+#include <unotools/bootstrap.hxx>
+
+#include <unotools/ucbhelper.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/util/XStringSubstitution.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <rtl/instance.hxx>
+
+#include <itemholder1.hxx>
+
+#include <vector>
+#include <hash_map>
+
+using namespace osl;
+using namespace utl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::util;
+using namespace com::sun::star::lang;
+
+namespace binfilter
+{
+
+// define ----------------------------------------------------------------
+
+#define SEARCHPATH_DELIMITER ';'
+
+#define ASCII_STR(s) OUString( RTL_CONSTASCII_USTRINGPARAM(s) )
+
+#define SIGN_STARTVARIABLE ASCII_STR("$(")
+#define SIGN_ENDVARIABLE ASCII_STR(")")
+
+// Supported variables by the old SvtPathOptions implementation
+#define SUBSTITUTE_INST "$(inst)"
+#define SUBSTITUTE_PROG "$(prog)"
+#define SUBSTITUTE_USER "$(user)"
+#define SUBSTITUTE_INSTPATH "$(instpath)"
+#define SUBSTITUTE_PROGPATH "$(progpath)"
+#define SUBSTITUTE_USERPATH "$(userpath)"
+#define SUBSTITUTE_INSTURL "$(insturl)"
+#define SUBSTITUTE_PROGURL "$(progurl)"
+#define SUBSTITUTE_USERURL "$(userurl)"
+#define SUBSTITUTE_PATH "$(path)"
+//#define SUBSTITUTE_LANG "$(lang)"
+#define SUBSTITUTE_LANGID "$(langid)"
+#define SUBSTITUTE_VLANG "$(vlang)"
+#define SUBSTITUTE_WORKDIRURL "$(workdirurl)"
+
+#define STRPOS_NOTFOUND -1
+
+struct OUStringHashCode
+{
+ size_t operator()( const ::rtl::OUString& sString ) const
+ {
+ return sString.hashCode();
+ }
+};
+
+enum VarNameProperty
+{
+ VAR_NEEDS_SYSTEM_PATH,
+ VAR_NEEDS_FILEURL
+};
+
+class NameToHandleMap : public ::std::hash_map< ::rtl::OUString, sal_Int32, OUStringHashCode, ::std::equal_to< ::rtl::OUString > >
+{
+ public:
+ inline void free() { NameToHandleMap().swap( *this ); }
+};
+
+class EnumToHandleMap : public ::std::hash_map< sal_Int32, sal_Int32, std::hash< sal_Int32 >, std::equal_to< sal_Int32 > >
+{
+ public:
+ inline void free() { EnumToHandleMap().swap( *this ); }
+};
+
+class VarNameToEnumMap : public ::std::hash_map< OUString, VarNameProperty, OUStringHashCode, ::std::equal_to< OUString > >
+{
+ public:
+ inline void free() { VarNameToEnumMap().swap( *this ); }
+};
+
+
+// class SvtPathOptions_Impl ---------------------------------------------
+class SvtPathOptions_Impl
+{
+ private:
+ // Local variables to return const references
+ std::vector< String > m_aPathArray;
+ Reference< XFastPropertySet > m_xPathSettings;
+ Reference< XStringSubstitution > m_xSubstVariables;
+ mutable EnumToHandleMap m_aMapEnumToPropHandle;
+ VarNameToEnumMap m_aMapVarNamesToEnum;
+
+ ::com::sun::star::lang::Locale m_aLocale;
+ String m_aEmptyString;
+ mutable ::osl::Mutex m_aMutex;
+
+ public:
+ SvtPathOptions_Impl();
+
+ // get the pathes, not const because of using a mutex
+ const String& GetPath( SvtPathOptions::Pathes );
+ const String& GetAddinPath() { return GetPath( SvtPathOptions::PATH_ADDIN ); }
+ const String& GetAutoCorrectPath() { return GetPath( SvtPathOptions::PATH_AUTOCORRECT ); }
+ const String& GetAutoTextPath() { return GetPath( SvtPathOptions::PATH_AUTOTEXT ); }
+ const String& GetBackupPath() { return GetPath( SvtPathOptions::PATH_BACKUP ); }
+ const String& GetBasicPath() { return GetPath( SvtPathOptions::PATH_BASIC ); }
+ const String& GetBitmapPath() { return GetPath( SvtPathOptions::PATH_BITMAP ); }
+ const String& GetConfigPath() { return GetPath( SvtPathOptions::PATH_CONFIG ); }
+ const String& GetDictionaryPath() { return GetPath( SvtPathOptions::PATH_DICTIONARY ); }
+ const String& GetFavoritesPath() { return GetPath( SvtPathOptions::PATH_FAVORITES ); }
+ const String& GetFilterPath() { return GetPath( SvtPathOptions::PATH_FILTER ); }
+ const String& GetGalleryPath() { return GetPath( SvtPathOptions::PATH_GALLERY ); }
+ const String& GetGraphicPath() { return GetPath( SvtPathOptions::PATH_GRAPHIC ); }
+ const String& GetHelpPath() { return GetPath( SvtPathOptions::PATH_HELP ); }
+ const String& GetLinguisticPath() { return GetPath( SvtPathOptions::PATH_LINGUISTIC ); }
+ const String& GetModulePath() { return GetPath( SvtPathOptions::PATH_MODULE ); }
+ const String& GetPalettePath() { return GetPath( SvtPathOptions::PATH_PALETTE ); }
+ const String& GetPluginPath() { return GetPath( SvtPathOptions::PATH_PLUGIN ); }
+ const String& GetStoragePath() { return GetPath( SvtPathOptions::PATH_STORAGE ); }
+ const String& GetTempPath() { return GetPath( SvtPathOptions::PATH_TEMP ); }
+ const String& GetTemplatePath() { return GetPath( SvtPathOptions::PATH_TEMPLATE ); }
+ const String& GetUserConfigPath() { return GetPath( SvtPathOptions::PATH_USERCONFIG ); }
+ const String& GetUserDictionaryPath() { return GetPath( SvtPathOptions::PATH_USERDICTIONARY ); }
+ const String& GetWorkPath() { return GetPath( SvtPathOptions::PATH_WORK ); }
+ const String& GetUIConfigPath() { return GetPath( SvtPathOptions::PATH_UICONFIG ); }
+ const String& GetFingerprintPath() { return GetPath( SvtPathOptions::PATH_FINGERPRINT ); }
+
+ // set the pathes
+ void SetPath( SvtPathOptions::Pathes, const String& rNewPath );
+ void SetAddinPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_ADDIN, rPath ); }
+ void SetAutoCorrectPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_AUTOCORRECT, rPath ); }
+ void SetAutoTextPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_AUTOTEXT, rPath ); }
+ void SetBackupPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_BACKUP, rPath ); }
+ void SetBasicPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_BASIC, rPath ); }
+ void SetBitmapPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_BITMAP, rPath ); }
+ void SetConfigPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_CONFIG, rPath ); }
+ void SetDictionaryPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_DICTIONARY, rPath ); }
+ void SetFavoritesPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_FAVORITES, rPath ); }
+ void SetFilterPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_FILTER, rPath ); }
+ void SetGalleryPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_GALLERY, rPath ); }
+ void SetGraphicPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_GRAPHIC, rPath ); }
+ void SetHelpPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_HELP, rPath ); }
+ void SetLinguisticPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_LINGUISTIC, rPath ); }
+ void SetModulePath( const String& rPath ) { SetPath( SvtPathOptions::PATH_MODULE, rPath ); }
+ void SetPalettePath( const String& rPath ) { SetPath( SvtPathOptions::PATH_PALETTE, rPath ); }
+ void SetPluginPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_PLUGIN, rPath ); }
+ void SetStoragePath( const String& rPath ) { SetPath( SvtPathOptions::PATH_STORAGE, rPath ); }
+ void SetTempPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_TEMP, rPath ); }
+ void SetTemplatePath( const String& rPath ) { SetPath( SvtPathOptions::PATH_TEMPLATE, rPath ); }
+ void SetUserConfigPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_USERCONFIG, rPath ); }
+ void SetUserDictionaryPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_USERDICTIONARY, rPath ); }
+ void SetWorkPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_WORK, rPath ); }
+
+ rtl::OUString SubstVar( const rtl::OUString& rVar );
+ rtl::OUString SubstituteAndConvert( const rtl::OUString& rPath );
+ rtl::OUString UsePathVariables( const rtl::OUString& rPath );
+
+ ::com::sun::star::lang::Locale GetLocale() const { return m_aLocale; }
+};
+
+// global ----------------------------------------------------------------
+
+static SvtPathOptions_Impl* pOptions = NULL;
+static sal_Int32 nRefCount = 0;
+
+// functions -------------------------------------------------------------
+struct PropertyStruct
+{
+ const char* pPropName; // The ascii name of the Office path
+ SvtPathOptions::Pathes ePath; // The enum value used by SvtPathOptions
+};
+
+struct VarNameAttribute
+{
+ const char* pVarName; // The name of the path variable
+ VarNameProperty eVarProperty; // Which return value is needed by this path variable
+};
+
+static PropertyStruct aPropNames[] =
+{
+ { "Addin", SvtPathOptions::PATH_ADDIN },
+ { "AutoCorrect", SvtPathOptions::PATH_AUTOCORRECT },
+ { "AutoText", SvtPathOptions::PATH_AUTOTEXT },
+ { "Backup", SvtPathOptions::PATH_BACKUP },
+ { "Basic", SvtPathOptions::PATH_BASIC },
+ { "Bitmap", SvtPathOptions::PATH_BITMAP },
+ { "Config", SvtPathOptions::PATH_CONFIG },
+ { "Dictionary", SvtPathOptions::PATH_DICTIONARY },
+ { "Favorite", SvtPathOptions::PATH_FAVORITES },
+ { "Filter", SvtPathOptions::PATH_FILTER },
+ { "Gallery", SvtPathOptions::PATH_GALLERY },
+ { "Graphic", SvtPathOptions::PATH_GRAPHIC },
+ { "Help", SvtPathOptions::PATH_HELP },
+ { "Linguistic", SvtPathOptions::PATH_LINGUISTIC },
+ { "Module", SvtPathOptions::PATH_MODULE },
+ { "Palette", SvtPathOptions::PATH_PALETTE },
+ { "Plugin", SvtPathOptions::PATH_PLUGIN },
+ { "Storage", SvtPathOptions::PATH_STORAGE },
+ { "Temp", SvtPathOptions::PATH_TEMP },
+ { "Template", SvtPathOptions::PATH_TEMPLATE },
+ { "UserConfig", SvtPathOptions::PATH_USERCONFIG },
+ { "UserDictionary", SvtPathOptions::PATH_USERDICTIONARY },
+ { "Work", SvtPathOptions::PATH_WORK },
+ { "UIConfig", SvtPathOptions::PATH_UICONFIG },
+ { "Fingerprint", SvtPathOptions::PATH_FINGERPRINT }
+};
+
+static VarNameAttribute aVarNameAttribute[] =
+{
+ { SUBSTITUTE_INSTPATH, VAR_NEEDS_SYSTEM_PATH }, // $(instpath)
+ { SUBSTITUTE_PROGPATH, VAR_NEEDS_SYSTEM_PATH }, // $(progpath)
+ { SUBSTITUTE_USERPATH, VAR_NEEDS_SYSTEM_PATH }, // $(userpath)
+ { SUBSTITUTE_PATH, VAR_NEEDS_SYSTEM_PATH }, // $(path)
+};
+
+#if 0
+// currently unused
+static Sequence< OUString > GetPathPropertyNames()
+{
+ const int nCount = sizeof( aPropNames ) / sizeof( PropertyStruct );
+ Sequence< OUString > aNames( nCount );
+ OUString* pNames = aNames.getArray();
+ for ( int i = 0; i < nCount; i++ )
+ pNames[i] = OUString::createFromAscii( aPropNames[i].pPropName );
+
+ return aNames;
+}
+#endif
+
+// class SvtPathOptions_Impl ---------------------------------------------
+
+const String& SvtPathOptions_Impl::GetPath( SvtPathOptions::Pathes ePath )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( ePath < SvtPathOptions::PATH_COUNT )
+ {
+ OUString aPathValue;
+ String aResult;
+ sal_Int32 nHandle = m_aMapEnumToPropHandle[ (sal_Int32)ePath ];
+
+ // Substitution is done by the service itself using the substition service
+ Any a = m_xPathSettings->getFastPropertyValue( nHandle );
+ a >>= aPathValue;
+ if( ePath == SvtPathOptions::PATH_ADDIN ||
+ ePath == SvtPathOptions::PATH_FILTER ||
+ ePath == SvtPathOptions::PATH_HELP ||
+ ePath == SvtPathOptions::PATH_MODULE ||
+ ePath == SvtPathOptions::PATH_PLUGIN ||
+ ePath == SvtPathOptions::PATH_STORAGE
+ )
+ {
+ // These office paths have to be converted to system pathes
+ utl::LocalFileHelper::ConvertURLToPhysicalName( aPathValue, aResult );
+ aPathValue = aResult;
+ }
+
+ m_aPathArray[ ePath ] = aPathValue;
+ return m_aPathArray[ ePath ];
+ }
+
+ return m_aEmptyString;
+}
+
+// -----------------------------------------------------------------------
+
+void SvtPathOptions_Impl::SetPath( SvtPathOptions::Pathes ePath, const String& rNewPath )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( ePath < SvtPathOptions::PATH_COUNT )
+ {
+ String aResult;
+ OUString aNewValue;
+ Any a;
+
+ switch ( ePath )
+ {
+ case SvtPathOptions::PATH_ADDIN:
+ case SvtPathOptions::PATH_FILTER:
+ case SvtPathOptions::PATH_HELP:
+ case SvtPathOptions::PATH_MODULE:
+ case SvtPathOptions::PATH_PLUGIN:
+ case SvtPathOptions::PATH_STORAGE:
+ {
+ // These office paths have to be convert back to UCB-URL's
+ utl::LocalFileHelper::ConvertPhysicalNameToURL( rNewPath, aResult );
+ aNewValue = aResult;
+ }
+ break;
+
+ default:
+ aNewValue = rNewPath;
+ }
+
+ // Resubstitution is done by the service itself using the substition service
+ a <<= aNewValue;
+ try
+ {
+ m_xPathSettings->setFastPropertyValue( m_aMapEnumToPropHandle[ (sal_Int32)ePath], a );
+ }
+ catch (const Exception&)
+ {
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+OUString SvtPathOptions_Impl::SubstituteAndConvert( const rtl::OUString& rPath )
+{
+ return SubstVar( rPath );
+}
+
+//-------------------------------------------------------------------------
+
+OUString SvtPathOptions_Impl::UsePathVariables( const OUString& rPath )
+{
+ return m_xSubstVariables->reSubstituteVariables( rPath );
+}
+
+// -----------------------------------------------------------------------
+
+OUString SvtPathOptions_Impl::SubstVar( const OUString& rVar )
+{
+ // Don't work at parameter-string directly. Copy it.
+ OUString aWorkText = rVar;
+
+ // Convert the returned path to system path!
+ BOOL bConvertLocal = FALSE;
+
+ // Search for first occure of "$(...".
+ sal_Int32 nPosition = aWorkText.indexOf( SIGN_STARTVARIABLE ); // = first position of "$(" in string
+ sal_Int32 nLength = 0; // = count of letters from "$(" to ")" in string
+
+ // Have we found any variable like "$(...)"?
+ if ( nPosition != STRPOS_NOTFOUND )
+ {
+ // Yes; Get length of found variable.
+ // If no ")" was found - nLength is set to 0 by default! see before.
+ sal_Int32 nEndPosition = aWorkText.indexOf( SIGN_ENDVARIABLE, nPosition );
+ if ( nEndPosition != STRPOS_NOTFOUND )
+ nLength = nEndPosition - nPosition + 1;
+ }
+
+ // Is there another path variable?
+ while ( ( nPosition != STRPOS_NOTFOUND ) && ( nLength > 0 ) )
+ {
+ // YES; Get the next variable for replace.
+ OUString aReplacement;
+ OUString aSubString = aWorkText.copy( nPosition, nLength );
+ aSubString = aSubString.toAsciiLowerCase();
+
+ // Look for special variable that needs a system path.
+ VarNameToEnumMap::const_iterator pIter = m_aMapVarNamesToEnum.find( aSubString );
+ if ( pIter != m_aMapVarNamesToEnum.end() )
+ bConvertLocal = TRUE;
+
+ nPosition += nLength;
+
+ // We must control index in string before call something at OUString!
+ // The OUString-implementation don't do it for us :-( but the result is not defined otherwise.
+ if ( nPosition + 1 > aWorkText.getLength() )
+ {
+ // Position is out of range. Break loop!
+ nPosition = STRPOS_NOTFOUND;
+ nLength = 0;
+ }
+ else
+ {
+ // Else; Position is valid. Search for next variable.
+ nPosition = aWorkText.indexOf( SIGN_STARTVARIABLE, nPosition );
+ // Have we found any variable like "$(...)"?
+ if ( nPosition != STRPOS_NOTFOUND )
+ {
+ // Yes; Get length of found variable. If no ")" was found - nLength must set to 0!
+ nLength = 0;
+ sal_Int32 nEndPosition = aWorkText.indexOf( SIGN_ENDVARIABLE, nPosition );
+ if ( nEndPosition != STRPOS_NOTFOUND )
+ nLength = nEndPosition - nPosition + 1;
+ }
+ }
+ }
+
+ aWorkText = m_xSubstVariables->substituteVariables( rVar, sal_False );
+
+ if ( bConvertLocal )
+ {
+ // Convert the URL to a system path for special path variables
+ String aReturn;
+ utl::LocalFileHelper::ConvertURLToPhysicalName( aWorkText, aReturn );
+ return aReturn;
+ }
+
+ return aWorkText;
+}
+
+// -----------------------------------------------------------------------
+
+SvtPathOptions_Impl::SvtPathOptions_Impl() :
+ m_aPathArray( (sal_Int32)SvtPathOptions::PATH_COUNT )
+{
+ Reference< XMultiServiceFactory > xSMgr = comphelper::getProcessServiceFactory();
+
+ // Create necessary services
+ m_xPathSettings = Reference< XFastPropertySet >( xSMgr->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.util.PathSettings" ))),
+ UNO_QUERY );
+ if ( !m_xPathSettings.is() )
+ {
+ // #112719#: check for existance
+ DBG_ERROR( "SvtPathOptions_Impl::SvtPathOptions_Impl(): #112719# happened again!" );
+ throw RuntimeException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Service com.sun.star.util.PathSettings cannot be created" )),
+ Reference< XInterface >() );
+ }
+
+ m_xSubstVariables = Reference< XStringSubstitution >( xSMgr->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.util.PathSubstitution" ))),
+ UNO_QUERY );
+ if ( !m_xSubstVariables.is() )
+ {
+ // #112719#: check for existance
+ DBG_ERROR( "SvtPathOptions_Impl::SvtPathOptions_Impl(): #112719# happened again!" );
+ throw RuntimeException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Service com.sun.star.util.PathSubstitution cannot be created" )),
+ Reference< XInterface >() );
+ }
+
+ // Create temporary hash map to have a mapping between property names and property handles
+ Reference< XPropertySet > xPropertySet = Reference< XPropertySet >( m_xPathSettings, UNO_QUERY );
+ Reference< XPropertySetInfo > xPropSetInfo = xPropertySet->getPropertySetInfo();
+ Sequence< Property > aPathPropSeq = xPropSetInfo->getProperties();
+
+ NameToHandleMap aTempHashMap;
+ for ( sal_Int32 n = 0; n < aPathPropSeq.getLength(); n++ )
+ {
+ const com::sun::star::beans::Property& aProperty = aPathPropSeq[n];
+ aTempHashMap.insert( NameToHandleMap::value_type( aProperty.Name, aProperty.Handle ));
+ }
+
+ // Create mapping between internal enum (SvtPathOptions::Pathes) and property handle
+ sal_Int32 nCount = sizeof( aPropNames ) / sizeof( PropertyStruct );
+ sal_Int32 i;
+ for ( i = 0; i < nCount; i++ )
+ {
+ NameToHandleMap::const_iterator pIter =
+ aTempHashMap.find( rtl::OUString::createFromAscii( aPropNames[i].pPropName ));
+
+ if ( pIter != aTempHashMap.end() )
+ {
+ sal_Int32 nHandle = pIter->second;
+ sal_Int32 nEnum = aPropNames[i].ePath;
+ m_aMapEnumToPropHandle.insert( EnumToHandleMap::value_type( nEnum, nHandle ));
+ }
+ }
+
+ // Create hash map for path variables that need a system path as a return value!
+ nCount = sizeof( aVarNameAttribute ) / sizeof( VarNameAttribute );
+ for ( i = 0; i < nCount; i++ )
+ {
+ m_aMapVarNamesToEnum.insert( VarNameToEnumMap::value_type(
+ OUString::createFromAscii( aVarNameAttribute[i].pVarName ),
+ aVarNameAttribute[i].eVarProperty ));
+ }
+
+ // Set language type!
+ Any aLocale = ConfigManager::GetConfigManager().GetDirectConfigProperty( ConfigManager::LOCALE );
+ OUString aLocaleStr;
+ if ( aLocale >>= aLocaleStr )
+ {
+ sal_Int32 nIndex = 0;
+ m_aLocale.Language = aLocaleStr.getToken(0, '-', nIndex );
+ m_aLocale.Country = aLocaleStr.getToken(0, '-', nIndex );
+ m_aLocale.Variant = aLocaleStr.getToken(0, '-', nIndex );
+ }
+ else
+ {
+ DBG_ERRORFILE( "wrong any type" );
+ m_aLocale.Language = OStringToOUString(OString("en"), RTL_TEXTENCODING_UTF8);
+ m_aLocale.Country = OStringToOUString(OString("US"), RTL_TEXTENCODING_UTF8);
+ m_aLocale.Variant = OStringToOUString(OString(""), RTL_TEXTENCODING_UTF8);
+ }
+}
+
+// -----------------------------------------------------------------------
+
+// class SvtPathOptions --------------------------------------------------
+
+namespace { struct lclMutex : public rtl::Static< ::osl::Mutex, lclMutex > {}; }
+
+SvtPathOptions::SvtPathOptions()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( lclMutex::get() );
+ if ( !pOptions )
+ {
+ pOptions = new SvtPathOptions_Impl;
+ ItemHolder1::holdConfigItem(E_PATHOPTIONS);
+ }
+ ++nRefCount;
+ pImp = pOptions;
+}
+
+// -----------------------------------------------------------------------
+
+SvtPathOptions::~SvtPathOptions()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( lclMutex::get() );
+ if ( !--nRefCount )
+ {
+ DELETEZ( pOptions );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetAddinPath() const
+{
+ return pImp->GetAddinPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetAutoCorrectPath() const
+{
+ return pImp->GetAutoCorrectPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetAutoTextPath() const
+{
+ return pImp->GetAutoTextPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetBackupPath() const
+{
+ return pImp->GetBackupPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetBasicPath() const
+{
+ return pImp->GetBasicPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetBitmapPath() const
+{
+ return pImp->GetBitmapPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetConfigPath() const
+{
+ return pImp->GetConfigPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetDictionaryPath() const
+{
+ return pImp->GetDictionaryPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetFavoritesPath() const
+{
+ return pImp->GetFavoritesPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetFilterPath() const
+{
+ return pImp->GetFilterPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetGalleryPath() const
+{
+ return pImp->GetGalleryPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetGraphicPath() const
+{
+ return pImp->GetGraphicPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetHelpPath() const
+{
+ return pImp->GetHelpPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetLinguisticPath() const
+{
+ return pImp->GetLinguisticPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetFingerprintPath() const
+{
+ return pImp->GetFingerprintPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetModulePath() const
+{
+ return pImp->GetModulePath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetPalettePath() const
+{
+ return pImp->GetPalettePath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetPluginPath() const
+{
+ return pImp->GetPluginPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetStoragePath() const
+{
+ return pImp->GetStoragePath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetTempPath() const
+{
+ return pImp->GetTempPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetTemplatePath() const
+{
+ return pImp->GetTemplatePath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetUserConfigPath() const
+{
+ return pImp->GetUserConfigPath();
+}
+
+const String& SvtPathOptions::GetUIConfigPath() const
+{
+ return pImp->GetUIConfigPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetUserDictionaryPath() const
+{
+ return pImp->GetUserDictionaryPath();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetWorkPath() const
+{
+ return pImp->GetWorkPath();
+}
+
+// -----------------------------------------------------------------------
+
+void SvtPathOptions::SetBasicPath( const String& rPath )
+{
+ pImp->SetBasicPath( rPath );
+}
+
+// -----------------------------------------------------------------------
+
+String SvtPathOptions::SubstituteVariable( const String& rVar )
+{
+ String aRet = pImp->SubstituteAndConvert( rVar );
+ return aRet;
+}
+
+String SvtPathOptions::UseVariable( const String& rPath )
+{
+ String aRet = pImp->UsePathVariables( rPath );
+ return aRet;
+}
+
+// -----------------------------------------------------------------------
+
+sal_Bool SvtPathOptions::SearchFile( String& rIniFile, Pathes ePath )
+{
+ // check parameter: empty inifile name?
+ if ( !rIniFile.Len() )
+ {
+ DBG_ERRORFILE( "SvtPathOptions::SearchFile(): invalid parameter" );
+ return sal_False;
+ }
+
+ String aIniFile = pImp->SubstVar( rIniFile );
+ sal_Bool bRet = sal_False;
+
+ switch ( ePath )
+ {
+ case PATH_USERCONFIG:
+ case PATH_USERDICTIONARY:
+ {
+ // path is a URL
+ sal_Bool bCfg = ( PATH_USERCONFIG == ePath );
+ bRet = sal_True;
+ INetURLObject aObj( bCfg ? GetUserConfigPath() : GetUserDictionaryPath() );
+ xub_StrLen i, nCount = aIniFile.GetTokenCount( '/' );
+ for ( i = 0; i < nCount; ++i )
+ aObj.insertName( aIniFile.GetToken( i, '/' ) );
+
+ if ( !::utl::UCBContentHelper::Exists( aObj.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ {
+ aObj.SetSmartURL( bCfg ? GetConfigPath() : GetDictionaryPath() );
+ aObj.insertName( aIniFile );
+ bRet = ::utl::UCBContentHelper::Exists( aObj.GetMainURL( INetURLObject::NO_DECODE ) );
+ }
+
+ if ( bRet )
+ rIniFile = aObj.GetMainURL( INetURLObject::NO_DECODE );
+
+ break;
+ }
+
+ default:
+ {
+ String aPath;
+ switch ( ePath )
+ {
+ case PATH_ADDIN: aPath = GetAddinPath(); break;
+ case PATH_AUTOCORRECT: aPath = GetAutoCorrectPath(); break;
+ case PATH_AUTOTEXT: aPath = GetAutoTextPath(); break;
+ case PATH_BACKUP: aPath = GetBackupPath(); break;
+ case PATH_BASIC: aPath = GetBasicPath(); break;
+ case PATH_BITMAP: aPath = GetBitmapPath(); break;
+ case PATH_CONFIG: aPath = GetConfigPath(); break;
+ case PATH_DICTIONARY: aPath = GetDictionaryPath(); break;
+ case PATH_FAVORITES: aPath = GetFavoritesPath(); break;
+ case PATH_FILTER: aPath = GetFilterPath(); break;
+ case PATH_GALLERY: aPath = GetGalleryPath(); break;
+ case PATH_GRAPHIC: aPath = GetGraphicPath(); break;
+ case PATH_HELP: aPath = GetHelpPath(); break;
+ case PATH_LINGUISTIC: aPath = GetLinguisticPath(); break;
+ case PATH_MODULE: aPath = GetModulePath(); break;
+ case PATH_PALETTE: aPath = GetPalettePath(); break;
+ case PATH_PLUGIN: aPath = GetPluginPath(); break;
+ case PATH_STORAGE: aPath = GetStoragePath(); break;
+ case PATH_TEMP: aPath = GetTempPath(); break;
+ case PATH_TEMPLATE: aPath = GetTemplatePath(); break;
+ case PATH_WORK: aPath = GetWorkPath(); break;
+ case PATH_UICONFIG: aPath = GetUIConfigPath(); break;
+ case PATH_FINGERPRINT: aPath = GetFingerprintPath(); break;
+ case PATH_USERDICTIONARY:/*-Wall???*/ break;
+ case PATH_USERCONFIG:/*-Wall???*/ break;
+ case PATH_COUNT: /*-Wall???*/ break;
+ }
+
+ sal_uInt16 j, nIdx = 0, nTokenCount = aPath.GetTokenCount( SEARCHPATH_DELIMITER );
+ for ( j = 0; j < nTokenCount; ++j )
+ {
+ BOOL bIsURL = TRUE;
+ String aPathToken = aPath.GetToken( 0, SEARCHPATH_DELIMITER, nIdx );
+ INetURLObject aObj( aPathToken );
+ if ( aObj.HasError() )
+ {
+ bIsURL = FALSE;
+ String aURL;
+ if ( LocalFileHelper::ConvertPhysicalNameToURL( aPathToken, aURL ) )
+ aObj.SetURL( aURL );
+ }
+
+ xub_StrLen i, nCount = aIniFile.GetTokenCount( '/' );
+ for ( i = 0; i < nCount; ++i )
+ aObj.insertName( aIniFile.GetToken( i, '/' ) );
+ bRet = ::utl::UCBContentHelper::Exists( aObj.GetMainURL( INetURLObject::NO_DECODE ) );
+
+ if ( bRet )
+ {
+ if ( !bIsURL )
+ ::utl::LocalFileHelper::ConvertURLToPhysicalName(
+ aObj.GetMainURL( INetURLObject::NO_DECODE ), rIniFile );
+ else
+ rIniFile = aObj.GetMainURL( INetURLObject::NO_DECODE );
+ break;
+ }
+ }
+ }
+ }
+
+ return bRet;
+}
+
+// class PathService -----------------------------------------------------
+
+class PathService : public ::cppu::WeakImplHelper2< ::com::sun::star::frame::XConfigManager, ::com::sun::star::lang::XServiceInfo >
+{
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
+ getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL substituteVariables( const ::rtl::OUString& sText ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& sKeyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& sKeyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL flush( ) throw(::com::sun::star::uno::RuntimeException);
+};
+
+// class PathService -----------------------------------------------------
+
+void SAL_CALL PathService::addPropertyChangeListener( const ::rtl::OUString&, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& ) throw(::com::sun::star::uno::RuntimeException) {}
+void SAL_CALL PathService::removePropertyChangeListener( const ::rtl::OUString&, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& ) throw(::com::sun::star::uno::RuntimeException) {}
+void SAL_CALL PathService::flush( ) throw(::com::sun::star::uno::RuntimeException) {}
+
+::rtl::OUString SAL_CALL PathService::substituteVariables( const ::rtl::OUString& sText ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return SvtPathOptions().SubstituteVariable( sText );
+}
+
+::rtl::OUString SAL_CALL PathService::getImplementationName( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return OUString::createFromAscii("com.sun.star.comp.svtools.PathService");
+}
+
+sal_Bool SAL_CALL PathService::supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException)
+{
+ if ( ServiceName.compareToAscii("com.sun.star.config.SpecialConfigManager") == COMPARE_EQUAL )
+ return sal_True;
+ else
+ return sal_False;
+}
+
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL PathService::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ Sequence< OUString > aRet(1);
+ *aRet.getArray() = OUString::createFromAscii("com.sun.star.config.SpecialConfigManager");
+ return aRet;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_printoptions.cxx b/binfilter/bf_svtools/source/config/svt_printoptions.cxx
new file mode 100644
index 000000000000..f0288581c8a5
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_printoptions.cxx
@@ -0,0 +1,498 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/printoptions.hxx>
+
+#include <unotools/configmgr.hxx>
+#include <unotools/configitem.hxx>
+#include <tools/debug.hxx>
+#include <vcl/print.hxx>
+#include <sal/macros.h>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <itemholder2.hxx>
+
+// -----------
+// - statics -
+// -----------
+
+namespace binfilter
+{
+
+#define DPI_COUNT (SAL_N_ELEMENTS(aDPIArray))
+
+// -----------
+// - Defines -
+// -----------
+
+#define ROOTNODE_START OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Print/Option"))
+
+#define PROPERTYNAME_REDUCETRANSPARENCY OUString(RTL_CONSTASCII_USTRINGPARAM("ReduceTransparency"))
+#define PROPERTYNAME_REDUCEDTRANSPARENCYMODE OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedTransparencyMode"))
+#define PROPERTYNAME_REDUCEGRADIENTS OUString(RTL_CONSTASCII_USTRINGPARAM("ReduceGradients"))
+#define PROPERTYNAME_REDUCEDGRADIENTMODE OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedGradientMode"))
+#define PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedGradientStepCount"))
+#define PROPERTYNAME_REDUCEBITMAPS OUString(RTL_CONSTASCII_USTRINGPARAM("ReduceBitmaps"))
+#define PROPERTYNAME_REDUCEDBITMAPMODE OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedBitmapMode"))
+#define PROPERTYNAME_REDUCEDBITMAPRESOLUTION OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedBitmapResolution"))
+#define PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedBitmapIncludesTransparency"))
+#define PROPERTYNAME_CONVERTTOGREYSCALES OUString(RTL_CONSTASCII_USTRINGPARAM("ConvertToGreyscales"))
+
+#define PROPERTYHDL_REDUCETRANSPARENCY 0
+#define PROPERTYHDL_REDUCEDTRANSPARENCYMODE 1
+#define PROPERTYHDL_REDUCEGRADIENTS 2
+#define PROPERTYHDL_REDUCEDGRADIENTMODE 3
+#define PROPERTYHDL_REDUCEDGRADIENTSTEPCOUNT 4
+#define PROPERTYHDL_REDUCEBITMAPS 5
+#define PROPERTYHDL_REDUCEDBITMAPMODE 6
+#define PROPERTYHDL_REDUCEDBITMAPRESOLUTION 7
+#define PROPERTYHDL_REDUCEDBITMAPINCLUDESTRANSPARENCY 8
+#define PROPERTYHDL_CONVERTTOGREYSCALES 9
+
+#define PROPERTYCOUNT 10
+
+// --------------
+// - Namespaces -
+// --------------
+
+using namespace ::utl;
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::com::sun::star::uno;
+
+// -----------
+// - statics -
+// -----------
+
+static SvtPrintOptions_Impl* pPrinterOptionsDataContainer = NULL;
+static SvtPrintOptions_Impl* pPrintFileOptionsDataContainer = NULL;
+
+SvtPrintOptions_Impl* SvtPrinterOptions::m_pStaticDataContainer = NULL;
+sal_Int32 SvtPrinterOptions::m_nRefCount = 0;
+
+SvtPrintOptions_Impl* SvtPrintFileOptions::m_pStaticDataContainer = NULL;
+sal_Int32 SvtPrintFileOptions::m_nRefCount = 0;
+
+// ------------------------
+// - SvtPrintOptions_Impl -
+// ------------------------
+
+class SvtPrintOptions_Impl : public ConfigItem
+{
+public:
+
+//---------------------------------------------------------------------------------------------------------
+// constructor / destructor
+//---------------------------------------------------------------------------------------------------------
+
+ SvtPrintOptions_Impl( const OUString& rConfigRoot );
+ ~SvtPrintOptions_Impl();
+
+//---------------------------------------------------------------------------------------------------------
+// overloaded methods of baseclass
+//---------------------------------------------------------------------------------------------------------
+
+ virtual void Commit();
+ void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& );
+
+//---------------------------------------------------------------------------------------------------------
+// public interface
+//---------------------------------------------------------------------------------------------------------
+
+ sal_Bool IsReduceTransparency() const { return m_bReduceTransparency; }
+ sal_Int16 GetReducedTransparencyMode() const { return m_nReducedTransparencyMode; }
+ sal_Bool IsReduceGradients() const { return m_bReduceGradients; }
+ sal_Int16 GetReducedGradientMode() const { return m_nReducedGradientMode; }
+ sal_Int16 GetReducedGradientStepCount() const { return m_nReducedGradientStepCount; }
+ sal_Bool IsReduceBitmaps() const { return m_bReduceBitmaps; }
+ sal_Int16 GetReducedBitmapMode() const { return m_nReducedBitmapMode; }
+ sal_Int16 GetReducedBitmapResolution() const { return m_nReducedBitmapResolution; }
+ sal_Bool IsReducedBitmapIncludesTransparency() const { return m_bReducedBitmapIncludesTransparency; }
+ sal_Bool IsConvertToGreyscales() const { return m_bConvertToGreyscales; }
+
+ void SetReduceTransparency( sal_Bool bState ) { m_bReduceTransparency = bState; SetModified(); }
+ void SetReducedTransparencyMode( sal_Int16 nMode ) { m_nReducedTransparencyMode = nMode; SetModified(); }
+ void SetReduceGradients( sal_Bool bState ) { m_bReduceGradients = bState; SetModified(); }
+ void SetReducedGradientMode( sal_Int16 nMode ) { m_nReducedGradientMode = nMode; SetModified(); }
+ void SetReducedGradientStepCount( sal_Int16 nStepCount ) { m_nReducedGradientStepCount = nStepCount; SetModified(); }
+ void SetReduceBitmaps( sal_Bool bState ) { m_bReduceBitmaps = bState; SetModified(); }
+ void SetReducedBitmapMode( sal_Int16 nMode ) { m_nReducedBitmapMode = nMode; SetModified(); }
+ void SetReducedBitmapResolution( sal_Int16 nResolution ) { m_nReducedBitmapResolution = nResolution; SetModified(); }
+ void SetReducedBitmapIncludesTransparency( sal_Bool bState ) { m_bReducedBitmapIncludesTransparency = bState; SetModified(); }
+ void SetConvertToGreyscales( sal_Bool bState ) { m_bConvertToGreyscales = bState; SetModified(); }
+
+//-------------------------------------------------------------------------------------------------------------
+// private methods
+//-------------------------------------------------------------------------------------------------------------
+
+private:
+
+ static Sequence< OUString > impl_GetPropertyNames();
+
+//-------------------------------------------------------------------------------------------------------------
+// private member
+//-------------------------------------------------------------------------------------------------------------
+
+private:
+
+ sal_Bool m_bReduceTransparency;
+ sal_Int16 m_nReducedTransparencyMode;
+ sal_Bool m_bReduceGradients;
+ sal_Int16 m_nReducedGradientMode;
+ sal_Int16 m_nReducedGradientStepCount;
+ sal_Bool m_bReduceBitmaps;
+ sal_Int16 m_nReducedBitmapMode;
+ sal_Int16 m_nReducedBitmapResolution;
+ sal_Bool m_bReducedBitmapIncludesTransparency;
+ sal_Bool m_bConvertToGreyscales;
+};
+
+// -----------------------------------------------------------------------------
+
+SvtPrintOptions_Impl::SvtPrintOptions_Impl( const OUString& rConfigRoot ) :
+ ConfigItem( rConfigRoot ),
+ m_bReduceTransparency( sal_False ),
+ m_nReducedTransparencyMode( 0 ),
+ m_bReduceGradients( sal_False ),
+ m_nReducedGradientMode( 0 ),
+ m_nReducedGradientStepCount( 64 ),
+ m_bReduceBitmaps( sal_False ),
+ m_nReducedBitmapMode( 1 ),
+ m_nReducedBitmapResolution( 3 ),
+ m_bReducedBitmapIncludesTransparency( sal_True ),
+ m_bConvertToGreyscales( sal_False )
+{
+ Sequence< OUString > seqNames( impl_GetPropertyNames() );
+ Sequence< Any > seqValues( GetProperties( seqNames ) );
+
+ DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtPrintOptions_Impl::SvtPrintOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to our internal member.
+ sal_Int32 nPropertyCount = seqValues.getLength();
+ sal_Int32 nProperty = 0;
+
+ for( nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtPrintOptions_Impl::SvtPrintOptions_Impl()\nInvalid property value for property detected!\n" );
+
+ switch( nProperty )
+ {
+ case PROPERTYHDL_REDUCETRANSPARENCY:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" );
+ seqValues[nProperty] >>= m_bReduceTransparency;
+ }
+ break;
+
+
+ case PROPERTYHDL_REDUCEDTRANSPARENCYMODE:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SHORT), "Invalid type" );
+ seqValues[nProperty] >>= m_nReducedTransparencyMode;
+ }
+ break;
+
+ case PROPERTYHDL_REDUCEGRADIENTS:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" );
+ seqValues[nProperty] >>= m_bReduceGradients;
+ }
+ break;
+
+ case PROPERTYHDL_REDUCEDGRADIENTMODE:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SHORT), "Invalid type" );
+ seqValues[nProperty] >>= m_nReducedGradientMode;
+ }
+ break;
+
+ case PROPERTYHDL_REDUCEDGRADIENTSTEPCOUNT:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SHORT), "Invalid type" );
+ seqValues[nProperty] >>= m_nReducedGradientStepCount;
+ }
+ break;
+
+ case PROPERTYHDL_REDUCEBITMAPS:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" );
+ seqValues[nProperty] >>= m_bReduceBitmaps;
+ }
+ break;
+
+ case PROPERTYHDL_REDUCEDBITMAPMODE:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SHORT), "Invalid type" );
+ seqValues[nProperty] >>= m_nReducedBitmapMode;
+ }
+ break;
+
+ case PROPERTYHDL_REDUCEDBITMAPRESOLUTION:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SHORT), "Invalid type" );
+ seqValues[nProperty] >>= m_nReducedBitmapResolution;
+ }
+ break;
+
+ case PROPERTYHDL_REDUCEDBITMAPINCLUDESTRANSPARENCY:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" );
+ seqValues[nProperty] >>= m_bReducedBitmapIncludesTransparency;
+ }
+ break;
+
+ case PROPERTYHDL_CONVERTTOGREYSCALES:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" );
+ seqValues[nProperty] >>= m_bConvertToGreyscales;
+ }
+ break;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+SvtPrintOptions_Impl::~SvtPrintOptions_Impl()
+{
+ if( IsModified() )
+ Commit();
+}
+
+// -----------------------------------------------------------------------------
+
+void SvtPrintOptions_Impl::Commit()
+{
+ Sequence< OUString > aSeqNames( impl_GetPropertyNames() );
+ Sequence< Any > aSeqValues( aSeqNames.getLength() );
+
+ for( sal_Int32 nProperty = 0, nCount = aSeqNames.getLength(); nProperty < nCount; ++nProperty )
+ {
+ switch( nProperty )
+ {
+ case PROPERTYHDL_REDUCETRANSPARENCY:
+ aSeqValues[nProperty] <<= m_bReduceTransparency;
+ break;
+
+ case PROPERTYHDL_REDUCEDTRANSPARENCYMODE:
+ aSeqValues[nProperty] <<= m_nReducedTransparencyMode;
+ break;
+
+ case PROPERTYHDL_REDUCEGRADIENTS:
+ aSeqValues[nProperty] <<= m_bReduceGradients;
+ break;
+
+ case PROPERTYHDL_REDUCEDGRADIENTMODE:
+ aSeqValues[nProperty] <<= m_nReducedGradientMode;
+ break;
+
+ case PROPERTYHDL_REDUCEDGRADIENTSTEPCOUNT:
+ aSeqValues[nProperty] <<= m_nReducedGradientStepCount;
+ break;
+
+ case PROPERTYHDL_REDUCEBITMAPS:
+ aSeqValues[nProperty] <<= m_bReduceBitmaps;
+ break;
+
+ case PROPERTYHDL_REDUCEDBITMAPMODE:
+ aSeqValues[nProperty] <<= m_nReducedBitmapMode;
+ break;
+
+ case PROPERTYHDL_REDUCEDBITMAPRESOLUTION:
+ aSeqValues[nProperty] <<= m_nReducedBitmapResolution;
+ break;
+
+ case PROPERTYHDL_REDUCEDBITMAPINCLUDESTRANSPARENCY:
+ aSeqValues[nProperty] <<= m_bReducedBitmapIncludesTransparency;
+ break;
+
+ case PROPERTYHDL_CONVERTTOGREYSCALES:
+ aSeqValues[nProperty] <<= m_bConvertToGreyscales;
+ break;
+ }
+ }
+
+ PutProperties( aSeqNames, aSeqValues );
+}
+
+ void SvtPrintOptions_Impl::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
+
+// -----------------------------------------------------------------------------
+
+Sequence< OUString > SvtPrintOptions_Impl::impl_GetPropertyNames()
+{
+ // Build static list of configuration key names.
+ static const OUString pProperties[] =
+ {
+ PROPERTYNAME_REDUCETRANSPARENCY,
+ PROPERTYNAME_REDUCEDTRANSPARENCYMODE,
+ PROPERTYNAME_REDUCEGRADIENTS,
+ PROPERTYNAME_REDUCEDGRADIENTMODE,
+ PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT,
+ PROPERTYNAME_REDUCEBITMAPS,
+ PROPERTYNAME_REDUCEDBITMAPMODE,
+ PROPERTYNAME_REDUCEDBITMAPRESOLUTION,
+ PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY,
+ PROPERTYNAME_CONVERTTOGREYSCALES
+ };
+
+ // Initialize return sequence with these list ...
+ static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
+
+ return seqPropertyNames;
+}
+
+// -----------------------
+// - SvtBasePrintOptions -
+// -----------------------
+
+SvtBasePrintOptions::SvtBasePrintOptions()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+SvtBasePrintOptions::~SvtBasePrintOptions()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+Mutex& SvtBasePrintOptions::GetOwnStaticMutex()
+{
+ // Initialize static mutex only for one time!
+ static Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+
+// -----------------------------------------------------------------------------
+
+// ---------------------
+// - SvtPrinterOptions -
+// ---------------------
+
+SvtPrinterOptions::SvtPrinterOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already!
+ if( m_pStaticDataContainer == NULL )
+ {
+ OUString aRootPath( ROOTNODE_START );
+ m_pStaticDataContainer = new SvtPrintOptions_Impl( aRootPath += OUString( RTL_CONSTASCII_USTRINGPARAM( "/Printer" ) ) );
+ pPrinterOptionsDataContainer = m_pStaticDataContainer;
+ ItemHolder2::holdConfigItem(E_PRINTOPTIONS);
+ }
+
+ SetDataContainer( m_pStaticDataContainer );
+}
+
+// -----------------------------------------------------------------------------
+
+SvtPrinterOptions::~SvtPrinterOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Decrease ouer refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pStaticDataContainer;
+ m_pStaticDataContainer = NULL;
+ pPrinterOptionsDataContainer = NULL;
+ }
+}
+
+// ---------------------
+// - SvtPrintFileOptions -
+// ---------------------
+
+SvtPrintFileOptions::SvtPrintFileOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already!
+ if( m_pStaticDataContainer == NULL )
+ {
+ OUString aRootPath( ROOTNODE_START );
+ m_pStaticDataContainer = new SvtPrintOptions_Impl( aRootPath += OUString( RTL_CONSTASCII_USTRINGPARAM( "/File" ) ) );
+ pPrintFileOptionsDataContainer = m_pStaticDataContainer;
+
+ ItemHolder2::holdConfigItem(E_PRINTFILEOPTIONS);
+ }
+
+ SetDataContainer( m_pStaticDataContainer );
+}
+
+// -----------------------------------------------------------------------------
+
+SvtPrintFileOptions::~SvtPrintFileOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Decrease ouer refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pStaticDataContainer;
+ m_pStaticDataContainer = NULL;
+ pPrintFileOptionsDataContainer = NULL;
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_printwarningoptions.cxx b/binfilter/bf_svtools/source/config/svt_printwarningoptions.cxx
new file mode 100644
index 000000000000..1281d66d00c1
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_printwarningoptions.cxx
@@ -0,0 +1,342 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+//_________________________________________________________________________________________________________________
+// includes
+//_________________________________________________________________________________________________________________
+
+#include <bf_svtools/printwarningoptions.hxx>
+
+#include <unotools/configmgr.hxx>
+
+#include <unotools/configitem.hxx>
+
+#include <tools/debug.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <itemholder1.hxx>
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+using namespace ::utl ;
+using namespace ::rtl ;
+using namespace ::osl ;
+using namespace ::com::sun::star::uno ;
+
+namespace binfilter
+{
+
+//_________________________________________________________________________________________________________________
+// const
+//_________________________________________________________________________________________________________________
+
+#define ROOTNODE_START OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Print"))
+
+#define PROPERTYNAME_PAPERSIZE OUString(RTL_CONSTASCII_USTRINGPARAM("Warning/PaperSize"))
+#define PROPERTYNAME_PAPERORIENTATION OUString(RTL_CONSTASCII_USTRINGPARAM("Warning/PaperOrientation"))
+#define PROPERTYNAME_NOTFOUND OUString(RTL_CONSTASCII_USTRINGPARAM("Warning/NotFound"))
+#define PROPERTYNAME_TRANSPARENCY OUString(RTL_CONSTASCII_USTRINGPARAM("Warning/Transparency"))
+#define PROPERTYNAME_PRINTINGMODIFIESDOCUMENT OUString(RTL_CONSTASCII_USTRINGPARAM("PrintingModifiesDocument"))
+
+#define PROPERTYHANDLE_PAPERSIZE 0
+#define PROPERTYHANDLE_PAPERORIENTATION 1
+#define PROPERTYHANDLE_NOTFOUND 2
+#define PROPERTYHANDLE_TRANSPARENCY 3
+#define PROPERTYHDL_PRINTINGMODIFIESDOCUMENT 4
+
+#define PROPERTYCOUNT 5
+
+class SvtPrintWarningOptions_Impl : public ConfigItem
+{
+public:
+
+//---------------------------------------------------------------------------------------------------------
+// constructor / destructor
+//---------------------------------------------------------------------------------------------------------
+
+ SvtPrintWarningOptions_Impl();
+ ~SvtPrintWarningOptions_Impl();
+
+//---------------------------------------------------------------------------------------------------------
+// overloaded methods of baseclass
+//---------------------------------------------------------------------------------------------------------
+
+ virtual void Commit();
+ void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& );
+
+//---------------------------------------------------------------------------------------------------------
+// public interface
+//---------------------------------------------------------------------------------------------------------
+
+ sal_Bool IsPaperSize() const { return m_bPaperSize; }
+ sal_Bool IsPaperOrientation() const { return m_bPaperOrientation; }
+ sal_Bool IsNotFound() const { return m_bNotFound; }
+ sal_Bool IsTransparency() const { return m_bTransparency; }
+ sal_Bool IsModifyDocumentOnPrintingAllowed() const { return m_bModifyDocumentOnPrintingAllowed; }
+
+ void SetPaperSize( sal_Bool bState ) { m_bPaperSize = bState; SetModified(); }
+ void SetPaperOrientation( sal_Bool bState ) { m_bPaperOrientation = bState; SetModified(); }
+ void SetNotFound( sal_Bool bState ) { m_bNotFound = bState; SetModified(); }
+ void SetTransparency( sal_Bool bState ) { m_bTransparency = bState; SetModified(); }
+ void SetModifyDocumentOnPrintingAllowed( sal_Bool bState ) { m_bModifyDocumentOnPrintingAllowed = bState; SetModified(); }
+
+//-------------------------------------------------------------------------------------------------------------
+// private methods
+//-------------------------------------------------------------------------------------------------------------
+
+private:
+
+ static Sequence< OUString > impl_GetPropertyNames();
+
+//-------------------------------------------------------------------------------------------------------------
+// private member
+//-------------------------------------------------------------------------------------------------------------
+
+private:
+
+ sal_Bool m_bPaperSize;
+ sal_Bool m_bPaperOrientation;
+ sal_Bool m_bNotFound;
+ sal_Bool m_bTransparency;
+ sal_Bool m_bModifyDocumentOnPrintingAllowed;
+};
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtPrintWarningOptions_Impl::SvtPrintWarningOptions_Impl() :
+ ConfigItem( ROOTNODE_START ),
+ m_bPaperSize( sal_False ),
+ m_bPaperOrientation( sal_False ),
+ m_bNotFound( sal_False ),
+ m_bTransparency( sal_True ),
+ m_bModifyDocumentOnPrintingAllowed( sal_True )
+{
+ Sequence< OUString > seqNames( impl_GetPropertyNames() );
+ Sequence< Any > seqValues( GetProperties( seqNames ) );
+
+ DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtPrintWarningOptions_Impl::SvtPrintWarningOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to our internal member.
+ sal_Int32 nPropertyCount = seqValues.getLength();
+ sal_Int32 nProperty = 0;
+
+ for( nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtPrintWarningOptions_Impl::SvtPrintWarningOptions_Impl()\nInvalid property value for property detected!\n" );
+
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_PAPERSIZE:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" );
+ seqValues[nProperty] >>= m_bPaperSize;
+ }
+ break;
+
+ case PROPERTYHANDLE_PAPERORIENTATION:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" );
+ seqValues[nProperty] >>= m_bPaperOrientation;
+ }
+ break;
+
+ case PROPERTYHANDLE_NOTFOUND:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" );
+ seqValues[nProperty] >>= m_bNotFound;
+ }
+ break;
+
+ case PROPERTYHANDLE_TRANSPARENCY:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" );
+ seqValues[nProperty] >>= m_bTransparency;
+ }
+ break;
+ case PROPERTYHDL_PRINTINGMODIFIESDOCUMENT:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" );
+ seqValues[nProperty] >>= m_bModifyDocumentOnPrintingAllowed;
+ }
+ break;
+
+ }
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtPrintWarningOptions_Impl::~SvtPrintWarningOptions_Impl()
+{
+ if( IsModified() )
+ Commit();
+}
+
+//*****************************************************************************************************************
+// Commit
+//*****************************************************************************************************************
+void SvtPrintWarningOptions_Impl::Commit()
+{
+ Sequence< OUString > aSeqNames( impl_GetPropertyNames() );
+ Sequence< Any > aSeqValues( aSeqNames.getLength() );
+
+ for( sal_Int32 nProperty = 0, nCount = aSeqNames.getLength(); nProperty < nCount; ++nProperty )
+ {
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_PAPERSIZE:
+ aSeqValues[nProperty] <<= m_bPaperSize;
+ break;
+
+ case PROPERTYHANDLE_PAPERORIENTATION:
+ aSeqValues[nProperty] <<= m_bPaperOrientation;
+ break;
+
+ case PROPERTYHANDLE_NOTFOUND:
+ aSeqValues[nProperty] <<= m_bNotFound;
+ break;
+
+ case PROPERTYHANDLE_TRANSPARENCY:
+ aSeqValues[nProperty] <<= m_bTransparency;
+ break;
+ case PROPERTYHDL_PRINTINGMODIFIESDOCUMENT:
+ aSeqValues[nProperty] <<= m_bModifyDocumentOnPrintingAllowed;
+ break;
+ }
+ }
+
+ PutProperties( aSeqNames, aSeqValues );
+}
+
+ void SvtPrintWarningOptions_Impl::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Sequence< OUString > SvtPrintWarningOptions_Impl::impl_GetPropertyNames()
+{
+ // Build static list of configuration key names.
+ static const OUString pProperties[] =
+ {
+ PROPERTYNAME_PAPERSIZE,
+ PROPERTYNAME_PAPERORIENTATION,
+ PROPERTYNAME_NOTFOUND,
+ PROPERTYNAME_TRANSPARENCY,
+ PROPERTYNAME_PRINTINGMODIFIESDOCUMENT
+ };
+
+ // Initialize return sequence with these list ...
+ static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
+
+ return seqPropertyNames;
+}
+
+//*****************************************************************************************************************
+// initialize static member
+// DON'T DO IT IN YOUR HEADER!
+// see definition for further informations
+//*****************************************************************************************************************
+SvtPrintWarningOptions_Impl* SvtPrintWarningOptions::m_pDataContainer = NULL;
+sal_Int32 SvtPrintWarningOptions::m_nRefCount = 0;
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtPrintWarningOptions::SvtPrintWarningOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already!
+ if( m_pDataContainer == NULL )
+ {
+ m_pDataContainer = new SvtPrintWarningOptions_Impl();
+ ItemHolder1::holdConfigItem(E_PRINTWARNINGOPTIONS);
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtPrintWarningOptions::~SvtPrintWarningOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Decrease ouer refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pDataContainer;
+ m_pDataContainer = NULL;
+ }
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Mutex& SvtPrintWarningOptions::GetOwnStaticMutex()
+{
+ // Initialize static mutex only for one time!
+ static Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_saveopt.cxx b/binfilter/bf_svtools/source/config/svt_saveopt.cxx
new file mode 100644
index 000000000000..f0f67bf1f737
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_saveopt.cxx
@@ -0,0 +1,653 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/saveopt.hxx>
+
+#include "rtl/instance.hxx"
+
+#include <unotools/configmgr.hxx>
+#include <unotools/configitem.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <osl/mutex.hxx>
+#include <comphelper/configurationhelper.hxx>
+#include <unotools/processfactory.hxx>
+#include <rtl/logfile.hxx>
+#include "itemholder1.hxx"
+
+using namespace utl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+namespace css = ::com::sun::star;
+
+namespace binfilter
+{
+
+class SvtSaveOptions_Impl;
+class SvtLoadOptions_Impl;
+
+#define CFG_READONLY_DEFAULT sal_False
+
+struct SvtLoadSaveOptions_Impl
+{
+ SvtSaveOptions_Impl* pSaveOpt;
+ SvtLoadOptions_Impl* pLoadOpt;
+};
+
+static SvtLoadSaveOptions_Impl* pOptions = NULL;
+static sal_Int32 nRefCount = 0;
+
+class SvtSaveOptions_Impl : public utl::ConfigItem
+{
+ sal_Int32 nAutoSaveTime;
+ sal_Bool bUseUserData,
+ bBackup,
+ bAutoSave,
+ bAutoSavePrompt,
+ bDocInfSave,
+ bSaveWorkingSet,
+ bSaveDocWins,
+ bSaveDocView,
+ bSaveRelINet,
+ bSaveRelFSys,
+ bSaveUnpacked,
+ bDoPrettyPrinting,
+ bWarnAlienFormat,
+ bLoadDocPrinter;
+
+ sal_Bool bROAutoSaveTime,
+ bROUseUserData,
+ bROBackup,
+ bROAutoSave,
+ bROAutoSavePrompt,
+ bRODocInfSave,
+ bROSaveWorkingSet,
+ bROSaveDocWins,
+ bROSaveDocView,
+ bROSaveRelINet,
+ bROSaveRelFSys,
+ bROSaveUnpacked,
+ bROWarnAlienFormat,
+ bRODoPrettyPrinting,
+ bROLoadDocPrinter;
+public:
+ SvtSaveOptions_Impl();
+ ~SvtSaveOptions_Impl();
+
+ virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
+ virtual void Commit();
+
+ sal_Int32 GetAutoSaveTime() const { return nAutoSaveTime; }
+ BOOL IsUseUserData() const { return bUseUserData; }
+ BOOL IsBackup() const { return bBackup; }
+ BOOL IsAutoSave() const { return bAutoSave; }
+ BOOL IsAutoSavePrompt() const { return bAutoSavePrompt; }
+ BOOL IsDocInfoSave() const { return bDocInfSave; }
+ BOOL IsSaveWorkingSet() const { return bSaveWorkingSet; }
+ BOOL IsSaveDocWins() const { return bSaveDocWins; }
+ BOOL IsSaveDocView() const { return bSaveDocView; }
+ BOOL IsSaveRelINet() const { return bSaveRelINet; }
+ BOOL IsSaveRelFSys() const { return bSaveRelFSys; }
+ BOOL IsSaveUnpacked() const { return bSaveUnpacked; }
+ sal_Bool IsPrettyPrintingEnabled( ) const { return bDoPrettyPrinting; }
+ sal_Bool IsWarnAlienFormat() const { return bWarnAlienFormat; }
+ sal_Bool IsLoadDocPrinter() const { return bLoadDocPrinter; }
+};
+
+#define FORMAT 0
+#define TIMEINTERVALL 1
+#define USEUSERDATA 2
+#define CREATEBACKUP 3
+#define AUTOSAVE 4
+#define PROMPT 5
+#define EDITPROPERTY 6
+#define SAVEDOCWINS 7
+#define SAVEVIEWINFO 8
+#define UNPACKED 9
+#define PRETTYPRINTING 10
+#define WARNALIENFORMAT 11
+#define LOADDOCPRINTER 12
+#define FILESYSTEM 13
+#define INTERNET 14
+#define SAVEWORKINGSET 15
+
+Sequence< OUString > GetPropertyNames()
+{
+ static const char* aPropNames[] =
+ {
+ "Graphic/Format",
+ "Document/AutoSaveTimeIntervall",
+ "Document/UseUserData",
+ "Document/CreateBackup",
+ "Document/AutoSave",
+ "Document/AutoSavePrompt",
+ "Document/EditProperty",
+ "Document/DocumentWindows",
+ "Document/ViewInfo",
+ "Document/Unpacked",
+ "Document/PrettyPrinting",
+ "Document/WarnAlienFormat",
+ "Document/LoadPrinter",
+ "URL/FileSystem",
+ "URL/Internet",
+ "WorkingSet",
+ };
+
+ const int nCount = sizeof( aPropNames ) / sizeof( const char* );
+ Sequence< OUString > aNames( nCount );
+ OUString* pNames = aNames.getArray();
+ for ( int i = 0; i < nCount; i++ )
+ pNames[i] = OUString::createFromAscii( aPropNames[i] );
+
+ return aNames;
+}
+
+// -----------------------------------------------------------------------
+
+SvtSaveOptions_Impl::SvtSaveOptions_Impl()
+ : ConfigItem( OUString::createFromAscii("Office.Common/Save") )
+ , nAutoSaveTime( 0 )
+ , bUseUserData( sal_False )
+ , bBackup( sal_False )
+ , bAutoSave( sal_False )
+ , bAutoSavePrompt( sal_False )
+ , bDocInfSave( sal_False )
+ , bSaveWorkingSet( sal_False )
+ , bSaveDocWins( sal_False )
+ , bSaveDocView( sal_False )
+ , bSaveRelINet( sal_False )
+ , bSaveRelFSys( sal_False )
+ , bSaveUnpacked( sal_False )
+ , bDoPrettyPrinting( sal_False )
+ , bWarnAlienFormat( sal_True )
+ , bLoadDocPrinter( sal_True )
+ , bROAutoSaveTime( CFG_READONLY_DEFAULT )
+ , bROUseUserData( CFG_READONLY_DEFAULT )
+ , bROBackup( CFG_READONLY_DEFAULT )
+ , bROAutoSave( CFG_READONLY_DEFAULT )
+ , bROAutoSavePrompt( CFG_READONLY_DEFAULT )
+ , bRODocInfSave( CFG_READONLY_DEFAULT )
+ , bROSaveWorkingSet( CFG_READONLY_DEFAULT )
+ , bROSaveDocWins( CFG_READONLY_DEFAULT )
+ , bROSaveDocView( CFG_READONLY_DEFAULT )
+ , bROSaveRelINet( CFG_READONLY_DEFAULT )
+ , bROSaveRelFSys( CFG_READONLY_DEFAULT )
+ , bROSaveUnpacked( CFG_READONLY_DEFAULT )
+ , bROWarnAlienFormat( CFG_READONLY_DEFAULT )
+ , bRODoPrettyPrinting( CFG_READONLY_DEFAULT )
+ , bROLoadDocPrinter( CFG_READONLY_DEFAULT )
+{
+ Sequence< OUString > aNames = GetPropertyNames();
+ Sequence< Any > aValues = GetProperties( aNames );
+ Sequence< sal_Bool > aROStates = GetReadOnlyStates( aNames );
+ EnableNotification( aNames );
+ const Any* pValues = aValues.getConstArray();
+ const sal_Bool* pROStates = aROStates.getConstArray();
+ DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
+ DBG_ASSERT( aROStates.getLength() == aNames.getLength(), "GetReadOnlyStates failed" );
+ if ( aValues.getLength() == aNames.getLength() && aROStates.getLength() == aNames.getLength() )
+ {
+ for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
+ {
+ DBG_ASSERT( pValues[nProp].hasValue(), "property value missing" );
+ if ( pValues[nProp].hasValue() )
+ {
+ sal_Int32 nTemp = 0;
+ switch ( nProp )
+ {
+ case TIMEINTERVALL :
+ if ( pValues[nProp] >>= nTemp )
+ nAutoSaveTime = nTemp;
+ else
+ {
+ DBG_ERROR( "Wrong Type!" );
+ }
+ bROAutoSaveTime = pROStates[nProp];
+ break;
+
+ case FORMAT:
+ // not supported anymore
+ break;
+
+ default:
+ {
+ sal_Bool bTemp = sal_Bool();
+ if ( pValues[nProp] >>= bTemp )
+ {
+ switch ( nProp )
+ {
+ case USEUSERDATA :
+ bUseUserData = bTemp;
+ bROUseUserData = pROStates[nProp];
+ break;
+ case CREATEBACKUP :
+ bBackup = bTemp;
+ bROBackup = pROStates[nProp];
+ break;
+ case AUTOSAVE :
+ bAutoSave = bTemp;
+ bROAutoSave = pROStates[nProp];
+ break;
+ case PROMPT :
+ bAutoSavePrompt = bTemp;
+ bROAutoSavePrompt = pROStates[nProp];
+ break;
+ case EDITPROPERTY :
+ bDocInfSave = bTemp;
+ bRODocInfSave = pROStates[nProp];
+ break;
+ case SAVEWORKINGSET :
+ bSaveWorkingSet = bTemp;
+ bROSaveWorkingSet = pROStates[nProp];
+ break;
+ case SAVEDOCWINS :
+ bSaveDocWins = bTemp;
+ bROSaveDocWins = pROStates[nProp];
+ break;
+ case SAVEVIEWINFO :
+ bSaveDocView = bTemp;
+ bROSaveDocView = pROStates[nProp];
+ break;
+ case FILESYSTEM :
+ bSaveRelFSys = bTemp;
+ bROSaveRelFSys = pROStates[nProp];
+ break;
+ case INTERNET :
+ bSaveRelINet = bTemp;
+ bROSaveRelINet = pROStates[nProp];
+ break;
+ case UNPACKED :
+ bSaveUnpacked = bTemp;
+ bROSaveUnpacked = pROStates[nProp];
+ break;
+
+ case PRETTYPRINTING:
+ bDoPrettyPrinting = bTemp;
+ bRODoPrettyPrinting = pROStates[nProp];
+ break;
+
+ case WARNALIENFORMAT:
+ bWarnAlienFormat = bTemp;
+ bROWarnAlienFormat = pROStates[nProp];
+ break;
+
+ case LOADDOCPRINTER:
+ bLoadDocPrinter = bTemp;
+ bROLoadDocPrinter = pROStates[nProp];
+ break;
+
+ default :
+ DBG_ERRORFILE( "invalid index to load a path" );
+ }
+ }
+ else
+ {
+ DBG_ERROR( "Wrong Type!" );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ try
+ {
+ css::uno::Reference< css::uno::XInterface > xCFG = ::comphelper::ConfigurationHelper::openConfig(
+ ::utl::getProcessServiceFactory(),
+ ::rtl::OUString::createFromAscii("org.openoffice.Office.Recovery"),
+ ::comphelper::ConfigurationHelper::E_READONLY);
+
+ ::comphelper::ConfigurationHelper::readRelativeKey(
+ xCFG,
+ ::rtl::OUString::createFromAscii("AutoSave"),
+ ::rtl::OUString::createFromAscii("Enabled")) >>= bAutoSave;
+
+ ::comphelper::ConfigurationHelper::readRelativeKey(
+ xCFG,
+ ::rtl::OUString::createFromAscii("AutoSave"),
+ ::rtl::OUString::createFromAscii("TimeIntervall")) >>= nAutoSaveTime;
+ }
+ catch(const css::uno::Exception&)
+ { DBG_ERROR("Could not find needed informations for AutoSave feature."); }
+}
+
+SvtSaveOptions_Impl::~SvtSaveOptions_Impl()
+{}
+
+void SvtSaveOptions_Impl::Commit()
+{
+ Sequence< OUString > aOrgNames = GetPropertyNames();
+ OUString* pOrgNames = aOrgNames.getArray();
+ sal_Int32 nOrgCount = aOrgNames.getLength();
+
+ Sequence< OUString > aNames( nOrgCount );
+ Sequence< Any > aValues( nOrgCount );
+ OUString* pNames = aNames.getArray();
+ Any* pValues = aValues.getArray();
+ sal_Int32 nRealCount = 0;
+
+ for (sal_Int32 i=0; i<nOrgCount; ++i)
+ {
+ switch (i)
+ {
+ case TIMEINTERVALL :
+ if (!bROAutoSaveTime)
+ {
+ pValues[nRealCount] <<= nAutoSaveTime;
+ pNames[nRealCount] = pOrgNames[i];
+ ++nRealCount;
+ }
+ break;
+ case USEUSERDATA :
+ if (!bROUseUserData)
+ {
+ pValues[nRealCount] <<= bUseUserData;
+ pNames[nRealCount] = pOrgNames[i];
+ ++nRealCount;
+ }
+ break;
+ case CREATEBACKUP :
+ if (!bROBackup)
+ {
+ pValues[nRealCount] <<= bBackup;
+ pNames[nRealCount] = pOrgNames[i];
+ ++nRealCount;
+ }
+ break;
+ case AUTOSAVE :
+ if (!bROAutoSave)
+ {
+ pValues[nRealCount] <<= bAutoSave;
+ pNames[nRealCount] = pOrgNames[i];
+ ++nRealCount;
+ }
+ break;
+ case PROMPT :
+ if (!bROAutoSavePrompt)
+ {
+ pValues[nRealCount] <<= bAutoSavePrompt;
+ pNames[nRealCount] = pOrgNames[i];
+ ++nRealCount;
+ }
+ break;
+ case EDITPROPERTY :
+ if (!bRODocInfSave)
+ {
+ pValues[nRealCount] <<= bDocInfSave;
+ pNames[nRealCount] = pOrgNames[i];
+ ++nRealCount;
+ }
+ break;
+ case SAVEWORKINGSET :
+ if (!bROSaveWorkingSet)
+ {
+ pValues[nRealCount] <<= bSaveWorkingSet;
+ pNames[nRealCount] = pOrgNames[i];
+ ++nRealCount;
+ }
+ break;
+ case SAVEDOCWINS :
+ if (!bROSaveDocWins)
+ {
+ pValues[nRealCount] <<= bSaveDocWins;
+ pNames[nRealCount] = pOrgNames[i];
+ ++nRealCount;
+ }
+ break;
+ case SAVEVIEWINFO :
+ if (!bROSaveDocView)
+ {
+ pValues[nRealCount] <<= bSaveDocView;
+ pNames[nRealCount] = pOrgNames[i];
+ ++nRealCount;
+ }
+ break;
+ case FILESYSTEM :
+ if (!bROSaveRelFSys)
+ {
+ pValues[nRealCount] <<= bSaveRelFSys;
+ pNames[nRealCount] = pOrgNames[i];
+ ++nRealCount;
+ }
+ break;
+ case INTERNET :
+ if (!bROSaveRelINet)
+ {
+ pValues[nRealCount] <<= bSaveRelINet;
+ pNames[nRealCount] = pOrgNames[i];
+ ++nRealCount;
+ }
+ break;
+ case UNPACKED :
+ if (!bROSaveUnpacked)
+ {
+ pValues[nRealCount] <<= bSaveUnpacked;
+ pNames[nRealCount] = pOrgNames[i];
+ ++nRealCount;
+ }
+ break;
+ case PRETTYPRINTING:
+ if (!bRODoPrettyPrinting)
+ {
+ pValues[nRealCount] <<= bDoPrettyPrinting;
+ pNames[nRealCount] = pOrgNames[i];
+ ++nRealCount;
+ }
+ break;
+
+ case WARNALIENFORMAT:
+ if (!bROWarnAlienFormat)
+ {
+ pValues[nRealCount] <<= bWarnAlienFormat;
+ pNames[nRealCount] = pOrgNames[i];
+ ++nRealCount;
+ }
+ break;
+
+ case LOADDOCPRINTER:
+ if (!bROLoadDocPrinter)
+ {
+ pValues[nRealCount] <<= bLoadDocPrinter;
+ pNames[nRealCount] = pOrgNames[i];
+ ++nRealCount;
+ }
+ break;
+
+ default:
+ DBG_ERRORFILE( "invalid index to save a path" );
+ }
+ }
+
+ aNames.realloc(nRealCount);
+ aValues.realloc(nRealCount);
+ PutProperties( aNames, aValues );
+
+ css::uno::Reference< css::uno::XInterface > xCFG = ::comphelper::ConfigurationHelper::openConfig(
+ ::utl::getProcessServiceFactory(),
+ ::rtl::OUString::createFromAscii("org.openoffice.Office.Recovery"),
+ ::comphelper::ConfigurationHelper::E_STANDARD);
+
+ ::comphelper::ConfigurationHelper::writeRelativeKey(
+ xCFG,
+ ::rtl::OUString::createFromAscii("AutoSave"),
+ ::rtl::OUString::createFromAscii("TimeIntervall"),
+ css::uno::makeAny(nAutoSaveTime));
+
+ ::comphelper::ConfigurationHelper::writeRelativeKey(
+ xCFG,
+ ::rtl::OUString::createFromAscii("AutoSave"),
+ ::rtl::OUString::createFromAscii("Enabled"),
+ css::uno::makeAny(bAutoSave));
+
+ ::comphelper::ConfigurationHelper::flush(xCFG);
+}
+
+// -----------------------------------------------------------------------
+
+void SvtSaveOptions_Impl::Notify( const Sequence<rtl::OUString>& )
+{
+}
+
+
+class SvtLoadOptions_Impl : public utl::ConfigItem
+{
+
+ sal_Bool bLoadUserDefinedSettings;
+
+public:
+ SvtLoadOptions_Impl();
+ ~SvtLoadOptions_Impl();
+
+ virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
+ virtual void Commit();
+
+ void SetLoadUserSettings(sal_Bool b){bLoadUserDefinedSettings = b; SetModified();}
+ sal_Bool IsLoadUserSettings() const {return bLoadUserDefinedSettings;}
+};
+// -----------------------------------------------------------------------
+const sal_Char cUserDefinedSettings[] = "UserDefinedSettings";
+
+SvtLoadOptions_Impl::SvtLoadOptions_Impl()
+ : ConfigItem( OUString::createFromAscii("Office.Common/Load") )
+ , bLoadUserDefinedSettings( sal_False )
+{
+ Sequence< OUString > aNames(1);
+ aNames[0] = OUString::createFromAscii(cUserDefinedSettings);
+ Sequence< Any > aValues = GetProperties( aNames );
+ EnableNotification( aNames );
+ const Any* pValues = aValues.getConstArray();
+ DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
+ if (pValues[0].getValueTypeClass() == ::com::sun::star::uno::TypeClass_BOOLEAN)
+ bLoadUserDefinedSettings = *(sal_Bool *)pValues[0].getValue();
+}
+// -----------------------------------------------------------------------
+SvtLoadOptions_Impl::~SvtLoadOptions_Impl()
+{
+}
+// -----------------------------------------------------------------------
+void SvtLoadOptions_Impl::Commit()
+{
+ Sequence< OUString > aNames(1);
+ aNames[0] = OUString::createFromAscii(cUserDefinedSettings);
+ Sequence< Any > aValues( 1 );
+ aValues[0].setValue(&bLoadUserDefinedSettings, ::getBooleanCppuType());
+ PutProperties( aNames, aValues );
+}
+// -----------------------------------------------------------------------
+void SvtLoadOptions_Impl::Notify( const Sequence<rtl::OUString>& )
+{
+ DBG_ERRORFILE( "properties have been changed" );
+}
+// -----------------------------------------------------------------------
+
+namespace
+{
+ class LocalSingleton : public rtl::Static< osl::Mutex, LocalSingleton >
+ {
+ };
+}
+
+// -----------------------------------------------------------------------
+SvtSaveOptions::SvtSaveOptions()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( LocalSingleton::get() );
+ if ( !pOptions )
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtSaveOptions_Impl::ctor()");
+ pOptions = new SvtLoadSaveOptions_Impl;
+ pOptions->pSaveOpt = new SvtSaveOptions_Impl;
+ pOptions->pLoadOpt = new SvtLoadOptions_Impl;
+
+ ItemHolder1::holdConfigItem(E_SAVEOPTIONS);
+ }
+ ++nRefCount;
+ pImp = pOptions;
+}
+
+// -----------------------------------------------------------------------
+
+SvtSaveOptions::~SvtSaveOptions()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( LocalSingleton::get() );
+ if ( !--nRefCount )
+ {
+ if ( pOptions->pSaveOpt->IsModified() )
+ pOptions->pSaveOpt->Commit();
+ if ( pOptions->pLoadOpt->IsModified() )
+ pOptions->pLoadOpt->Commit();
+
+ DELETEZ( pOptions->pLoadOpt );
+ DELETEZ( pOptions->pSaveOpt );
+ DELETEZ( pOptions );
+ }
+}
+
+sal_Bool SvtSaveOptions::IsBackup() const
+{
+ return pImp->pSaveOpt->IsBackup();
+}
+
+sal_Bool SvtSaveOptions::IsSaveDocView() const
+{
+ return pImp->pSaveOpt->IsSaveDocView();
+}
+
+sal_Bool SvtSaveOptions::IsSaveRelINet() const
+{
+ return pImp->pSaveOpt->IsSaveRelINet();
+}
+
+sal_Bool SvtSaveOptions::IsSaveRelFSys() const
+{
+ return pImp->pSaveOpt->IsSaveRelFSys();
+}
+
+sal_Bool SvtSaveOptions::IsSaveUnpacked() const
+{
+ return pImp->pSaveOpt->IsSaveUnpacked();
+}
+
+sal_Bool SvtSaveOptions::IsLoadUserSettings() const
+{
+ return pImp->pLoadOpt->IsLoadUserSettings();
+}
+
+sal_Bool SvtSaveOptions::IsPrettyPrinting() const
+{
+ return pImp->pSaveOpt->IsPrettyPrintingEnabled();
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_searchopt.cxx b/binfilter/bf_svtools/source/config/svt_searchopt.cxx
new file mode 100644
index 000000000000..545c3ed5ffa2
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_searchopt.cxx
@@ -0,0 +1,406 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 "searchopt.hxx"
+
+#include <tools/solar.h>
+#include <tools/debug.hxx>
+#include <unotools/configitem.hxx>
+#include <sal/macros.h>
+
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/uno/Any.h>
+#include <rtl/logfile.hxx>
+
+
+using namespace rtl;
+using namespace utl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::i18n;
+
+namespace binfilter
+{
+
+#define MAX_FLAGS_OFFSET 24
+
+//////////////////////////////////////////////////////////////////////
+
+
+class SvtSearchOptions_Impl : public ConfigItem
+{
+ INT32 nFlags;
+ BOOL bModified;
+
+ // disallow copy-constructor and assignment-operator for now
+ SvtSearchOptions_Impl( const SvtSearchOptions_Impl & );
+ SvtSearchOptions_Impl & operator = ( const SvtSearchOptions_Impl & );
+
+protected:
+ BOOL IsModified() const { return bModified; }
+ using ConfigItem::SetModified;
+ void SetModified( BOOL bVal );
+ BOOL Load();
+ BOOL Save();
+
+ Sequence< OUString > GetPropertyNames() const;
+
+public:
+ SvtSearchOptions_Impl();
+ virtual ~SvtSearchOptions_Impl();
+
+ // ConfigItem
+ virtual void Commit();
+ void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
+
+ BOOL GetFlag( USHORT nOffset ) const;
+ void SetFlag( USHORT nOffset, BOOL bVal );
+};
+
+
+
+SvtSearchOptions_Impl::SvtSearchOptions_Impl() :
+ ConfigItem( OUString::createFromAscii( "Office.Common/SearchOptions" ) )
+{
+ RTL_LOGFILE_CONTEXT(aLog, "svtools SvtSearchOptions_Impl::SvtSearchOptions_Impl()");
+ nFlags = 0x0003FFFF; // set all options values to 'true'
+ Load();
+ SetModified( FALSE );
+}
+
+
+SvtSearchOptions_Impl::~SvtSearchOptions_Impl()
+{
+ Commit();
+}
+
+
+void SvtSearchOptions_Impl::Commit()
+{
+ if (IsModified())
+ Save();
+}
+
+ void SvtSearchOptions_Impl::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
+
+BOOL SvtSearchOptions_Impl::GetFlag( USHORT nOffset ) const
+{
+ DBG_ASSERT( nOffset <= MAX_FLAGS_OFFSET, "offset out of range");
+ return ((nFlags >> nOffset) & 0x01) ? TRUE : FALSE;
+}
+
+
+void SvtSearchOptions_Impl::SetFlag( USHORT nOffset, BOOL bVal )
+{
+ DBG_ASSERT( nOffset <= MAX_FLAGS_OFFSET, "offset out of range");
+ INT32 nOldFlags = nFlags;
+ INT32 nMask = ((INT32) 1) << nOffset;
+ if (bVal)
+ nFlags |= nMask;
+ else
+ nFlags &= ~nMask;
+ if (nFlags != nOldFlags)
+ SetModified( TRUE );
+}
+
+
+void SvtSearchOptions_Impl::SetModified( BOOL bVal )
+{
+ bModified = bVal;
+ if (bModified)
+ {
+ ConfigItem::SetModified();
+ }
+}
+
+
+Sequence< OUString > SvtSearchOptions_Impl::GetPropertyNames() const
+{
+ static const char* aPropNames[ MAX_FLAGS_OFFSET + 1 ] =
+ {
+ "IsWholeWordsOnly", // 0
+ "IsBackwards", // 1
+ "IsUseRegularExpression", // 2
+ //"IsCurrentSelectionOnly", // interactively set or not...
+ "IsSearchForStyles", // 3
+ "IsSimilaritySearch", // 4
+ "IsUseAsianOptions", // 5
+ "IsMatchCase", // 6
+ "Japanese/IsMatchFullHalfWidthForms", // 7
+ "Japanese/IsMatchHiraganaKatakana", // 8
+ "Japanese/IsMatchContractions", // 9
+ "Japanese/IsMatchMinusDashCho-on", // 10
+ "Japanese/IsMatchRepeatCharMarks", // 11
+ "Japanese/IsMatchVariantFormKanji", // 12
+ "Japanese/IsMatchOldKanaForms", // 13
+ "Japanese/IsMatch_DiZi_DuZu", // 14
+ "Japanese/IsMatch_BaVa_HaFa", // 15
+ "Japanese/IsMatch_TsiThiChi_DhiZi", // 16
+ "Japanese/IsMatch_HyuIyu_ByuVyu", // 17
+ "Japanese/IsMatch_SeShe_ZeJe", // 18
+ "Japanese/IsMatch_IaIya", // 19
+ "Japanese/IsMatch_KiKu", // 20
+ "Japanese/IsIgnorePunctuation", // 21
+ "Japanese/IsIgnoreWhitespace", // 22
+ "Japanese/IsIgnoreProlongedSoundMark", // 23
+ "Japanese/IsIgnoreMiddleDot" // 24
+ };
+
+ const int nCount = SAL_N_ELEMENTS( aPropNames );
+ Sequence< OUString > aNames( nCount );
+ OUString* pNames = aNames.getArray();
+ for (INT32 i = 0; i < nCount; ++i)
+ pNames[i] = OUString::createFromAscii( aPropNames[i] );
+
+ return aNames;
+}
+
+
+BOOL SvtSearchOptions_Impl::Load()
+{
+ BOOL bSucc = FALSE;
+
+ Sequence< OUString > aNames = GetPropertyNames();
+ INT32 nProps = aNames.getLength();
+
+ const Sequence< Any > aValues = GetProperties( aNames );
+ DBG_ASSERT( aValues.getLength() == aNames.getLength(),
+ "GetProperties failed" );
+ //EnableNotification( aNames );
+
+ if (nProps && aValues.getLength() == nProps)
+ {
+ bSucc = TRUE;
+
+ const Any* pValues = aValues.getConstArray();
+ for (USHORT i = 0; i < nProps; ++i)
+ {
+ const Any &rVal = pValues[i];
+ DBG_ASSERT( rVal.hasValue(), "property value missing" );
+ if (rVal.hasValue())
+ {
+ BOOL bVal = BOOL();
+ if (rVal >>= bVal)
+ {
+ if (i <= MAX_FLAGS_OFFSET)
+ {
+ // use index in sequence as flag index
+ SetFlag( i, bVal );
+ }
+ else
+ {
+ DBG_ERROR( "unexpected index" );
+ }
+ }
+ else
+ {
+ DBG_ERROR( "unexpected type" );
+ bSucc = FALSE;
+ }
+ }
+ else
+ {
+ DBG_ERROR( "value missing" );
+ bSucc = FALSE;
+ }
+ }
+ }
+ DBG_ASSERT( bSucc, "LoadConfig failed" );
+
+ return bSucc;
+}
+
+
+BOOL SvtSearchOptions_Impl::Save()
+{
+ BOOL bSucc = FALSE;
+
+ const Sequence< OUString > aNames = GetPropertyNames();
+ INT32 nProps = aNames.getLength();
+
+ Sequence< Any > aValues( nProps );
+ Any *pValue = aValues.getArray();
+
+ DBG_ASSERT( nProps == MAX_FLAGS_OFFSET + 1,
+ "unexpected size of index" );
+ if (nProps && nProps == MAX_FLAGS_OFFSET + 1)
+ {
+ for (USHORT i = 0; i < nProps; ++i)
+ pValue[i] <<= (BOOL) GetFlag(i);
+ bSucc |= PutProperties( aNames, aValues );
+ }
+
+ if (bSucc)
+ SetModified( FALSE );
+
+ return bSucc;
+}
+
+
+//////////////////////////////////////////////////////////////////////
+
+SvtSearchOptions::SvtSearchOptions()
+{
+ pImpl = new SvtSearchOptions_Impl;
+}
+
+
+SvtSearchOptions::~SvtSearchOptions()
+{
+ delete pImpl;
+}
+
+BOOL SvtSearchOptions::IsWholeWordsOnly() const
+{
+ return pImpl->GetFlag( 0 );
+}
+
+
+BOOL SvtSearchOptions::IsBackwards() const
+{
+ return pImpl->GetFlag( 1 );
+}
+
+BOOL SvtSearchOptions::IsUseRegularExpression() const
+{
+ return pImpl->GetFlag( 2 );
+}
+
+BOOL SvtSearchOptions::IsSimilaritySearch() const
+{
+ return pImpl->GetFlag( 4 );
+}
+
+BOOL SvtSearchOptions::IsUseAsianOptions() const
+{
+ return pImpl->GetFlag( 5 );
+}
+
+BOOL SvtSearchOptions::IsMatchCase() const
+{
+ return pImpl->GetFlag( 6 );
+}
+
+BOOL SvtSearchOptions::IsMatchFullHalfWidthForms() const
+{
+ return pImpl->GetFlag( 7 );
+}
+
+BOOL SvtSearchOptions::IsMatchHiraganaKatakana() const
+{
+ return pImpl->GetFlag( 8 );
+}
+
+BOOL SvtSearchOptions::IsMatchContractions() const
+{
+ return pImpl->GetFlag( 9 );
+}
+
+BOOL SvtSearchOptions::IsMatchMinusDashChoon() const
+{
+ return pImpl->GetFlag( 10 );
+}
+
+
+BOOL SvtSearchOptions::IsMatchRepeatCharMarks() const
+{
+ return pImpl->GetFlag( 11 );
+}
+
+BOOL SvtSearchOptions::IsMatchVariantFormKanji() const
+{
+ return pImpl->GetFlag( 12 );
+}
+
+BOOL SvtSearchOptions::IsMatchOldKanaForms() const
+{
+ return pImpl->GetFlag( 13 );
+}
+
+
+BOOL SvtSearchOptions::IsMatchDiziDuzu() const
+{
+ return pImpl->GetFlag( 14 );
+}
+
+BOOL SvtSearchOptions::IsMatchBavaHafa() const
+{
+ return pImpl->GetFlag( 15 );
+}
+
+BOOL SvtSearchOptions::IsMatchTsithichiDhizi() const
+{
+ return pImpl->GetFlag( 16 );
+}
+
+BOOL SvtSearchOptions::IsMatchHyuiyuByuvyu() const
+{
+ return pImpl->GetFlag( 17 );
+}
+
+BOOL SvtSearchOptions::IsMatchSesheZeje() const
+{
+ return pImpl->GetFlag( 18 );
+}
+
+BOOL SvtSearchOptions::IsMatchIaiya() const
+{
+ return pImpl->GetFlag( 19 );
+}
+
+BOOL SvtSearchOptions::IsMatchKiku() const
+{
+ return pImpl->GetFlag( 20 );
+}
+
+BOOL SvtSearchOptions::IsIgnorePunctuation() const
+{
+ return pImpl->GetFlag( 21 );
+}
+
+BOOL SvtSearchOptions::IsIgnoreWhitespace() const
+{
+ return pImpl->GetFlag( 22 );
+}
+
+BOOL SvtSearchOptions::IsIgnoreProlongedSoundMark() const
+{
+ return pImpl->GetFlag( 23 );
+}
+
+BOOL SvtSearchOptions::IsIgnoreMiddleDot() const
+{
+ return pImpl->GetFlag( 24 );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_securityoptions.cxx b/binfilter/bf_svtools/source/config/svt_securityoptions.cxx
new file mode 100644
index 000000000000..478c7b5e846a
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_securityoptions.cxx
@@ -0,0 +1,850 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+//_________________________________________________________________________________________________________________
+// includes
+//_________________________________________________________________________________________________________________
+
+#include <bf_svtools/securityoptions.hxx>
+
+#include <unotools/configmgr.hxx>
+
+#include <unotools/configitem.hxx>
+
+#include <tools/debug.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+#include <tools/urlobj.hxx>
+
+#include <tools/wldcrd.hxx>
+
+#include <bf_svtools/pathoptions.hxx>
+
+#include <rtl/logfile.hxx>
+#include "itemholder1.hxx"
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+using namespace ::utl ;
+using namespace ::rtl ;
+using namespace ::osl ;
+using namespace ::com::sun::star::uno ;
+
+namespace binfilter
+{
+
+//_________________________________________________________________________________________________________________
+// const
+//_________________________________________________________________________________________________________________
+
+#define ROOTNODE_SECURITY OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Security/Scripting"))
+#define DEFAULT_SECUREURL Sequence< OUString >()
+#define DEFAULT_SECLEVEL 3
+#define DEFAULT_TRUSTEDAUTHORS Sequence< SvtSecurityOptions::Certificate >()
+
+// xmlsec05 depricated
+#define DEFAULT_STAROFFICEBASIC eALWAYS_EXECUTE
+
+#define CSTR_SECUREURL "SecureURL"
+#define CSTR_DOCWARN_SAVEORSEND "WarnSaveOrSendDoc"
+#define CSTR_DOCWARN_SIGNING "WarnSignDoc"
+#define CSTR_DOCWARN_PRINT "WarnPrintDoc"
+#define CSTR_DOCWARN_CREATEPDF "WarnCreatePDF"
+#define CSTR_DOCWARN_REMOVEPERSONALINFO "RemovePersonalInfoOnSaving"
+#define CSTR_DOCWARN_RECOMMENDPASSWORD "RecommendPasswordProtection"
+#define CSTR_CTRLCLICK_HYPERLINK "HyperlinksWithCtrlClick"
+#define CSTR_MACRO_SECLEVEL "MacroSecurityLevel"
+#define CSTR_MACRO_TRUSTEDAUTHORS "TrustedAuthors"
+#define CSTR_MACRO_DISABLE "DisableMacrosExecution"
+#define CSTR_TRUSTEDAUTHOR_SUBJECTNAME "SubjectName"
+#define CSTR_TRUSTEDAUTHOR_SERIALNUMBER "SerialNumber"
+#define CSTR_TRUSTEDAUTHOR_RAWDATA "RawData"
+
+#define PROPERTYNAME_SECUREURL OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_SECUREURL ))
+#define PROPERTYNAME_DOCWARN_SAVEORSEND OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_DOCWARN_SAVEORSEND ))
+#define PROPERTYNAME_DOCWARN_SIGNING OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_DOCWARN_SIGNING ))
+#define PROPERTYNAME_DOCWARN_PRINT OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_DOCWARN_PRINT ))
+#define PROPERTYNAME_DOCWARN_CREATEPDF OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_DOCWARN_CREATEPDF ))
+#define PROPERTYNAME_DOCWARN_REMOVEPERSONALINFO OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_DOCWARN_REMOVEPERSONALINFO ))
+#define PROPERTYNAME_DOCWARN_RECOMMENDPASSWORD OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_DOCWARN_RECOMMENDPASSWORD ))
+#define PROPERTYNAME_CTRLCLICK_HYPERLINK OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_CTRLCLICK_HYPERLINK ))
+#define PROPERTYNAME_MACRO_SECLEVEL OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_MACRO_SECLEVEL ))
+#define PROPERTYNAME_MACRO_TRUSTEDAUTHORS OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_MACRO_TRUSTEDAUTHORS ))
+#define PROPERTYNAME_MACRO_DISABLE OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_MACRO_DISABLE ))
+#define PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_TRUSTEDAUTHOR_SUBJECTNAME))
+#define PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_TRUSTEDAUTHOR_SERIALNUMBER))
+#define PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA OUString(RTL_CONSTASCII_USTRINGPARAM(CSTR_TRUSTEDAUTHOR_RAWDATA))
+
+// xmlsec05 depricated
+#define PROPERTYNAME_STAROFFICEBASIC OUString(RTL_CONSTASCII_USTRINGPARAM("OfficeBasic" ))
+#define PROPERTYNAME_EXECUTEPLUGINS OUString(RTL_CONSTASCII_USTRINGPARAM("ExecutePlugins" ))
+#define PROPERTYNAME_WARNINGENABLED OUString(RTL_CONSTASCII_USTRINGPARAM("Warning" ))
+#define PROPERTYNAME_CONFIRMATIONENABLED OUString(RTL_CONSTASCII_USTRINGPARAM("Confirmation" ))
+// xmlsec05 depricated
+
+
+#define PROPERTYHANDLE_SECUREURL 0
+
+// xmlsec05 depricated
+#define PROPERTYHANDLE_STAROFFICEBASIC 1
+#define PROPERTYHANDLE_EXECUTEPLUGINS 2
+#define PROPERTYHANDLE_WARNINGENABLED 3
+#define PROPERTYHANDLE_CONFIRMATIONENABLED 4
+// xmlsec05 depricated
+
+#define PROPERTYHANDLE_DOCWARN_SAVEORSEND 5
+#define PROPERTYHANDLE_DOCWARN_SIGNING 6
+#define PROPERTYHANDLE_DOCWARN_PRINT 7
+#define PROPERTYHANDLE_DOCWARN_CREATEPDF 8
+#define PROPERTYHANDLE_DOCWARN_REMOVEPERSONALINFO 9
+#define PROPERTYHANDLE_DOCWARN_RECOMMENDPASSWORD 10
+#define PROPERTYHANDLE_CTRLCLICK_HYPERLINK 11
+#define PROPERTYHANDLE_MACRO_SECLEVEL 12
+#define PROPERTYHANDLE_MACRO_TRUSTEDAUTHORS 13
+#define PROPERTYHANDLE_MACRO_DISABLE 14
+
+#define PROPERTYCOUNT 15
+#define PROPERTYHANDLE_INVALID -1
+
+#define CFG_READONLY_DEFAULT sal_False
+
+//_________________________________________________________________________________________________________________
+// private declarations!
+//_________________________________________________________________________________________________________________
+
+class SvtSecurityOptions_Impl : public ConfigItem
+{
+ //-------------------------------------------------------------------------------------------------------------
+ // public methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ public:
+
+ //---------------------------------------------------------------------------------------------------------
+ // constructor / destructor
+ //---------------------------------------------------------------------------------------------------------
+
+ SvtSecurityOptions_Impl();
+ ~SvtSecurityOptions_Impl();
+
+ //---------------------------------------------------------------------------------------------------------
+ // overloaded methods of baseclass
+ //---------------------------------------------------------------------------------------------------------
+
+ /*-****************************************************************************************************//**
+ @short called for notify of configmanager
+ @descr These method is called from the ConfigManager before application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. You must update your
+ internal values.
+
+ @seealso baseclass ConfigItem
+
+ @param "seqPropertyNames" is the list of properties which should be updated.
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Notify( const Sequence< OUString >& seqPropertyNames );
+
+ /*-****************************************************************************************************//**
+ @short write changes to configuration
+ @descr These method writes the changed values into the sub tree
+ and should always called in our destructor to guarantee consistency of config data.
+
+ @seealso baseclass ConfigItem
+
+ @param -
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Commit();
+
+ //---------------------------------------------------------------------------------------------------------
+ // public interface
+ //---------------------------------------------------------------------------------------------------------
+
+ inline sal_Int32 GetMacroSecurityLevel ( ) const ;
+
+ inline sal_Bool IsMacroDisabled ( ) const ;
+
+private:
+
+ /*-****************************************************************************************************//**
+ @short return list of key names of ouer configuration management which represent our module tree
+ @descr These methods return a static const list of key names. We need it to get needed values from our
+ configuration management.
+
+ @seealso -
+
+ @param -
+ @return A list of needed configuration keys is returned.
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ void SetProperty( sal_Int32 nHandle, const Any& rValue, sal_Bool bReadOnly );
+ void LoadAuthors( void );
+ static sal_Int32 GetHandle( const OUString& rPropertyName );
+
+ static Sequence< OUString > GetPropertyNames();
+
+ Sequence< OUString > m_seqSecureURLs;
+ sal_Bool m_bSaveOrSend;
+ sal_Bool m_bSigning;
+ sal_Bool m_bPrint;
+ sal_Bool m_bCreatePDF;
+ sal_Bool m_bRemoveInfo;
+ sal_Bool m_bRecommendPwd;
+ sal_Bool m_bCtrlClickHyperlink;
+ sal_Int32 m_nSecLevel;
+ Sequence< SvtSecurityOptions::Certificate > m_seqTrustedAuthors;
+ sal_Bool m_bDisableMacros;
+
+ sal_Bool m_bROSecureURLs;
+ sal_Bool m_bROSaveOrSend;
+ sal_Bool m_bROSigning;
+ sal_Bool m_bROPrint;
+ sal_Bool m_bROCreatePDF;
+ sal_Bool m_bRORemoveInfo;
+ sal_Bool m_bRORecommendPwd;
+ sal_Bool m_bROCtrlClickHyperlink;
+ sal_Bool m_bROSecLevel;
+ sal_Bool m_bROTrustedAuthors;
+ sal_Bool m_bRODisableMacros;
+
+
+ // xmlsec05 depricated
+ EBasicSecurityMode m_eBasicMode;
+ sal_Bool m_bExecutePlugins;
+ sal_Bool m_bWarning;
+ sal_Bool m_bConfirmation;
+
+ sal_Bool m_bROConfirmation;
+ sal_Bool m_bROWarning;
+ sal_Bool m_bROExecutePlugins;
+ sal_Bool m_bROBasicMode;
+};
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()
+ :ConfigItem ( ROOTNODE_SECURITY )
+ ,m_seqSecureURLs ( DEFAULT_SECUREURL )
+ ,m_bSaveOrSend ( sal_True )
+ ,m_bSigning ( sal_True )
+ ,m_bPrint ( sal_True )
+ ,m_bCreatePDF ( sal_True )
+ ,m_bRemoveInfo ( sal_True )
+ ,m_nSecLevel ( sal_True )
+ ,m_seqTrustedAuthors ( DEFAULT_TRUSTEDAUTHORS )
+ ,m_bDisableMacros ( sal_False )
+ ,m_bROSecureURLs ( CFG_READONLY_DEFAULT )
+ ,m_bROSaveOrSend ( CFG_READONLY_DEFAULT )
+ ,m_bROSigning ( CFG_READONLY_DEFAULT )
+ ,m_bROPrint ( CFG_READONLY_DEFAULT )
+ ,m_bROCreatePDF ( CFG_READONLY_DEFAULT )
+ ,m_bRORemoveInfo ( CFG_READONLY_DEFAULT )
+ ,m_bROSecLevel ( CFG_READONLY_DEFAULT )
+ ,m_bROTrustedAuthors ( CFG_READONLY_DEFAULT )
+ ,m_bRODisableMacros ( sal_True ) // currently is not intended to be changed
+
+ // xmlsec05 depricated
+ , m_eBasicMode ( DEFAULT_STAROFFICEBASIC )
+ , m_bExecutePlugins ( sal_True )
+ , m_bWarning ( sal_True )
+ , m_bConfirmation ( sal_True )
+ , m_bROConfirmation ( CFG_READONLY_DEFAULT )
+ , m_bROWarning ( CFG_READONLY_DEFAULT )
+ , m_bROExecutePlugins ( CFG_READONLY_DEFAULT )
+ , m_bROBasicMode ( CFG_READONLY_DEFAULT )
+ // xmlsec05 depricated
+
+{
+ Sequence< OUString > seqNames = GetPropertyNames ( );
+ Sequence< Any > seqValues = GetProperties ( seqNames );
+ Sequence< sal_Bool > seqRO = GetReadOnlyStates ( seqNames );
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to our internal member.
+ sal_Int32 nPropertyCount = seqValues.getLength();
+ for( sal_Int32 nProperty = 0 ; nProperty < nPropertyCount ; ++nProperty )
+ SetProperty( nProperty, seqValues[ nProperty ], seqRO[ nProperty ] );
+
+ LoadAuthors();
+
+ // Enable notification mechanism of our baseclass.
+ // We need it to get information about changes outside these class on our used configuration keys!*/
+
+ EnableNotification( seqNames );
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtSecurityOptions_Impl::~SvtSecurityOptions_Impl()
+{
+ if( IsModified() )
+ Commit();
+}
+
+void SvtSecurityOptions_Impl::SetProperty( sal_Int32 nProperty, const Any& rValue, sal_Bool bRO )
+{
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_SECUREURL:
+ {
+ m_seqSecureURLs.realloc( 0 );
+ rValue >>= m_seqSecureURLs;
+ SvtPathOptions aOpt;
+ sal_uInt32 nCount = m_seqSecureURLs.getLength();
+ for( sal_uInt32 nItem = 0 ; nItem < nCount ; ++nItem )
+ m_seqSecureURLs[ nItem ] = aOpt.SubstituteVariable( m_seqSecureURLs[ nItem ] );
+ m_bROSecureURLs = bRO;
+ }
+ break;
+
+ case PROPERTYHANDLE_DOCWARN_SAVEORSEND:
+ {
+ rValue >>= m_bSaveOrSend;
+ m_bROSaveOrSend = bRO;
+ }
+ break;
+
+ case PROPERTYHANDLE_DOCWARN_SIGNING:
+ {
+ rValue >>= m_bSigning;
+ m_bROSigning = bRO;
+ }
+ break;
+
+ case PROPERTYHANDLE_DOCWARN_PRINT:
+ {
+ rValue >>= m_bPrint;
+ m_bROPrint = bRO;
+ }
+ break;
+
+ case PROPERTYHANDLE_DOCWARN_CREATEPDF:
+ {
+ rValue >>= m_bCreatePDF;
+ m_bROCreatePDF = bRO;
+ }
+
+ case PROPERTYHANDLE_DOCWARN_REMOVEPERSONALINFO:
+ {
+ rValue >>= m_bRemoveInfo;
+ m_bRORemoveInfo = bRO;
+ }
+
+ case PROPERTYHANDLE_DOCWARN_RECOMMENDPASSWORD:
+ {
+ rValue >>= m_bRecommendPwd;
+ m_bRORecommendPwd = bRO;
+ }
+
+ case PROPERTYHANDLE_CTRLCLICK_HYPERLINK:
+ {
+ rValue >>= m_bCtrlClickHyperlink;
+ m_bROCtrlClickHyperlink = bRO;
+ }
+
+ case PROPERTYHANDLE_MACRO_SECLEVEL:
+ {
+ rValue >>= m_nSecLevel;
+ m_bROSecLevel = bRO;
+ }
+ break;
+
+ case PROPERTYHANDLE_MACRO_TRUSTEDAUTHORS:
+ {
+ // don't care about value here...
+ m_bROTrustedAuthors = bRO;
+ }
+ break;
+
+ case PROPERTYHANDLE_MACRO_DISABLE:
+ {
+ rValue >>= m_bDisableMacros;
+ m_bRODisableMacros = bRO;
+ }
+ break;
+
+
+ // xmlsec05 depricated
+ case PROPERTYHANDLE_STAROFFICEBASIC:
+ {
+ sal_Int32 nMode = 0;
+ rValue >>= nMode;
+ m_eBasicMode = (EBasicSecurityMode)nMode;
+ m_bROBasicMode = bRO;
+ }
+ break;
+ case PROPERTYHANDLE_EXECUTEPLUGINS:
+ {
+ rValue >>= m_bExecutePlugins;
+ m_bROExecutePlugins = bRO;
+ }
+ break;
+ case PROPERTYHANDLE_WARNINGENABLED:
+ {
+ rValue >>= m_bWarning;
+ m_bROWarning = bRO;
+ }
+ break;
+ case PROPERTYHANDLE_CONFIRMATIONENABLED:
+ {
+ rValue >>= m_bConfirmation;
+ m_bROConfirmation = bRO;
+ }
+ break;
+ // xmlsec05 depricated
+
+
+ #if OSL_DEBUG_LEVEL > 1
+ default:
+ DBG_ASSERT( false, "SvtSecurityOptions_Impl::SetProperty()\nUnkown property!\n" );
+ #endif
+ }
+}
+
+void SvtSecurityOptions_Impl::LoadAuthors( void )
+{
+ m_seqTrustedAuthors.realloc( 0 ); // first clear
+ Sequence< OUString > lAuthors = GetNodeNames( PROPERTYNAME_MACRO_TRUSTEDAUTHORS );
+ sal_Int32 c1 = lAuthors.getLength();
+ if( c1 )
+ {
+ sal_Int32 c2 = c1 * 3; // 3 Properties inside Struct TrustedAuthor
+ Sequence< OUString > lAllAuthors( c2 );
+
+ sal_Int32 i1;
+ sal_Int32 i2;
+ OUString aSep( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
+ for( i1 = 0, i2 = 0 ; i1 < c1 ; ++i1 )
+ {
+ lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + lAuthors[ i1 ] + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME;
+ ++i2;
+ lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + lAuthors[ i1 ] + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER;
+ ++i2;
+ lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + lAuthors[ i1 ] + aSep + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA;
+ ++i2;
+ }
+
+ Sequence< Any > lValues = GetProperties( lAllAuthors );
+ if( lValues.getLength() == c2 )
+ {
+ m_seqTrustedAuthors.realloc( c1 );
+ SvtSecurityOptions::Certificate aCert( 3 );
+ for( i1 = 0, i2 = 0 ; i1 < c1 ; ++i1 )
+ {
+ lValues[ i2 ] >>= aCert[ 0 ];
+ ++i2;
+ lValues[ i2 ] >>= aCert[ 1 ];
+ ++i2;
+ lValues[ i2 ] >>= aCert[ 2 ];
+ ++i2;
+ m_seqTrustedAuthors[ i1 ] = aCert;
+ }
+ }
+ }
+}
+
+sal_Int32 SvtSecurityOptions_Impl::GetHandle( const OUString& rName )
+{
+ sal_Int32 nHandle;
+
+ if( rName.compareToAscii( CSTR_SECUREURL ) == 0 )
+ nHandle = PROPERTYHANDLE_SECUREURL;
+ else if( rName.compareToAscii( CSTR_DOCWARN_SAVEORSEND ) == 0 )
+ nHandle = PROPERTYHANDLE_DOCWARN_SAVEORSEND;
+ else if( rName.compareToAscii( CSTR_DOCWARN_SIGNING ) == 0 )
+ nHandle = PROPERTYHANDLE_DOCWARN_SIGNING;
+ else if( rName.compareToAscii( CSTR_DOCWARN_PRINT ) == 0 )
+ nHandle = PROPERTYHANDLE_DOCWARN_PRINT;
+ else if( rName.compareToAscii( CSTR_DOCWARN_CREATEPDF ) == 0 )
+ nHandle = PROPERTYHANDLE_DOCWARN_CREATEPDF;
+ else if( rName.compareToAscii( CSTR_DOCWARN_REMOVEPERSONALINFO ) == 0 )
+ nHandle = PROPERTYHANDLE_DOCWARN_REMOVEPERSONALINFO;
+ else if( rName.compareToAscii( CSTR_DOCWARN_RECOMMENDPASSWORD ) == 0 )
+ nHandle = PROPERTYHANDLE_DOCWARN_RECOMMENDPASSWORD;
+ else if( rName.compareToAscii( CSTR_CTRLCLICK_HYPERLINK ) == 0 )
+ nHandle = PROPERTYHANDLE_CTRLCLICK_HYPERLINK;
+ else if( rName.compareToAscii( CSTR_MACRO_SECLEVEL ) == 0 )
+ nHandle = PROPERTYHANDLE_MACRO_SECLEVEL;
+ else if( rName.compareToAscii( CSTR_MACRO_TRUSTEDAUTHORS ) == 0 )
+ nHandle = PROPERTYHANDLE_MACRO_TRUSTEDAUTHORS;
+ else if( rName.compareToAscii( CSTR_MACRO_DISABLE ) == 0 )
+ nHandle = PROPERTYHANDLE_MACRO_DISABLE;
+
+ // xmlsec05 depricated
+ else if( rName == PROPERTYNAME_STAROFFICEBASIC )
+ nHandle = PROPERTYHANDLE_STAROFFICEBASIC;
+ else if( rName == PROPERTYNAME_EXECUTEPLUGINS )
+ nHandle = PROPERTYHANDLE_EXECUTEPLUGINS;
+ else if( rName == PROPERTYNAME_WARNINGENABLED )
+ nHandle = PROPERTYHANDLE_WARNINGENABLED;
+ else if( rName == PROPERTYNAME_CONFIRMATIONENABLED )
+ nHandle = PROPERTYHANDLE_CONFIRMATIONENABLED;
+ // xmlsec05 depricated
+
+ else
+ nHandle = PROPERTYHANDLE_INVALID;
+
+ return nHandle;
+}
+
+void SvtSecurityOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames )
+{
+ // Use given list of updated properties to get his values from configuration directly!
+ Sequence< Any > seqValues = GetProperties( seqPropertyNames );
+ Sequence< sal_Bool > seqRO = GetReadOnlyStates( seqPropertyNames );
+ // Safe impossible cases.
+ // We need values from ALL notified configuration keys.
+ DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtSecurityOptions_Impl::Notify()\nI miss some values of configuration keys!\n" );
+ // Step over list of property names and get right value from coreesponding value list to set it on internal members!
+ sal_Int32 nCount = seqPropertyNames.getLength();
+ for( sal_Int32 nProperty = 0 ; nProperty < nCount ; ++nProperty )
+ SetProperty( GetHandle( seqPropertyNames[ nProperty ] ), seqValues[ nProperty ], seqRO[ nProperty ] );
+
+ // read set of trusted authors separately
+ LoadAuthors();
+}
+
+void SvtSecurityOptions_Impl::Commit()
+{
+ // Get names of supported properties, create a list for values and copy current values to it.
+ Sequence< OUString > lOrgNames = GetPropertyNames();
+ sal_Int32 nOrgCount = lOrgNames.getLength();
+
+ Sequence< OUString > lNames(nOrgCount);
+ Sequence< Any > lValues(nOrgCount);
+ sal_Int32 nRealCount = 0;
+ bool bDone;
+
+ ClearNodeSet( PROPERTYNAME_MACRO_TRUSTEDAUTHORS );
+
+ for( sal_Int32 nProperty = 0 ; nProperty < nOrgCount ; ++nProperty )
+ {
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_SECUREURL:
+ {
+ bDone = !m_bROSecureURLs;
+ if( bDone )
+ {
+ Sequence< OUString > lURLs( m_seqSecureURLs );
+ SvtPathOptions aOpt;
+ sal_Int32 nURLsCnt = lURLs.getLength();
+ for( sal_Int32 nItem = 0 ; nItem < nURLsCnt ; ++nItem )
+ lURLs[ nItem ] = aOpt.UseVariable( lURLs[ nItem ] );
+ lValues[ nRealCount ] <<= lURLs;
+ }
+ }
+ break;
+
+ case PROPERTYHANDLE_DOCWARN_SAVEORSEND:
+ {
+ bDone = !m_bROSaveOrSend;
+ if( bDone )
+ lValues[ nRealCount ] <<= m_bSaveOrSend;
+ }
+ break;
+
+ case PROPERTYHANDLE_DOCWARN_SIGNING:
+ {
+ bDone = !m_bROSigning;
+ if( bDone )
+ lValues[ nRealCount ] <<= m_bSigning;
+ }
+ break;
+
+ case PROPERTYHANDLE_DOCWARN_PRINT:
+ {
+ bDone = !m_bROPrint;
+ if( bDone )
+ lValues[ nRealCount ] <<= m_bPrint;
+ }
+ break;
+
+ case PROPERTYHANDLE_DOCWARN_CREATEPDF:
+ {
+ bDone = !m_bROCreatePDF;
+ if( bDone )
+ lValues[ nRealCount ] <<= m_bCreatePDF;
+ }
+ break;
+
+ case PROPERTYHANDLE_DOCWARN_REMOVEPERSONALINFO:
+ {
+ bDone = !m_bRORemoveInfo;
+ if( bDone )
+ lValues[ nRealCount ] <<= m_bRemoveInfo;
+ }
+ break;
+
+ case PROPERTYHANDLE_DOCWARN_RECOMMENDPASSWORD:
+ {
+ bDone = !m_bRORecommendPwd;
+ if( bDone )
+ lValues[ nRealCount ] <<= m_bRecommendPwd;
+ }
+ break;
+
+ case PROPERTYHANDLE_CTRLCLICK_HYPERLINK:
+ {
+ bDone = !m_bROCtrlClickHyperlink;
+ if( bDone )
+ lValues[ nRealCount ] <<= m_bCtrlClickHyperlink;
+ }
+ break;
+
+ case PROPERTYHANDLE_MACRO_SECLEVEL:
+ {
+ bDone = !m_bROSecLevel;
+ if( bDone )
+ lValues[ nRealCount ] <<= m_nSecLevel;
+ }
+ break;
+
+ case PROPERTYHANDLE_MACRO_TRUSTEDAUTHORS:
+ {
+ bDone = !m_bROTrustedAuthors;
+ if( bDone )
+ {
+ sal_Int32 nCnt = m_seqTrustedAuthors.getLength();
+ if( nCnt )
+ {
+ String s;
+ s.AppendAscii( CSTR_MACRO_TRUSTEDAUTHORS );
+ s.AppendAscii( "/a" );
+
+ Sequence< Sequence< com::sun::star::beans::PropertyValue > > lPropertyValuesSeq( nCnt );
+ for( sal_Int32 i = 0 ; i < nCnt ; ++i )
+ {
+ String aPrefix( s );
+ aPrefix += String::CreateFromInt32( i );
+ aPrefix.AppendAscii( "/" );
+ Sequence< com::sun::star::beans::PropertyValue > lPropertyValues( 3 );
+ lPropertyValues[ 0 ].Name = aPrefix + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME;
+ lPropertyValues[ 0 ].Value <<= m_seqTrustedAuthors[ i ][0];
+ lPropertyValues[ 1 ].Name = aPrefix + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER;
+ lPropertyValues[ 1 ].Value <<= m_seqTrustedAuthors[ i ][1];
+ lPropertyValues[ 2 ].Name = aPrefix + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA;
+ lPropertyValues[ 2 ].Value <<= m_seqTrustedAuthors[ i ][2];
+
+
+ SetSetProperties( PROPERTYNAME_MACRO_TRUSTEDAUTHORS, lPropertyValues );
+ }
+
+ bDone = false; // because we save in loop above!
+ }
+ else
+ bDone = false;
+ }
+ }
+ break;
+
+ case PROPERTYHANDLE_MACRO_DISABLE:
+ {
+ bDone = !m_bRODisableMacros;
+ if( bDone )
+ lValues[ nRealCount ] <<= (sal_Bool)m_bDisableMacros;
+ }
+ break;
+
+
+ // xmlsec05 depricated
+ case PROPERTYHANDLE_STAROFFICEBASIC:
+ {
+ bDone = !m_bROBasicMode;
+ if( bDone )
+ lValues[ nRealCount ] <<= (sal_Int32)m_eBasicMode;
+ }
+ break;
+ case PROPERTYHANDLE_EXECUTEPLUGINS:
+ {
+ bDone = !m_bROExecutePlugins;
+ if( bDone )
+ lValues[ nRealCount ] <<= m_bExecutePlugins;
+ }
+ break;
+ case PROPERTYHANDLE_WARNINGENABLED:
+ {
+ bDone = !m_bROWarning;
+ if( bDone )
+ lValues[ nRealCount ] <<= m_bWarning;
+ }
+ break;
+ case PROPERTYHANDLE_CONFIRMATIONENABLED:
+ {
+ bDone = !m_bROConfirmation;
+ if( bDone )
+ lValues[ nRealCount ] <<= m_bConfirmation;
+ }
+ break;
+ // xmlsec05 depricated
+
+
+ default:
+ bDone = false;
+ }
+
+ if( bDone )
+ {
+ lNames[ nRealCount ] = lOrgNames[ nProperty ];
+ ++nRealCount;
+ }
+ }
+ // Set properties in configuration.
+ lNames.realloc(nRealCount);
+ lValues.realloc(nRealCount);
+ PutProperties( lNames, lValues );
+}
+
+inline sal_Int32 SvtSecurityOptions_Impl::GetMacroSecurityLevel() const
+{
+ return m_nSecLevel;
+}
+
+inline sal_Bool SvtSecurityOptions_Impl::IsMacroDisabled() const
+{
+ return m_bDisableMacros;
+}
+
+Sequence< OUString > SvtSecurityOptions_Impl::GetPropertyNames()
+{
+ // Build static list of configuration key names.
+ static const OUString pProperties[] =
+ {
+ PROPERTYNAME_SECUREURL,
+ PROPERTYNAME_STAROFFICEBASIC,
+ PROPERTYNAME_EXECUTEPLUGINS,
+ PROPERTYNAME_WARNINGENABLED,
+ PROPERTYNAME_CONFIRMATIONENABLED,
+ PROPERTYNAME_DOCWARN_SAVEORSEND,
+ PROPERTYNAME_DOCWARN_SIGNING,
+ PROPERTYNAME_DOCWARN_PRINT,
+ PROPERTYNAME_DOCWARN_CREATEPDF,
+ PROPERTYNAME_DOCWARN_REMOVEPERSONALINFO,
+ PROPERTYNAME_DOCWARN_RECOMMENDPASSWORD,
+ PROPERTYNAME_CTRLCLICK_HYPERLINK,
+ PROPERTYNAME_MACRO_SECLEVEL,
+ PROPERTYNAME_MACRO_TRUSTEDAUTHORS,
+ PROPERTYNAME_MACRO_DISABLE
+ };
+ // Initialize return sequence with these list ...
+ static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
+ // ... and return it.
+ return seqPropertyNames;
+}
+
+//*****************************************************************************************************************
+// initialize static member
+// DON'T DO IT IN YOUR HEADER!
+// see definition for further informations
+//*****************************************************************************************************************
+SvtSecurityOptions_Impl* SvtSecurityOptions::m_pDataContainer = NULL ;
+sal_Int32 SvtSecurityOptions::m_nRefCount = 0 ;
+
+SvtSecurityOptions::SvtSecurityOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetInitMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already exist!
+ if( m_pDataContainer == NULL )
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtSecurityOptions_Impl::ctor()");
+ m_pDataContainer = new SvtSecurityOptions_Impl;
+
+ ItemHolder1::holdConfigItem(E_SECURITYOPTIONS);
+ }
+}
+
+SvtSecurityOptions::~SvtSecurityOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetInitMutex() );
+ // Decrease ouer refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pDataContainer;
+ m_pDataContainer = NULL;
+ }
+}
+
+Mutex& SvtSecurityOptions::GetInitMutex()
+{
+ // Initialize static mutex only for one time!
+ static Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be faster then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_sourceviewconfig.cxx b/binfilter/bf_svtools/source/config/svt_sourceviewconfig.cxx
new file mode 100644
index 000000000000..74eb53438169
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_sourceviewconfig.cxx
@@ -0,0 +1,241 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/sourceviewconfig.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <unotools/configitem.hxx>
+#include <tools/debug.hxx>
+#include <rtl/instance.hxx>
+#include <bf_svtools/smplhint.hxx>
+
+#include <itemholder1.hxx>
+
+using namespace utl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+namespace binfilter
+{
+
+class SourceViewConfig_Impl : public utl::ConfigItem, public SfxBroadcaster
+{
+private:
+ OUString m_sFontName;
+ sal_Int16 m_nFontHeight;
+ sal_Bool m_bProportionalFontOnly;
+
+ void Load();
+
+ static Sequence< OUString > GetPropertyNames();
+
+public:
+ SourceViewConfig_Impl();
+ ~SourceViewConfig_Impl();
+
+ virtual void Notify( const Sequence< rtl::OUString >& aPropertyNames );
+ virtual void Commit();
+
+ const rtl::OUString& GetFontName() const
+ {return m_sFontName;}
+ void SetFontName(const rtl::OUString& rName)
+ {
+ if(rName != m_sFontName)
+ {
+ m_sFontName = rName;
+ SetModified();
+ }
+ }
+
+ sal_Int16 GetFontHeight() const
+ {return m_nFontHeight;}
+ void SetFontHeight(sal_Int16 nHeight)
+ {
+ if(m_nFontHeight != nHeight)
+ {
+ m_nFontHeight = nHeight;
+ SetModified();
+ }
+ }
+
+ sal_Bool IsShowProportionalFontsOnly() const
+ {return m_bProportionalFontOnly;}
+ void SetShowProportionalFontsOnly(sal_Bool bSet)
+ {
+ if(m_bProportionalFontOnly != bSet)
+ {
+ m_bProportionalFontOnly = bSet;
+ SetModified();
+ }
+ }
+};
+// initialization of static members --------------------------------------
+SourceViewConfig_Impl* SourceViewConfig::m_pImplConfig = 0;
+sal_Int32 SourceViewConfig::m_nRefCount = 0;
+namespace { struct lclMutex : public rtl::Static< ::osl::Mutex, lclMutex > {}; }
+/* -----------------------------28.08.2002 16:45------------------------------
+
+ ---------------------------------------------------------------------------*/
+SourceViewConfig_Impl::SourceViewConfig_Impl() :
+ ConfigItem(OUString::createFromAscii("Office.Common/Font/SourceViewFont")),
+ m_nFontHeight(12),
+ m_bProportionalFontOnly(sal_False)
+{
+ Load();
+}
+/* -----------------------------28.08.2002 16:45------------------------------
+
+ ---------------------------------------------------------------------------*/
+SourceViewConfig_Impl::~SourceViewConfig_Impl()
+{
+}
+/* -----------------------------28.08.2002 16:25------------------------------
+
+ ---------------------------------------------------------------------------*/
+Sequence< OUString > SourceViewConfig_Impl::GetPropertyNames()
+{
+ //this list needs exactly to mach the enum PropertyNameIndex
+ static const char* aPropNames[] =
+ {
+ "FontName" // 0
+ ,"FontHeight" // 1
+ ,"NonProportionalFontsOnly" // 2
+ };
+ const int nCount = sizeof( aPropNames ) / sizeof( const char* );
+ Sequence< OUString > aNames( nCount );
+ OUString* pNames = aNames.getArray();
+ for ( int i = 0; i < nCount; i++ )
+ pNames[i] = OUString::createFromAscii( aPropNames[i] );
+
+ return aNames;
+}
+
+/*-- 28.08.2002 16:37:59---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SourceViewConfig_Impl::Load()
+{
+ Sequence< OUString > aNames = GetPropertyNames();
+ Sequence< Any > aValues = GetProperties( aNames );
+ EnableNotification( aNames );
+ const Any* pValues = aValues.getConstArray();
+ DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
+ if ( aValues.getLength() == aNames.getLength() )
+ {
+ for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
+ {
+ if ( pValues[nProp].hasValue() )
+ {
+ switch( nProp )
+ {
+ case 0: pValues[nProp] >>= m_sFontName; break;
+ case 1: pValues[nProp] >>= m_nFontHeight; break;
+ case 2: pValues[nProp] >>= m_bProportionalFontOnly; break;
+ }
+ }
+ }
+ }
+}
+/*-- 28.08.2002 16:38:00---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SourceViewConfig_Impl::Notify( const Sequence< OUString >& )
+{
+ Load();
+}
+/*-- 28.08.2002 16:38:00---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SourceViewConfig_Impl::Commit()
+{
+ ClearModified();
+ Sequence< OUString > aNames = GetPropertyNames();
+ Sequence< Any > aValues( aNames.getLength() );
+ Any* pValues = aValues.getArray();
+ for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
+ {
+ switch( nProp )
+ {
+ case 0: pValues[nProp] <<= m_sFontName; break;
+ case 1: pValues[nProp] <<= m_nFontHeight; break;
+ case 2: pValues[nProp] <<= m_bProportionalFontOnly; break;
+ default:
+ DBG_ERRORFILE( "invalid index to save a user token" );
+ }
+ }
+ PutProperties( aNames, aValues );
+
+ //notify SfxListener
+ {
+ SfxSimpleHint aHint = SfxSimpleHint( SFX_HINT_DATACHANGED );
+ Broadcast(aHint);
+ }
+}
+/*-- 28.08.2002 16:32:19---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SourceViewConfig::SourceViewConfig()
+{
+ {
+ ::osl::MutexGuard aGuard( lclMutex::get() );
+ if(!m_pImplConfig)
+ {
+ m_pImplConfig = new SourceViewConfig_Impl;
+ ItemHolder1::holdConfigItem(E_SOURCEVIEWCONFIG);
+ }
+
+ ++m_nRefCount;
+ }
+ StartListening( *m_pImplConfig, TRUE );
+}
+/*-- 28.08.2002 16:32:19---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SourceViewConfig::~SourceViewConfig()
+{
+ EndListening( *m_pImplConfig, TRUE );
+ ::osl::MutexGuard aGuard( lclMutex::get() );
+ if( !--m_nRefCount )
+ {
+ if( m_pImplConfig->IsModified() )
+ m_pImplConfig->Commit();
+ DELETEZ( m_pImplConfig );
+ }
+}
+/* -----------------------------30.08.2002 10:40------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SourceViewConfig::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ Broadcast( rHint );
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_startoptions.cxx b/binfilter/bf_svtools/source/config/svt_startoptions.cxx
new file mode 100644
index 000000000000..24e11bf0a84f
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_startoptions.cxx
@@ -0,0 +1,376 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+//_________________________________________________________________________________________________________________
+// includes
+//_________________________________________________________________________________________________________________
+
+#include <bf_svtools/startoptions.hxx>
+
+#include <unotools/configmgr.hxx>
+
+#include <unotools/configitem.hxx>
+
+#include <tools/debug.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <rtl/logfile.hxx>
+#include "itemholder1.hxx"
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+using namespace ::utl ;
+using namespace ::rtl ;
+using namespace ::osl ;
+using namespace ::com::sun::star::uno ;
+
+namespace binfilter
+{
+
+//_________________________________________________________________________________________________________________
+// const
+//_________________________________________________________________________________________________________________
+
+#define DEFAULT_SHOWINTRO sal_True
+#define DEFAULT_CONNECTIONURL OUString()
+
+#define ROOTNODE_START OUString(RTL_CONSTASCII_USTRINGPARAM("Setup/Office" ))
+#define PROPERTYNAME_SHOWINTRO OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupShowIntro" ))
+#define PROPERTYNAME_CONNECTIONURL OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupConnectionURL" ))
+
+#define PROPERTYHANDLE_SHOWINTRO 0
+#define PROPERTYHANDLE_CONNECTIONURL 1
+
+#define PROPERTYCOUNT 2
+
+//_________________________________________________________________________________________________________________
+// private declarations!
+//_________________________________________________________________________________________________________________
+
+class SvtStartOptions_Impl : public ConfigItem
+{
+ //-------------------------------------------------------------------------------------------------------------
+ // public methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ public:
+
+ //---------------------------------------------------------------------------------------------------------
+ // constructor / destructor
+ //---------------------------------------------------------------------------------------------------------
+
+ SvtStartOptions_Impl();
+ ~SvtStartOptions_Impl();
+
+ //---------------------------------------------------------------------------------------------------------
+ // overloaded methods of baseclass
+ //---------------------------------------------------------------------------------------------------------
+
+ /*-****************************************************************************************************//**
+ @short called for notify of configmanager
+ @descr These method is called from the ConfigManager before application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. You must update your
+ internal values.
+
+ @ATTENTION We don't implement these method - because we support readonly values at runtime only!
+
+ @seealso baseclass ConfigItem
+
+ @param "seqPropertyNames" is the list of properties which should be updated.
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Notify( const Sequence< OUString >& seqPropertyNames );
+
+ /*-****************************************************************************************************//**
+ @short write changes to configuration
+ @descr These method writes the changed values into the sub tree
+ and should always called in our destructor to guarantee consistency of config data.
+
+ @ATTENTION We don't implement these method - because we support readonly values at runtime only!
+
+ @seealso baseclass ConfigItem
+
+ @param -
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Commit();
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ /*-****************************************************************************************************//**
+ @short return list of fix key names of ouer configuration management which represent oue module tree
+ @descr These methods return a static const list of key names. We need it to get needed values from our
+ configuration management. We return well known key names only - because the "UserData" node
+ is handled in a special way!
+
+ @seealso -
+
+ @param -
+ @return A list of needed configuration keys is returned.
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ static Sequence< OUString > impl_GetPropertyNames();
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private member
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ sal_Bool m_bShowIntro ; /// cache "ShowIntro" of Start section
+ OUString m_sConnectionURL ; /// cache "Connection" of Start section
+};
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtStartOptions_Impl::SvtStartOptions_Impl()
+ // Init baseclasses first
+ : ConfigItem ( ROOTNODE_START )
+ // Init member then.
+ , m_bShowIntro ( DEFAULT_SHOWINTRO )
+{
+ // Use our static list of configuration keys to get his values.
+ Sequence< OUString > seqNames = impl_GetPropertyNames();
+ Sequence< Any > seqValues = GetProperties( seqNames ) ;
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtStartOptions_Impl::SvtStartOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to ouer internal member.
+ sal_Int32 nPropertyCount = seqValues.getLength() ;
+ sal_Int32 nProperty = 0 ;
+ for( nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ // Safe impossible cases.
+ // Check any for valid value.
+ DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtStartOptions_Impl::SvtStartOptions_Impl()\nInvalid property value for property detected!\n" );
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_SHOWINTRO : {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtStartOptions_Impl::SvtStartOptions_Impl()\nWho has changed the value type of \"Office.Common\\Start\\ShowIntro\"?" );
+ seqValues[nProperty] >>= m_bShowIntro;
+ }
+ break;
+
+ case PROPERTYHANDLE_CONNECTIONURL : {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_STRING), "SvtStartOptions_Impl::SvtStartOptions_Impl()\nWho has changed the value type of \"Office.Common\\Start\\Connection\"?" );
+ seqValues[nProperty] >>= m_sConnectionURL;
+ }
+ break;
+ }
+ }
+
+ // Don't enable notification mechanism of ouer baseclass!
+ // We support readonly variables in the moment.
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtStartOptions_Impl::~SvtStartOptions_Impl()
+{
+ // We must save our current values .. if user forget it!
+ if( IsModified() == sal_True )
+ {
+ Commit();
+ }
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtStartOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames )
+{
+ // Use given list of updated properties to get his values from configuration directly!
+ Sequence< Any > seqValues = GetProperties( seqPropertyNames );
+ // Safe impossible cases.
+ // We need values from ALL notified configuration keys.
+ DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtStartOptions_Impl::Notify()\nI miss some values of configuration keys!\n" );
+ // Step over list of property names and get right value from coreesponding value list to set it on internal members!
+ sal_Int32 nCount = seqPropertyNames.getLength();
+ for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
+ {
+ if( seqPropertyNames[nProperty] == PROPERTYNAME_SHOWINTRO )
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtStartOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\Start\\ShowIntro\"?" );
+ seqValues[nProperty] >>= m_bShowIntro;
+ }
+ else
+ if( seqPropertyNames[nProperty] == PROPERTYNAME_CONNECTIONURL )
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_STRING), "SvtStartOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\Start\\Connection\"?" );
+ seqValues[nProperty] >>= m_sConnectionURL;
+ }
+ #if OSL_DEBUG_LEVEL > 1
+ else DBG_ASSERT( sal_False, "SvtStartOptions_Impl::Notify()\nUnkown property detected ... I can't handle these!\n" );
+ #endif
+ }
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtStartOptions_Impl::Commit()
+{
+ // Get names of supported properties, create a list for values and copy current values to it.
+ Sequence< OUString > seqNames = impl_GetPropertyNames();
+ sal_Int32 nCount = seqNames.getLength();
+ Sequence< Any > seqValues ( nCount );
+ for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
+ {
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_SHOWINTRO : {
+ seqValues[nProperty] <<= m_bShowIntro;
+ }
+ break;
+ case PROPERTYHANDLE_CONNECTIONURL : {
+ seqValues[nProperty] <<= m_sConnectionURL;
+ }
+ break;
+ }
+ }
+ // Set properties in configuration.
+ PutProperties( seqNames, seqValues );
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Sequence< OUString > SvtStartOptions_Impl::impl_GetPropertyNames()
+{
+ // Build static list of configuration key names.
+ static const OUString pProperties[] =
+ {
+ PROPERTYNAME_SHOWINTRO ,
+ PROPERTYNAME_CONNECTIONURL ,
+ };
+ // Initialize return sequence with these list ...
+ static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
+ // ... and return it.
+ return seqPropertyNames;
+}
+
+//*****************************************************************************************************************
+// initialize static member
+// DON'T DO IT IN YOUR HEADER!
+// see definition for further informations
+//*****************************************************************************************************************
+SvtStartOptions_Impl* SvtStartOptions::m_pDataContainer = NULL ;
+sal_Int32 SvtStartOptions::m_nRefCount = 0 ;
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtStartOptions::SvtStartOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already!
+ if( m_pDataContainer == NULL )
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtStartOptions_Impl::ctor()");
+ m_pDataContainer = new SvtStartOptions_Impl();
+
+ ItemHolder1::holdConfigItem(E_STARTOPTIONS);
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtStartOptions::~SvtStartOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Decrease ouer refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pDataContainer;
+ m_pDataContainer = NULL;
+ }
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Mutex& SvtStartOptions::GetOwnStaticMutex()
+{
+ // Initialize static mutex only for one time!
+ static Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_syslocaleoptions.cxx b/binfilter/bf_svtools/source/config/svt_syslocaleoptions.cxx
new file mode 100644
index 000000000000..72b07b7ba6e9
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_syslocaleoptions.cxx
@@ -0,0 +1,476 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/syslocaleoptions.hxx>
+
+#include <broadcast.hxx>
+#include <listener.hxx>
+#include <bf_svtools/smplhint.hxx>
+#include <i18npool/mslangid.hxx>
+#include <tools/string.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <rtl/instance.hxx>
+#include <unotools/configmgr.hxx>
+#include <unotools/configitem.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <vcl/settings.hxx>
+#include <vcl/svapp.hxx>
+
+#include <rtl/logfile.hxx>
+
+#include "itemholder2.hxx"
+
+namespace binfilter
+{
+
+#define CFG_READONLY_DEFAULT sal_False
+
+using namespace osl;
+using namespace utl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+
+
+SvtSysLocaleOptions_Impl* SvtSysLocaleOptions::pOptions = NULL;
+sal_Int32 SvtSysLocaleOptions::nRefCount = 0;
+namespace
+{
+ struct CurrencyChangeLink
+ : public rtl::Static<Link, CurrencyChangeLink> {};
+}
+
+class SvtSysLocaleOptions_Impl : public utl::ConfigItem
+{
+ OUString m_aLocaleString; // en-US or de-DE or empty for SYSTEM
+ LanguageType m_eLocaleLanguageType; // same for convenience access
+ OUString m_aCurrencyString; // USD-en-US or EUR-de-DE
+ SvtBroadcaster m_aBroadcaster;
+ ULONG m_nBlockedHint; // pending hints
+ sal_Int32 m_nBroadcastBlocked; // broadcast only if this is 0
+ sal_Bool m_bDecimalSeparator; //use decimal separator same as locale
+
+
+ sal_Bool m_bROLocale;
+ sal_Bool m_bROCurrency;
+ sal_Bool m_bRODecimalSeparator;
+
+ static const Sequence< /* const */ OUString > GetPropertyNames();
+
+ void UpdateMiscSettings_Impl();
+ ULONG ChangeLocaleSettings();
+ void ChangeDefaultCurrency() const;
+ void Broadcast( ULONG nHint );
+
+public:
+ SvtSysLocaleOptions_Impl();
+ virtual ~SvtSysLocaleOptions_Impl();
+
+ virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
+ virtual void Commit();
+
+ const OUString& GetLocaleString() const
+ { return m_aLocaleString; }
+ LanguageType GetLocaleLanguageType() const
+ { return m_eLocaleLanguageType; }
+
+ const OUString& GetCurrencyString() const
+ { return m_aCurrencyString; }
+
+ sal_Bool IsDecimalSeparatorAsLocale() const { return m_bDecimalSeparator;}
+
+ SvtBroadcaster& GetBroadcaster()
+ { return m_aBroadcaster; }
+};
+
+
+#define ROOTNODE_SYSLOCALE OUString(RTL_CONSTASCII_USTRINGPARAM("Setup/L10N"))
+
+#define PROPERTYNAME_LOCALE OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupSystemLocale"))
+#define PROPERTYNAME_CURRENCY OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupCurrency"))
+#define PROPERTYNAME_DECIMALSEPARATOR OUString(RTL_CONSTASCII_USTRINGPARAM("DecimalSeparatorAsLocale"))
+
+#define PROPERTYHANDLE_LOCALE 0
+#define PROPERTYHANDLE_CURRENCY 1
+#define PROPERTYHANDLE_DECIMALSEPARATOR 2
+
+#define PROPERTYCOUNT 3
+
+const Sequence< OUString > SvtSysLocaleOptions_Impl::GetPropertyNames()
+{
+ static const OUString pProperties[] =
+ {
+ PROPERTYNAME_LOCALE,
+ PROPERTYNAME_CURRENCY,
+ PROPERTYNAME_DECIMALSEPARATOR
+ };
+ static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
+ return seqPropertyNames;
+}
+
+
+// -----------------------------------------------------------------------
+
+SvtSysLocaleOptions_Impl::SvtSysLocaleOptions_Impl()
+ : ConfigItem( ROOTNODE_SYSLOCALE )
+ , m_nBlockedHint( 0 )
+ , m_nBroadcastBlocked( 0 )
+ , m_bDecimalSeparator( sal_True )
+ , m_bROLocale(CFG_READONLY_DEFAULT)
+ , m_bROCurrency(CFG_READONLY_DEFAULT)
+ , m_bRODecimalSeparator(sal_False)
+
+{
+ if ( !IsValidConfigMgr() )
+ ChangeLocaleSettings(); // assume SYSTEM defaults during Setup
+ else
+ {
+ const Sequence< OUString > aNames = GetPropertyNames();
+ Sequence< Any > aValues = GetProperties( aNames );
+ Sequence< sal_Bool > aROStates = GetReadOnlyStates( aNames );
+ const Any* pValues = aValues.getConstArray();
+ const sal_Bool* pROStates = aROStates.getConstArray();
+ DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
+ DBG_ASSERT( aROStates.getLength() == aNames.getLength(), "GetReadOnlyStates failed" );
+ if ( aValues.getLength() == aNames.getLength() && aROStates.getLength() == aNames.getLength() )
+ {
+ for ( sal_Int32 nProp = 0; nProp < aNames.getLength(); nProp++ )
+ {
+ DBG_ASSERT( pValues[nProp].hasValue(), "property value missing" );
+ if ( pValues[nProp].hasValue() )
+ {
+ switch ( nProp )
+ {
+ case PROPERTYHANDLE_LOCALE :
+ {
+ OUString aStr;
+ if ( pValues[nProp] >>= aStr )
+ m_aLocaleString = aStr;
+ else
+ {
+ DBG_ERRORFILE( "Wrong property type!" );
+ }
+ m_bROLocale = pROStates[nProp];
+ }
+ break;
+ case PROPERTYHANDLE_CURRENCY :
+ {
+ OUString aStr;
+ if ( pValues[nProp] >>= aStr )
+ m_aCurrencyString = aStr;
+ else
+ {
+ DBG_ERRORFILE( "Wrong property type!" );
+ }
+ m_bROCurrency = pROStates[nProp];
+ }
+ break;
+ case PROPERTYHANDLE_DECIMALSEPARATOR:
+ {
+ sal_Bool bValue = sal_Bool();
+ if ( pValues[nProp] >>= bValue )
+ m_bDecimalSeparator = bValue;
+ else
+ {
+ DBG_ERRORFILE( "Wrong property type!" );
+ }
+ m_bRODecimalSeparator = pROStates[nProp];
+ }
+ break;
+ default:
+ DBG_ERRORFILE( "Wrong property type!" );
+ }
+ }
+ }
+ }
+ UpdateMiscSettings_Impl();
+ ChangeLocaleSettings();
+ EnableNotification( aNames );
+ }
+}
+
+
+SvtSysLocaleOptions_Impl::~SvtSysLocaleOptions_Impl()
+{
+ if ( IsModified() )
+ Commit();
+}
+
+
+void SvtSysLocaleOptions_Impl::Broadcast( ULONG nHint )
+{
+ if ( m_nBroadcastBlocked )
+ m_nBlockedHint |= nHint;
+ else
+ {
+ nHint |= m_nBlockedHint;
+ m_nBlockedHint = 0;
+ if ( nHint )
+ {
+ if ( nHint & SYSLOCALEOPTIONS_HINT_CURRENCY )
+ ChangeDefaultCurrency();
+ SfxSimpleHint aHint( nHint );
+ GetBroadcaster().Broadcast( aHint );
+ }
+ }
+}
+
+
+void SvtSysLocaleOptions_Impl::Commit()
+{
+ const Sequence< OUString > aOrgNames = GetPropertyNames();
+ sal_Int32 nOrgCount = aOrgNames.getLength();
+
+ Sequence< OUString > aNames( nOrgCount );
+ Sequence< Any > aValues( nOrgCount );
+
+ OUString* pNames = aNames.getArray();
+ Any* pValues = aValues.getArray();
+ sal_Int32 nRealCount = 0;
+
+ for ( sal_Int32 nProp = 0; nProp < nOrgCount; nProp++ )
+ {
+ switch ( nProp )
+ {
+ case PROPERTYHANDLE_LOCALE :
+ {
+ if (!m_bROLocale)
+ {
+ pNames[nRealCount] = aOrgNames[nProp];
+ pValues[nRealCount] <<= m_aLocaleString;
+ ++nRealCount;
+ }
+ }
+ break;
+ case PROPERTYHANDLE_CURRENCY :
+ {
+ if (!m_bROLocale)
+ {
+ pNames[nRealCount] = aOrgNames[nProp];
+ pValues[nRealCount] <<= m_aCurrencyString;
+ ++nRealCount;
+ }
+ }
+ break;
+ case PROPERTYHANDLE_DECIMALSEPARATOR:
+ if( !m_bRODecimalSeparator )
+ {
+ pNames[nRealCount] = aOrgNames[nProp];
+ pValues[nRealCount] <<= m_bDecimalSeparator;
+ ++nRealCount;
+ }
+ break;
+ default:
+ DBG_ERRORFILE( "invalid index to save a path" );
+ }
+ }
+ aNames.realloc(nRealCount);
+ aValues.realloc(nRealCount);
+ PutProperties( aNames, aValues );
+ ClearModified();
+}
+
+
+ULONG SvtSysLocaleOptions_Impl::ChangeLocaleSettings()
+{
+ // An empty config value denotes SYSTEM locale
+ if ( m_aLocaleString.getLength() )
+ m_eLocaleLanguageType = MsLangId::convertIsoStringToLanguage( m_aLocaleString );
+ else
+ m_eLocaleLanguageType = LANGUAGE_SYSTEM;
+ ULONG nHint = 0;
+ // new locale and no fixed currency => locale default currency might change
+ if ( !m_aCurrencyString.getLength() )
+ nHint |= SYSLOCALEOPTIONS_HINT_CURRENCY;
+ return nHint;
+}
+
+
+void SvtSysLocaleOptions_Impl::ChangeDefaultCurrency() const
+{
+ const Link& rLink = SvtSysLocaleOptions::GetCurrencyChangeLink();
+ if ( rLink.IsSet() )
+ rLink.Call( NULL );
+}
+
+
+void SvtSysLocaleOptions_Impl::Notify( const Sequence< rtl::OUString >& seqPropertyNames )
+{
+ ULONG nHint = 0;
+ Sequence< Any > seqValues = GetProperties( seqPropertyNames );
+ Sequence< sal_Bool > seqROStates = GetReadOnlyStates( seqPropertyNames );
+ sal_Int32 nCount = seqPropertyNames.getLength();
+ for( sal_Int32 nProp = 0; nProp < nCount; ++nProp )
+ {
+ if( seqPropertyNames[nProp] == PROPERTYNAME_LOCALE )
+ {
+ DBG_ASSERT( seqValues[nProp].getValueTypeClass() == TypeClass_STRING, "Locale property type" );
+ seqValues[nProp] >>= m_aLocaleString;
+ m_bROLocale = seqROStates[nProp];
+ nHint |= SYSLOCALEOPTIONS_HINT_LOCALE;
+ nHint |= ChangeLocaleSettings();
+ }
+ else if( seqPropertyNames[nProp] == PROPERTYNAME_CURRENCY )
+ {
+ DBG_ASSERT( seqValues[nProp].getValueTypeClass() == TypeClass_STRING, "Currency property type" );
+ seqValues[nProp] >>= m_aCurrencyString;
+ m_bROCurrency = seqROStates[nProp];
+ nHint |= SYSLOCALEOPTIONS_HINT_CURRENCY;
+ }
+ else if( seqPropertyNames[nProp] == PROPERTYNAME_DECIMALSEPARATOR )
+ {
+ seqValues[nProp] >>= m_bDecimalSeparator;
+ m_bRODecimalSeparator = seqROStates[nProp];
+ UpdateMiscSettings_Impl();
+ }
+ }
+ if ( nHint )
+ Broadcast( nHint );
+}
+/* -----------------10.02.2004 15:25-----------------
+
+ --------------------------------------------------*/
+void SvtSysLocaleOptions_Impl::UpdateMiscSettings_Impl()
+{
+ AllSettings aAllSettings( Application::GetSettings() );
+ MiscSettings aMiscSettings = aAllSettings.GetMiscSettings();
+ aMiscSettings.SetEnableLocalizedDecimalSep(m_bDecimalSeparator);
+ aAllSettings.SetMiscSettings( aMiscSettings );
+ Application::SetSettings( aAllSettings );
+}
+
+// ====================================================================
+
+SvtSysLocaleOptions::SvtSysLocaleOptions()
+{
+ MutexGuard aGuard( GetMutex() );
+ if ( !pOptions )
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtSysLocaleOptions_Impl::ctor()");
+ pOptions = new SvtSysLocaleOptions_Impl;
+
+ ItemHolder2::holdConfigItem(E_SYSLOCALEOPTIONS);
+ }
+ ++nRefCount;
+}
+
+
+SvtSysLocaleOptions::~SvtSysLocaleOptions()
+{
+ MutexGuard aGuard( GetMutex() );
+ if ( !--nRefCount )
+ {
+ delete pOptions;
+ pOptions = NULL;
+ }
+}
+
+
+// static
+Mutex& SvtSysLocaleOptions::GetMutex()
+{
+ static Mutex* pMutex = NULL;
+ if( !pMutex )
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if( !pMutex )
+ {
+ // #i77768# Due to a static reference in the toolkit lib
+ // we need a mutex that lives longer than the svtools library.
+ // Otherwise the dtor would use a destructed mutex!!
+ pMutex = new Mutex;
+ }
+ }
+ return *pMutex;
+}
+
+BOOL SvtSysLocaleOptions::AddListener( SvtListener& rLst )
+{
+ MutexGuard aGuard( GetMutex() );
+ return rLst.StartListening( pOptions->GetBroadcaster() );
+}
+
+
+BOOL SvtSysLocaleOptions::RemoveListener( SvtListener& rLst )
+{
+ MutexGuard aGuard( GetMutex() );
+ return rLst.EndListening( pOptions->GetBroadcaster() );
+}
+
+
+const OUString& SvtSysLocaleOptions::GetCurrencyConfigString() const
+{
+ MutexGuard aGuard( GetMutex() );
+ return pOptions->GetCurrencyString();
+}
+
+/*-- 11.02.2004 13:31:41---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+
+// static
+void SvtSysLocaleOptions::GetCurrencyAbbrevAndLanguage( String& rAbbrev,
+ LanguageType& eLang, const ::rtl::OUString& rConfigString )
+{
+ sal_Int32 nDelim = rConfigString.indexOf( '-' );
+ if ( nDelim >= 0 )
+ {
+ rAbbrev = rConfigString.copy( 0, nDelim );
+ String aIsoStr( rConfigString.copy( nDelim+1 ) );
+ eLang = MsLangId::convertIsoStringToLanguage( aIsoStr );
+ }
+ else
+ {
+ rAbbrev = rConfigString;
+ eLang = (rAbbrev.Len() ? LANGUAGE_NONE : LANGUAGE_SYSTEM);
+ }
+}
+
+
+// static
+void SvtSysLocaleOptions::SetCurrencyChangeLink( const Link& rLink )
+{
+ MutexGuard aGuard( GetMutex() );
+ DBG_ASSERT( !CurrencyChangeLink::get().IsSet(), "SvtSysLocaleOptions::SetCurrencyChangeLink: already set" );
+ CurrencyChangeLink::get() = rLink;
+}
+
+
+// static
+const Link& SvtSysLocaleOptions::GetCurrencyChangeLink()
+{
+ MutexGuard aGuard( GetMutex() );
+ return CurrencyChangeLink::get();
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_undoopt.cxx b/binfilter/bf_svtools/source/config/svt_undoopt.cxx
new file mode 100644
index 000000000000..8b94c1c41363
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_undoopt.cxx
@@ -0,0 +1,209 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/undoopt.hxx>
+
+#include "rtl/instance.hxx"
+#include <unotools/configmgr.hxx>
+#include <unotools/configitem.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <osl/mutex.hxx>
+#include <bf_svtools/smplhint.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/logfile.hxx>
+#include "itemholder2.hxx"
+
+using namespace utl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+namespace binfilter
+{
+
+static SvtUndoOptions_Impl* pOptions = NULL;
+static sal_Int32 nRefCount = 0;
+
+#define STEPS 0
+
+class SvtUndoOptions_Impl : public utl::ConfigItem, public SfxBroadcaster
+{
+ sal_Int32 nUndoCount;
+ Sequence< rtl::OUString > m_aPropertyNames;
+
+public:
+ SvtUndoOptions_Impl();
+
+ virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
+ virtual void Commit();
+ void Load();
+
+ void SetUndoCount( sal_Int32 n ) { nUndoCount = n; SetModified(); }
+ sal_Int32 GetUndoCount() const { return nUndoCount; }
+};
+
+// -----------------------------------------------------------------------
+
+SvtUndoOptions_Impl::SvtUndoOptions_Impl()
+ : ConfigItem( OUString::createFromAscii("Office.Common/Undo") )
+ , nUndoCount( 20 )
+{
+ Load();
+}
+
+void SvtUndoOptions_Impl::Commit()
+{
+ Sequence< Any > aValues( m_aPropertyNames.getLength() );
+ Any* pValues = aValues.getArray();
+ for ( int nProp = 0; nProp < m_aPropertyNames.getLength(); nProp++ )
+ {
+ switch ( nProp )
+ {
+ case STEPS :
+ pValues[nProp] <<= nUndoCount;
+ break;
+ default:
+ DBG_ERRORFILE( "invalid index to save a path" );
+ }
+ }
+
+ PutProperties( m_aPropertyNames, aValues );
+ //broadcast changes
+ Broadcast(SfxSimpleHint(SFX_HINT_UNDO_OPTIONS_CHANGED));
+}
+
+// -----------------------------------------------------------------------
+void SvtUndoOptions_Impl::Load()
+{
+ if(!m_aPropertyNames.getLength())
+ {
+ static const char* aPropNames[] =
+ {
+ "Steps",
+ };
+
+ const int nCount = sizeof( aPropNames ) / sizeof( const char* );
+ m_aPropertyNames.realloc(nCount);
+ OUString* pNames = m_aPropertyNames.getArray();
+ for ( int i = 0; i < nCount; i++ )
+ pNames[i] = OUString::createFromAscii( aPropNames[i] );
+ EnableNotification( m_aPropertyNames );
+ }
+
+ Sequence< Any > aValues = GetProperties( m_aPropertyNames );
+ const Any* pValues = aValues.getConstArray();
+ DBG_ASSERT( aValues.getLength() == m_aPropertyNames.getLength(), "GetProperties failed" );
+ if ( aValues.getLength() == m_aPropertyNames.getLength() )
+ {
+ for ( int nProp = 0; nProp < m_aPropertyNames.getLength(); nProp++ )
+ {
+ DBG_ASSERT( pValues[nProp].hasValue(), "property value missing" );
+ if ( pValues[nProp].hasValue() )
+ {
+ switch ( nProp )
+ {
+ case STEPS :
+ {
+ sal_Int32 nTemp = 0;
+ if ( pValues[nProp] >>= nTemp )
+ nUndoCount = nTemp;
+ else
+ {
+ DBG_ERROR( "Wrong Type!" );
+ }
+ break;
+ }
+
+ default:
+ DBG_ERROR( "Wrong Type!" );
+ break;
+ }
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------
+void SvtUndoOptions_Impl::Notify( const Sequence<rtl::OUString>& )
+{
+ Load();
+ //broadcast changes
+ Broadcast(SfxSimpleHint(SFX_HINT_UNDO_OPTIONS_CHANGED));
+}
+
+// -----------------------------------------------------------------------
+namespace
+{
+ class LocalSingleton : public rtl::Static< osl::Mutex, LocalSingleton >
+ {
+ };
+}
+
+// -----------------------------------------------------------------------
+SvtUndoOptions::SvtUndoOptions()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( LocalSingleton::get() );
+ if ( !pOptions )
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtUndoOptions_Impl::ctor()");
+ pOptions = new SvtUndoOptions_Impl;
+
+ ItemHolder2::holdConfigItem(E_UNDOOPTIONS);
+ }
+ ++nRefCount;
+ pImp = pOptions;
+ StartListening(*pImp);
+}
+
+// -----------------------------------------------------------------------
+
+SvtUndoOptions::~SvtUndoOptions()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( LocalSingleton::get() );
+ EndListening(*pImp);
+ if ( !--nRefCount )
+ {
+ if ( pOptions->IsModified() )
+ pOptions->Commit();
+ DELETEZ( pOptions );
+ }
+}
+
+void SvtUndoOptions::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ SolarMutexGuard aVclGuard;
+ Broadcast( rHint );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_useroptions.cxx b/binfilter/bf_svtools/source/config/svt_useroptions.cxx
new file mode 100644
index 000000000000..d3cb2f6ea285
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_useroptions.cxx
@@ -0,0 +1,597 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/useroptions.hxx>
+
+#include <unotools/configmgr.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <bf_svtools/smplhint.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <rtl/instance.hxx>
+#include <rtl/logfile.hxx>
+#include "itemholder2.hxx"
+
+using namespace utl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+namespace binfilter
+{
+
+// class SvtUserOptions_Impl ---------------------------------------------
+
+class SvtUserOptions_Impl : public utl::ConfigItem, public SfxBroadcaster
+{
+private:
+ String m_aCompany;
+ String m_aFirstName;
+ String m_aLastName;
+ String m_aID;
+ String m_aStreet;
+ String m_aCity;
+ String m_aState;
+ String m_aZip;
+ String m_aCountry;
+ String m_aPosition;
+ String m_aTitle;
+ String m_aTelephoneHome;
+ String m_aTelephoneWork;
+ String m_aFax;
+ String m_aEmail;
+ String m_aCustomerNumber;
+ String m_aFathersName;
+ String m_aApartment;
+
+ String m_aEmptyString;
+ String m_aFullName;
+ String m_aLocale;
+
+ sal_Bool m_bIsROCompany;
+ sal_Bool m_bIsROFirstName;
+ sal_Bool m_bIsROLastName;
+ sal_Bool m_bIsROID;
+ sal_Bool m_bIsROStreet;
+ sal_Bool m_bIsROCity;
+ sal_Bool m_bIsROState;
+ sal_Bool m_bIsROZip;
+ sal_Bool m_bIsROCountry;
+ sal_Bool m_bIsROPosition;
+ sal_Bool m_bIsROTitle;
+ sal_Bool m_bIsROTelephoneHome;
+ sal_Bool m_bIsROTelephoneWork;
+ sal_Bool m_bIsROFax;
+ sal_Bool m_bIsROEmail;
+ sal_Bool m_bIsROCustomerNumber;
+ sal_Bool m_bIsROFathersName;
+ sal_Bool m_bIsROApartment;
+
+ typedef String SvtUserOptions_Impl:: *StrPtr;
+
+ void InitFullName();
+ void Load();
+
+ static void InitUserPropertyNames();
+public:
+ SvtUserOptions_Impl();
+ ~SvtUserOptions_Impl();
+
+ virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
+ virtual void Commit();
+
+ // get the user token
+ const String& GetCompany() const { return m_aCompany; }
+ const String& GetFirstName() const { return m_aFirstName; }
+ const String& GetLastName() const { return m_aLastName; }
+ const String& GetID() const { return m_aID; }
+ const String& GetStreet() const { return m_aStreet; }
+ const String& GetCity() const { return m_aCity; }
+ const String& GetState() const { return m_aState; }
+ const String& GetZip() const { return m_aZip; }
+ const String& GetCountry() const { return m_aCountry; }
+ const String& GetPosition() const { return m_aPosition; }
+ const String& GetTitle() const { return m_aTitle; }
+ const String& GetTelephoneHome() const { return m_aTelephoneHome; }
+ const String& GetTelephoneWork() const { return m_aTelephoneWork; }
+ const String& GetFax() const { return m_aFax; }
+ const String& GetEmail() const { return m_aEmail; }
+ const String& GetCustomerNumber() const { return m_aCustomerNumber; }
+ const String& GetFathersName() const { return m_aFathersName; }
+ const String& GetApartment() const { return m_aApartment; }
+
+ const String& GetFullName();
+ const String& GetLocale() const { return m_aLocale; }
+};
+
+// global ----------------------------------------------------------------
+
+static SvtUserOptions_Impl* pOptions = NULL;
+static sal_Int32 nRefCount = 0;
+
+#define READONLY_DEFAULT sal_False
+
+// functions -------------------------------------------------------------
+
+namespace
+{
+ struct PropertyNames
+ : public rtl::Static< Sequence< rtl::OUString >, PropertyNames> {};
+}
+
+// -----------------------------------------------------------------------
+
+void SvtUserOptions_Impl::InitUserPropertyNames()
+{
+ static const char* aPropNames[] =
+ {
+ "Data/l", // USER_OPT_CITY
+ "Data/o", // USER_OPT_COMPANY
+ "Data/c", // USER_OPT_COUNTRY
+ "Data/mail", // USER_OPT_EMAIL
+ "Data/facsimiletelephonenumber",// USER_OPT_FAX
+ "Data/givenname", // USER_OPT_FIRSTNAME
+ "Data/sn", // USER_OPT_LASTNAME
+ "Data/position", // USER_OPT_POSITION
+ "Data/st", // USER_OPT_STATE
+ "Data/street", // USER_OPT_STREET
+ "Data/homephone", // USER_OPT_TELEPHONEHOME
+ "Data/telephonenumber", // USER_OPT_TELEPHONEWORK
+ "Data/title", // USER_OPT_TITLE
+ "Data/initials", // USER_OPT_ID
+ "Data/postalcode", // USER_OPT_ZIP
+ "Data/fathersname", // USER_OPT_FATHERSNAME
+ "Data/apartment" // USER_OPT_APARTMENT
+ };
+ const int nCount = sizeof( aPropNames ) / sizeof( const char* );
+ Sequence< rtl::OUString > &rPropertyNames = PropertyNames::get();
+ rPropertyNames.realloc(nCount);
+ OUString* pNames = rPropertyNames.getArray();
+ for ( int i = 0; i < nCount; i++ )
+ pNames[i] = OUString::createFromAscii( aPropNames[i] );
+}
+
+// -----------------------------------------------------------------------
+
+void SvtUserOptions_Impl::InitFullName()
+{
+ m_aFullName = GetFirstName();
+ m_aFullName.EraseLeadingAndTrailingChars();
+ if ( m_aFullName.Len() )
+ m_aFullName += ' ';
+ m_aFullName += GetLastName();
+ m_aFullName.EraseTrailingChars();
+}
+
+// -----------------------------------------------------------------------
+SvtUserOptions_Impl::SvtUserOptions_Impl() :
+
+ ConfigItem( OUString::createFromAscii("UserProfile") ),
+
+ m_bIsROCompany( READONLY_DEFAULT ),
+ m_bIsROFirstName( READONLY_DEFAULT ),
+ m_bIsROLastName( READONLY_DEFAULT ),
+ m_bIsROID( READONLY_DEFAULT ),
+ m_bIsROStreet( READONLY_DEFAULT ),
+ m_bIsROCity( READONLY_DEFAULT ),
+ m_bIsROState( READONLY_DEFAULT ),
+ m_bIsROZip( READONLY_DEFAULT ),
+ m_bIsROCountry( READONLY_DEFAULT ),
+ m_bIsROPosition( READONLY_DEFAULT ),
+ m_bIsROTitle( READONLY_DEFAULT ),
+ m_bIsROTelephoneHome( READONLY_DEFAULT ),
+ m_bIsROTelephoneWork( READONLY_DEFAULT ),
+ m_bIsROFax( READONLY_DEFAULT ),
+ m_bIsROEmail( READONLY_DEFAULT ),
+ m_bIsROCustomerNumber( READONLY_DEFAULT ),
+ m_bIsROFathersName( READONLY_DEFAULT ),
+ m_bIsROApartment( READONLY_DEFAULT )
+{
+ InitUserPropertyNames();
+ EnableNotification( PropertyNames::get() );
+ Load();
+ Any aAny = ConfigManager::GetConfigManager().GetDirectConfigProperty( ConfigManager::LOCALE );
+ OUString aLocale;
+ if ( aAny >>= aLocale )
+ m_aLocale = String( aLocale );
+ else
+ {
+ DBG_ERRORFILE( "SvtUserOptions_Impl::SvtUserOptions_Impl(): no locale found" );
+ }
+}
+// -----------------------------------------------------------------------
+
+SvtUserOptions_Impl::~SvtUserOptions_Impl()
+{
+}
+
+// -----------------------------------------------------------------------
+void SvtUserOptions_Impl::Load()
+{
+ Sequence< rtl::OUString > &rPropertyNames = PropertyNames::get();
+ Sequence< Any > seqValues = GetProperties( rPropertyNames );
+ Sequence< sal_Bool > seqRO = GetReadOnlyStates( rPropertyNames );
+ const Any* pValues = seqValues.getConstArray();
+ DBG_ASSERT( seqValues.getLength() == rPropertyNames.getLength(), "GetProperties failed" );
+ if ( seqValues.getLength() == rPropertyNames.getLength() )
+ {
+ OUString aTempStr;
+
+ for ( int nProp = 0; nProp < rPropertyNames.getLength(); nProp++ )
+ {
+ if ( pValues[nProp].hasValue() )
+ {
+ if ( pValues[nProp] >>= aTempStr )
+ {
+ String* pToken = NULL;
+ sal_Bool* pBool = NULL;
+
+ switch ( nProp )
+ {
+ case USER_OPT_COMPANY:
+ pToken = &m_aCompany; pBool = &m_bIsROCompany; break;
+ case USER_OPT_FIRSTNAME:
+ pToken = &m_aFirstName; pBool = &m_bIsROFirstName; break;
+ case USER_OPT_LASTNAME:
+ pToken = &m_aLastName; pBool = &m_bIsROLastName; break;
+ case USER_OPT_ID:
+ pToken = &m_aID; pBool = &m_bIsROID; break;
+ case USER_OPT_STREET:
+ pToken = &m_aStreet; pBool = &m_bIsROStreet; break;
+ case USER_OPT_CITY:
+ pToken = &m_aCity; pBool = &m_bIsROCity; break;
+ case USER_OPT_STATE:
+ pToken = &m_aState; pBool = &m_bIsROState; break;
+ case USER_OPT_ZIP:
+ pToken = &m_aZip; pBool = &m_bIsROZip; break;
+ case USER_OPT_COUNTRY:
+ pToken = &m_aCountry; pBool = &m_bIsROCountry; break;
+ case USER_OPT_POSITION:
+ pToken = &m_aPosition; pBool = &m_bIsROPosition; break;
+ case USER_OPT_TITLE:
+ pToken = &m_aTitle; pBool = &m_bIsROTitle; break;
+ case USER_OPT_TELEPHONEHOME:
+ pToken = &m_aTelephoneHome; pBool = &m_bIsROTelephoneHome; break;
+ case USER_OPT_TELEPHONEWORK:
+ pToken = &m_aTelephoneWork; pBool = &m_bIsROTelephoneWork; break;
+ case USER_OPT_FAX:
+ pToken = &m_aFax; pBool = &m_bIsROFax; break;
+ case USER_OPT_EMAIL:
+ pToken = &m_aEmail; pBool = &m_bIsROEmail; break;
+ case USER_OPT_FATHERSNAME:
+ pToken = &m_aFathersName; pBool = &m_bIsROFathersName; break;
+ case USER_OPT_APARTMENT:
+ pToken = &m_aApartment; pBool = &m_bIsROApartment; break;
+ default:
+ DBG_ERRORFILE( "invalid index to load a user token" );
+ }
+
+ if ( pToken )
+ *pToken = String( aTempStr );
+ if ( pBool )
+ *pBool = seqRO[nProp];
+ }
+ else
+ {
+ DBG_ERRORFILE( "Wrong any type" );
+ }
+ }
+ }
+ }
+ InitFullName();
+}
+// -----------------------------------------------------------------------
+
+void SvtUserOptions_Impl::Commit()
+{
+ Sequence< rtl::OUString > &rPropertyNames = PropertyNames::get();
+ sal_Int32 nOrgCount = rPropertyNames.getLength();
+
+ Sequence< OUString > seqNames( nOrgCount );
+ Sequence< Any > seqValues( nOrgCount );
+ sal_Int32 nRealCount = 0;
+
+ OUString aTempStr;
+
+ for ( int nProp = 0; nProp < nOrgCount; nProp++ )
+ {
+ sal_Bool* pbReadonly = NULL;
+
+ switch ( nProp )
+ {
+ case USER_OPT_COMPANY:
+ aTempStr = OUString( m_aCompany ); pbReadonly = &m_bIsROCompany; break;
+ case USER_OPT_FIRSTNAME:
+ aTempStr = OUString( m_aFirstName ); pbReadonly = &m_bIsROFirstName; break;
+ case USER_OPT_LASTNAME:
+ aTempStr = OUString( m_aLastName ); pbReadonly = &m_bIsROLastName; break;
+ case USER_OPT_ID:
+ aTempStr = OUString( m_aID ); pbReadonly = &m_bIsROID; break;
+ case USER_OPT_STREET:
+ aTempStr = OUString( m_aStreet ); pbReadonly = &m_bIsROStreet; break;
+ case USER_OPT_CITY:
+ aTempStr = OUString( m_aCity ); pbReadonly = &m_bIsROCity; break;
+ case USER_OPT_STATE:
+ aTempStr = OUString( m_aState ); pbReadonly = &m_bIsROState; break;
+ case USER_OPT_ZIP:
+ aTempStr = OUString( m_aZip ); pbReadonly = &m_bIsROZip; break;
+ case USER_OPT_COUNTRY:
+ aTempStr = OUString( m_aCountry ); pbReadonly = &m_bIsROCountry; break;
+ case USER_OPT_POSITION:
+ aTempStr = OUString( m_aPosition ); pbReadonly = &m_bIsROPosition; break;
+ case USER_OPT_TITLE:
+ aTempStr = OUString( m_aTitle ); pbReadonly = &m_bIsROTitle; break;
+ case USER_OPT_TELEPHONEHOME:
+ aTempStr = OUString( m_aTelephoneHome ); pbReadonly = &m_bIsROTelephoneHome; break;
+ case USER_OPT_TELEPHONEWORK:
+ aTempStr = OUString( m_aTelephoneWork ); pbReadonly = &m_bIsROTelephoneWork; break;
+ case USER_OPT_FAX:
+ aTempStr = OUString( m_aFax ); pbReadonly = &m_bIsROFax; break;
+ case USER_OPT_EMAIL:
+ aTempStr = OUString( m_aEmail ); pbReadonly = &m_bIsROEmail; break;
+ case USER_OPT_FATHERSNAME:
+ aTempStr = OUString( m_aFathersName ); pbReadonly = &m_bIsROFathersName; break;
+ case USER_OPT_APARTMENT:
+ aTempStr = OUString( m_aApartment ); pbReadonly = &m_bIsROApartment; break;
+ default:
+ DBG_ERRORFILE( "invalid index to save a user token" );
+ }
+
+ if ( pbReadonly && !(*pbReadonly) )
+ {
+ seqValues[nRealCount] <<= aTempStr;
+ seqNames[nRealCount] = rPropertyNames[nProp];
+ ++nRealCount;
+ }
+ }
+
+ // Set properties in configuration.
+ seqNames.realloc( nRealCount );
+ seqValues.realloc( nRealCount );
+ PutProperties( seqNames, seqValues );
+ //broadcast changes
+ Broadcast(SfxSimpleHint(SFX_HINT_USER_OPTIONS_CHANGED));
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtUserOptions_Impl::GetFullName()
+{
+ if ( IsModified() )
+ InitFullName();
+ return m_aFullName;
+}
+
+// -----------------------------------------------------------------------
+
+void SvtUserOptions_Impl::Notify( const Sequence<rtl::OUString>& )
+{
+ Load();
+ Broadcast(SfxSimpleHint(SFX_HINT_USER_OPTIONS_CHANGED));
+}
+
+// class SvtUserOptions --------------------------------------------------
+
+SvtUserOptions::SvtUserOptions()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( GetInitMutex() );
+
+ if ( !pOptions )
+ {
+ RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtUserOptions_Impl::ctor()");
+ pOptions = new SvtUserOptions_Impl;
+
+ ItemHolder2::holdConfigItem(E_USEROPTIONS);
+ }
+ ++nRefCount;
+ pImp = pOptions;
+ StartListening( *pImp);
+}
+
+// -----------------------------------------------------------------------
+
+SvtUserOptions::~SvtUserOptions()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( GetInitMutex() );
+
+ if ( !--nRefCount )
+ {
+ if ( pOptions->IsModified() )
+ pOptions->Commit();
+ DELETEZ( pOptions );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+::osl::Mutex& SvtUserOptions::GetInitMutex()
+{
+ // Initialize static mutex only for one time!
+ static ::osl::Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if ( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ // We must check our pointer again -
+ // because another instance of our class will be faster then this instance!
+ if ( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static ::osl::Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtUserOptions::GetCompany() const
+{
+ ::osl::MutexGuard aGuard( GetInitMutex() );
+ return pImp->GetCompany();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtUserOptions::GetFirstName() const
+{
+ ::osl::MutexGuard aGuard( GetInitMutex() );
+ return pImp->GetFirstName();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtUserOptions::GetLastName() const
+{
+ ::osl::MutexGuard aGuard( GetInitMutex() );
+ return pImp->GetLastName();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtUserOptions::GetID() const
+{
+ ::osl::MutexGuard aGuard( GetInitMutex() );
+ return pImp->GetID();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtUserOptions::GetStreet() const
+{
+ ::osl::MutexGuard aGuard( GetInitMutex() );
+ return pImp->GetStreet();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtUserOptions::GetCity() const
+{
+ ::osl::MutexGuard aGuard( GetInitMutex() );
+ return pImp->GetCity();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtUserOptions::GetState() const
+{
+ ::osl::MutexGuard aGuard( GetInitMutex() );
+ return pImp->GetState();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtUserOptions::GetZip() const
+{
+ ::osl::MutexGuard aGuard( GetInitMutex() );
+ return pImp->GetZip();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtUserOptions::GetCountry() const
+{
+ ::osl::MutexGuard aGuard( GetInitMutex() );
+ return pImp->GetCountry();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtUserOptions::GetPosition() const
+{
+ ::osl::MutexGuard aGuard( GetInitMutex() );
+ return pImp->GetPosition();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtUserOptions::GetTitle() const
+{
+ ::osl::MutexGuard aGuard( GetInitMutex() );
+ return pImp->GetTitle();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtUserOptions::GetTelephoneHome() const
+{
+ ::osl::MutexGuard aGuard( GetInitMutex() );
+ return pImp->GetTelephoneHome();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtUserOptions::GetTelephoneWork() const
+{
+ ::osl::MutexGuard aGuard( GetInitMutex() );
+ return pImp->GetTelephoneWork();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtUserOptions::GetFax() const
+{
+ ::osl::MutexGuard aGuard( GetInitMutex() );
+ return pImp->GetFax();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtUserOptions::GetEmail() const
+{
+ ::osl::MutexGuard aGuard( GetInitMutex() );
+ return pImp->GetEmail();
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtUserOptions::GetFullName() const
+{
+ ::osl::MutexGuard aGuard( GetInitMutex() );
+ return pImp->GetFullName();
+}
+
+/* -----------------07.07.2003 09:30-----------------
+
+ --------------------------------------------------*/
+void SvtUserOptions::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ SolarMutexGuard aVclGuard;
+ Broadcast( rHint );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_viewoptions.cxx b/binfilter/bf_svtools/source/config/svt_viewoptions.cxx
new file mode 100644
index 000000000000..4088950c854e
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_viewoptions.cxx
@@ -0,0 +1,559 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+//_________________________________________________________________________________________________________________
+// includes
+//_________________________________________________________________________________________________________________
+
+#include <bf_svtools/viewoptions.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <hash_map>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+#include <com/sun/star/container/XNameContainer.hpp>
+
+#include <com/sun/star/container/XNameAccess.hpp>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <unotools/configpathes.hxx>
+
+#include <comphelper/configurationhelper.hxx>
+
+#include <unotools/processfactory.hxx>
+
+#include <itemholder1.hxx>
+
+namespace binfilter
+{
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+namespace css = ::com::sun::star;
+
+//_________________________________________________________________________________________________________________
+// const
+//_________________________________________________________________________________________________________________
+
+#ifdef CONST_ASCII
+ #error "Who define CONST_ASCII before! I use it to create const ascii strings ..."
+#else
+ #define CONST_ASCII(SASCIIVALUE) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SASCIIVALUE))
+#endif
+
+#define PATHSEPERATOR CONST_ASCII("/")
+
+#define PACKAGE_VIEWS CONST_ASCII("org.openoffice.Office.Views")
+
+#define LIST_DIALOGS CONST_ASCII("Dialogs" )
+#define LIST_TABDIALOGS CONST_ASCII("TabDialogs")
+#define LIST_TABPAGES CONST_ASCII("TabPages" )
+#define LIST_WINDOWS CONST_ASCII("Windows" )
+
+#define PROPERTY_WINDOWSTATE CONST_ASCII("WindowState")
+#define PROPERTY_PAGEID CONST_ASCII("PageID" )
+#define PROPERTY_VISIBLE CONST_ASCII("Visible" )
+#define PROPERTY_USERDATA CONST_ASCII("UserData" )
+
+#define PROPCOUNT_DIALOGS 1
+#define PROPCOUNT_TABDIALOGS 2
+#define PROPCOUNT_TABPAGES 1
+#define PROPCOUNT_WINDOWS 2
+
+#define DEFAULT_WINDOWSTATE ::rtl::OUString()
+#define DEFAULT_USERDATA css::uno::Sequence< css::beans::NamedValue >()
+#define DEFAULT_PAGEID 0
+#define DEFAULT_VISIBLE sal_False
+
+//#define DEBUG_VIEWOPTIONS
+
+#ifdef DEBUG_VIEWOPTIONS
+ #define _LOG_COUNTER_( _SVIEW_, _NREAD_, _NWRITE_ ) \
+ { \
+ FILE* pFile = fopen( "viewdbg.txt", "a" ); \
+ fprintf( pFile, "%s[%d, %d]\n", ::rtl::OUStringToOString(_SVIEW_, RTL_TEXTENCODING_UTF8).getStr(), _NREAD_, _NWRITE_ ); \
+ fclose( pFile ); \
+ }
+#endif // DEBUG_VIEWOPTIONS
+
+#define SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION_PARAM_EXCEPTION) \
+ { \
+ ::rtl::OUStringBuffer sMsg(256); \
+ sMsg.appendAscii("Unexpected exception catched. Original message was:\n\"" ); \
+ sMsg.append (SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION_PARAM_EXCEPTION.Message); \
+ sMsg.appendAscii("\"" ); \
+ OSL_ENSURE(sal_False, ::rtl::OUStringToOString(sMsg.makeStringAndClear(), RTL_TEXTENCODING_UTF8).getStr()); \
+ }
+
+//_________________________________________________________________________________________________________________
+// initialization!
+//_________________________________________________________________________________________________________________
+
+SvtViewOptionsBase_Impl* SvtViewOptions::m_pDataContainer_Dialogs = NULL ;
+sal_Int32 SvtViewOptions::m_nRefCount_Dialogs = 0 ;
+SvtViewOptionsBase_Impl* SvtViewOptions::m_pDataContainer_TabDialogs = NULL ;
+sal_Int32 SvtViewOptions::m_nRefCount_TabDialogs = 0 ;
+SvtViewOptionsBase_Impl* SvtViewOptions::m_pDataContainer_TabPages = NULL ;
+sal_Int32 SvtViewOptions::m_nRefCount_TabPages = 0 ;
+SvtViewOptionsBase_Impl* SvtViewOptions::m_pDataContainer_Windows = NULL ;
+sal_Int32 SvtViewOptions::m_nRefCount_Windows = 0 ;
+
+//_________________________________________________________________________________________________________________
+// private declarations!
+//_________________________________________________________________________________________________________________
+
+/*-************************************************************************************************************//**
+ @descr declare one configuration item
+ These struct hold information about one view item. But not all member are used for all entries!
+ User must decide which information are usefull and which not. We are a container iztem only and doesnt
+ know anything about the context.
+ But; we support a feature:
+ decision between items with default values (should not realy exist in configuration!)
+ and items with real values - changed by user. So user can suppress saving of realy unused items
+ to disk - because; defaulted items could be restored on runtime without reading from disk!!!
+ And if only items with valid information was written to cfg - we mustn't read so much and save time.
+ So we start with an member m_bDefault=True and reset it to False after first set-call.
+ Deficiencies of these solution - we cant allow direct read/write access to our member. We must
+ support it by set/get-methods ...
+*//*-*************************************************************************************************************/
+class IMPL_TViewData
+{
+ public:
+ //---------------------------------------------------------------------------------------------------------
+ // create "default" item
+ IMPL_TViewData()
+ {
+ m_sWindowState = DEFAULT_WINDOWSTATE ;
+ m_lUserData = DEFAULT_USERDATA ;
+ m_nPageID = DEFAULT_PAGEID ;
+ m_bVisible = DEFAULT_VISIBLE ;
+
+ m_bDefault = sal_True ;
+ }
+
+ //---------------------------------------------------------------------------------------------------------
+ // write access - with reseting of default state
+ void setWindowState( const ::rtl::OUString& sValue )
+ {
+ m_bDefault = (
+ ( m_bDefault == sal_True ) &&
+ ( sValue == DEFAULT_WINDOWSTATE )
+ );
+ m_sWindowState = sValue;
+ }
+
+ //---------------------------------------------------------------------------------------------------------
+ void setUserData( const css::uno::Sequence< css::beans::NamedValue >& lValue )
+ {
+ m_bDefault = (
+ ( m_bDefault == sal_True ) &&
+ ( lValue == DEFAULT_USERDATA )
+ );
+ m_lUserData = lValue;
+ }
+
+ //---------------------------------------------------------------------------------------------------------
+ void setPageID( sal_Int32 nValue )
+ {
+ m_bDefault = (
+ ( m_bDefault == sal_True ) &&
+ ( nValue == DEFAULT_PAGEID )
+ );
+ m_nPageID = nValue;
+ }
+
+ //---------------------------------------------------------------------------------------------------------
+ void setVisible( sal_Bool bValue )
+ {
+ m_bDefault = (
+ ( m_bDefault == sal_True ) &&
+ ( bValue == DEFAULT_VISIBLE )
+ );
+ m_bVisible = bValue;
+ }
+
+ //---------------------------------------------------------------------------------------------------------
+ // read access
+ ::rtl::OUString getWindowState() { return m_sWindowState; }
+ css::uno::Sequence< css::beans::NamedValue > getUserData () { return m_lUserData ; }
+ sal_Int32 getPageID () { return m_nPageID ; }
+ sal_Bool getVisible () { return m_bVisible ; }
+
+ //---------------------------------------------------------------------------------------------------------
+ // special operation for easy access on user data
+ void setUserItem( const ::rtl::OUString& sName ,
+ const css::uno::Any& aValue )
+ {
+ // we change UserData in every case!
+ // a) we change already existing item
+ // or b) we add a new one
+ m_bDefault = sal_False;
+
+ sal_Bool bExist = sal_False;
+ sal_Int32 nCount = m_lUserData.getLength();
+
+ // change it, if it already exist ...
+ for( sal_Int32 nStep=0; nStep<nCount; ++nStep )
+ {
+ if( m_lUserData[nStep].Name == sName )
+ {
+ m_lUserData[nStep].Value = aValue ;
+ bExist = sal_True;
+ break;
+ }
+ }
+
+ // ... or create new list item
+ if( bExist == sal_False )
+ {
+ m_lUserData.realloc( nCount+1 );
+ m_lUserData[nCount].Name = sName ;
+ m_lUserData[nCount].Value = aValue ;
+ }
+ }
+
+ //---------------------------------------------------------------------------------------------------------
+ css::uno::Any getUserItem( const ::rtl::OUString& sName )
+ {
+ // default value - if item not exist!
+ css::uno::Any aValue;
+
+ sal_Int32 nCount = m_lUserData.getLength();
+ for( sal_Int32 nStep=0; nStep<nCount; ++nStep )
+ {
+ if( m_lUserData[nStep].Name == sName )
+ {
+ aValue = m_lUserData[nStep].Value;
+ break;
+ }
+ }
+ return aValue;
+ }
+
+ //---------------------------------------------------------------------------------------------------------
+ // check for default items
+ sal_Bool isDefault() { return m_bDefault; }
+
+ private:
+ ::rtl::OUString m_sWindowState ;
+ css::uno::Sequence< css::beans::NamedValue > m_lUserData ;
+ sal_Int32 m_nPageID ;
+ sal_Bool m_bVisible ;
+
+ sal_Bool m_bDefault ;
+};
+
+struct IMPL_TStringHashCode
+{
+ size_t operator()(const ::rtl::OUString& sString) const
+ {
+ return sString.hashCode();
+ }
+};
+
+typedef ::std::hash_map< ::rtl::OUString ,
+ IMPL_TViewData ,
+ IMPL_TStringHashCode ,
+ ::std::equal_to< ::rtl::OUString > > IMPL_TViewHash;
+
+/*-************************************************************************************************************//**
+ @descr Implement base data container for view options elements.
+ Every item support ALL possible configuration informations.
+ But not every superclass should use them! Because some view types don't
+ have it realy.
+
+ @attention We implement a write-througt-cache! We use it for reading - but write all changes directly to
+ configuration. (changes are made on internal cache too!). So it's easier to distinguish
+ between added/changed/removed elements without any complex mask or bool flag informations.
+ Caches from configuration and our own one are synchronized every time - if we do so.
+*//*-*************************************************************************************************************/
+class SvtViewOptionsBase_Impl
+{
+ //-------------------------------------------------------------------------------------------------------------
+ public:
+ SvtViewOptionsBase_Impl ( const ::rtl::OUString& sList );
+ virtual ~SvtViewOptionsBase_Impl ( );
+
+ //-------------------------------------------------------------------------------------------------------------
+ private:
+ ::rtl::OUString m_sListName;
+ css::uno::Reference< css::container::XNameAccess > m_xRoot;
+ css::uno::Reference< css::container::XNameAccess > m_xSet;
+
+ #ifdef DEBUG_VIEWOPTIONS
+ sal_Int32 m_nReadCount ;
+ sal_Int32 m_nWriteCount ;
+ #endif
+};
+
+/*-************************************************************************************************************//**
+ @descr Implement the base data container.
+*//*-*************************************************************************************************************/
+
+/*-************************************************************************************************************//**
+ @short ctor
+ @descr We use it to open right configuration file and let configuration objects fill her caches.
+ Then we read all existing entries from right list and cached it inside our object too.
+ Normaly we should enable notifications for changes on these values too ... but these feature
+ isn't full implemented in the moment.
+
+ @seealso baseclass ::utl::ConfigItem
+ @seealso method Notify()
+
+ @param -
+ @return -
+
+ @last change 19.10.2001 07:54
+*//*-*************************************************************************************************************/
+SvtViewOptionsBase_Impl::SvtViewOptionsBase_Impl( const ::rtl::OUString& sList )
+ : m_sListName ( sList ) // we must know, which view type we must support
+ #ifdef DEBUG_VIEWOPTIONS
+ , m_nReadCount ( 0 )
+ , m_nWriteCount( 0 )
+ #endif
+{
+ try
+ {
+ m_xRoot = css::uno::Reference< css::container::XNameAccess >(
+ ::comphelper::ConfigurationHelper::openConfig(
+ ::utl::getProcessServiceFactory(),
+ PACKAGE_VIEWS,
+ ::comphelper::ConfigurationHelper::E_STANDARD),
+ css::uno::UNO_QUERY);
+ if (m_xRoot.is())
+ m_xRoot->getByName(sList) >>= m_xSet;
+ }
+ catch(const css::uno::Exception& ex)
+ {
+ m_xRoot.clear();
+ m_xSet.clear();
+
+ SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(ex)
+ }
+}
+
+/*-************************************************************************************************************//**
+ @short dtor
+ @descr If something was changed on our internal cached values - baselcass can tell us that by return value
+ of method "IsModified()". So we should flush these changes by calling "Commit()" of our own instance.
+ It's an auto-save. Normaly user of these object should do that explicitly!
+
+ @attention We implement a write through cache! So we mustn't do it realy. All changes was written to cfg directly.
+ Commit isn't neccessary then.
+
+ @seealso baseclass ::utl::ConfigItem
+ @seealso method IsModified()
+ @seealso method SetModified()
+ @seealso method Commit()
+
+ @param -
+ @return -
+
+ @last change 19.10.2001 08:02
+*//*-*************************************************************************************************************/
+SvtViewOptionsBase_Impl::~SvtViewOptionsBase_Impl()
+{
+ try
+ {
+ if (m_xRoot.is())
+ ::comphelper::ConfigurationHelper::flush(m_xRoot);
+ }
+ catch(const css::uno::Exception& ex)
+ {
+ SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(ex)
+ }
+ m_xRoot.clear();
+ m_xSet.clear();
+
+ #ifdef DEBUG_VIEWOPTIONS
+ _LOG_COUNTER_( m_sListName, m_nReadCount, m_nWriteCount )
+ #endif // DEBUG_VIEWOPTIONS
+}
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtViewOptions::SvtViewOptions( EViewType eType ,
+ const ::rtl::OUString& sViewName )
+ : m_eViewType ( eType )
+ , m_sViewName ( sViewName )
+{
+ // Global access, must be guarded (multithreading!)
+ ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
+
+ // Search for right dat container for this view type and initialize right data container or set right ref count!
+ switch( eType )
+ {
+ case E_DIALOG : {
+ // Increase ref count for dialog data container first.
+ ++m_nRefCount_Dialogs;
+ // If these instance the first user of the dialog data container - create these impl static container!
+ if( m_nRefCount_Dialogs == 1 )
+ {
+ //m_pDataContainer_Dialogs = new SvtViewDialogOptions_Impl( LIST_DIALOGS );
+ m_pDataContainer_Dialogs = new SvtViewOptionsBase_Impl( LIST_DIALOGS );
+ ItemHolder1::holdConfigItem(E_VIEWOPTIONS_DIALOG);
+ }
+ }
+ break;
+ case E_TABDIALOG : {
+ // Increase ref count for tab-dialog data container first.
+ ++m_nRefCount_TabDialogs;
+ // If these instance the first user of the tab-dialog data container - create these impl static container!
+ if( m_nRefCount_TabDialogs == 1 )
+ {
+ m_pDataContainer_TabDialogs = new SvtViewOptionsBase_Impl( LIST_TABDIALOGS );
+ ItemHolder1::holdConfigItem(E_VIEWOPTIONS_TABDIALOG);
+ }
+ }
+ break;
+ case E_TABPAGE : {
+ // Increase ref count for tab-page data container first.
+ ++m_nRefCount_TabPages;
+ // If these instance the first user of the tab-page data container - create these impl static container!
+ if( m_nRefCount_TabPages == 1 )
+ {
+ m_pDataContainer_TabPages = new SvtViewOptionsBase_Impl( LIST_TABPAGES );
+ ItemHolder1::holdConfigItem(E_VIEWOPTIONS_TABPAGE);
+ }
+ }
+ break;
+ case E_WINDOW : {
+ // Increase ref count for window data container first.
+ ++m_nRefCount_Windows;
+ // If these instance the first user of the window data container - create these impl static container!
+ if( m_nRefCount_Windows == 1 )
+ {
+ m_pDataContainer_Windows = new SvtViewOptionsBase_Impl( LIST_WINDOWS );
+ ItemHolder1::holdConfigItem(E_VIEWOPTIONS_WINDOW);
+ }
+ }
+ break;
+ default : OSL_ENSURE( sal_False, "SvtViewOptions::SvtViewOptions()\nThese view type is unknown! All following calls at these instance will do nothing!\n" );
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtViewOptions::~SvtViewOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
+
+ // Search for right dat container for this view type and deinitialize right data container or set right ref count!
+ switch( m_eViewType )
+ {
+ case E_DIALOG : {
+ // Decrease ref count for dialog data container first.
+ --m_nRefCount_Dialogs;
+ // If these instance the last user of the dialog data container - delete these impl static container!
+ if( m_nRefCount_Dialogs == 0 )
+ {
+ delete m_pDataContainer_Dialogs;
+ m_pDataContainer_Dialogs = NULL;
+ }
+ }
+ break;
+ case E_TABDIALOG : {
+ // Decrease ref count for tab-dialog data container first.
+ --m_nRefCount_TabDialogs;
+ // If these instance the last user of the tab-dialog data container - delete these impl static container!
+ if( m_nRefCount_TabDialogs == 0 )
+ {
+ delete m_pDataContainer_TabDialogs;
+ m_pDataContainer_TabDialogs = NULL;
+ }
+ }
+ break;
+ case E_TABPAGE : {
+ // Decrease ref count for tab-page data container first.
+ --m_nRefCount_TabPages;
+ // If these instance the last user of the tab-page data container - delete these impl static container!
+ if( m_nRefCount_TabPages == 0 )
+ {
+ delete m_pDataContainer_TabPages;
+ m_pDataContainer_TabPages = NULL;
+ }
+ }
+ break;
+ case E_WINDOW : {
+ // Decrease ref count for window data container first.
+ --m_nRefCount_Windows;
+ // If these instance the last user of the window data container - delete these impl static container!
+ if( m_nRefCount_Windows == 0 )
+ {
+ delete m_pDataContainer_Windows;
+ m_pDataContainer_Windows = NULL;
+ }
+ }
+ break;
+ }
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+::osl::Mutex& SvtViewOptions::GetOwnStaticMutex()
+{
+ // Initialize static mutex only for one time!
+ static ::osl::Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static ::osl::Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/config/svt_workingsetoptions.cxx b/binfilter/bf_svtools/source/config/svt_workingsetoptions.cxx
new file mode 100644
index 000000000000..a191d57ff486
--- /dev/null
+++ b/binfilter/bf_svtools/source/config/svt_workingsetoptions.cxx
@@ -0,0 +1,348 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+//_________________________________________________________________________________________________________________
+// includes
+//_________________________________________________________________________________________________________________
+
+#include <bf_svtools/workingsetoptions.hxx>
+
+#include <unotools/configmgr.hxx>
+
+#include <unotools/configitem.hxx>
+
+#include <tools/debug.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <itemholder1.hxx>
+
+//_________________________________________________________________________________________________________________
+// namespaces
+//_________________________________________________________________________________________________________________
+
+using namespace ::utl ;
+using namespace ::rtl ;
+using namespace ::osl ;
+using namespace ::com::sun::star::uno ;
+
+namespace binfilter
+{
+
+//_________________________________________________________________________________________________________________
+// const
+//_________________________________________________________________________________________________________________
+
+#define ROOTNODE_WORKINGSET OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/WorkingSet"))
+#define DEFAULT_WINDOWLIST Sequence< OUString >()
+
+#define PROPERTYNAME_WINDOWLIST OUString(RTL_CONSTASCII_USTRINGPARAM("WindowList" ))
+
+#define PROPERTYHANDLE_WINDOWLIST 0
+
+#define PROPERTYCOUNT 1
+
+//_________________________________________________________________________________________________________________
+// private declarations!
+//_________________________________________________________________________________________________________________
+
+class SvtWorkingSetOptions_Impl : public ConfigItem
+{
+ //-------------------------------------------------------------------------------------------------------------
+ // public methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ public:
+
+ //---------------------------------------------------------------------------------------------------------
+ // constructor / destructor
+ //---------------------------------------------------------------------------------------------------------
+
+ SvtWorkingSetOptions_Impl();
+ ~SvtWorkingSetOptions_Impl();
+
+ //---------------------------------------------------------------------------------------------------------
+ // overloaded methods of baseclass
+ //---------------------------------------------------------------------------------------------------------
+
+ /*-****************************************************************************************************//**
+ @short called for notify of configmanager
+ @descr These method is called from the ConfigManager before application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. You must update your
+ internal values.
+
+ @seealso baseclass ConfigItem
+
+ @param "seqPropertyNames" is the list of properties which should be updated.
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Notify( const Sequence< OUString >& seqPropertyNames );
+
+ /*-****************************************************************************************************//**
+ @short write changes to configuration
+ @descr These method writes the changed values into the sub tree
+ and should always called in our destructor to guarantee consistency of config data.
+
+ @seealso baseclass ConfigItem
+
+ @param -
+ @return -
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ virtual void Commit();
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private methods
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ /*-****************************************************************************************************//**
+ @short return list of key names of ouer configuration management which represent oue module tree
+ @descr These methods return a static const list of key names. We need it to get needed values from our
+ configuration management.
+
+ @seealso -
+
+ @param -
+ @return A list of needed configuration keys is returned.
+
+ @onerror -
+ *//*-*****************************************************************************************************/
+
+ static Sequence< OUString > GetPropertyNames();
+
+ //-------------------------------------------------------------------------------------------------------------
+ // private member
+ //-------------------------------------------------------------------------------------------------------------
+
+ private:
+
+ Sequence< OUString > m_seqWindowList ;
+};
+
+//_________________________________________________________________________________________________________________
+// definitions
+//_________________________________________________________________________________________________________________
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtWorkingSetOptions_Impl::SvtWorkingSetOptions_Impl()
+ // Init baseclasses first
+ : ConfigItem ( ROOTNODE_WORKINGSET )
+ // Init member then.
+ , m_seqWindowList ( DEFAULT_WINDOWLIST )
+{
+ // Use our static list of configuration keys to get his values.
+ Sequence< OUString > seqNames = GetPropertyNames ( );
+ Sequence< Any > seqValues = GetProperties ( seqNames );
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtWorkingSetOptions_Impl::SvtWorkingSetOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to ouer internal member.
+ sal_Int32 nPropertyCount = seqValues.getLength();
+ for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ // Safe impossible cases.
+ // Check any for valid value.
+ DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtWorkingSetOptions_Impl::SvtWorkingSetOptions_Impl()\nInvalid property value detected!\n" );
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_WINDOWLIST : {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SEQUENCE), "SvtWorkingSetOptions_Impl::SvtWorkingSetOptions_Impl()\nWho has changed the value type of \"Office.Common\\WorkingSet\\WindowList\"?" );
+ seqValues[nProperty] >>= m_seqWindowList;
+ }
+ break;
+ }
+ }
+
+ // Enable notification mechanism of ouer baseclass.
+ // We need it to get information about changes outside these class on ouer used configuration keys!
+ EnableNotification( seqNames );
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtWorkingSetOptions_Impl::~SvtWorkingSetOptions_Impl()
+{
+ // We must save our current values .. if user forget it!
+ if( IsModified() == sal_True )
+ {
+ Commit();
+ }
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtWorkingSetOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames )
+{
+ // Use given list of updated properties to get his values from configuration directly!
+ Sequence< Any > seqValues = GetProperties( seqPropertyNames );
+ // Safe impossible cases.
+ // We need values from ALL notified configuration keys.
+ DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtWorkingSetOptions_Impl::Notify()\nI miss some values of configuration keys!\n" );
+ // Step over list of property names and get right value from coreesponding value list to set it on internal members!
+ sal_Int32 nCount = seqPropertyNames.getLength();
+ for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
+ {
+ if( seqPropertyNames[nProperty] == PROPERTYNAME_WINDOWLIST )
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SEQUENCE), "SvtWorkingSetOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\WorkingSet\\WindowList\"?" );
+ seqValues[nProperty] >>= m_seqWindowList;
+ }
+ #if OSL_DEBUG_LEVEL > 1
+ else DBG_ASSERT( sal_False, "SvtWorkingSetOptions_Impl::Notify()\nUnkown property detected ... I can't handle these!\n" );
+ #endif
+ }
+}
+
+//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+void SvtWorkingSetOptions_Impl::Commit()
+{
+ // Get names of supported properties, create a list for values and copy current values to it.
+ Sequence< OUString > seqNames = GetPropertyNames ();
+ sal_Int32 nCount = seqNames.getLength();
+ Sequence< Any > seqValues ( nCount );
+ for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
+ {
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_WINDOWLIST : {
+ seqValues[nProperty] <<= m_seqWindowList;
+ }
+ break;
+ }
+ }
+ // Set properties in configuration.
+ PutProperties( seqNames, seqValues );
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Sequence< OUString > SvtWorkingSetOptions_Impl::GetPropertyNames()
+{
+ // Build static list of configuration key names.
+ static const OUString pProperties[] =
+ {
+ PROPERTYNAME_WINDOWLIST ,
+ };
+ // Initialize return sequence with these list ...
+ static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
+ // ... and return it.
+ return seqPropertyNames;
+}
+
+//*****************************************************************************************************************
+// initialize static member
+// DON'T DO IT IN YOUR HEADER!
+// see definition for further informations
+//*****************************************************************************************************************
+SvtWorkingSetOptions_Impl* SvtWorkingSetOptions::m_pDataContainer = NULL ;
+sal_Int32 SvtWorkingSetOptions::m_nRefCount = 0 ;
+
+//*****************************************************************************************************************
+// constructor
+//*****************************************************************************************************************
+SvtWorkingSetOptions::SvtWorkingSetOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Increase ouer refcount ...
+ ++m_nRefCount;
+ // ... and initialize ouer data container only if it not already exist!
+ if( m_pDataContainer == NULL )
+ {
+ m_pDataContainer = new SvtWorkingSetOptions_Impl;
+ ItemHolder1::holdConfigItem(E_WORKINGSETOPTIONS);
+ }
+}
+
+//*****************************************************************************************************************
+// destructor
+//*****************************************************************************************************************
+SvtWorkingSetOptions::~SvtWorkingSetOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Decrease ouer refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy ouer static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pDataContainer;
+ m_pDataContainer = NULL;
+ }
+}
+
+//*****************************************************************************************************************
+// private method
+//*****************************************************************************************************************
+Mutex& SvtWorkingSetOptions::GetOwnStaticMutex()
+{
+ // Initialize static mutex only for one time!
+ static Mutex* pMutex = NULL;
+ // If these method first called (Mutex not already exist!) ...
+ if( pMutex == NULL )
+ {
+ // ... we must create a new one. Protect follow code with the global mutex -
+ // It must be - we create a static variable!
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
+ if( pMutex == NULL )
+ {
+ // Create the new mutex and set it for return on static variable.
+ static Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+ // Return new created or already existing mutex object.
+ return *pMutex;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filerec/makefile.mk b/binfilter/bf_svtools/source/filerec/makefile.mk
new file mode 100644
index 000000000000..82e898179e23
--- /dev/null
+++ b/binfilter/bf_svtools/source/filerec/makefile.mk
@@ -0,0 +1,46 @@
+#*************************************************************************
+#
+# DO NOT ALTER 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=binfilter
+TARGET=filerec
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/svt_filerec.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/binfilter/bf_svtools/source/filerec/svt_filerec.cxx b/binfilter/bf_svtools/source/filerec/svt_filerec.cxx
new file mode 100644
index 000000000000..4c27a7d7b4b7
--- /dev/null
+++ b/binfilter/bf_svtools/source/filerec/svt_filerec.cxx
@@ -0,0 +1,774 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/filerec.hxx>
+#include <osl/endian.h>
+
+namespace binfilter
+{
+
+//========================================================================
+
+SV_IMPL_VARARR( SfxUINT32s, UINT32 );
+
+//========================================================================
+
+/* Die folgenden Makros extrahieren Teilbereiche aus einem UINT32 Wert.
+ Diese UINT32-Werte werden anstelle der einzelnen Werte gestreamt,
+ um Calls zu sparen.
+*/
+
+#define SFX_REC_PRE(n) ( ((n) & 0x000000FF) )
+#define SFX_REC_OFS(n) ( ((n) & 0xFFFFFF00) >> 8 )
+#define SFX_REC_TYP(n) ( ((n) & 0x000000FF) )
+#define SFX_REC_VER(n) ( ((n) & 0x0000FF00) >> 8 )
+#define SFX_REC_TAG(n) ( ((n) & 0xFFFF0000) >> 16 )
+
+#define SFX_REC_CONTENT_VER(n) ( ((n) & 0x000000FF) )
+#define SFX_REC_CONTENT_OFS(n) ( ((n) & 0xFFFFFF00) >> 8 )
+
+//-------------------------------------------------------------------------
+
+/* Die folgenden Makros setzen Teilbereiche zu einem UINT32 Wert zusammen.
+ Diese UINT32-Werte werden anstelle der einzelnen Werte gestreamt,
+ um Calls zu sparen.
+*/
+
+#define SFX_REC_MINI_HEADER(nPreTag,nStartPos,nEndPos) \
+ ( UINT32(nPreTag) | \
+ UINT32(nEndPos-nStartPos-SFX_REC_HEADERSIZE_MINI) << 8 )
+
+#define SFX_REC_HEADER(nRecType,nContentTag,nContentVer) \
+ ( UINT32(nRecType) | \
+ ( UINT32(nContentVer) << 8 ) | \
+ ( UINT32(nContentTag) << 16 ) )
+
+#define SFX_REC_CONTENT_HEADER(nContentVer,n1StStartPos,nCurStartPos) \
+ ( UINT32(nContentVer) | \
+ UINT32( nCurStartPos - n1StStartPos ) << 8 )
+
+//=========================================================================
+
+UINT32 SfxMiniRecordWriter::Close
+(
+ FASTBOOL bSeekToEndOfRec /* TRUE (default)
+ Der Stream wird an das Ende des Records
+ positioniert.
+
+ FALSE
+ Der Stream wird an den Anfang des
+ Contents (also hinter den Header)
+ positioniert.
+ */
+)
+
+/* [Beschreibung]
+
+ Diese Methode schlie\st den Record. Dabei wird haupts"achlich der
+ Header geschrieben.
+
+ Wurde der Header bereits geschrieben, hat der Aufruf keine Wirkung.
+
+
+ [R"uckgabewert]
+
+ UINT32 != 0
+ Position im Stream, die direkt hinter dem Record liegt.
+ 'bSeekToEndOfRecord==TRUE'
+ => R"uckgabewert == aktuelle Stream-Position nach Aufruf
+
+ == 0
+ Der Header war bereits geschrieben worden.
+*/
+
+{
+ // wurde der Header noch nicht geschrieben?
+ if ( !_bHeaderOk )
+ {
+ // Header an den Anfang des Records schreiben
+ UINT32 nEndPos = _pStream->Tell();
+ _pStream->Seek( _nStartPos );
+ *_pStream << SFX_REC_MINI_HEADER( _nPreTag, _nStartPos, nEndPos );
+
+ // je nachdem ans Ende des Records seeken oder hinter Header bleiben
+ if ( bSeekToEndOfRec )
+ _pStream->Seek( nEndPos );
+
+ // Header wurde JETZT geschrieben
+ _bHeaderOk = TRUE;
+ return nEndPos;
+ }
+#ifdef DBG_UTIL
+ // mu\s Fix-Size-Record gepr"uft werden?
+ else if ( SFX_BOOL_DONTCARE == _bHeaderOk )
+ {
+ // Header auslesen, um Soll-Gr"o\se zu bestimmen
+ UINT32 nEndPos = _pStream->Tell();
+ _pStream->Seek( _nStartPos );
+ UINT32 nHeader;
+ *_pStream >> nHeader;
+ _pStream->Seek( nEndPos );
+
+ // Soll-Gr"o\se mit Ist-Gr"o\se vergleichen
+ DBG_ASSERT( nEndPos - SFX_REC_OFS(nHeader) == _nStartPos + sizeof(UINT32),
+ "fixed record size incorrect" );
+ DbgOutf( "SfxFileRec: written record until %ul", nEndPos );
+ }
+#endif
+
+ // Record war bereits geschlossen
+ return 0;
+}
+
+//=========================================================================
+
+FASTBOOL SfxMiniRecordReader::SetHeader_Impl( UINT32 nHeader )
+
+/* [Beschreibung]
+
+ Interne Methode zum nachtr"aglichen Verarbeiten eines extern gelesenen
+ Headers. Falls der Header eine End-Of-Records-Kennung darstellt,
+ wird am Stream ein Errorcode gesetzt und FALSE zur"uckgeliefert. Im
+ Fehlerfall wird der Stream jedoch nicht auf den Record-Anfang zur"uck-
+ gesetzt.
+*/
+
+{
+ FASTBOOL bRet = TRUE;
+
+ // Record-Ende und Pre-Tag aus dem Header ermitteln
+ _nEofRec = _pStream->Tell() + SFX_REC_OFS(nHeader);
+ _nPreTag = sal::static_int_cast< BYTE >(SFX_REC_PRE(nHeader));
+
+ // wenn End-Of-Record-Kennung, dann Fehler
+ if ( _nPreTag == SFX_REC_PRETAG_EOR )
+ {
+ _pStream->SetError( ERRCODE_IO_WRONGFORMAT );
+ bRet = FALSE;
+ }
+ return bRet;
+}
+
+//-------------------------------------------------------------------------
+
+SfxMiniRecordReader::SfxMiniRecordReader
+(
+ SvStream* pStream, /* <SvStream>, an dessen aktueller
+ Position sich ein <SfxMiniRecord>
+ befindet.
+ */
+ BYTE nTag // Pre-Tag des gew"unschten Records
+)
+
+/* [Beschreibung]
+
+ Dieser Ctor interpretiert 'pStream' ab der aktuellen Position als
+ eine l"uckenlose Folge von, von dieser Klassen-Gruppe interpretierbaren,
+ Records. Der in dieser Folge erste als <SfxMiniRecord> interpretierbare
+ (also ggf. auch ein extended-Record) mit dem PreTag 'nTag' wird ge"offnet
+ und durch diese Instanz repr"asentiert.
+
+ Wird das Ende des Streams oder die Kennung SFX_REC_PRETAG_EOR
+ erreicht, bevor ein Record mit dem ge"unschten Pre-Tag gefunden wird,
+ ist die erzeugte Instanz ung"ultig ('IsValid() == FALSE'). Ein ent-
+ sprechender Error-Code (ERRCODE_IO_EOF bzw. ERRCODE_IO_WRONGFORMAT)
+ ist dann am Stream gesetzt, dessen Position ist dann au\serdem unver-
+ "andert.
+
+ Bei 'nTag==SFX_FILEREC_PRETAG_EOR' wird nicht versucht, einen Record
+ zu lesen, es wird sofort 'IsValid()' auf FALSE gesetzt und kein Error-Code
+ am Stream gesetzt. Dies ist dauzu gedacht, ohne 'new' und 'delete'
+ abw"rtskompatibel SfxMiniRecords einbauen zu k"onnen. Siehe dazu
+ <SfxItemSet::Load()>.
+
+
+ [Anwendungsvorschlag]
+
+ Wird dieser Ctor in einer bereits ausgelieferten Programmversion
+ verwendet, k"onnen in das File-Format jeweils davor kompatibel neue
+ Records mit einer anderen Kennung eingef"ugt werden. Diese werden
+ schlie\slich automatisch "uberlesen. Erkauft wird diese M"oglichkeit
+ allerdings mit etwas schlechterem Laufzeitverhalten im Vergleich mit
+ direktem 'drauf-los-lesen', der sich jedoch auf einen Vergleich zweier
+ Bytes reduziert, falls der gesuchte Record der erste in der Folge ist.
+*/
+
+: _pStream( pStream ),
+ _bSkipped( nTag == SFX_REC_PRETAG_EOR )
+{
+ // ggf. ignorieren (s.o.)
+ if ( _bSkipped )
+ {
+ _nPreTag = nTag;
+ return;
+ }
+
+ // StartPos merken, um im Fehlerfall zur"uck-seeken zu k"onnen
+ UINT32 nStartPos = pStream->Tell();
+
+ // passenden Record suchen
+ while(TRUE)
+ {
+ // Header lesen
+ DBG( DbgOutf( "SfxFileRec: searching record at %ul", pStream->Tell() ) );
+ UINT32 nHeader;
+ *pStream >> nHeader;
+
+ // Headerdaten von Basisklasse extrahieren lassen
+ SetHeader_Impl( nHeader );
+
+ // ggf. Fehler behandeln
+ if ( pStream->IsEof() )
+ _nPreTag = SFX_REC_PRETAG_EOR;
+ else if ( _nPreTag == SFX_REC_PRETAG_EOR )
+ pStream->SetError( ERRCODE_IO_WRONGFORMAT );
+ else
+ {
+ // wenn gefunden, dann Schleife abbrechen
+ if ( _nPreTag == nTag )
+ break;
+
+ // sonst skippen und weitersuchen
+ pStream->Seek( _nEofRec );
+ continue;
+ }
+
+ // Fehler => zur"uck-seeken
+ pStream->Seek( nStartPos );
+ break;
+ }
+}
+
+//=========================================================================
+
+SfxSingleRecordWriter::SfxSingleRecordWriter
+(
+ BYTE nRecordType, // f"ur Subklassen
+ SvStream* pStream, // Stream, in dem der Record angelegt wird
+ UINT16 nContentTag, // Inhalts-Art-Kennung
+ BYTE nContentVer // Inhalts-Versions-Kennung
+)
+
+/* [Beschreibung]
+
+ Interner Ctor f"ur Subklassen.
+*/
+
+: SfxMiniRecordWriter( pStream, SFX_REC_PRETAG_EXT )
+{
+ // Erweiterten Header hiner den des SfxMiniRec schreiben
+ *pStream << SFX_REC_HEADER(nRecordType, nContentTag, nContentVer);
+}
+
+//-------------------------------------------------------------------------
+
+SfxSingleRecordWriter::SfxSingleRecordWriter
+(
+ SvStream* pStream, // Stream, in dem der Record angelegt wird
+ UINT16 nContentTag, // Inhalts-Art-Kennung
+ BYTE nContentVer // Inhalts-Versions-Kennung
+)
+
+/* [Beschreibung]
+
+ Legt in 'pStream' einen 'SfxSingleRecord' an, dessen Content-Gr"o\se
+ nicht bekannt ist, sondern nach dam Streamen des Contents errechnet
+ werden soll.
+*/
+
+: SfxMiniRecordWriter( pStream, SFX_REC_PRETAG_EXT )
+{
+ // Erweiterten Header hiner den des SfxMiniRec schreiben
+ *pStream << SFX_REC_HEADER( SFX_REC_TYPE_SINGLE, nContentTag, nContentVer);
+}
+
+//=========================================================================
+
+inline FASTBOOL SfxSingleRecordReader::ReadHeader_Impl( USHORT nTypes )
+
+/* [Beschreibung]
+
+ Interne Methode zum Einlesen eines SfxMultiRecord-Headers, nachdem
+ die Basisklasse bereits initialisiert und deren Header gelesen ist.
+ Ggf. ist ein Error-Code am Stream gesetzt, im Fehlerfall wird jedoch
+ nicht zur"uckge-seekt.
+*/
+
+{
+ FASTBOOL bRet;
+
+ // Basisklassen-Header einlesen
+ UINT32 nHeader=0;
+ *_pStream >> nHeader;
+ if ( !SetHeader_Impl( nHeader ) )
+ bRet = FALSE;
+ else
+ {
+ // eigenen Header einlesen
+ *_pStream >> nHeader;
+ _nRecordVer = sal::static_int_cast< BYTE >(SFX_REC_VER(nHeader));
+ _nRecordTag = sal::static_int_cast< UINT16 >(SFX_REC_TAG(nHeader));
+
+ // falscher Record-Typ?
+ _nRecordType = sal::static_int_cast< BYTE >(SFX_REC_TYP(nHeader));
+ bRet = 0 != ( nTypes & _nRecordType);
+ }
+ return bRet;
+}
+
+//-------------------------------------------------------------------------
+
+SfxSingleRecordReader::SfxSingleRecordReader( SvStream *pStream, USHORT nTag )
+{
+ // StartPos merken, um im Fehlerfall zur"uck-seeken zu k"onnen
+ UINT32 nStartPos = pStream->Tell();
+
+ // richtigen Record suchen, ggf. Error-Code setzen und zur"uck-seeken
+ Construct_Impl( pStream );
+ if ( !FindHeader_Impl( SFX_REC_TYPE_SINGLE, nTag ) )
+ {
+ // Error-Code setzen und zur"uck-seeken
+ pStream->Seek( nStartPos );
+ pStream->SetError( ERRCODE_IO_WRONGFORMAT );
+ }
+}
+
+//-------------------------------------------------------------------------
+
+FASTBOOL SfxSingleRecordReader::FindHeader_Impl
+(
+ UINT16 nTypes, // arithm. Veroderung erlaubter Record-Typen
+ UINT16 nTag // zu findende Record-Art-Kennung
+)
+
+/* [Beschreibung]
+
+ Interne Methode zum lesen des Headers des ersten Record, der einem
+ der Typen in 'nTypes' entspricht und mit der Art-Kennung 'nTag'
+ gekennzeichnet ist.
+
+ Kann ein solcher Record nicht gefunden werden, wird am Stream ein
+ Errorcode gesetzt, zur"uck-geseekt und FALSE zur"uckgeliefert.
+*/
+
+{
+ // StartPos merken, um im Fehlerfall zur"uck-seeken zu k"onnen
+ UINT32 nStartPos = _pStream->Tell();
+
+ // richtigen Record suchen
+ while ( !_pStream->IsEof() )
+ {
+ // Header lesen
+ UINT32 nHeader;
+ DBG( DbgOutf( "SfxFileRec: searching record at %ul", _pStream->Tell() ) );
+ *_pStream >> nHeader;
+ if ( !SetHeader_Impl( nHeader ) )
+ // EOR => Such-Schleife abbreichen
+ break;
+
+ // Extended Record gefunden?
+ if ( _nPreTag == SFX_REC_PRETAG_EXT )
+ {
+ // Extended Header lesen
+ *_pStream >> nHeader;
+ _nRecordTag = sal::static_int_cast< UINT16 >(SFX_REC_TAG(nHeader));
+
+ // richtigen Record gefunden?
+ if ( _nRecordTag == nTag )
+ {
+ // gefundener Record-Typ passend?
+ _nRecordType = sal::static_int_cast< BYTE >(
+ SFX_REC_TYP(nHeader));
+ if ( nTypes & _nRecordType )
+ // ==> gefunden
+ return TRUE;
+
+ // error => Such-Schleife abbrechen
+ break;
+ }
+ }
+
+ // sonst skippen
+ if ( !_pStream->IsEof() )
+ _pStream->Seek( _nEofRec );
+ }
+
+ // Fehler setzen und zur"uck-seeken
+ _pStream->SetError( ERRCODE_IO_WRONGFORMAT );
+ _pStream->Seek( nStartPos );
+ return FALSE;
+}
+
+SfxMultiFixRecordWriter::SfxMultiFixRecordWriter
+(
+ BYTE nRecordType, // Subklassen Record-Kennung
+ SvStream* pStream, // Stream, in dem der Record angelegt wird
+ UINT16 nContentTag, // Content-Art-Kennung
+ BYTE nContentVer, // Content-Versions-Kennung
+ UINT32 // Gr"o\se jedes einzelnen Contents in Bytes
+)
+
+/* [Beschreibung]
+
+ Interne Methode f"ur Subklassen.
+*/
+
+: SfxSingleRecordWriter( nRecordType, pStream, nContentTag, nContentVer ),
+ _nContentCount( 0 )
+{
+ // Platz f"ur eigenen Header
+ pStream->SeekRel( + SFX_REC_HEADERSIZE_MULTI );
+}
+
+//=========================================================================
+
+UINT32 SfxMultiFixRecordWriter::Close( FASTBOOL bSeekToEndOfRec )
+
+// siehe <SfxMiniRecordWriter>
+
+{
+ // Header noch nicht geschrieben?
+ if ( !_bHeaderOk )
+ {
+ // Position hinter Record merken, um sie restaurieren zu k"onnen
+ UINT32 nEndPos = SfxSingleRecordWriter::Close( FALSE );
+
+ // gegen"uber SfxSingleRecord erweiterten Header schreiben
+ *_pStream << _nContentCount;
+ *_pStream << _nContentSize;
+
+ // je nachdem ans Ende des Records seeken oder hinter Header bleiben
+ if ( bSeekToEndOfRec )
+ _pStream->Seek(nEndPos);
+ return nEndPos;
+ }
+
+ // Record war bereits geschlossen
+ return 0;
+}
+
+//=========================================================================
+
+SfxMultiVarRecordWriter::SfxMultiVarRecordWriter
+(
+ BYTE nRecordType, // Record-Kennung der Subklasse
+ SvStream* pStream, // Stream, in dem der Record angelegt wird
+ UINT16 nRecordTag, // Gesamt-Art-Kennung
+ BYTE nRecordVer // Gesamt-Versions-Kennung
+)
+
+/* [Beschreibung]
+
+ Interner Ctor f"ur Subklassen.
+*/
+
+: SfxMultiFixRecordWriter( nRecordType, pStream, nRecordTag, nRecordVer, 0 ),
+ _nContentVer( 0 )
+{
+}
+
+//-------------------------------------------------------------------------
+
+SfxMultiVarRecordWriter::SfxMultiVarRecordWriter
+(
+ SvStream* pStream, // Stream, in dem der Record angelegt wird
+ UINT16 nRecordTag, // Gesamt-Art-Kennung
+ BYTE nRecordVer // Gesamt-Versions-Kennung
+)
+
+/* [Beschreibung]
+
+ Legt in 'pStream' einen 'SfxMultiVarRecord' an, dessen Content-Gr"o\sen
+ weder bekannt sind noch identisch sein m"ussen, sondern jeweils nach dem
+ Streamen jedes einzelnen Contents errechnet werden sollen.
+
+
+ [Anmerkung]
+
+ Diese Methode ist nicht inline, da f"ur die Initialisierung eines
+ <SvULongs>-Members zu viel Code generiert werden w"urde.
+*/
+
+: SfxMultiFixRecordWriter( SFX_REC_TYPE_VARSIZE,
+ pStream, nRecordTag, nRecordVer, 0 ),
+ _nContentVer( 0 )
+{
+}
+
+//-------------------------------------------------------------------------
+
+SfxMultiVarRecordWriter::~SfxMultiVarRecordWriter()
+
+/* [Beschreibung]
+
+ Der Dtor der Klasse <SfxMultiVarRecordWriter> schlie\st den Record
+ automatisch, falls <SfxMultiVarRecordWriter::Close()> nicht bereits
+ explizit gerufen wurde.
+*/
+
+{
+ // wurde der Header noch nicht geschrieben oder mu\s er gepr"uft werden
+ if ( !_bHeaderOk )
+ Close();
+}
+
+//-------------------------------------------------------------------------
+
+void SfxMultiVarRecordWriter::FlushContent_Impl()
+
+/* [Beschreibung]
+
+ Interne Methode zum Abschlie\sen eines einzelnen Contents.
+*/
+
+{
+ // Versions-Kennung und Positions-Offset des aktuellen Contents merken;
+ // das Positions-Offset ist relativ zur Startposition des ersten Contents
+ _aContentOfs.Insert(
+ SFX_REC_CONTENT_HEADER(_nContentVer,_nStartPos,_nContentStartPos),
+ _nContentCount-1 );
+}
+
+//-------------------------------------------------------------------------
+
+void SfxMultiVarRecordWriter::NewContent()
+
+// siehe <SfxMultiFixRecordWriter>
+
+{
+ // schon ein Content geschrieben?
+ if ( _nContentCount )
+ FlushContent_Impl();
+
+ // neuen Content beginnen
+ _nContentStartPos = _pStream->Tell();
+ ++_nContentCount;
+}
+
+//-------------------------------------------------------------------------
+
+UINT32 SfxMultiVarRecordWriter::Close( FASTBOOL bSeekToEndOfRec )
+
+// siehe <SfxMiniRecordWriter>
+
+{
+ // Header noch nicht geschrieben?
+ if ( !_bHeaderOk )
+ {
+ // ggf. letzten Content abschlie\sen
+ if ( _nContentCount )
+ FlushContent_Impl();
+
+ // Content-Offset-Tabelle schreiben
+ UINT32 nContentOfsPos = _pStream->Tell();
+ //! darf man das so einr"ucken?
+ #if defined(OSL_LITENDIAN)
+ _pStream->Write( _aContentOfs.GetData(),
+ sizeof(UINT32)*_nContentCount );
+ #else
+ for ( USHORT n = 0; n < _nContentCount; ++n )
+ *_pStream << UINT32(_aContentOfs[n]);
+ #endif
+
+ // SfxMultiFixRecordWriter::Close() "uberspringen!
+ UINT32 nEndPos = SfxSingleRecordWriter::Close( FALSE );
+
+ // eigenen Header schreiben
+ *_pStream << _nContentCount;
+ if ( SFX_REC_TYPE_VARSIZE_RELOC == _nPreTag ||
+ SFX_REC_TYPE_MIXTAGS_RELOC == _nPreTag )
+ *_pStream << static_cast<UINT32>(nContentOfsPos - ( _pStream->Tell() + sizeof(UINT32) ));
+ else
+ *_pStream << nContentOfsPos;
+
+ // ans Ende des Records seeken bzw. am Ende des Headers bleiben
+ if ( bSeekToEndOfRec )
+ _pStream->Seek(nEndPos);
+ return nEndPos;
+ }
+
+ // Record war bereits vorher geschlossen
+ return 0;
+}
+
+//=========================================================================
+
+void SfxMultiMixRecordWriter::NewContent
+(
+ UINT16 nContentTag, // Kennung f"ur die Art des Contents
+ BYTE nContentVer // Kennung f"ur die Version des Contents
+)
+
+/* [Beschreibung]
+
+ Mit dieser Methode wird in den Record ein neuer Content eingef"ugt
+ und dessen Content-Tag sowie dessen Content-Version angegeben. Jeder,
+ auch der 1. Record mu\s durch Aufruf dieser Methode eingeleitet werden.
+*/
+
+{
+ // ggf. vorherigen Record abschlie\sen
+ if ( _nContentCount )
+ FlushContent_Impl();
+
+ // Tag vor den Content schreiben, Version und Startposition merken
+ _nContentStartPos = _pStream->Tell();
+ ++_nContentCount;
+ *_pStream << nContentTag;
+ _nContentVer = nContentVer;
+}
+
+//=========================================================================
+
+FASTBOOL SfxMultiRecordReader::ReadHeader_Impl()
+
+/* [Beschreibung]
+
+ Interne Methode zum Einlesen eines SfxMultiRecord-Headers, nachdem
+ die Basisklasse bereits initialisiert und deren Header gelesen ist.
+ Ggf. ist ein Error-Code am Stream gesetzt, im Fehlerfall wird jedoch
+ nicht zur"uckge-seekt.
+*/
+
+{
+ // eigenen Header lesen
+ *_pStream >> _nContentCount;
+ *_pStream >> _nContentSize; // Fix: jedes einzelnen, Var|Mix: Tabellen-Pos.
+
+ // mu\s noch eine Tabelle mit Content-Offsets geladen werden?
+ if ( _nRecordType != SFX_REC_TYPE_FIXSIZE )
+ {
+ // Tabelle aus dem Stream einlesen
+ UINT32 nContentPos = _pStream->Tell();
+ if ( _nRecordType == SFX_REC_TYPE_VARSIZE_RELOC ||
+ _nRecordType == SFX_REC_TYPE_MIXTAGS_RELOC )
+ _pStream->SeekRel( + _nContentSize );
+ else
+ _pStream->Seek( _nContentSize );
+ _pContentOfs = new UINT32[_nContentCount];
+ //! darf man jetzt so einr"ucken
+ #if defined(OSL_LITENDIAN)
+ _pStream->Read( _pContentOfs, sizeof(UINT32)*_nContentCount );
+ #else
+ for ( USHORT n = 0; n < _nContentCount; ++n )
+ *_pStream >> _pContentOfs[n];
+ #endif
+ _pStream->Seek( nContentPos );
+ }
+
+ // Header konnte gelesen werden, wenn am Stream kein Error gesetzt ist
+ return !_pStream->GetError();
+}
+
+//-------------------------------------------------------------------------
+
+SfxMultiRecordReader::SfxMultiRecordReader( SvStream *pStream, UINT16 nTag )
+: _nContentNo(0)
+{
+ // Position im Stream merken, um im Fehlerfall zur"uck-seeken zu k"onnen
+ _nStartPos = pStream->Tell();
+
+ // passenden Record suchen und Basisklasse initialisieren
+ SfxSingleRecordReader::Construct_Impl( pStream );
+ if ( SfxSingleRecordReader::FindHeader_Impl( SFX_REC_TYPE_FIXSIZE |
+ SFX_REC_TYPE_VARSIZE | SFX_REC_TYPE_VARSIZE_RELOC |
+ SFX_REC_TYPE_MIXTAGS | SFX_REC_TYPE_MIXTAGS_RELOC,
+ nTag ) )
+ {
+ // eigenen Header dazu-lesen
+ if ( !ReadHeader_Impl() )
+ // nicht lesbar => als ung"ultig markieren und zur"uck-seeken
+ SetInvalid_Impl( _nStartPos);
+ }
+}
+
+//-------------------------------------------------------------------------
+
+SfxMultiRecordReader::~SfxMultiRecordReader()
+{
+ delete[] _pContentOfs;
+}
+
+//-------------------------------------------------------------------------
+
+FASTBOOL SfxMultiRecordReader::GetContent()
+
+/* [Beschreibung]
+
+ Positioniert den Stream an den Anfang des n"chsten bzw. beim 1. Aufruf
+ auf den Anfang des ersten Contents im Record und liest ggf. dessen
+ Header ein.
+
+ Liegt laut Record-Header kein Content mehr vor, wird FALSE zur"uck-
+ gegeben. Trotz einem TRUE-Returnwert kann am Stream ein Fehlercode
+ gesetzt sein, z.B. falls er unvorhergesehenerweise (kaputtes File)
+ zuende ist.
+*/
+
+{
+ // noch ein Content vorhanden?
+ if ( _nContentNo < _nContentCount )
+ {
+ // den Stream an den Anfang des Contents positionieren
+ UINT32 nOffset = _nRecordType == SFX_REC_TYPE_FIXSIZE
+ ? _nContentNo * _nContentSize
+ : SFX_REC_CONTENT_OFS(_pContentOfs[_nContentNo]);
+ UINT32 nNewPos = _nStartPos + nOffset;
+ DBG_ASSERT( nNewPos >= _pStream->Tell(), "SfxMultiRecordReader::GetContent() - New position before current, to much data red!" );
+
+ // #99366#: correct stream pos in every case;
+ // the if clause was added by MT a long time ago,
+ // maybe to 'repair' other corrupt documents; but this
+ // gives errors when writing with 5.1 and reading with current
+ // versions, so we decided to remove the if clause (KA-05/17/2002)
+ // if ( nNewPos > _pStream->Tell() )
+ _pStream->Seek( nNewPos );
+
+ // ggf. Content-Header lesen
+ if ( _nRecordType == SFX_REC_TYPE_MIXTAGS ||
+ _nRecordType == SFX_REC_TYPE_MIXTAGS_RELOC )
+ {
+ _nContentVer = sal::static_int_cast< BYTE >(
+ SFX_REC_CONTENT_VER(_pContentOfs[_nContentNo]));
+ *_pStream >> _nContentTag;
+ }
+
+ // ContentNo weiterz"ahlen
+ ++_nContentNo;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/FilterConfigCache.hxx b/binfilter/bf_svtools/source/filter.vcl/filter/FilterConfigCache.hxx
new file mode 100644
index 000000000000..7ba338500569
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/FilterConfigCache.hxx
@@ -0,0 +1,145 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 _FILTER_CONFIG_CACHE_HXX_
+#define _FILTER_CONFIG_CACHE_HXX_
+
+#include <tools/string.hxx>
+#include <rtl/ustring.hxx>
+#include "bf_svtools/svtdllapi.h"
+#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+#include <vector>
+
+namespace binfilter
+{
+
+class FilterConfigCache
+{
+ struct FilterConfigCacheEntry
+ {
+ ::rtl::OUString sInternalFilterName;
+ ::rtl::OUString sType;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > lExtensionList;
+ ::rtl::OUString sUIName;
+ ::rtl::OUString sDocumentService;
+ ::rtl::OUString sFilterService;
+ ::rtl::OUString sTemplateName;
+
+ ::rtl::OUString sMediaType;
+ ::rtl::OUString sFilterType;
+
+ sal_Int32 nFlags;
+ sal_Int32 nFileFormatVersion;
+
+ // user data
+ String sFilterName;
+ sal_Bool bHasDialog : 1;
+ sal_Bool bIsInternalFilter : 1;
+ sal_Bool bIsPixelFormat : 1;
+
+ sal_Bool CreateFilterName( const ::rtl::OUString& rUserDataEntry );
+ String GetShortName( );
+
+ static const char* InternalPixelFilterNameList[];
+ static const char* InternalVectorFilterNameList[];
+ static const char* ExternalPixelFilterNameList[];
+ };
+
+ typedef std::vector< FilterConfigCacheEntry > CacheVector;
+
+
+ CacheVector aImport;
+ CacheVector aExport;
+ sal_Bool bUseConfig;
+
+ static sal_Bool bInitialized;
+ static sal_Int32 nIndType;
+ static sal_Int32 nIndUIName;
+ static sal_Int32 nIndDocumentService;
+ static sal_Int32 nIndFilterService;
+ static sal_Int32 nIndFlags;
+ static sal_Int32 nIndUserData;
+ static sal_Int32 nIndFileFormatVersion;
+ static sal_Int32 nIndTemplateName;
+
+ static const char* InternalFilterListForSvxLight[];
+
+ void ImplInit();
+ void ImplInitSmart();
+
+ public :
+
+ sal_uInt16 GetImportFormatCount() const
+ { return sal::static_int_cast< sal_uInt16 >(aImport.size()); };
+ sal_uInt16 GetImportFormatNumber( const String& rFormatName );
+ sal_uInt16 GetImportFormatNumberForMediaType( const String& rMediaType );
+ sal_uInt16 GetImportFormatNumberForShortName( const String& rShortName );
+ sal_uInt16 GetImportFormatNumberForTypeName( const String& rType );
+ String GetImportFilterName( sal_uInt16 nFormat );
+ String GetImportFormatName( sal_uInt16 nFormat );
+ String GetImportFormatExtension( sal_uInt16 nFormat, sal_Int32 nEntry = 0);
+ String GetImportFormatMediaType( sal_uInt16 nFormat );
+ String GetImportFormatShortName( sal_uInt16 nFormat );
+ String GetImportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry );
+ String GetImportFilterType( sal_uInt16 nFormat );
+ String GetImportFilterTypeName( sal_uInt16 nFormat );
+
+ sal_Bool IsImportInternalFilter( sal_uInt16 nFormat );
+ sal_Bool IsImportPixelFormat( sal_uInt16 nFormat );
+
+ sal_uInt16 GetExportFormatCount() const
+ { return sal::static_int_cast< sal_uInt16 >(aExport.size()); };
+ sal_uInt16 GetExportFormatNumber( const String& rFormatName );
+ sal_uInt16 GetExportFormatNumberForMediaType( const String& rMediaType );
+ sal_uInt16 GetExportFormatNumberForShortName( const String& rShortName );
+ sal_uInt16 GetExportFormatNumberForTypeName( const String& rType );
+ String GetExportFilterName( sal_uInt16 nFormat );
+ String GetExportFormatName( sal_uInt16 nFormat );
+ String GetExportFormatExtension( sal_uInt16 nFormat, sal_Int32 nEntry = 0 );
+ String GetExportFormatMediaType( sal_uInt16 nFormat );
+ String GetExportFormatShortName( sal_uInt16 nFormat );
+ String GetExportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry );
+ String GetExportFilterTypeName( sal_uInt16 nFormat );
+
+ sal_Bool IsExportInternalFilter( sal_uInt16 nFormat );
+ sal_Bool IsExportPixelFormat( sal_uInt16 nFormat );
+
+ FilterConfigCache( sal_Bool bUseConfig );
+ ~FilterConfigCache();
+
+};
+
+}
+
+#endif // _FILTER_CONFIG_CACHE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/makefile.mk b/binfilter/bf_svtools/source/filter.vcl/filter/makefile.mk
new file mode 100644
index 000000000000..14f5735f8c6c
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/makefile.mk
@@ -0,0 +1,68 @@
+#*************************************************************************
+#
+# DO NOT ALTER 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=binfilter
+TARGET=filter
+LIBTARGET=NO
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= $(SLO)$/svt_filter.obj \
+ $(SLO)$/svt_filter2.obj \
+ $(SLO)$/svt_sgfbram.obj \
+ $(SLO)$/svt_sgvmain.obj \
+ $(SLO)$/svt_sgvtext.obj \
+ $(SLO)$/svt_sgvspln.obj \
+ $(SLO)$/svt_FilterConfigItem.obj \
+ $(SLO)$/svt_FilterConfigCache.obj
+
+EXCEPTIONSNOOPTFILES= $(SLO)$/svt_filter.obj \
+ $(SLO)$/svt_FilterConfigItem.obj \
+ $(SLO)$/svt_FilterConfigCache.obj
+
+LIB1TARGET= $(SLB)$/$(TARGET).lib
+LIB1OBJFILES= \
+ $(SLO)$/svt_filter.obj \
+ $(SLO)$/svt_filter2.obj \
+ $(SLO)$/svt_sgfbram.obj \
+ $(SLO)$/svt_sgvmain.obj \
+ $(SLO)$/svt_sgvtext.obj \
+ $(SLO)$/svt_sgvspln.obj \
+ $(SLO)$/svt_FilterConfigItem.obj \
+ $(SLO)$/svt_FilterConfigCache.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/sgf.ini b/binfilter/bf_svtools/source/filter.vcl/filter/sgf.ini
new file mode 100644
index 000000000000..7444e40c8836
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/sgf.ini
@@ -0,0 +1,118 @@
+#Family : (Roman,Swiss,Modern,Script,Decora);
+#CharSet : (Ansi,IBMPC,Mac,Symbol,System); Default is System
+#Attribute: (Bold,Ital,Sans,Serf,Fixd);
+
+[SGV Fonts fuer StarView]
+#IF-ID Fontname Attribute SV-Fam ChSet Width FontName
+ 3848=(ITC Zapf Dingbats) Decora ()
+ 5720=(Symbol) Serf Decora Symbol ()
+ 5721=(Symbol) Bold Serf Decora Symbol ()
+ 5723=(Symbol Sans) Sans Decora Symbol ()
+ 5724=(Symbol Sans) Bold Sans Decora Symbol ()
+ 90133=(Dom Casual) Sans Script ()
+ 90326=(Brush) Bold Ital Serf Script ()
+ 90349=(Park Avenue) Ital Serf Script ()
+ 90508=(Uncial) Sans Roman ()
+ 91118=(Antique Olive) Bold Sans Swiss ()
+ 91119=(Antique Olive) Sans Swiss ()
+ 91120=(Antique Olive Compact) Bold Sans Swiss ()
+ 91335=(ITC Benguiat) Bold Serf Roman ()
+ 91336=(ITC Benguiat) Bold Ital Serf Roman ()
+ 91846=(Antique Olive) Ital Sans Roman ()
+#92500=(CG Times) Serf Roman ()
+#92501=(CG Times) Ital Serf Roman ()
+#92504=(CG Times) Bold Serf Roman ()
+#92505=(CG Times) Bold Ital Serf Roman ()
+#93950=(Courier) Serf Fixd Modern ()
+#93951=(Courier) Ital Serf Fixd Modern ()
+#93952=(Courier) Bold Serf Fixd Modern ()
+#93953=(Courier) Bold Ital Serf Fixd Modern ()
+#94021=(Univers) Sans Swiss ()
+#94022=(Univers) Ital Sans Swiss ()
+#94023=(Univers) Bold Sans Swiss ()
+#94024=(Univers) Bold Ital Sans Swiss ()
+102004=(Avanti) Bold Ital Sans Swiss ()
+102005=(Avanti) Ital Sans Swiss ()
+102007=(Booklet) Bold Sans Roman ()
+102008=(Booklet) Bold Ital Sans Roman ()
+102009=(Booklet) Ital Sans Roman ()
+102010=(Centuri) Sans Roman ()
+102011=(Centuri) Bold Sans Roman ()
+102012=(Centuri) Bold Ital Sans Roman ()
+102013=(Centuri) Ital Sans Roman ()
+102014=(Paltus) Bold Sans Roman ()
+102015=(Paltus) Sans Roman ()
+102016=(Paltus) Bold Ital Sans Roman ()
+102017=(Paltus) Ital Sans Roman ()
+102018=(Sans) Sans Swiss ()
+102019=(Sans) Bold Sans Swiss ()
+102020=(Sans) Bold Ital Sans Swiss ()
+102021=(Sans) Ital Sans Swiss ()
+102022=(SansCondensed) Sans Swiss ()
+102023=(SansCondensed) Bold Sans Swiss ()
+102024=(SansCondensed) Bold Ital Sans Swiss ()
+102025=(SansCondensed) Ital Sans Swiss ()
+102026=(PS-Roman) Sans Roman ()
+102027=(PS-Roman) Bold Sans Roman ()
+102028=(PS-Roman) Bold Ital Sans Roman ()
+102029=(PS-Roman) Ital Sans Roman ()
+200111=(Chalenge) Sans ()
+200112=(Chalenge) Bold Sans ()
+200113=(Chalenge) Ital Sans ()
+200114=(Chalenge) Bold Ital Sans ()
+200121=(Office) Sans ()
+200122=(Office) Bold Sans ()
+200123=(Office) Ital Sans ()
+200124=(Office) Bold Ital Sans ()
+200131=(Milano) Sans ()
+200132=(Milano) Bold Sans ()
+200133=(Milano) Ital Sans ()
+200134=(Milano) Bold Ital Sans ()
+200141=(Atlantic) Sans Roman ()
+200142=(Atlantic) Bold Sans Roman ()
+200143=(Atlantic) Ital Sans Roman ()
+200144=(Atlantic) Bold Ital Sans Roman ()
+200151=(Pentagon) Sans ()
+200152=(Pentagon) Bold Sans ()
+200153=(Pentagon) Ital Sans ()
+200154=(Pentagon) Bold Ital Sans ()
+200161=(Classico) Sans ()
+200162=(Classico) Bold Sans ()
+200163=(Classico) Ital Sans ()
+200164=(Classico) Bold Ital Sans ()
+200211=(Westcost) Sans ()
+200212=(Westcost) Bold Sans ()
+200213=(Westcost) Ital Sans ()
+200214=(Westcost) Bold Ital Sans ()
+200221=(Finish) Sans ()
+200222=(Finish) Bold Sans ()
+200223=(Finish) Ital Sans ()
+200224=(Finish) Bold Ital Sans ()
+200231=(Classic) Sans ()
+200232=(Classic) Bold Sans ()
+200233=(Classic) Ital Sans ()
+200234=(Classic) Bold Ital Sans ()
+200241=(Hilton) Sans ()
+200242=(Hilton) Bold Sans ()
+200243=(Hilton) Ital Sans ()
+200244=(Hilton) Bold Ital Sans ()
+200251=(Progress) Sans ()
+200252=(Progress) Bold Sans ()
+200253=(Progress) Ital Sans ()
+200254=(Progress) Bold Ital Sans ()
+200261=(PrestigeElite) Sans ()
+200262=(PrestigeElite) Bold Sans ()
+200263=(PrestigeElite) Ital Sans ()
+200271=(Ovetti) Bold Sans ()
+200272=(Ovetti) Sans ()
+200301=(Cescendo) Sans ()
+200302=(Funky) Sans Decora ()
+200303=(Speed) Sans Decora ()
+200304=(Skyline) Sans Decora ()
+200305=(Calculator) Sans Decora ()
+200306=(Xpress) Sans Decora ()
+200307=(Console) Sans Decora ()
+200308=(Paisley) Sans ()
+200309=(Nova) Sans ()
+200310=(New York) Sans Decora ()
+200311=(Shanghai) Sans Decora ()
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_FilterConfigCache.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_FilterConfigCache.cxx
new file mode 100644
index 000000000000..9564fbde0cb0
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_FilterConfigCache.cxx
@@ -0,0 +1,618 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 "FilterConfigCache.hxx"
+#include <bf_svtools/filter.hxx>
+#include <tools/debug.hxx>
+#include <tools/string.hxx>
+#include <rtl/ustring.hxx>
+
+#include <com/sun/star/uno/Any.h>
+#include <unotools/processfactory.hxx>
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#define TOKEN_COUNT_FOR_OWN_FILTER 3
+// #define TOKEN_INDEX_FOR_IDENT 0
+#define TOKEN_INDEX_FOR_FILTER 1
+// #define TOKEN_INDEX_FOR_HASDIALOG 2
+
+using namespace ::com::sun::star::lang ; // XMultiServiceFactory
+using namespace ::com::sun::star::container ; // XNameAccess
+using namespace ::com::sun::star::uno ; // Reference
+using namespace ::com::sun::star::beans ; // PropertyValue
+using namespace ::utl ; // getProcessServiceFactory();
+using namespace ::rtl ;
+
+namespace binfilter
+{
+
+const char* FilterConfigCache::FilterConfigCacheEntry::InternalPixelFilterNameList[] =
+{
+ IMP_BMP, IMP_GIF, IMP_PNG,IMP_JPEG, IMP_XBM, IMP_XPM,
+ EXP_BMP, EXP_JPEG, EXP_PNG, NULL
+};
+
+const char* FilterConfigCache::FilterConfigCacheEntry::InternalVectorFilterNameList[] =
+{
+ IMP_SVMETAFILE, IMP_WMF, IMP_EMF, IMP_SVSGF, IMP_SVSGV,
+ EXP_SVMETAFILE, EXP_WMF, EXP_EMF, EXP_SVG, NULL
+};
+
+const char* FilterConfigCache::FilterConfigCacheEntry::ExternalPixelFilterNameList[] =
+{
+ "egi", "icd", "ipd", "ipx", "ipb", "epb", "epg",
+ "epp", "ira", "era", "itg", "iti", "eti", "exp", NULL
+};
+
+sal_Bool FilterConfigCache::bInitialized = sal_False;
+sal_Int32 FilterConfigCache::nIndType = -1;
+sal_Int32 FilterConfigCache::nIndUIName = -1;
+sal_Int32 FilterConfigCache::nIndDocumentService = -1;
+sal_Int32 FilterConfigCache::nIndFilterService = -1;
+sal_Int32 FilterConfigCache::nIndFlags = -1;
+sal_Int32 FilterConfigCache::nIndUserData = -1;
+sal_Int32 FilterConfigCache::nIndFileFormatVersion = -1;
+sal_Int32 FilterConfigCache::nIndTemplateName = -1;
+
+sal_Bool FilterConfigCache::FilterConfigCacheEntry::CreateFilterName( const OUString& rUserDataEntry )
+{
+ bIsPixelFormat = bIsInternalFilter = sal_False;
+ sFilterName = String( rUserDataEntry );
+ const char** pPtr;
+ for ( pPtr = InternalPixelFilterNameList; *pPtr && ( bIsInternalFilter == sal_False ); pPtr++ )
+ {
+ if ( sFilterName.EqualsIgnoreCaseAscii( *pPtr ) )
+ {
+ bIsInternalFilter = sal_True;
+ bIsPixelFormat = sal_True;
+ }
+ }
+ for ( pPtr = InternalVectorFilterNameList; *pPtr && ( bIsInternalFilter == sal_False ); pPtr++ )
+ {
+ if ( sFilterName.EqualsIgnoreCaseAscii( *pPtr ) )
+ bIsInternalFilter = sal_True;
+ }
+ if ( !bIsInternalFilter )
+ {
+ for ( pPtr = ExternalPixelFilterNameList; *pPtr && ( bIsPixelFormat == sal_False ); pPtr++ )
+ {
+ if ( sFilterName.EqualsIgnoreCaseAscii( *pPtr ) )
+ bIsPixelFormat = sal_True;
+ }
+ String aTemp( OUString::createFromAscii( SVLIBRARY( "?" ) ) );
+ xub_StrLen nIndex = aTemp.Search( (sal_Unicode)'?' );
+ aTemp.Replace( nIndex, 1, sFilterName );
+ sFilterName = aTemp;
+ }
+ return sFilterName.Len() != 0;
+}
+
+String FilterConfigCache::FilterConfigCacheEntry::GetShortName()
+{
+ String aShortName;
+ if ( lExtensionList.getLength() )
+ {
+ aShortName = lExtensionList[ 0 ];
+ if ( aShortName.SearchAscii( "*.", 0 ) == 0 )
+ aShortName.Erase( 0, 2 );
+ }
+ return aShortName;
+}
+
+/** helper to open the configuration root of the underlying
+ config package
+
+ @param sPackage
+ specify, which config package should be opened.
+ Must be one of the defined static values TYPEPKG or FILTERPKG.
+
+ @return A valid object if open was successfull. The access on opened
+ data will be readonly. It returns NULL in case open failed.
+
+ @throws It let pass RuntimeExceptions only.
+ */
+Reference< XInterface > openConfig(const char* sPackage)
+ throw(RuntimeException)
+{
+ static OUString TYPEPKG( RTL_CONSTASCII_USTRINGPARAM( "types" ) );
+ static OUString FILTERPKG( RTL_CONSTASCII_USTRINGPARAM( "filters" ) );
+
+ Reference< XMultiServiceFactory > xSMGR = getProcessServiceFactory();
+ Reference< XInterface > xCfg;
+ try
+ {
+ // get access to config API (not to file!)
+ Reference< XMultiServiceFactory > xConfigProvider( xSMGR->createInstance(
+ OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")), UNO_QUERY);
+
+ if (xConfigProvider.is())
+ {
+ Sequence< Any > lParams(1);
+ PropertyValue aParam ;
+
+ // define cfg path for open
+ aParam.Name = OUString::createFromAscii("nodepath");
+ if (TYPEPKG.equalsIgnoreAsciiCaseAscii(sPackage))
+ aParam.Value <<= OUString::createFromAscii("/org.openoffice.TypeDetection.Types/Types");
+ if (FILTERPKG.equalsIgnoreAsciiCaseAscii(sPackage))
+ aParam.Value <<= OUString::createFromAscii("/org.openoffice.TypeDetection.GraphicFilter/Filters");
+ lParams[0] = makeAny(aParam);
+
+ // get access to file
+ xCfg = xConfigProvider->createInstanceWithArguments(
+ OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"), lParams);
+ }
+ }
+ catch(const RuntimeException&)
+ { throw; }
+ catch(const Exception&)
+ { xCfg.clear(); }
+
+ return xCfg;
+}
+
+void FilterConfigCache::ImplInit()
+{
+ static OUString STYPE ( RTL_CONSTASCII_USTRINGPARAM( "Type" ) );
+ static OUString SUINAME ( RTL_CONSTASCII_USTRINGPARAM( "UIName" ) );
+ static OUString SDOCUMENTSERVICE ( RTL_CONSTASCII_USTRINGPARAM( "DocumentService" ) );
+ static OUString SFILTERSERVICE ( RTL_CONSTASCII_USTRINGPARAM( "FilterService" ) );
+ static OUString STEMPLATENAME ( RTL_CONSTASCII_USTRINGPARAM( "TemplateName" ) );
+ static OUString SFILEFORMATVERSION ( RTL_CONSTASCII_USTRINGPARAM( "FileFormatVersion" ) );
+ static OUString SUICOMPONENT ( RTL_CONSTASCII_USTRINGPARAM( "UIComponent" ) );
+ static OUString SFLAGS ( RTL_CONSTASCII_USTRINGPARAM( "Flags" ) );
+ static OUString SUSERDATA ( RTL_CONSTASCII_USTRINGPARAM( "UserData" ) );
+ static OUString SMEDIATYPE ( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) );
+ static OUString SEXTENSIONS ( RTL_CONSTASCII_USTRINGPARAM( "Extensions" ) );
+ static OUString SFORMATNAME ( RTL_CONSTASCII_USTRINGPARAM( "FormatName" ) );
+ static OUString SREALFILTERNAME ( RTL_CONSTASCII_USTRINGPARAM( "RealFilterName" ) );
+
+ // get access to config
+ Reference< XNameAccess > xTypeAccess ( openConfig("types" ), UNO_QUERY );
+ Reference< XNameAccess > xFilterAccess( openConfig("filters"), UNO_QUERY );
+
+ if ( xTypeAccess.is() && xFilterAccess.is() )
+ {
+ Sequence< OUString > lAllFilter = xFilterAccess->getElementNames();
+ sal_Int32 nAllFilterCount = lAllFilter.getLength();
+
+ for ( sal_Int32 i = 0; i < nAllFilterCount; i++ )
+ {
+ OUString sInternalFilterName = lAllFilter[ i ];
+ Reference< XPropertySet > xFilterSet;
+ xFilterAccess->getByName( sInternalFilterName ) >>= xFilterSet;
+ if (!xFilterSet.is())
+ continue;
+
+ FilterConfigCacheEntry aEntry;
+
+ aEntry.sInternalFilterName = sInternalFilterName;
+ xFilterSet->getPropertyValue(STYPE) >>= aEntry.sType;
+ xFilterSet->getPropertyValue(SUINAME) >>= aEntry.sUIName;
+ xFilterSet->getPropertyValue(SREALFILTERNAME) >>= aEntry.sFilterType;
+ Sequence< OUString > lFlags;
+ xFilterSet->getPropertyValue(SFLAGS) >>= lFlags;
+ if (lFlags.getLength()!=1 || !lFlags[0].getLength())
+ continue;
+ if (lFlags[0].equalsIgnoreAsciiCaseAscii("import"))
+ aEntry.nFlags = 1;
+ else
+ if (lFlags[0].equalsIgnoreAsciiCaseAscii("export"))
+ aEntry.nFlags = 2;
+
+ OUString sUIComponent;
+ xFilterSet->getPropertyValue(SUICOMPONENT) >>= sUIComponent;
+ aEntry.bHasDialog = sUIComponent.getLength();
+
+ ::rtl::OUString sFormatName;
+ xFilterSet->getPropertyValue(SFORMATNAME) >>= sFormatName;
+ aEntry.CreateFilterName( sFormatName );
+
+ Reference< XPropertySet > xTypeSet;
+ xTypeAccess->getByName( aEntry.sType ) >>= xTypeSet;
+ if (!xTypeSet.is())
+ continue;
+
+ xTypeSet->getPropertyValue(SMEDIATYPE) >>= aEntry.sMediaType;
+ xTypeSet->getPropertyValue(SEXTENSIONS) >>= aEntry.lExtensionList;
+
+ // The first extension will be used
+ // to generate our internal FilterType ( BMP, WMF ... )
+ String aExtension( aEntry.GetShortName() );
+ if (aExtension.Len() != 3)
+ continue;
+
+ if ( aEntry.nFlags & 1 )
+ aImport.push_back( aEntry );
+ if ( aEntry.nFlags & 2 )
+ aExport.push_back( aEntry );
+
+ // bFilterEntryCreated!?
+ if (!( aEntry.nFlags & 3 ))
+ continue; //? Entry was already inserted ... but following code will be supressed?!
+ }
+ }
+};
+
+const char* FilterConfigCache::InternalFilterListForSvxLight[] =
+{
+ "bmp","1","SVBMP",
+ "bmp","2","SVBMP",
+ "dxf","1","idx",
+ "eps","1","ips",
+ "eps","2","eps",
+ "gif","1","SVIGIF",
+ "gif","2","egi",
+ "jpg","1","SVIJPEG",
+ "jpg","2","SVEJPEG",
+ "sgv","1","SVSGV",
+ "sgf","1","SVSGF",
+ "met","1","ime",
+ "met","2","eme",
+ "png","1","SVIPNG",
+ "png","2","SVEPNG",
+ "pct","1","ipt",
+ "pct","2","ept",
+ "pcd","1","icd",
+ "psd","1","ipd",
+ "pcx","1","ipx",
+ "pbm","1","ipb",
+ "pbm","2","epb",
+ "pgm","1","ipb",
+ "pgm","2","epg",
+ "ppm","1","ipb",
+ "ppm","2","epp",
+ "ras","1","ira",
+ "ras","2","era",
+ "svm","1","SVMETAFILE",
+ "svm","2","SVMETAFILE",
+ "tga","1","itg",
+ "tif","1","iti",
+ "tif","2","eti",
+ "emf","1","SVEMF",
+ "emf","2","SVEMF",
+ "wmf","1","SVWMF",
+ "wmf","2","SVWMF",
+ "xbm","1","SVIXBM",
+ "xpm","1","SVIXPM",
+ "xpm","2","exp",
+ "svg","2","SVESVG",
+ NULL
+};
+
+void FilterConfigCache::ImplInitSmart()
+{
+ const char** pPtr;
+ for ( pPtr = InternalFilterListForSvxLight; *pPtr; pPtr++ )
+ {
+ FilterConfigCacheEntry aEntry;
+
+ OUString sExtension( OUString::createFromAscii( *pPtr++ ) );
+
+ aEntry.lExtensionList.realloc( 1 );
+ aEntry.lExtensionList[ 0 ] = sExtension;
+
+ aEntry.sType = sExtension;
+ aEntry.sUIName = sExtension;
+
+ ByteString sFlags( *pPtr++ );
+ aEntry.nFlags = sFlags.ToInt32();
+
+ OUString sUserData( OUString::createFromAscii( *pPtr ) );
+ aEntry.CreateFilterName( sUserData );
+
+ if ( aEntry.nFlags & 1 )
+ aImport.push_back( aEntry );
+ if ( aEntry.nFlags & 2 )
+ aExport.push_back( aEntry );
+ }
+}
+
+// ------------------------------------------------------------------------
+
+FilterConfigCache::FilterConfigCache( sal_Bool bConfig ) :
+ bUseConfig ( bConfig )
+{
+ if ( bUseConfig )
+ ImplInit();
+ else
+ ImplInitSmart();
+}
+
+FilterConfigCache::~FilterConfigCache()
+{
+
+}
+
+String FilterConfigCache::GetImportFilterName( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aImport.begin() + nFormat );
+ return ( aIter < aImport.end() ) ? aIter->sFilterName : String();
+}
+
+sal_uInt16 FilterConfigCache::GetImportFormatNumber( const String& rFormatName )
+{
+ CacheVector::iterator aIter( aImport.begin() );
+ while ( aIter != aImport.end() )
+ {
+ if ( aIter->sUIName.equalsIgnoreAsciiCase( rFormatName ) )
+ break;
+ aIter++;
+ }
+ return sal::static_int_cast< sal_uInt16 >(aIter == aImport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aImport.begin());
+}
+
+sal_uInt16 FilterConfigCache::GetImportFormatNumberForMediaType( const String& rMediaType )
+{
+ CacheVector::iterator aIter( aImport.begin() );
+ while ( aIter != aImport.end() )
+ {
+ if ( aIter->sMediaType.equalsIgnoreAsciiCase( rMediaType ) )
+ break;
+ aIter++;
+ }
+ return sal::static_int_cast< sal_uInt16 >(aIter == aImport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aImport.begin());
+}
+
+sal_uInt16 FilterConfigCache::GetImportFormatNumberForShortName( const String& rShortName )
+{
+ CacheVector::iterator aIter( aImport.begin() );
+ while ( aIter != aImport.end() )
+ {
+ if ( aIter->GetShortName().EqualsIgnoreCaseAscii( rShortName ) )
+ break;
+ aIter++;
+ }
+ return sal::static_int_cast< sal_uInt16 >(aIter == aImport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aImport.begin());
+}
+
+sal_uInt16 FilterConfigCache::GetImportFormatNumberForTypeName( const String& rType )
+{
+ CacheVector::iterator aIter( aImport.begin() );
+ while ( aIter != aImport.end() )
+ {
+ if ( aIter->sType.equalsIgnoreAsciiCase( rType ) )
+ break;
+ aIter++;
+ }
+ return sal::static_int_cast< sal_uInt16 >(aIter == aImport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aImport.begin());
+}
+
+String FilterConfigCache::GetImportFormatName( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aImport.begin() + nFormat );
+ String aUIName;
+ if ( aIter < aImport.end() )
+ aUIName = aIter->sUIName;
+ return aUIName;
+}
+
+String FilterConfigCache::GetImportFormatMediaType( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aImport.begin() + nFormat );
+ String aMediaType;
+ if ( aIter < aImport.end() )
+ aMediaType = aIter->sMediaType;
+ return aMediaType;
+}
+
+String FilterConfigCache::GetImportFormatShortName( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aImport.begin() + nFormat );
+ String aType;
+ if ( aIter < aImport.end() )
+ aType = aIter->GetShortName();
+ aType.ToUpperAscii();
+ return aType;
+}
+
+String FilterConfigCache::GetImportFormatExtension( sal_uInt16 nFormat, sal_Int32 nEntry )
+{
+ CacheVector::iterator aIter( aImport.begin() + nFormat );
+ String aExtension;
+ if ( aIter < aImport.end() )
+ {
+ if ( nEntry < aIter->lExtensionList.getLength() )
+ aExtension = aIter->lExtensionList[ nEntry ];
+ }
+ return aExtension;
+}
+
+String FilterConfigCache::GetImportFilterType( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aImport.begin() + nFormat );
+ String aType;
+ if ( aIter < aImport.end() )
+ aType = aIter->sType;
+ return aType;
+}
+
+String FilterConfigCache::GetImportFilterTypeName( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aImport.begin() + nFormat );
+ String aFilterType;
+ if ( aIter < aImport.end() )
+ aFilterType = aIter->sFilterType;
+ return aFilterType;
+}
+
+String FilterConfigCache::GetImportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry )
+{
+ String aWildcard( GetImportFormatExtension( nFormat, nEntry ) );
+ if ( aWildcard.Len() )
+ aWildcard.Insert( UniString::CreateFromAscii( "*.", 2 ), 0 );
+ return aWildcard;
+}
+
+sal_Bool FilterConfigCache::IsImportInternalFilter( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aImport.begin() + nFormat );
+ return ( aIter < aImport.end() ) ? aIter->bIsInternalFilter != 0 : sal_False;
+}
+
+sal_Bool FilterConfigCache::IsImportPixelFormat( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aImport.begin() + nFormat );
+ return ( aIter < aImport.end() ) ? aIter->bIsPixelFormat != 0 : sal_False;
+}
+
+// ------------------------------------------------------------------------
+
+String FilterConfigCache::GetExportFilterName( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aExport.begin() + nFormat );
+ return ( aIter < aExport.end() ) ? aIter->sFilterName : String();
+}
+
+sal_uInt16 FilterConfigCache::GetExportFormatNumber( const String& rFormatName )
+{
+ CacheVector::iterator aIter( aExport.begin() );
+ while ( aIter != aExport.end() )
+ {
+ if ( aIter->sUIName.equalsIgnoreAsciiCase( rFormatName ) )
+ break;
+ aIter++;
+ }
+ return sal::static_int_cast< sal_uInt16 >(aIter == aExport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aExport.begin());
+}
+
+sal_uInt16 FilterConfigCache::GetExportFormatNumberForMediaType( const String& rMediaType )
+{
+ CacheVector::iterator aIter( aExport.begin() );
+ while ( aIter != aExport.end() )
+ {
+ if ( aIter->sMediaType.equalsIgnoreAsciiCase( rMediaType ) )
+ break;
+ aIter++;
+ }
+ return sal::static_int_cast< sal_uInt16 >(aIter == aExport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aExport.begin());
+}
+
+sal_uInt16 FilterConfigCache::GetExportFormatNumberForShortName( const String& rShortName )
+{
+ CacheVector::iterator aIter( aExport.begin() );
+ while ( aIter != aExport.end() )
+ {
+ if ( aIter->GetShortName().EqualsIgnoreCaseAscii( rShortName ) )
+ break;
+ aIter++;
+ }
+ return sal::static_int_cast< sal_uInt16 >(aIter == aExport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aExport.begin());
+}
+
+sal_uInt16 FilterConfigCache::GetExportFormatNumberForTypeName( const String& rType )
+{
+ CacheVector::iterator aIter( aExport.begin() );
+ while ( aIter != aExport.end() )
+ {
+ if ( aIter->sType.equalsIgnoreAsciiCase( rType ) )
+ break;
+ aIter++;
+ }
+ return sal::static_int_cast< sal_uInt16 >(aIter == aExport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aExport.begin());
+}
+
+String FilterConfigCache::GetExportFormatName( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aExport.begin() + nFormat );
+ String aUIName;
+ if ( aIter < aExport.end() )
+ aUIName = aIter->sUIName;
+ return aUIName;
+}
+
+String FilterConfigCache::GetExportFormatMediaType( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aExport.begin() + nFormat );
+ String aMediaType;
+ if ( aIter < aExport.end() )
+ aMediaType = aIter->sMediaType;
+ return aMediaType;
+}
+
+String FilterConfigCache::GetExportFormatShortName( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aExport.begin() + nFormat );
+ String aType;
+ if ( aIter < aExport.end() )
+ aType = aIter->GetShortName();
+ aType.ToUpperAscii();
+ return aType;
+}
+
+String FilterConfigCache::GetExportFormatExtension( sal_uInt16 nFormat, sal_Int32 nEntry )
+{
+ CacheVector::iterator aIter( aExport.begin() + nFormat );
+ String aExtension;
+ if ( aIter < aExport.end() )
+ {
+ if ( nEntry < aIter->lExtensionList.getLength() )
+ aExtension = aIter->lExtensionList[ nEntry ];
+ }
+ return aExtension;
+}
+
+String FilterConfigCache::GetExportFilterTypeName( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aExport.begin() + nFormat );
+ String aFilterType;
+ if ( aIter < aExport.end() )
+ aFilterType = aIter->sFilterType;
+ return aFilterType;
+}
+
+String FilterConfigCache::GetExportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry )
+{
+ String aWildcard( GetExportFormatExtension( nFormat, nEntry ) );
+ if ( aWildcard.Len() )
+ aWildcard.Insert( UniString::CreateFromAscii( "*.", 2 ), 0 );
+ return aWildcard;
+}
+
+sal_Bool FilterConfigCache::IsExportInternalFilter( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aExport.begin() + nFormat );
+ return ( aIter < aExport.end() ) ? aIter->bIsInternalFilter != 0 : sal_False;
+}
+
+sal_Bool FilterConfigCache::IsExportPixelFormat( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aExport.begin() + nFormat );
+ return ( aIter < aExport.end() ) ? aIter->bIsPixelFormat != 0 : sal_False;
+}
+
+
+// ------------------------------------------------------------------------
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_FilterConfigItem.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_FilterConfigItem.cxx
new file mode 100644
index 000000000000..1f211613ebc7
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_FilterConfigItem.cxx
@@ -0,0 +1,383 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/string.hxx>
+#include <bf_svtools/FilterConfigItem.hxx>
+#include <tools/debug.hxx>
+#include <unotools/configmgr.hxx>
+#include <unotools/processfactory.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/XChangesBatch.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+
+using namespace ::rtl;
+using namespace ::utl ; // getProcessServiceFactory
+using namespace ::com::sun::star::lang ; // XMultiServiceFactory
+using namespace ::com::sun::star::beans ; // PropertyValue
+using namespace ::com::sun::star::uno ; // Reference
+using namespace ::com::sun::star::util ; // XChangesBatch
+using namespace ::com::sun::star::awt ; // Size
+using namespace ::com::sun::star::container ; //
+using namespace ::com::sun::star::task ; // XStatusIndicator
+
+namespace binfilter
+{
+
+static sal_Bool ImpIsTreeAvailable( Reference< XMultiServiceFactory >& rXCfgProv, const String& rTree )
+{
+ sal_Bool bAvailable = rTree.Len() != 0;
+ if ( bAvailable )
+ {
+ xub_StrLen nTokenCount = rTree.GetTokenCount( (sal_Unicode)'/' );
+ xub_StrLen i = 0;
+
+ if ( rTree.GetChar( 0 ) == (sal_Unicode)'/' )
+ i++;
+ if ( rTree.GetChar( rTree.Len() - 1 ) == (sal_Unicode)'/' )
+ nTokenCount--;
+
+ Any aAny;
+ aAny <<= (OUString)rTree.GetToken( i++, (sal_Unicode)'/' );
+
+ // creation arguments: nodepath
+ PropertyValue aPathArgument;
+ aPathArgument.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) );
+ aPathArgument.Value = aAny;
+
+ Sequence< Any > aArguments( 1 );
+ aArguments[ 0 ] <<= aPathArgument;
+
+ Reference< XInterface > xReadAccess;
+ try
+ {
+ xReadAccess = rXCfgProv->createInstanceWithArguments(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" ) ),
+ aArguments );
+ }
+ catch ( ::com::sun::star::uno::Exception& )
+ {
+ bAvailable = sal_False;
+ }
+ if ( xReadAccess.is() )
+ {
+ for ( ; bAvailable && ( i < nTokenCount ); i++ )
+ {
+ Reference< XHierarchicalNameAccess > xHierarchicalNameAccess
+ ( xReadAccess, UNO_QUERY );
+
+ if ( !xHierarchicalNameAccess.is() )
+ bAvailable = sal_False;
+ else
+ {
+ String aNode( rTree.GetToken( i, (sal_Unicode)'/' ) );
+ if ( !xHierarchicalNameAccess->hasByHierarchicalName( aNode ) )
+ bAvailable = sal_False;
+ else
+ {
+ Any a( xHierarchicalNameAccess->getByHierarchicalName( aNode ) );
+ try
+ {
+ a >>= xReadAccess;
+ }
+ catch ( ::com::sun::star::uno::Exception& )
+ {
+ bAvailable = sal_False;
+ }
+ }
+ }
+ }
+ }
+ }
+ return bAvailable;
+}
+
+void FilterConfigItem::ImpInitTree( const String& rSubTree )
+{
+ bModified = sal_False;
+
+ OUString sTree( ConfigManager::GetConfigBaseURL() );
+ sTree += rSubTree;
+ Reference< XMultiServiceFactory > xSMGR = getProcessServiceFactory(); // get global uno service manager
+
+ Reference< XMultiServiceFactory > xCfgProv(
+ xSMGR->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ) ),
+ UNO_QUERY );
+
+ if ( xCfgProv.is() )
+ {
+ if ( ImpIsTreeAvailable( xCfgProv, String( sTree ) ) )
+ {
+ Any aAny;
+ // creation arguments: nodepath
+ PropertyValue aPathArgument;
+ aAny <<= sTree;
+ aPathArgument.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) );
+ aPathArgument.Value = aAny;
+
+ // creation arguments: commit mode
+ PropertyValue aModeArgument;
+ sal_Bool bAsyncron = sal_True;
+ aAny <<= bAsyncron;
+ aModeArgument.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "lazywrite" ) );
+ aModeArgument.Value = aAny;
+
+ Sequence< Any > aArguments( 2 );
+ aArguments[ 0 ] <<= aPathArgument;
+ aArguments[ 1 ] <<= aModeArgument;
+
+ try
+ {
+ xUpdatableView = xCfgProv->createInstanceWithArguments(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ),
+ aArguments );
+ if ( xUpdatableView.is() )
+ xPropSet = Reference< XPropertySet >( xUpdatableView, UNO_QUERY );
+ }
+ catch ( ::com::sun::star::uno::Exception& )
+ {
+ DBG_ERROR( "FilterConfigItem::FilterConfigItem - Could not access configuration Key" );
+ }
+ }
+ }
+}
+
+FilterConfigItem::FilterConfigItem( const OUString& rSubTree )
+{
+ ImpInitTree( rSubTree );
+}
+
+FilterConfigItem::FilterConfigItem( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >* pFilterData )
+{
+ if ( pFilterData )
+ aFilterData = *pFilterData;
+}
+
+FilterConfigItem::~FilterConfigItem()
+{
+ if ( xUpdatableView.is() )
+ {
+ if ( xPropSet.is() && bModified )
+ {
+ Reference< XChangesBatch > xUpdateControl( xUpdatableView, UNO_QUERY );
+ if ( xUpdateControl.is() )
+ {
+ try
+ {
+ xUpdateControl->commitChanges();
+ }
+ catch ( ::com::sun::star::uno::Exception& )
+ {
+ DBG_ERROR( "FilterConfigItem::FilterConfigItem - Could not update configuration data" );
+ }
+ }
+ }
+ }
+}
+
+sal_Bool FilterConfigItem::ImplGetPropertyValue( Any& rAny, const Reference< XPropertySet >& rXPropSet, const OUString& rString, sal_Bool bTestPropertyAvailability )
+{
+ sal_Bool bRetValue = sal_True;
+
+ if ( rXPropSet.is() )
+ {
+ if ( bTestPropertyAvailability )
+ {
+ bRetValue = sal_False;
+ try
+ {
+ Reference< XPropertySetInfo >
+ aXPropSetInfo( rXPropSet->getPropertySetInfo() );
+ if ( aXPropSetInfo.is() )
+ bRetValue = aXPropSetInfo->hasPropertyByName( rString );
+ }
+ catch( ::com::sun::star::uno::Exception& )
+ {
+ //
+ }
+ }
+ if ( bRetValue )
+ {
+ try
+ {
+ rAny = rXPropSet->getPropertyValue( rString );
+ if ( !rAny.hasValue() )
+ bRetValue = sal_False;
+ }
+ catch( ::com::sun::star::uno::Exception& )
+ {
+ bRetValue = sal_False;
+ }
+ }
+ }
+ else
+ bRetValue = sal_False;
+ return bRetValue;
+}
+
+
+// if property is available it returns a pointer,
+// otherwise the result is null
+PropertyValue* FilterConfigItem::GetPropertyValue( Sequence< PropertyValue >& rPropSeq, const OUString& rName )
+{
+ PropertyValue* pPropValue = NULL;
+
+ sal_Int32 i, nCount;
+ for ( i = 0, nCount = rPropSeq.getLength(); i < nCount; i++ )
+ {
+ if ( rPropSeq[ i ].Name == rName )
+ {
+ pPropValue = &rPropSeq[ i ];
+ break;
+ }
+ }
+ return pPropValue;
+}
+
+/* if PropertySequence already includes a PropertyValue using the same name, the
+ corresponding PropertyValue is replaced, otherwise the given PropertyValue
+ will be appended */
+
+sal_Bool FilterConfigItem::WritePropertyValue( Sequence< PropertyValue >& rPropSeq, const PropertyValue& rPropValue )
+{
+ sal_Bool bRet = sal_False;
+ if ( rPropValue.Name.getLength() )
+ {
+ sal_Int32 i, nCount;
+ for ( i = 0, nCount = rPropSeq.getLength(); i < nCount; i++ )
+ {
+ if ( rPropSeq[ i ].Name == rPropValue.Name )
+ break;
+ }
+ if ( i == nCount )
+ rPropSeq.realloc( ++nCount );
+
+ rPropSeq[ i ] = rPropValue;
+
+ bRet = sal_True;
+ }
+ return bRet;
+}
+
+sal_Bool FilterConfigItem::ReadBool( const OUString& rKey, sal_Bool bDefault )
+{
+ Any aAny;
+ sal_Bool bRetValue = bDefault;
+ PropertyValue* pPropVal = GetPropertyValue( aFilterData, rKey );
+ if ( pPropVal )
+ {
+ pPropVal->Value >>= bRetValue;
+ }
+ else if ( ImplGetPropertyValue( aAny, xPropSet, rKey, sal_True ) )
+ {
+ aAny >>= bRetValue;
+ }
+ PropertyValue aBool;
+ aBool.Name = rKey;
+ aBool.Value <<= bRetValue;
+ WritePropertyValue( aFilterData, aBool );
+ return bRetValue;
+}
+
+sal_Int32 FilterConfigItem::ReadInt32( const OUString& rKey, sal_Int32 nDefault )
+{
+ Any aAny;
+ sal_Int32 nRetValue = nDefault;
+ PropertyValue* pPropVal = GetPropertyValue( aFilterData, rKey );
+ if ( pPropVal )
+ {
+ pPropVal->Value >>= nRetValue;
+ }
+ else if ( ImplGetPropertyValue( aAny, xPropSet, rKey, sal_True ) )
+ {
+ aAny >>= nRetValue;
+ }
+ PropertyValue aInt32;
+ aInt32.Name = rKey;
+ aInt32.Value <<= nRetValue;
+ WritePropertyValue( aFilterData, aInt32 );
+ return nRetValue;
+}
+
+void FilterConfigItem::WriteInt32( const OUString& rKey, sal_Int32 nNewValue )
+{
+ PropertyValue aInt32;
+ aInt32.Name = rKey;
+ aInt32.Value <<= nNewValue;
+ WritePropertyValue( aFilterData, aInt32 );
+
+ if ( xPropSet.is() )
+ {
+ Any aAny;
+
+ if ( ImplGetPropertyValue( aAny, xPropSet, rKey, sal_True ) )
+ {
+ sal_Int32 nOldValue;
+ if ( aAny >>= nOldValue )
+ {
+ if ( nOldValue != nNewValue )
+ {
+ aAny <<= nNewValue;
+ try
+ {
+ xPropSet->setPropertyValue( rKey, aAny );
+ bModified = sal_True;
+ }
+ catch ( ::com::sun::star::uno::Exception& )
+ {
+ DBG_ERROR( "FilterConfigItem::WriteInt32 - could not set PropertyValue" );
+ }
+ }
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+Reference< XStatusIndicator > FilterConfigItem::GetStatusIndicator() const
+{
+ Reference< XStatusIndicator > xStatusIndicator;
+ const rtl::OUString sStatusIndicator( RTL_CONSTASCII_USTRINGPARAM( "StatusIndicator" ) );
+
+ sal_Int32 i, nCount = aFilterData.getLength();
+ for ( i = 0; i < nCount; i++ )
+ {
+ if ( aFilterData[ i ].Name == sStatusIndicator )
+ {
+ aFilterData[ i ].Value >>= xStatusIndicator;
+ break;
+ }
+ }
+ return xStatusIndicator;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_filter.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_filter.cxx
new file mode 100644
index 000000000000..12766aa131fc
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_filter.cxx
@@ -0,0 +1,2019 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+#if defined UNX && defined ALPHA
+#include <fstream.hxx>
+#endif
+#include <osl/mutex.hxx>
+#include <comphelper/processfactory.hxx>
+#include <ucbhelper/content.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <tools/urlobj.hxx>
+#include <vcl/salctype.hxx>
+#include <vcl/pngread.hxx>
+#include <vcl/pngwrite.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/file.hxx>
+#include <bf_svtools/filter.hxx>
+#include "FilterConfigCache.hxx"
+#include <bf_svtools/FilterConfigItem.hxx>
+#include <bf_svtools/fltcall.hxx>
+#include <bf_svtools/wmf.hxx>
+#include "gifread.hxx"
+#include "jpeg.hxx"
+#include "xbmread.hxx"
+#include "xpmread.hxx"
+#include <bf_svtools/solar.hrc>
+#include "sgffilt.hxx"
+#include "osl/module.hxx"
+
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/XWeak.hpp>
+#include <com/sun/star/uno/XAggregation.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/svg/XSVGWriter.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/ucb/CommandAbortedException.hpp>
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/localfilehelper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <rtl/bootstrap.hxx>
+#include <rtl/instance.hxx>
+
+#define PMGCHUNG_msOG 0x6d734f47 // Microsoft Office Animated GIF
+
+#if defined WIN || (defined OS2 && !defined ICC)
+
+#define IMPORT_FUNCTION_NAME "_GraphicImport"
+#define EXPORT_FUNCTION_NAME "_GraphicExport"
+#define IMPDLG_FUNCTION_NAME "_DoImportDialog"
+#define EXPDLG_FUNCTION_NAME "_DoExportDialog"
+
+#else
+
+#define IMPORT_FUNCTION_NAME "GraphicImport"
+#define EXPORT_FUNCTION_NAME "GraphicExport"
+#define IMPDLG_FUNCTION_NAME "DoImportDialog"
+#define EXPDLG_FUNCTION_NAME "DoExportDialog"
+
+#endif
+
+// Compilerfehler, wenn Optimierung bei WNT & MSC
+#ifdef _MSC_VER
+#pragma optimize( "", off )
+#endif
+
+// -----------
+// - statics -
+// -----------
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+namespace binfilter
+{
+
+static List* pFilterHdlList = NULL;
+
+static ::osl::Mutex& getListMutex()
+{
+ static ::osl::Mutex s_aListProtection;
+ return s_aListProtection;
+}
+
+static GraphicFilter* pGraphicFilter=0;
+
+// -------------------------
+// - ImpFilterOutputStream -
+// -------------------------
+
+class ImpFilterOutputStream : public ::cppu::WeakImplHelper1< ::com::sun::star::io::XOutputStream >
+{
+protected:
+
+ SvStream& mrStm;
+
+ virtual void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< sal_Int8 >& rData ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) { mrStm.Write( rData.getConstArray(), rData.getLength() ); }
+ virtual void SAL_CALL flush() throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) { mrStm.Flush(); }
+ virtual void SAL_CALL closeOutput() throw() {}
+
+public:
+
+ ImpFilterOutputStream( SvStream& rStm ) : mrStm( rStm ) {}
+ ~ImpFilterOutputStream() {}
+};
+
+BOOL ImplDirEntryHelper::Exists( const INetURLObject& rObj )
+{
+ BOOL bExists = FALSE;
+
+ try
+ {
+ ::rtl::OUString aTitle;
+ ::ucbhelper::Content aCnt( rObj.GetMainURL( INetURLObject::NO_DECODE ),
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() );
+
+ bExists = aCnt.isDocument();
+ }
+ catch( ::com::sun::star::ucb::CommandAbortedException& )
+ {
+ DBG_ERRORFILE( "CommandAbortedException" );
+ }
+ catch( ::com::sun::star::ucb::ContentCreationException& )
+ {
+ DBG_ERRORFILE( "ContentCreationException" );
+ }
+ catch( ... )
+ {
+// DBG_ERRORFILE( "Any other exception" );
+ }
+ return bExists;
+}
+
+// -----------------------------------------------------------------------------
+
+void ImplDirEntryHelper::Kill( const String& rMainUrl )
+{
+ try
+ {
+ ::ucbhelper::Content aCnt( rMainUrl,
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() );
+
+ aCnt.executeCommand( ::rtl::OUString::createFromAscii( "delete" ),
+ ::com::sun::star::uno::makeAny( sal_Bool( sal_True ) ) );
+ }
+ catch( ::com::sun::star::ucb::CommandAbortedException& )
+ {
+ DBG_ERRORFILE( "CommandAbortedException" );
+ }
+ catch( ... )
+ {
+ DBG_ERRORFILE( "Any other exception" );
+ }
+}
+
+// --------------------
+// - Helper functions -
+// --------------------
+
+//--------------------------------------------------------------------------
+
+BYTE* ImplSearchEntry( BYTE* pSource, BYTE* pDest, ULONG nComp, ULONG nSize )
+{
+ while ( nComp-- >= nSize )
+ {
+ ULONG i;
+ for ( i = 0; i < nSize; i++ )
+ {
+ if ( ( pSource[i]&~0x20 ) != ( pDest[i]&~0x20 ) )
+ break;
+ }
+ if ( i == nSize )
+ return pSource;
+ pSource++;
+ }
+ return NULL;
+}
+
+//--------------------------------------------------------------------------
+
+inline String ImpGetExtension( const String &rPath )
+{
+ String aExt;
+ INetURLObject aURL( rPath );
+ aExt = aURL.GetFileExtension().toAsciiUpperCase();
+ return aExt;
+}
+
+/*************************************************************************
+|*
+|* ImpPeekGraphicFormat()
+|*
+|* Beschreibung:
+|* Diese Funktion kann zweierlei:
+|* 1.) Datei anlesen, Dateiformat ermitteln
+|* Eingabe-prarameter:
+|* rPath - Dateipfad
+|* rFormatExtension - Inhalt egal
+|* bTest - setze FALSE
+|* Ausgabe-parameter:
+|* Funkionswert - TRUE wenn Erfolg
+|* rFormatExtension - Bei Erfolg: uebliche Dateiendung
+|* des Formats (Grossbuchstaben)
+|* 2.) Datei anlesen, Dateiformat ueberpruefen
+|* Eingabe-prarameter:
+|* rPath - Dateipfad
+|* rFormatExtension - uebliche Dateiendung des Formats
+|* (Grossbuchstaben)
+|* bTest - setze TRUE
+|* Ausgabe-parameter:
+|* Funkionswert - FALSE, wenn die Datei bestimmt nicht
+|* vom uebgebenen Format ist.
+|* TRUE, wenn die Datei WAHRSCHEINLICH von
+|* dem Format ist, ODER WENN DAS FORMAT
+|* DIESER FUNKTION NICHT BEKANNT IST!
+|*
+|* Ersterstellung OH 26.05.95
+|* Letzte Aenderung OH 07.08.95
+|*
+*************************************************************************/
+
+static BOOL ImpPeekGraphicFormat( SvStream& rStream, String& rFormatExtension, BOOL bTest )
+{
+ USHORT i;
+ BYTE sFirstBytes[ 256 ];
+ ULONG nFirstLong,nSecondLong;
+ ULONG nStreamPos = rStream.Tell();
+
+ rStream.Seek( STREAM_SEEK_TO_END );
+ ULONG nStreamLen = rStream.Tell() - nStreamPos;
+ rStream.Seek( nStreamPos );
+
+ if ( !nStreamLen )
+ {
+ SvLockBytes* pLockBytes = rStream.GetLockBytes();
+ if ( pLockBytes )
+ pLockBytes->SetSynchronMode( TRUE );
+
+ rStream.Seek( STREAM_SEEK_TO_END );
+ nStreamLen = rStream.Tell() - nStreamPos;
+ rStream.Seek( nStreamPos );
+ }
+ // Die ersten 256 Bytes in einen Buffer laden:
+ if( nStreamLen >= 256 )
+ rStream.Read( sFirstBytes, 256 );
+ else
+ {
+ rStream.Read( sFirstBytes, nStreamLen );
+
+ for( i = (USHORT) nStreamLen; i < 256; i++ )
+ sFirstBytes[ i ]=0;
+ }
+
+ if( rStream.GetError() )
+ return FALSE;
+
+ // Die ersten 8 Bytes in nFirstLong, nSecondLong unterbringen,
+ // Big-Endian:
+ for( i = 0, nFirstLong = 0L, nSecondLong = 0L; i < 4; i++ )
+ {
+ nFirstLong=(nFirstLong<<8)|(ULONG)sFirstBytes[i];
+ nSecondLong=(nSecondLong<<8)|(ULONG)sFirstBytes[i+4];
+ }
+
+ // Folgende Variable ist nur bei bTest==TRUE interessant. Sie
+ // bleibt FALSE, wenn das Format (rFormatExtension) hier noch nicht
+ // einprogrammiert wurde.
+ BOOL bSomethingTested = FALSE;
+
+ // Nun werden die verschieden Formate ueberprueft. Dabei ist die
+ // Reihenfolge nicht egal. Z.b. koennte eine MET-Datei auch durch
+ // den BMP-Test gehen, umgekehrt kann eine BMP-Datei kaum durch den
+ // MET-Test gehen. Also sollte MET vor BMP getestet werden.
+ // Theoretisch waere aber vielleicht auch eine BMP-Datei denkbar,
+ // die durch den MET-Test geht.
+ // Diese Probleme gibt es natuerlich nicht nur bei MET und BMP.
+ // Deshalb wird im Falle der Uberpruefung eines Formats (bTest==TRUE)
+ // nur genau dieses eine Format getestet. Alles andere koennte fatale
+ // Folgen haben, z.B. wenn der Benutzer sagt, es sei BMP-Datei (und es
+ // ist BMP-Datei), und hier wuerde die Datei durch den MET-Test gehen...
+
+ //--------------------------- MET ------------------------------------
+ if( !bTest || ( rFormatExtension.CompareToAscii( "MET", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested=TRUE;
+ if( sFirstBytes[2] == 0xd3 )
+ {
+ rStream.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+ rStream.Seek( nStreamPos );
+ USHORT nFieldSize;
+ BYTE nMagic;
+ BOOL bOK=TRUE;
+ rStream >> nFieldSize >> nMagic;
+ for (i=0; i<3; i++) {
+ if (nFieldSize<6) { bOK=FALSE; break; }
+ if (nStreamLen < rStream.Tell() + nFieldSize ) { bOK=FALSE; break; }
+ rStream.SeekRel(nFieldSize-3);
+ rStream >> nFieldSize >> nMagic;
+ if (nMagic!=0xd3) { bOK=FALSE; break; }
+ }
+ rStream.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ if (bOK && !rStream.GetError()) {
+ rFormatExtension= UniString::CreateFromAscii( "MET", 3 );
+ return TRUE;
+ }
+ }
+ }
+
+ //--------------------------- BMP ------------------------------------
+ if( !bTest || ( rFormatExtension.CompareToAscii( "BMP", 3 ) == COMPARE_EQUAL ) )
+ {
+ BYTE nOffs;
+
+ bSomethingTested=TRUE;
+
+ // OS/2-Bitmaparray ('BA') koennen wir evtl. auch lesen,
+ // dementspr. muessen wir den Offset anpassen,
+ // um auf die erste Bitmap im Array zu stossen
+ if ( sFirstBytes[0] == 0x42 && sFirstBytes[1] == 0x41 )
+ nOffs = 14;
+ else
+ nOffs = 0;
+
+ // Jetzt testen wir zunaechst auf 'BM'
+ if ( sFirstBytes[0+nOffs]==0x42 && sFirstBytes[1+nOffs]==0x4d )
+ {
+ // unter OS/2 koennen die Reserved-Flags != 0 sein
+ // (was sie eigentlich nicht duerften);
+ // in diesem Fall testen wir die Groesse des BmpInfoHeaders
+ if ( ( sFirstBytes[6+nOffs]==0x00 &&
+ sFirstBytes[7+nOffs]==0x00 &&
+ sFirstBytes[8+nOffs]==0x00 &&
+ sFirstBytes[9+nOffs]==0x00 ) ||
+ sFirstBytes[14+nOffs] == 0x28 ||
+ sFirstBytes[14+nOffs] == 0x0c )
+ {
+ rFormatExtension = UniString::CreateFromAscii( "BMP", 3 );
+ return TRUE;
+ }
+ }
+ }
+
+ //--------------------------- WMF/EMF ------------------------------------
+
+ if( !bTest ||
+ ( rFormatExtension.CompareToAscii( "WMF", 3 ) == COMPARE_EQUAL ) ||
+ ( rFormatExtension.CompareToAscii( "EMF", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested = TRUE;
+
+ if ( nFirstLong==0xd7cdc69a || nFirstLong==0x01000900 )
+ {
+ rFormatExtension = UniString::CreateFromAscii( "WMF", 3 );
+ return TRUE;
+ }
+ else if( nFirstLong == 0x01000000 && sFirstBytes[ 40 ] == 0x20 && sFirstBytes[ 41 ] == 0x45 &&
+ sFirstBytes[ 42 ] == 0x4d && sFirstBytes[ 43 ] == 0x46 )
+ {
+ rFormatExtension = UniString::CreateFromAscii( "EMF", 3 );
+ return TRUE;
+ }
+ }
+
+ //--------------------------- PCX ------------------------------------
+ if( !bTest || ( rFormatExtension.CompareToAscii( "PCX", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested=TRUE;
+ if (sFirstBytes[0]==0x0a)
+ {
+ BYTE nVersion=sFirstBytes[1];
+ BYTE nEncoding=sFirstBytes[2];
+ if( ( nVersion==0 || nVersion==2 || nVersion==3 || nVersion==5 ) && nEncoding<=1 )
+ {
+ rFormatExtension = UniString::CreateFromAscii( "PCX", 3 );
+ return TRUE;
+ }
+ }
+ }
+
+ //--------------------------- TIF ------------------------------------
+ if( !bTest || ( rFormatExtension.CompareToAscii( "TIF", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested=TRUE;
+ if ( nFirstLong==0x49492a00 || nFirstLong==0x4d4d002a )
+ {
+ rFormatExtension=UniString::CreateFromAscii( "TIF", 3 );
+ return TRUE;
+ }
+ }
+
+ //--------------------------- GIF ------------------------------------
+ if( !bTest || ( rFormatExtension.CompareToAscii( "GIF", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested=TRUE;
+ if ( nFirstLong==0x47494638 && (sFirstBytes[4]==0x37 || sFirstBytes[4]==0x39) && sFirstBytes[5]==0x61 )
+ {
+ rFormatExtension = UniString::CreateFromAscii( "GIF", 3 );
+ return TRUE;
+ }
+ }
+
+ //--------------------------- PNG ------------------------------------
+ if( !bTest || ( rFormatExtension.CompareToAscii( "PNG", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested=TRUE;
+ if (nFirstLong==0x89504e47 && nSecondLong==0x0d0a1a0a)
+ {
+ rFormatExtension = UniString::CreateFromAscii( "PNG", 3 );
+ return TRUE;
+ }
+ }
+
+ //--------------------------- JPG ------------------------------------
+ if( !bTest || ( rFormatExtension.CompareToAscii( "JPG", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested=TRUE;
+ if ( ( nFirstLong==0xffd8ffe0 && sFirstBytes[6]==0x4a && sFirstBytes[7]==0x46 && sFirstBytes[8]==0x49 && sFirstBytes[9]==0x46 ) ||
+ ( nFirstLong==0xffd8fffe ) || ( 0xffd8ff00 == ( nFirstLong & 0xffffff00 ) ) )
+ {
+ rFormatExtension = UniString::CreateFromAscii( "JPG", 3 );
+ return TRUE;
+ }
+ }
+
+ //--------------------------- SVM ------------------------------------
+ if( !bTest || ( rFormatExtension.CompareToAscii( "SVM", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested=TRUE;
+ if( nFirstLong==0x53564744 && sFirstBytes[4]==0x49 )
+ {
+ rFormatExtension = UniString::CreateFromAscii( "SVM", 3 );
+ return TRUE;
+ }
+ else if( sFirstBytes[0]==0x56 && sFirstBytes[1]==0x43 && sFirstBytes[2]==0x4C &&
+ sFirstBytes[3]==0x4D && sFirstBytes[4]==0x54 && sFirstBytes[5]==0x46 )
+ {
+ rFormatExtension = UniString::CreateFromAscii( "SVM", 3 );
+ return TRUE;
+ }
+ }
+
+ //--------------------------- PCD ------------------------------------
+ if( !bTest || ( rFormatExtension.CompareToAscii( "PCD", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested = TRUE;
+ if( nStreamLen >= 2055 )
+ {
+ char sBuf[8];
+ rStream.Seek( nStreamPos + 2048 );
+ rStream.Read( sBuf, 7 );
+
+ if( strncmp( sBuf, "PCD_IPI", 7 ) == 0 )
+ {
+ rFormatExtension = UniString::CreateFromAscii( "PCD", 3 );
+ return TRUE;
+ }
+ }
+ }
+
+ //--------------------------- PSD ------------------------------------
+ if( !bTest || ( rFormatExtension.CompareToAscii( "PSD", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested = TRUE;
+ if ( ( nFirstLong == 0x38425053 ) && ( (nSecondLong >> 16 ) == 1 ) )
+ {
+ rFormatExtension = UniString::CreateFromAscii( "PSD", 3 );
+ return TRUE;
+ }
+ }
+
+ //--------------------------- EPS ------------------------------------
+ if( !bTest || ( rFormatExtension.CompareToAscii( "EPS", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested = TRUE;
+ if ( ( nFirstLong == 0xC5D0D3C6 ) || ( ImplSearchEntry( sFirstBytes, (BYTE*)"%!PS-Adobe", 10, 10 ) &&
+ ImplSearchEntry( &sFirstBytes[15], (BYTE*)"EPS", 3, 3 ) ) )
+ {
+ rFormatExtension = UniString::CreateFromAscii( "EPS", 3 );
+ return TRUE;
+ }
+ }
+
+ //--------------------------- DXF ------------------------------------
+ if( !bTest || ( rFormatExtension.CompareToAscii( "DXF", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested=TRUE;
+
+ i=0;
+ while (i<256 && sFirstBytes[i]<=32)
+ i++;
+
+ if (i<256)
+ {
+ if( sFirstBytes[i]=='0' )
+ i++;
+ else
+ i=256;
+ }
+ while( i<256 && sFirstBytes[i]<=32 )
+ i++;
+
+ if (i+7<256)
+ {
+ if (strncmp((char*)(sFirstBytes+i),"SECTION",7)==0)
+ {
+ rFormatExtension = UniString::CreateFromAscii( "DXF", 3 );
+ return TRUE;
+ }
+ }
+
+ if( strncmp( (char*) sFirstBytes, "AutoCAD Binary DXF", 18 ) == 0 )
+ {
+ rFormatExtension = UniString::CreateFromAscii( "DXF", 3 );
+ return TRUE;
+ }
+ }
+
+ //--------------------------- PCT ------------------------------------
+ if( !bTest || ( rFormatExtension.CompareToAscii( "PCT", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested = TRUE;
+ BYTE sBuf[4];
+ sal_uInt32 nOffset; // in ms documents the pict format is used without the first 512 bytes
+ for ( nOffset = 10; ( nOffset <= 522 ) && ( ( nStreamPos + nOffset + 3 ) <= nStreamLen ); nOffset += 512 )
+ {
+ rStream.Seek( nStreamPos + nOffset );
+ rStream.Read( sBuf,3 );
+ if ( sBuf[ 0 ] == 0x00 && sBuf[ 1 ] == 0x11 && ( sBuf[ 2 ] == 0x01 || sBuf[ 2 ] == 0x02 ) )
+ {
+ rFormatExtension = UniString::CreateFromAscii( "PCT", 3 );
+ return TRUE;
+ }
+ }
+ }
+
+ //------------------------- PBM + PGM + PPM ---------------------------
+ if( !bTest ||
+ ( rFormatExtension.CompareToAscii( "PBM", 3 ) == COMPARE_EQUAL ) ||
+ ( rFormatExtension.CompareToAscii( "PGM", 3 ) == COMPARE_EQUAL ) ||
+ ( rFormatExtension.CompareToAscii( "PPM", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested=TRUE;
+ if ( sFirstBytes[ 0 ] == 'P' )
+ {
+ switch( sFirstBytes[ 1 ] )
+ {
+ case '1' :
+ case '4' :
+ rFormatExtension = UniString::CreateFromAscii( "PBM", 3 );
+ return TRUE;
+
+ case '2' :
+ case '5' :
+ rFormatExtension = UniString::CreateFromAscii( "PGM", 3 );
+ return TRUE;
+
+ case '3' :
+ case '6' :
+ rFormatExtension = UniString::CreateFromAscii( "PPM", 3 );
+ return TRUE;
+ }
+ }
+ }
+
+ //--------------------------- RAS( SUN RasterFile )------------------
+ if( !bTest || ( rFormatExtension.CompareToAscii( "RAS", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested=TRUE;
+ if( nFirstLong == 0x59a66a95 )
+ {
+ rFormatExtension = UniString::CreateFromAscii( "RAS", 3 );
+ return TRUE;
+ }
+ }
+
+ //--------------------------- XPM ------------------------------------
+ if( !bTest )
+ {
+ bSomethingTested = TRUE;
+ if( ImplSearchEntry( sFirstBytes, (BYTE*)"/* XPM */", 256, 9 ) )
+ {
+ rFormatExtension = UniString::CreateFromAscii( "XPM", 3 );
+ return TRUE;
+ }
+ }
+ else if( rFormatExtension.CompareToAscii( "XPM", 3 ) == COMPARE_EQUAL )
+ {
+ bSomethingTested = TRUE;
+ return TRUE;
+ }
+
+ //--------------------------- XBM ------------------------------------
+ if( !bTest )
+ {
+ ULONG nSize = ( nStreamLen > 2048 ) ? 2048 : nStreamLen;
+ BYTE* pBuf = new BYTE [ nSize ];
+
+ rStream.Seek( nStreamPos );
+ rStream.Read( pBuf, nSize );
+ BYTE* pPtr = ImplSearchEntry( pBuf, (BYTE*)"#define", nSize, 7 );
+
+ if( pPtr )
+ {
+ if( ImplSearchEntry( pPtr, (BYTE*)"_width", pBuf + nSize - pPtr, 6 ) )
+ {
+ rFormatExtension = UniString::CreateFromAscii( "XBM", 3 );
+ delete[] pBuf;
+ return TRUE;
+ }
+ }
+ delete[] pBuf;
+ }
+ else if( rFormatExtension.CompareToAscii( "XBM", 3 ) == COMPARE_EQUAL )
+ {
+ bSomethingTested = TRUE;
+ return TRUE;
+ }
+
+ //--------------------------- TGA ------------------------------------
+ if( !bTest || ( rFormatExtension.CompareToAscii( "TGA", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested = TRUE;
+ if( rFormatExtension.CompareToAscii( "TGA", 3 ) == COMPARE_EQUAL )
+ return TRUE;
+ }
+
+ //--------------------------- SGV ------------------------------------
+ if( !bTest || ( rFormatExtension.CompareToAscii( "SGV", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested = TRUE;
+ if( rFormatExtension.CompareToAscii( "SGV", 3 ) == COMPARE_EQUAL )
+ return TRUE;
+ }
+
+ //--------------------------- SGF ------------------------------------
+ if( !bTest || ( rFormatExtension.CompareToAscii( "SGF", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested=TRUE;
+ if( sFirstBytes[ 0 ] == 'J' && sFirstBytes[ 1 ] == 'J' )
+ {
+ rFormatExtension = UniString::CreateFromAscii( "SGF", 3 );
+ return TRUE;
+ }
+ }
+
+ return bTest && !bSomethingTested;
+}
+
+//--------------------------------------------------------------------------
+
+sal_uInt16 GraphicFilter::ImpTestOrFindFormat( const String& rPath, SvStream& rStream, sal_uInt16& rFormat )
+{
+ sal_uInt16 n = pConfig->GetImportFormatCount();
+
+ // ggf. Filter bzw. Format durch anlesen ermitteln,
+ // oder durch anlesen zusichern, dass das Format stimmt:
+ if( rFormat == GRFILTER_FORMAT_DONTKNOW )
+ {
+ String aFormatExt;
+ if( ImpPeekGraphicFormat( rStream, aFormatExt, FALSE ) )
+ {
+ for( sal_uInt16 i = 0; i < n; i++ )
+ {
+ if( pConfig->GetImportFormatExtension( i ).EqualsIgnoreCaseAscii( aFormatExt ) )
+ {
+ rFormat = i;
+ return GRFILTER_OK;
+ }
+ }
+ }
+ // ggf. Filter anhand der Datei-Endung raussuchen:
+ if( rPath.Len() )
+ {
+ String aExt( ImpGetExtension( rPath ) );
+ for( sal_uInt16 i = 0; i < n; i++ )
+ {
+ if( pConfig->GetImportFormatExtension( i ).EqualsIgnoreCaseAscii( aExt ) )
+ {
+ rFormat = i;
+ return GRFILTER_OK;
+ }
+ }
+ }
+ return GRFILTER_FORMATERROR;
+ }
+ else
+ {
+ String aTmpStr( pConfig->GetImportFormatExtension( rFormat ) );
+ if( !ImpPeekGraphicFormat( rStream, aTmpStr, TRUE ) )
+ return GRFILTER_FORMATERROR;
+ if ( pConfig->GetImportFormatExtension( rFormat ).EqualsIgnoreCaseAscii( "pcd" ) )
+ {
+ sal_Int32 nBase = 2; // default Base0
+ if ( pConfig->GetImportFilterType( rFormat ).EqualsIgnoreCaseAscii( "pcd_Photo_CD_Base4" ) )
+ nBase = 1;
+ else if ( pConfig->GetImportFilterType( rFormat ).EqualsIgnoreCaseAscii( "pcd_Photo_CD_Base16" ) )
+ nBase = 0;
+ String aFilterConfigPath( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Filter/Graphic/Import/PCD" ) );
+ FilterConfigItem aFilterConfigItem( aFilterConfigPath );
+ aFilterConfigItem.WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Resolution" ) ), nBase );
+ }
+ }
+
+ return GRFILTER_OK;
+}
+
+//--------------------------------------------------------------------------
+
+static Graphic ImpGetScaledGraphic( const Graphic& rGraphic, FilterConfigItem& rConfigItem )
+{
+ Graphic aGraphic;
+
+ sal_Int32 nLogicalWidth = rConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "LogicalWidth" ) ), 0 );
+ sal_Int32 nLogicalHeight = rConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "LogicalHeight" ) ), 0 );
+
+ if ( rGraphic.GetType() != GRAPHIC_NONE )
+ {
+ sal_Int32 nMode = rConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "ExportMode" ) ), -1 );
+
+ if ( nMode == -1 ) // the property is not there, this is possible, if the graphic filter
+ { // is called via UnoGraphicExporter and not from a graphic export Dialog
+ nMode = 0; // then we are defaulting this mode to 0
+ if ( nLogicalWidth || nLogicalHeight )
+ nMode = 2;
+ }
+
+
+ Size aOriginalSize;
+ Size aPrefSize( rGraphic.GetPrefSize() );
+ MapMode aPrefMapMode( rGraphic.GetPrefMapMode() );
+ if ( aPrefMapMode == MAP_PIXEL )
+ aOriginalSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_100TH_MM );
+ else
+ aOriginalSize = Application::GetDefaultDevice()->LogicToLogic( aPrefSize, aPrefMapMode, MAP_100TH_MM );
+ if ( !nLogicalWidth )
+ nLogicalWidth = aOriginalSize.Width();
+ if ( !nLogicalHeight )
+ nLogicalHeight = aOriginalSize.Height();
+ if( rGraphic.GetType() == GRAPHIC_BITMAP )
+ {
+
+ // Aufloesung wird eingestellt
+ if( nMode == 1 )
+ {
+ Bitmap aBitmap( rGraphic.GetBitmap() );
+ MapMode aMap( MAP_100TH_INCH );
+
+ sal_Int32 nDPI = rConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Resolution" ) ), 75 );
+ Fraction aFrac( 1, Min( Max( nDPI, sal_Int32( 75 ) ), sal_Int32( 600 ) ) );
+
+ aMap.SetScaleX( aFrac );
+ aMap.SetScaleY( aFrac );
+
+ Size aOldSize = aBitmap.GetSizePixel();
+ aBitmap.SetPrefMapMode( aMap );
+ aBitmap.SetPrefSize( Size( aOldSize.Width() * 100,
+ aOldSize.Height() * 100 ) );
+
+ aGraphic = Graphic( aBitmap );
+ }
+ // Groesse wird eingestellt
+ else if( nMode == 2 )
+ {
+ BitmapEx aBitmapEx( rGraphic.GetBitmapEx() );
+ aBitmapEx.SetPrefMapMode( MapMode( MAP_100TH_MM ) );
+ aBitmapEx.SetPrefSize( Size( nLogicalWidth, nLogicalHeight ) );
+ aGraphic = Graphic( aBitmapEx );
+ }
+ else
+ aGraphic = rGraphic;
+
+ sal_Int32 nColors = rConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Color" ) ), 0 ); // #92767#
+ if ( nColors ) // graphic conversion necessary ?
+ {
+ BitmapEx aBmpEx( aGraphic.GetBitmapEx() );
+ aBmpEx.Convert( (BmpConversion)nColors ); // the entries in the xml section have the same meaning as
+ aGraphic = aBmpEx; // they have in the BmpConversion enum, so it should be
+ } // allowed to cast them
+ }
+ else
+ {
+ if( ( nMode == 1 ) || ( nMode == 2 ) )
+ {
+ GDIMetaFile aMtf( rGraphic.GetGDIMetaFile() );
+ ::com::sun::star::awt::Size aDefaultSize( 10000, 10000 );
+ Size aNewSize( OutputDevice::LogicToLogic( Size( nLogicalWidth, nLogicalHeight ), MAP_100TH_MM, aMtf.GetPrefMapMode() ) );
+
+ if( aNewSize.Width() && aNewSize.Height() )
+ {
+ const Size aPreferredSize( aMtf.GetPrefSize() );
+ aMtf.Scale( Fraction( aNewSize.Width(), aPreferredSize.Width() ),
+ Fraction( aNewSize.Height(), aPreferredSize.Height() ) );
+ }
+ aGraphic = Graphic( aMtf );
+ }
+ else
+ aGraphic = rGraphic;
+ }
+
+ }
+ else
+ aGraphic = rGraphic;
+
+ return aGraphic;
+}
+
+static String ImpCreateFullFilterPath( const String& rPath, const String& rFilterName )
+{
+ ::rtl::OUString aPathURL;
+
+ ::osl::FileBase::getFileURLFromSystemPath( rPath, aPathURL );
+ aPathURL += String( '/' );
+
+ ::rtl::OUString aSystemPath;
+ ::osl::FileBase::getSystemPathFromFileURL( aPathURL, aSystemPath );
+ aSystemPath += ::rtl::OUString( rFilterName );
+
+ return String( aSystemPath );
+}
+
+
+// --------------------------
+// - ImpFilterLibCacheEntry -
+// --------------------------
+
+class ImpFilterLibCache;
+
+struct ImpFilterLibCacheEntry
+{
+ ImpFilterLibCacheEntry* mpNext;
+ osl::Module maLibrary;
+ String maFiltername;
+ PFilterCall mpfnImport;
+ PFilterDlgCall mpfnImportDlg;
+
+ ImpFilterLibCacheEntry( const String& rPathname, const String& rFiltername );
+ int operator==( const String& rFiltername ) const { return maFiltername == rFiltername; }
+
+ PFilterCall GetImportFunction();
+ PFilterDlgCall GetImportDlgFunction();
+ PFilterCall GetExportFunction() { return (PFilterCall) maLibrary.getFunctionSymbol( UniString::CreateFromAscii( EXPORT_FUNCTION_NAME ) ); }
+ PFilterDlgCall GetExportDlgFunction() { return (PFilterDlgCall) maLibrary.getFunctionSymbol( UniString::CreateFromAscii( EXPDLG_FUNCTION_NAME ) ); }
+};
+
+// ------------------------------------------------------------------------
+
+ImpFilterLibCacheEntry::ImpFilterLibCacheEntry( const String& rPathname, const String& rFiltername ) :
+ mpNext ( NULL ),
+ maLibrary ( rPathname ),
+ maFiltername ( rFiltername ),
+ mpfnImport ( NULL ),
+ mpfnImportDlg ( NULL )
+{
+}
+
+// ------------------------------------------------------------------------
+
+PFilterCall ImpFilterLibCacheEntry::GetImportFunction()
+{
+ if( !mpfnImport )
+ mpfnImport = (PFilterCall) maLibrary.getFunctionSymbol( UniString::CreateFromAscii( IMPORT_FUNCTION_NAME ) );
+
+ return mpfnImport;
+}
+
+// ------------------------------------------------------------------------
+
+PFilterDlgCall ImpFilterLibCacheEntry::GetImportDlgFunction()
+{
+ if( !mpfnImportDlg )
+ mpfnImportDlg = (PFilterDlgCall)maLibrary.getFunctionSymbol( UniString::CreateFromAscii( IMPDLG_FUNCTION_NAME ) );
+
+ return mpfnImportDlg;
+}
+
+// ---------------------
+// - ImpFilterLibCache -
+// ---------------------
+
+class ImpFilterLibCache
+{
+ ImpFilterLibCacheEntry* mpFirst;
+ ImpFilterLibCacheEntry* mpLast;
+
+public:
+ ImpFilterLibCache();
+ ~ImpFilterLibCache();
+
+ ImpFilterLibCacheEntry* GetFilter( const String& rFilterPath, const String& rFiltername );
+};
+
+// ------------------------------------------------------------------------
+
+ImpFilterLibCache::ImpFilterLibCache() :
+ mpFirst ( NULL ),
+ mpLast ( NULL )
+{
+}
+
+// ------------------------------------------------------------------------
+
+ImpFilterLibCache::~ImpFilterLibCache()
+{
+ ImpFilterLibCacheEntry* pEntry = mpFirst;
+ while( pEntry )
+ {
+ ImpFilterLibCacheEntry* pNext = pEntry->mpNext;
+ delete pEntry;
+ pEntry = pNext;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+ImpFilterLibCacheEntry* ImpFilterLibCache::GetFilter( const String& rFilterPath, const String& rFilterName )
+{
+ ImpFilterLibCacheEntry* pEntry = mpFirst;
+
+ while( pEntry )
+ {
+ if( *pEntry == rFilterName )
+ break;
+ else
+ pEntry = pEntry->mpNext;
+ }
+ if( !pEntry )
+ {
+ String aPhysicalName( ImpCreateFullFilterPath( rFilterPath, rFilterName ) );
+ pEntry = new ImpFilterLibCacheEntry( aPhysicalName, rFilterName );
+
+ if ( pEntry->maLibrary.is() )
+ {
+ if( !mpFirst )
+ mpFirst = mpLast = pEntry;
+ else
+ mpLast = mpLast->mpNext = pEntry;
+ }
+ else
+ {
+ delete pEntry;
+ pEntry = NULL;
+ }
+ }
+ return pEntry;
+};
+
+// ------------------------------------------------------------------------
+
+namespace { struct Cache : public rtl::Static<ImpFilterLibCache, Cache> {}; }
+
+// -----------------
+// - GraphicFilter -
+// -----------------
+
+GraphicFilter::GraphicFilter( sal_Bool bConfig ) :
+ bUseConfig ( bConfig )
+{
+ ImplInit();
+}
+
+// ------------------------------------------------------------------------
+
+GraphicFilter::~GraphicFilter()
+{
+ {
+ ::osl::MutexGuard aGuard( getListMutex() );
+ pFilterHdlList->Remove( (void*)this );
+ if ( !pFilterHdlList->Count() )
+ {
+ delete pFilterHdlList, pFilterHdlList = NULL;
+ delete pConfig;
+ }
+ }
+
+
+ delete pErrorEx;
+}
+
+// ------------------------------------------------------------------------
+
+void GraphicFilter::ImplInit()
+{
+ {
+ ::osl::MutexGuard aGuard( getListMutex() );
+
+ if ( !pFilterHdlList )
+ {
+ pFilterHdlList = new List;
+ pConfig = new FilterConfigCache( bUseConfig );
+ }
+ else
+ pConfig = ((GraphicFilter*)pFilterHdlList->First())->pConfig;
+
+ pFilterHdlList->Insert( (void*)this );
+ }
+
+ if( bUseConfig )
+ {
+#if defined WNT
+ rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM("BRAND_BASE_DIR"));
+#else
+ rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM("OOO_BASE_DIR"));
+#endif
+ rtl::Bootstrap::expandMacros(url); //TODO: detect failure
+ utl::LocalFileHelper::ConvertURLToPhysicalName(url, aFilterPath);
+ }
+
+ pErrorEx = new FilterErrorEx;
+ bAbort = sal_False;
+}
+
+// ------------------------------------------------------------------------
+
+ULONG GraphicFilter::ImplSetError( ULONG nError, const SvStream* pStm )
+{
+ pErrorEx->nFilterError = nError;
+ pErrorEx->nStreamError = pStm ? pStm->GetError() : ERRCODE_NONE;
+ return nError;
+}
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::GetImportFormatCount()
+{
+ return pConfig->GetImportFormatCount();
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::GetImportFormatNumber( const String& rFormatName )
+{
+ return pConfig->GetImportFormatNumber( rFormatName );
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::GetImportFormatNumberForMediaType( const String& rMediaType )
+{
+ return pConfig->GetImportFormatNumberForMediaType( rMediaType );
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::GetImportFormatNumberForShortName( const String& rShortName )
+{
+ return pConfig->GetImportFormatNumberForShortName( rShortName );
+}
+
+// ------------------------------------------------------------------------
+
+sal_uInt16 GraphicFilter::GetImportFormatNumberForTypeName( const String& rType )
+{
+ return pConfig->GetImportFormatNumberForTypeName( rType );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetImportFormatName( USHORT nFormat )
+{
+ return pConfig->GetImportFormatName( nFormat );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetImportFormatTypeName( USHORT nFormat )
+{
+ return pConfig->GetImportFilterTypeName( nFormat );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetImportFormatMediaType( USHORT nFormat )
+{
+ return pConfig->GetImportFormatMediaType( nFormat );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetImportFormatShortName( USHORT nFormat )
+{
+ return pConfig->GetImportFormatShortName( nFormat );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetImportWildcard( USHORT nFormat, sal_Int32 nEntry )
+{
+ return pConfig->GetImportWildcard( nFormat, nEntry );
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GraphicFilter::IsImportPixelFormat( USHORT nFormat )
+{
+ return pConfig->IsImportPixelFormat( nFormat );
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::GetExportFormatCount()
+{
+ return pConfig->GetExportFormatCount();
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::GetExportFormatNumber( const String& rFormatName )
+{
+ return pConfig->GetExportFormatNumber( rFormatName );
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::GetExportFormatNumberForMediaType( const String& rMediaType )
+{
+ return pConfig->GetExportFormatNumberForMediaType( rMediaType );
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::GetExportFormatNumberForShortName( const String& rShortName )
+{
+ return pConfig->GetExportFormatNumberForShortName( rShortName );
+}
+
+// ------------------------------------------------------------------------
+
+sal_uInt16 GraphicFilter::GetExportFormatNumberForTypeName( const String& rType )
+{
+ return pConfig->GetExportFormatNumberForTypeName( rType );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetExportFormatName( USHORT nFormat )
+{
+ return pConfig->GetExportFormatName( nFormat );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetExportFormatTypeName( USHORT nFormat )
+{
+ return pConfig->GetExportFilterTypeName( nFormat );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetExportFormatMediaType( USHORT nFormat )
+{
+ return pConfig->GetExportFormatMediaType( nFormat );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetExportFormatShortName( USHORT nFormat )
+{
+ return pConfig->GetExportFormatShortName( nFormat );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetExportWildcard( USHORT nFormat, sal_Int32 nEntry )
+{
+ return pConfig->GetExportWildcard( nFormat, nEntry );
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::CanImportGraphic( const INetURLObject& rPath,
+ USHORT nFormat, USHORT* pDeterminedFormat )
+{
+ sal_uInt16 nRetValue = GRFILTER_FORMATERROR;
+ DBG_ASSERT( rPath.GetProtocol() != INET_PROT_NOT_VALID, "GraphicFilter::CanImportGraphic() : ProtType == INET_PROT_NOT_VALID" );
+
+ String aMainUrl( rPath.GetMainURL( INetURLObject::NO_DECODE ) );
+ SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aMainUrl, STREAM_READ | STREAM_SHARE_DENYNONE );
+ if ( pStream )
+ {
+ nRetValue = CanImportGraphic( aMainUrl, *pStream, nFormat, pDeterminedFormat );
+ delete pStream;
+ }
+ return nRetValue;
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::CanImportGraphic( const String& rMainUrl, SvStream& rIStream,
+ USHORT nFormat, USHORT* pDeterminedFormat )
+{
+ ULONG nStreamPos = rIStream.Tell();
+ sal_uInt16 nRes = ImpTestOrFindFormat( rMainUrl, rIStream, nFormat );
+
+ rIStream.Seek(nStreamPos);
+
+ if( nRes==GRFILTER_OK && pDeterminedFormat!=NULL )
+ *pDeterminedFormat = nFormat;
+
+ return (USHORT) ImplSetError( nRes, &rIStream );
+}
+
+// ------------------------------------------------------------------------
+//SJ: TODO, we need to create a GraphicImporter component
+USHORT GraphicFilter::ImportGraphic( Graphic& rGraphic, const INetURLObject& rPath,
+ USHORT nFormat, USHORT * pDeterminedFormat, sal_uInt32 nImportFlags )
+{
+ sal_uInt16 nRetValue = GRFILTER_FORMATERROR;
+ DBG_ASSERT( rPath.GetProtocol() != INET_PROT_NOT_VALID, "GraphicFilter::ImportGraphic() : ProtType == INET_PROT_NOT_VALID" );
+
+ String aMainUrl( rPath.GetMainURL( INetURLObject::NO_DECODE ) );
+ SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aMainUrl, STREAM_READ | STREAM_SHARE_DENYNONE );
+ if ( pStream )
+ {
+ nRetValue = ImportGraphic( rGraphic, aMainUrl, *pStream, nFormat, pDeterminedFormat, nImportFlags );
+ delete pStream;
+ }
+ return nRetValue;
+}
+
+USHORT GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath, SvStream& rIStream,
+ USHORT nFormat, USHORT* pDeterminedFormat, sal_uInt32 nImportFlags )
+{
+ return ImportGraphic( rGraphic, rPath, rIStream, nFormat, pDeterminedFormat, nImportFlags, NULL );
+}
+
+//-------------------------------------------------------------------------
+
+USHORT GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath, SvStream& rIStream,
+ USHORT nFormat, USHORT* pDeterminedFormat, sal_uInt32 nImportFlags,
+ com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData )
+{
+ String aFilterName;
+ ULONG nStmBegin;
+ USHORT nStatus;
+ GraphicReader* pContext = rGraphic.GetContext();
+ GfxLinkType eLinkType = GFX_LINK_TYPE_NONE;
+ BOOL bDummyContext = ( pContext == (GraphicReader*) 1 );
+ const BOOL bLinkSet = rGraphic.IsLink();
+ FilterConfigItem* pFilterConfigItem = NULL;
+
+ Size aPreviewSizeHint( 0, 0 );
+ sal_Bool bAllowPartialStreamRead = sal_False;
+ sal_Bool bCreateNativeLink = sal_True;
+
+ ResetLastError();
+
+ if ( pFilterData )
+ {
+ sal_Int32 i;
+ for ( i = 0; i < pFilterData->getLength(); i++ )
+ {
+ if ( (*pFilterData)[ i ].Name.equalsAscii( "PreviewSizeHint" ) )
+ {
+ awt::Size aSize;
+ if ( (*pFilterData)[ i ].Value >>= aSize )
+ {
+ aPreviewSizeHint = Size( aSize.Width, aSize.Height );
+ if ( aSize.Width || aSize.Height )
+ nImportFlags |= GRFILTER_I_FLAGS_FOR_PREVIEW;
+ else
+ nImportFlags &=~GRFILTER_I_FLAGS_FOR_PREVIEW;
+ }
+ }
+ else if ( (*pFilterData)[ i ].Name.equalsAscii( "AllowPartialStreamRead" ) )
+ {
+ (*pFilterData)[ i ].Value >>= bAllowPartialStreamRead;
+ if ( bAllowPartialStreamRead )
+ nImportFlags |= GRFILTER_I_FLAGS_ALLOW_PARTIAL_STREAMREAD;
+ else
+ nImportFlags &=~GRFILTER_I_FLAGS_ALLOW_PARTIAL_STREAMREAD;
+ }
+ else if ( (*pFilterData)[ i ].Name.equalsAscii( "CreateNativeLink" ) )
+ {
+ (*pFilterData)[ i ].Value >>= bCreateNativeLink;
+ }
+ }
+ }
+
+ if( !pContext || bDummyContext )
+ {
+ if( bDummyContext )
+ {
+ rGraphic.SetContext( NULL );
+ nStmBegin = 0;
+ }
+ else
+ nStmBegin = rIStream.Tell();
+
+ bAbort = FALSE;
+ nStatus = ImpTestOrFindFormat( rPath, rIStream, nFormat );
+ // Falls Pending, geben wir GRFILTER_OK zurueck,
+ // um mehr Bytes anzufordern
+ if( rIStream.GetError() == ERRCODE_IO_PENDING )
+ {
+ rGraphic.SetContext( (GraphicReader*) 1 );
+ rIStream.ResetError();
+ rIStream.Seek( nStmBegin );
+ return (USHORT) ImplSetError( GRFILTER_OK );
+ }
+
+ rIStream.Seek( nStmBegin );
+
+ if( ( nStatus != GRFILTER_OK ) || rIStream.GetError() )
+ return (USHORT) ImplSetError( ( nStatus != GRFILTER_OK ) ? nStatus : GRFILTER_OPENERROR, &rIStream );
+
+ if( pDeterminedFormat )
+ *pDeterminedFormat = nFormat;
+
+ aFilterName = pConfig->GetImportFilterName( nFormat );
+ }
+ else
+ {
+ if( pContext && !bDummyContext )
+ aFilterName = pContext->GetUpperFilterName();
+
+ nStmBegin = 0;
+ nStatus = GRFILTER_OK;
+ }
+
+ // read graphic
+ if ( pConfig->IsImportInternalFilter( nFormat ) )
+ {
+ if( aFilterName.EqualsIgnoreCaseAscii( IMP_GIF ) )
+ {
+ if( rGraphic.GetContext() == (GraphicReader*) 1 )
+ rGraphic.SetContext( NULL );
+
+ if( !ImportGIF( rIStream, rGraphic ) )
+ nStatus = GRFILTER_FILTERERROR;
+ else
+ eLinkType = GFX_LINK_TYPE_NATIVE_GIF;
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( IMP_PNG ) )
+ {
+ if ( rGraphic.GetContext() == (GraphicReader*) 1 )
+ rGraphic.SetContext( NULL );
+
+ vcl::PNGReader aPNGReader( rIStream );
+
+ // ignore animation for previews and set preview size
+ if( aPreviewSizeHint.Width() || aPreviewSizeHint.Height() )
+ {
+ // position the stream at the end of the image if requested
+ if( !bAllowPartialStreamRead )
+ aPNGReader.GetChunks();
+ }
+ else
+ {
+ // check if this PNG contains a GIF chunk!
+ const std::vector< vcl::PNGReader::ChunkData >& rChunkData = aPNGReader.GetChunks();
+ std::vector< vcl::PNGReader::ChunkData >::const_iterator aIter( rChunkData.begin() );
+ std::vector< vcl::PNGReader::ChunkData >::const_iterator aEnd ( rChunkData.end() );
+ while( aIter != aEnd )
+ {
+ // Microsoft Office is storing Animated GIFs in following chunk
+ if ( aIter->nType == PMGCHUNG_msOG )
+ {
+ sal_uInt32 nChunkSize = aIter->aData.size();
+ if ( nChunkSize > 11 )
+ {
+ const std::vector< sal_uInt8 >& rData = aIter->aData;
+ SvMemoryStream aIStrm( (void*)&rData[ 11 ], nChunkSize - 11, STREAM_READ );
+ ImportGIF( aIStrm, rGraphic );
+ eLinkType = GFX_LINK_TYPE_NATIVE_PNG;
+ break;
+ }
+ }
+ aIter++;
+ }
+ }
+
+ if ( eLinkType == GFX_LINK_TYPE_NONE )
+ {
+ BitmapEx aBmpEx( aPNGReader.Read( aPreviewSizeHint ) );
+ if ( aBmpEx.IsEmpty() )
+ nStatus = GRFILTER_FILTERERROR;
+ else
+ {
+ rGraphic = aBmpEx;
+ eLinkType = GFX_LINK_TYPE_NATIVE_PNG;
+ }
+ }
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( IMP_JPEG ) )
+ {
+ if( rGraphic.GetContext() == (GraphicReader*) 1 )
+ rGraphic.SetContext( NULL );
+
+ // set LOGSIZE flag always, if not explicitly disabled
+ // (see #90508 and #106763)
+ if( 0 == ( nImportFlags & GRFILTER_I_FLAGS_DONT_SET_LOGSIZE_FOR_JPEG ) )
+ nImportFlags |= GRFILTER_I_FLAGS_SET_LOGSIZE_FOR_JPEG;
+
+ if( !ImportJPEG( rIStream, rGraphic, NULL, nImportFlags ) )
+ nStatus = GRFILTER_FILTERERROR;
+ else
+ eLinkType = GFX_LINK_TYPE_NATIVE_JPG;
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( IMP_XBM ) )
+ {
+ if( rGraphic.GetContext() == (GraphicReader*) 1 )
+ rGraphic.SetContext( NULL );
+
+ if( !ImportXBM( rIStream, rGraphic ) )
+ nStatus = GRFILTER_FILTERERROR;
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( IMP_XPM ) )
+ {
+ if( rGraphic.GetContext() == (GraphicReader*) 1 )
+ rGraphic.SetContext( NULL );
+
+ if( !ImportXPM( rIStream, rGraphic ) )
+ nStatus = GRFILTER_FILTERERROR;
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( IMP_BMP ) ||
+ aFilterName.EqualsIgnoreCaseAscii( IMP_SVMETAFILE ) )
+ {
+ // SV interne Importfilter fuer Bitmaps und MetaFiles
+ rIStream >> rGraphic;
+ if( rIStream.GetError() )
+ nStatus = GRFILTER_FORMATERROR;
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( IMP_WMF ) ||
+ aFilterName.EqualsIgnoreCaseAscii( IMP_EMF ) )
+ {
+ GDIMetaFile aMtf;
+ if( !ConvertWMFToGDIMetaFile( rIStream, aMtf, NULL ) )
+ nStatus = GRFILTER_FORMATERROR;
+ else
+ {
+ rGraphic = aMtf;
+ eLinkType = GFX_LINK_TYPE_NATIVE_WMF;
+ }
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( IMP_SVSGF )
+ || aFilterName.EqualsIgnoreCaseAscii( IMP_SVSGV ) )
+ {
+ USHORT nVersion;
+ unsigned char nTyp = CheckSgfTyp( rIStream, nVersion );
+
+ switch( nTyp )
+ {
+ case SGF_BITIMAGE:
+ {
+ SvMemoryStream aTempStream;
+ if( aTempStream.GetError() )
+ return GRFILTER_OPENERROR;
+
+ if( !SgfBMapFilter( rIStream, aTempStream ) )
+ nStatus = GRFILTER_FILTERERROR;
+ else
+ {
+ aTempStream.Seek( 0L );
+ aTempStream >> rGraphic;
+
+ if( aTempStream.GetError() )
+ nStatus = GRFILTER_FILTERERROR;
+ }
+ }
+ break;
+
+ case SGF_SIMPVECT:
+ {
+ GDIMetaFile aMtf;
+ if( !SgfVectFilter( rIStream, aMtf ) )
+ nStatus = GRFILTER_FILTERERROR;
+ else
+ rGraphic = Graphic( aMtf );
+ }
+ break;
+
+ case SGF_STARDRAW:
+ {
+ if( nVersion != SGV_VERSION )
+ nStatus = GRFILTER_VERSIONERROR;
+ else
+ {
+ GDIMetaFile aMtf;
+ if( !SgfSDrwFilter( rIStream, aMtf,
+ INetURLObject(aFilterPath) ) )
+ {
+ nStatus = GRFILTER_FILTERERROR;
+ }
+ else
+ rGraphic = Graphic( aMtf );
+ }
+ }
+ break;
+
+ default:
+ {
+ nStatus = GRFILTER_FORMATERROR;
+ }
+ break;
+ }
+ }
+ else
+ nStatus = GRFILTER_FILTERERROR;
+ }
+ else
+ {
+ ImpFilterLibCacheEntry* pFilter = NULL;
+
+ // find first filter in filter pathes
+ xub_StrLen i, nTokenCount = aFilterPath.GetTokenCount( ';' );
+ ImpFilterLibCache &rCache = Cache::get();
+ for( i = 0; ( i < nTokenCount ) && ( pFilter == NULL ); i++ )
+ pFilter = rCache.GetFilter( aFilterPath.GetToken(i), aFilterName );
+ if( !pFilter )
+ nStatus = GRFILTER_FILTERERROR;
+ else
+ {
+ PFilterCall pFunc = pFilter->GetImportFunction();
+
+ if( !pFunc )
+ nStatus = GRFILTER_FILTERERROR;
+ else
+ {
+ String aShortName;
+ if( nFormat != GRFILTER_FORMAT_DONTKNOW )
+ {
+ aShortName = GetImportFormatShortName( nFormat ).ToUpperAscii();
+ if ( ( pFilterConfigItem == NULL ) && aShortName.EqualsAscii( "PCD" ) )
+ {
+ String aFilterConfigPath( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Filter/Graphic/Import/PCD" ) );
+ pFilterConfigItem = new FilterConfigItem( aFilterConfigPath );
+ }
+ }
+ if( !(*pFunc)( rIStream, rGraphic, pFilterConfigItem, sal_False ) )
+ nStatus = GRFILTER_FORMATERROR;
+ else
+ {
+ // try to set link type if format matches
+ if( nFormat != GRFILTER_FORMAT_DONTKNOW )
+ {
+ if( aShortName.CompareToAscii( TIF_SHORTNAME ) == COMPARE_EQUAL )
+ eLinkType = GFX_LINK_TYPE_NATIVE_TIF;
+ else if( aShortName.CompareToAscii( MET_SHORTNAME ) == COMPARE_EQUAL )
+ eLinkType = GFX_LINK_TYPE_NATIVE_MET;
+ else if( aShortName.CompareToAscii( PCT_SHORTNAME ) == COMPARE_EQUAL )
+ eLinkType = GFX_LINK_TYPE_NATIVE_PCT;
+ }
+ }
+ }
+ }
+ }
+
+ if( nStatus == GRFILTER_OK && bCreateNativeLink && ( eLinkType != GFX_LINK_TYPE_NONE ) && !rGraphic.GetContext() && !bLinkSet )
+ {
+ const ULONG nStmEnd = rIStream.Tell();
+ const ULONG nBufSize = nStmEnd - nStmBegin;
+
+ if( nBufSize )
+ {
+ BYTE* pBuf=0;
+ try
+ {
+ pBuf = new BYTE[ nBufSize ];
+ }
+ catch (std::bad_alloc)
+ {
+ nStatus = GRFILTER_TOOBIG;
+ }
+
+ if( nStatus == GRFILTER_OK )
+ {
+ rIStream.Seek( nStmBegin );
+ rIStream.Read( pBuf, nBufSize );
+ rGraphic.SetLink( GfxLink( pBuf, nBufSize, eLinkType, TRUE ) );
+ }
+ }
+ }
+
+ // Set error code or try to set native buffer
+ if( nStatus != GRFILTER_OK )
+ {
+ if( bAbort )
+ nStatus = GRFILTER_ABORT;
+
+ ImplSetError( nStatus, &rIStream );
+ rIStream.Seek( nStmBegin );
+ rGraphic.Clear();
+ }
+
+ delete pFilterConfigItem;
+ return nStatus;
+}
+
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::ExportGraphic( const Graphic& rGraphic, const INetURLObject& rPath,
+ sal_uInt16 nFormat, const uno::Sequence< beans::PropertyValue >* pFilterData )
+{
+ sal_uInt16 nRetValue = GRFILTER_FORMATERROR;
+ DBG_ASSERT( rPath.GetProtocol() != INET_PROT_NOT_VALID, "GraphicFilter::ExportGraphic() : ProtType == INET_PROT_NOT_VALID" );
+ BOOL bAlreadyExists = ImplDirEntryHelper::Exists( rPath );
+
+ String aMainUrl( rPath.GetMainURL( INetURLObject::NO_DECODE ) );
+ SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aMainUrl, STREAM_WRITE | STREAM_TRUNC );
+ if ( pStream )
+ {
+ nRetValue = ExportGraphic( rGraphic, aMainUrl, *pStream, nFormat, pFilterData );
+ delete pStream;
+
+ if( ( GRFILTER_OK != nRetValue ) && !bAlreadyExists )
+ ImplDirEntryHelper::Kill( aMainUrl );
+ }
+ return nRetValue;
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::ExportGraphic( const Graphic& rGraphic, const String& rPath,
+ SvStream& rOStm, sal_uInt16 nFormat, const uno::Sequence< beans::PropertyValue >* pFilterData )
+{
+ USHORT nFormatCount = GetExportFormatCount();
+
+ ResetLastError();
+
+ if( nFormat == GRFILTER_FORMAT_DONTKNOW )
+ {
+ INetURLObject aURL( rPath );
+ String aExt( aURL.GetFileExtension().toAsciiUpperCase() );
+
+
+ for( USHORT i = 0; i < nFormatCount; i++ )
+ {
+ if ( pConfig->GetExportFormatExtension( nFormat ).EqualsIgnoreCaseAscii( aExt ) )
+ {
+ nFormat=i;
+ break;
+ }
+ }
+ }
+ if( nFormat >= nFormatCount )
+ return (USHORT) ImplSetError( GRFILTER_FORMATERROR );
+
+ FilterConfigItem aConfigItem( (uno::Sequence< beans::PropertyValue >*)pFilterData );
+ String aFilterName( pConfig->GetExportFilterName( nFormat ) );
+
+ bAbort = FALSE;
+ USHORT nStatus = GRFILTER_OK;
+ GraphicType eType;
+ Graphic aGraphic( rGraphic );
+
+ aGraphic = ImpGetScaledGraphic( rGraphic, aConfigItem );
+ eType = aGraphic.GetType();
+
+ if( pConfig->IsExportPixelFormat( nFormat ) )
+ {
+ if( eType != GRAPHIC_BITMAP )
+ {
+ Size aSizePixel;
+ ULONG nColorCount,nBitsPerPixel,nNeededMem,nMaxMem;
+ VirtualDevice aVirDev;
+
+ // Maximalen Speicherbedarf fuer das Bildes holen:
+// if( GetOptionsConfig() )
+// nMaxMem = (UINT32)GetOptionsConfig()->ReadKey( "VEC-TO-PIX-MAX-KB", "1024" ).ToInt32();
+// else
+ nMaxMem = 1024;
+
+ nMaxMem *= 1024; // In Bytes
+
+ // Berechnen, wie gross das Bild normalerweise werden wuerde:
+ aSizePixel=aVirDev.LogicToPixel(aGraphic.GetPrefSize(),aGraphic.GetPrefMapMode());
+
+ // Berechnen, wieviel Speicher das Bild benoetigen wuerde:
+ nColorCount=aVirDev.GetColorCount();
+ if (nColorCount<=2) nBitsPerPixel=1;
+ else if (nColorCount<=4) nBitsPerPixel=2;
+ else if (nColorCount<=16) nBitsPerPixel=4;
+ else if (nColorCount<=256) nBitsPerPixel=8;
+ else if (nColorCount<=65536) nBitsPerPixel=16;
+ else nBitsPerPixel=24;
+ nNeededMem=((ULONG)aSizePixel.Width()*(ULONG)aSizePixel.Height()*nBitsPerPixel+7)/8;
+
+ // ggf. Groesse des Bildes einschraenken:
+ if (nMaxMem<nNeededMem)
+ {
+ double fFak=sqrt(((double)nMaxMem)/((double)nNeededMem));
+ aSizePixel.Width()=(ULONG)(((double)aSizePixel.Width())*fFak);
+ aSizePixel.Height()=(ULONG)(((double)aSizePixel.Height())*fFak);
+ }
+
+ aVirDev.SetMapMode(MapMode(MAP_PIXEL));
+ aVirDev.SetOutputSizePixel(aSizePixel);
+ Graphic aGraphic2=aGraphic;
+ aGraphic2.Draw(&aVirDev,Point(0,0),aSizePixel); // Gemein: dies aendert den MapMode
+ aVirDev.SetMapMode(MapMode(MAP_PIXEL));
+ aGraphic=Graphic(aVirDev.GetBitmap(Point(0,0),aSizePixel));
+ }
+ }
+ if( rOStm.GetError() )
+ nStatus = GRFILTER_IOERROR;
+ if( GRFILTER_OK == nStatus )
+ {
+ if ( pConfig->IsExportInternalFilter( nFormat ) )
+ {
+ if( aFilterName.EqualsIgnoreCaseAscii( EXP_BMP ) )
+ {
+ Bitmap aBmp( aGraphic.GetBitmap() );
+ sal_Int32 nColorRes = aConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Colors" ) ), 0 );
+ if ( nColorRes && ( nColorRes <= (USHORT)BMP_CONVERSION_24BIT) )
+ {
+ if( !aBmp.Convert( (BmpConversion) nColorRes ) )
+ aBmp = aGraphic.GetBitmap();
+ }
+ sal_Bool bRleCoding = aConfigItem.ReadBool( String( RTL_CONSTASCII_USTRINGPARAM( "RLE_Coding" ) ), sal_True );
+ // Wollen wir RLE-Kodiert speichern?
+ aBmp.Write( rOStm, bRleCoding );
+
+ if( rOStm.GetError() )
+ nStatus = GRFILTER_IOERROR;
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( EXP_SVMETAFILE ) )
+ {
+ sal_Int32 nVersion = aConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ), 0 ) ;
+ if ( nVersion )
+ rOStm.SetVersion( nVersion );
+ GDIMetaFile aMTF;
+
+ if ( eType != GRAPHIC_BITMAP )
+ aMTF = aGraphic.GetGDIMetaFile();
+ else
+ {
+ VirtualDevice aVirDev;
+
+ aMTF.Record( &aVirDev );
+ aGraphic.Draw( &aVirDev, Point(), aGraphic.GetPrefSize() );
+ aMTF.Stop();
+ aMTF.SetPrefSize( aGraphic.GetPrefSize() );
+ aMTF.SetPrefMapMode( aGraphic.GetPrefMapMode() );
+ }
+ rOStm << aMTF;
+ if( rOStm.GetError() )
+ nStatus = GRFILTER_IOERROR;
+ }
+ else if ( aFilterName.EqualsIgnoreCaseAscii( EXP_WMF ) )
+ {
+ if( eType == GRAPHIC_GDIMETAFILE )
+ {
+ if ( !ConvertGDIMetaFileToWMF( aGraphic.GetGDIMetaFile(), rOStm, &aConfigItem ) )
+ nStatus = GRFILTER_FORMATERROR;
+ }
+ else
+ {
+ Bitmap aBmp( aGraphic.GetBitmap() );
+ GDIMetaFile aMTF;
+ VirtualDevice aVirDev;
+
+ aMTF.Record( &aVirDev );
+ aVirDev.DrawBitmap( Point(), aBmp );
+ aMTF.Stop();
+ aMTF.SetPrefSize( aBmp.GetSizePixel() );
+
+ if( !ConvertGDIMetaFileToWMF( aMTF, rOStm, &aConfigItem ) )
+ nStatus = GRFILTER_FORMATERROR;
+ }
+ if( rOStm.GetError() )
+ nStatus = GRFILTER_IOERROR;
+ }
+ else if ( aFilterName.EqualsIgnoreCaseAscii( EXP_EMF ) )
+ {
+ if( eType == GRAPHIC_GDIMETAFILE )
+ {
+ if ( !ConvertGDIMetaFileToEMF( aGraphic.GetGDIMetaFile(), rOStm, &aConfigItem ) )
+ nStatus = GRFILTER_FORMATERROR;
+ }
+ else
+ {
+ Bitmap aBmp( aGraphic.GetBitmap() );
+ GDIMetaFile aMTF;
+ VirtualDevice aVirDev;
+
+ aMTF.Record( &aVirDev );
+ aVirDev.DrawBitmap( Point(), aBmp );
+ aMTF.Stop();
+ aMTF.SetPrefSize( aBmp.GetSizePixel() );
+
+ if( !ConvertGDIMetaFileToEMF( aMTF, rOStm, &aConfigItem ) )
+ nStatus = GRFILTER_FORMATERROR;
+ }
+ if( rOStm.GetError() )
+ nStatus = GRFILTER_IOERROR;
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( EXP_JPEG ) )
+ {
+ if( !ExportJPEG( rOStm, aGraphic, pFilterData ) )
+ nStatus = GRFILTER_FORMATERROR;
+
+ if( rOStm.GetError() )
+ nStatus = GRFILTER_IOERROR;
+ }
+ else if ( aFilterName.EqualsIgnoreCaseAscii( EXP_PNG ) )
+ {
+ vcl::PNGWriter aPNGWriter( aGraphic.GetBitmapEx(), pFilterData );
+ if ( pFilterData )
+ {
+ sal_Int32 k, j, i = 0;
+ for ( i = 0; i < pFilterData->getLength(); i++ )
+ {
+ if ( (*pFilterData)[ i ].Name.equalsAscii( "AdditionalChunks" ) )
+ {
+ com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > aAdditionalChunkSequence;
+ if ( (*pFilterData)[ i ].Value >>= aAdditionalChunkSequence )
+ {
+ for ( j = 0; j < aAdditionalChunkSequence.getLength(); j++ )
+ {
+ if ( aAdditionalChunkSequence[ j ].Name.getLength() == 4 )
+ {
+ sal_uInt32 nChunkType = 0;
+ for ( k = 0; k < 4; k++ )
+ {
+ nChunkType <<= 8;
+ nChunkType |= (sal_uInt8)aAdditionalChunkSequence[ j ].Name[ k ];
+ }
+ com::sun::star::uno::Sequence< sal_Int8 > aByteSeq;
+ if ( aAdditionalChunkSequence[ j ].Value >>= aByteSeq )
+ {
+ std::vector< vcl::PNGWriter::ChunkData >& rChunkData = aPNGWriter.GetChunks();
+ if ( rChunkData.size() )
+ {
+ sal_uInt32 nChunkLen = aByteSeq.getLength();
+
+ vcl::PNGWriter::ChunkData aChunkData;
+ aChunkData.nType = nChunkType;
+ if ( nChunkLen )
+ {
+ aChunkData.aData.resize( nChunkLen );
+ rtl_copyMemory( &aChunkData.aData[ 0 ], aByteSeq.getConstArray(), nChunkLen );
+ }
+ std::vector< vcl::PNGWriter::ChunkData >::iterator aIter = rChunkData.end() - 1;
+ rChunkData.insert( aIter, aChunkData );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ aPNGWriter.Write( rOStm );
+
+ if( rOStm.GetError() )
+ nStatus = GRFILTER_IOERROR;
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( EXP_SVG ) )
+ {
+ try
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+
+ if( xMgr.is() )
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > xSaxWriter( xMgr->createInstance(
+ ::rtl::OUString::createFromAscii( "com.sun.star.xml.sax.Writer" ) ), ::com::sun::star::uno::UNO_QUERY );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::svg::XSVGWriter > xSVGWriter( xMgr->createInstance(
+ ::rtl::OUString::createFromAscii( "com.sun.star.svg.SVGWriter" ) ), ::com::sun::star::uno::UNO_QUERY );
+
+ if( xSaxWriter.is() && xSVGWriter.is() )
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XActiveDataSource > xActiveDataSource(
+ xSaxWriter, ::com::sun::star::uno::UNO_QUERY );
+
+ if( xActiveDataSource.is() )
+ {
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xStmIf(
+ static_cast< ::cppu::OWeakObject* >( new ImpFilterOutputStream( rOStm ) ) );
+
+ SvMemoryStream aMemStm( 65535, 65535 );
+
+ aMemStm.SetCompressMode( COMPRESSMODE_FULL );
+ ( (GDIMetaFile&) aGraphic.GetGDIMetaFile() ).Write( aMemStm );
+
+ xActiveDataSource->setOutputStream( ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >(
+ xStmIf, ::com::sun::star::uno::UNO_QUERY ) );
+ ::com::sun::star::uno::Sequence< sal_Int8 > aMtfSeq( (sal_Int8*) aMemStm.GetData(), aMemStm.Tell() );
+ xSVGWriter->write( xSaxWriter, aMtfSeq );
+ }
+ }
+ }
+ }
+ catch( ::com::sun::star::uno::Exception& )
+ {
+ nStatus = GRFILTER_IOERROR;
+ }
+ }
+ else
+ nStatus = GRFILTER_FILTERERROR;
+ }
+ else
+ {
+ xub_StrLen i, nTokenCount = aFilterPath.GetTokenCount( ';' );
+ for ( i = 0; i < nTokenCount; i++ )
+ {
+ String aPhysicalName( ImpCreateFullFilterPath( aFilterPath.GetToken( i ), aFilterName ) );
+ osl::Module aLibrary( aPhysicalName );
+
+ PFilterCall pFunc = (PFilterCall) aLibrary.getFunctionSymbol( UniString::CreateFromAscii( EXPORT_FUNCTION_NAME ) );
+ // Dialog in DLL ausfuehren
+ if( pFunc )
+ {
+ if ( !(*pFunc)( rOStm, aGraphic, &aConfigItem, sal_False ) )
+ nStatus = GRFILTER_FORMATERROR;
+ break;
+ }
+ else
+ nStatus = GRFILTER_FILTERERROR;
+ }
+ }
+ }
+ if( nStatus != GRFILTER_OK )
+ {
+ if( bAbort )
+ nStatus = GRFILTER_ABORT;
+
+ ImplSetError( nStatus, &rOStm );
+ }
+ return nStatus;
+}
+
+// ------------------------------------------------------------------------
+
+void GraphicFilter::ResetLastError()
+{
+ pErrorEx->nFilterError = pErrorEx->nStreamError = 0UL;
+}
+
+// ------------------------------------------------------------------------
+
+IMPL_LINK( GraphicFilter, FilterCallback, ConvertData*, pData )
+{
+ long nRet = 0L;
+
+ if( pData )
+ {
+ USHORT nFormat = GRFILTER_FORMAT_DONTKNOW;
+ ByteString aShortName;
+ switch( pData->mnFormat )
+ {
+ case( CVT_BMP ): aShortName = BMP_SHORTNAME; break;
+ case( CVT_GIF ): aShortName = GIF_SHORTNAME; break;
+ case( CVT_JPG ): aShortName = JPG_SHORTNAME; break;
+ case( CVT_MET ): aShortName = MET_SHORTNAME; break;
+ case( CVT_PCT ): aShortName = PCT_SHORTNAME; break;
+ case( CVT_PNG ): aShortName = PNG_SHORTNAME; break;
+ case( CVT_SVM ): aShortName = SVM_SHORTNAME; break;
+ case( CVT_TIF ): aShortName = TIF_SHORTNAME; break;
+ case( CVT_WMF ): aShortName = WMF_SHORTNAME; break;
+ case( CVT_EMF ): aShortName = EMF_SHORTNAME; break;
+
+ default:
+ break;
+ }
+ if( GRAPHIC_NONE == pData->maGraphic.GetType() || pData->maGraphic.GetContext() ) // Import
+ {
+ // Import
+ nFormat = GetImportFormatNumberForShortName( String( aShortName.GetBuffer(), RTL_TEXTENCODING_UTF8 ) );
+ nRet = ImportGraphic( pData->maGraphic, String(), pData->mrStm ) == 0;
+ }
+ else if( aShortName.Len() )
+ {
+ // Export
+ nFormat = GetExportFormatNumberForShortName( String( aShortName.GetBuffer(), RTL_TEXTENCODING_UTF8 ) );
+ nRet = ExportGraphic( pData->maGraphic, String(), pData->mrStm, nFormat ) == 0;
+ }
+ }
+ return nRet;
+}
+
+// ------------------------------------------------------------------------
+
+GraphicFilter* GraphicFilter::GetGraphicFilter()
+{
+ if( !pGraphicFilter )
+ {
+ pGraphicFilter = new GraphicFilter;
+ pGraphicFilter->GetImportFormatCount();
+ }
+ return pGraphicFilter;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_filter2.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_filter2.cxx
new file mode 100644
index 000000000000..ef904a862442
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_filter2.cxx
@@ -0,0 +1,1325 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/urlobj.hxx>
+#include <string.h>
+#include <stdio.h>
+#include <tools/stream.hxx>
+#include <tools/debug.hxx>
+#include <vcl/outdev.hxx>
+#include <tools/config.hxx>
+#include <bf_svtools/filter.hxx>
+#include "FilterConfigCache.hxx"
+#include <unotools/ucbstreamhelper.hxx>
+
+#define DATA_SIZE 640
+
+namespace binfilter
+{
+
+BYTE* ImplSearchEntry( BYTE* , BYTE* , ULONG , ULONG );
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+GraphicDescriptor::GraphicDescriptor( SvStream& rInStream, const String* pPath) :
+ pFileStm ( NULL )
+{
+ ImpConstruct();
+
+ if ( pPath )
+ {
+ INetURLObject aURL( *pPath );
+ aPathExt = aURL.GetFileExtension().toAsciiLowerCase();
+ }
+ nStmPos = rInStream.Tell();
+ pBaseStm = &rInStream;
+ bBaseStm = TRUE;
+
+ if ( !pBaseStm->GetError() )
+ bDataReady = TRUE;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+GraphicDescriptor::~GraphicDescriptor()
+{
+ delete pFileStm;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::Detect( BOOL bExtendedInfo )
+{
+ BOOL bRet = FALSE;
+
+ // Link-Status ueberpruefen
+ if ( bLinked && bLinkChanged )
+ {
+ DBG_ASSERT( aReqLink.IsSet(), "Wo ist der RequestHandler???" );
+ pMemStm = (SvStream*) aReqLink.Call( this );
+ if ( pMemStm )
+ {
+ nStmPos = pMemStm->Tell();
+ bDataReady = TRUE;
+ }
+ }
+
+ if ( bDataReady )
+ {
+ SvStream& rStm = GetSearchStream();
+ UINT16 nOldFormat = rStm.GetNumberFormatInt();
+
+ if ( ImpDetectGIF( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectJPG( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectBMP( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectPNG( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectTIF( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectPCX( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectDXF( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectMET( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectSGF( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectSGV( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectSVM( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectWMF( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectEMF( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectPCT( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectXBM( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectXPM( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectPBM( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectPGM( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectPPM( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectRAS( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectTGA( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectPSD( rStm, bExtendedInfo ) ) bRet = TRUE;
+ else if ( ImpDetectEPS( rStm, bExtendedInfo ) ) bRet = TRUE;
+
+ // diese Formate lassen sich nur bei WideSearch im gesamten
+ // Stream ermitteln
+ else if ( bWideSearch )
+ {
+ if ( ImpDetectPCD( rStm, bExtendedInfo ) )
+ bRet = TRUE;
+ }
+
+ rStm.SetNumberFormatInt( nOldFormat );
+ rStm.Seek( nStmPos );
+ }
+
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+SvStream& GraphicDescriptor::GetSearchStream() const
+{
+ DBG_ASSERT( bDataReady, "Was laeuft hier falsch???" );
+
+ if ( bLinked )
+ return *pMemStm;
+ else if ( bBaseStm )
+ return *pBaseStm;
+ else
+ return *pFileStm;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void GraphicDescriptor::ImpConstruct()
+{
+ if ( !pFileStm )
+ pFileStm = new SvStream();
+ nFormat = GFF_NOT;
+ nBitsPerPixel = 0;
+ nPlanes = 0;
+ bCompressed = FALSE;
+ bDataReady = FALSE;
+ bLinked = FALSE;
+ bWideSearch = TRUE;
+ bBaseStm = FALSE;
+ pMemStm = NULL;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectBMP( SvStream& rStm, BOOL bExtendedInfo )
+{
+ UINT16 nTemp16;
+ BOOL bRet = FALSE;
+
+ rStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ rStm.Seek( nStmPos );
+
+ rStm >> nTemp16;
+
+ // OS/2-BitmapArray
+ if ( nTemp16 == 0x4142 )
+ {
+ rStm.SeekRel( 0x0c );
+ rStm >> nTemp16;
+ }
+
+ // Bitmap
+ if ( nTemp16 == 0x4d42 )
+ {
+ nFormat = GFF_BMP;
+ bRet = TRUE;
+
+ if ( bExtendedInfo )
+ {
+ UINT32 nTemp32;
+ UINT32 nCompression;
+
+ // bis zur ersten Information
+ rStm.SeekRel( 0x10 );
+
+ // PixelBreite auslesen
+ rStm >> nTemp32;
+ aPixSize.Width() = nTemp32;
+
+ // PixelHoehe auslesen
+ rStm >> nTemp32;
+ aPixSize.Height() = nTemp32;
+
+ // Planes auslesen
+ rStm >> nTemp16;
+ nPlanes = nTemp16;
+
+ // BitCount auslesen
+ rStm >> nTemp16;
+ nBitsPerPixel = nTemp16;
+
+ // Compression auslesen
+ rStm >> nTemp32;
+ bCompressed = ( ( nCompression = nTemp32 ) > 0 );
+
+ // logische Breite
+ rStm.SeekRel( 4 );
+ rStm >> nTemp32;
+ if ( nTemp32 )
+ aLogSize.Width() = ( aPixSize.Width() * 100000 ) / nTemp32;
+
+ // logische Hoehe
+ rStm >> nTemp32;
+ if ( nTemp32 )
+ aLogSize.Height() = ( aPixSize.Height() * 100000 ) / nTemp32;
+
+ // Wir wollen noch etwas feiner differenzieren und
+ // auf sinnvolle Werte ueberpruefen ( Bug-Id #29001 )
+ if ( ( nBitsPerPixel > 24 ) || ( nCompression > 3 ) )
+ {
+ nFormat = GFF_NOT;
+ bRet = FALSE;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectGIF( SvStream& rStm, BOOL bExtendedInfo )
+{
+ UINT32 n32;
+ UINT16 n16;
+ BOOL bRet = FALSE;
+ BYTE cByte;
+
+ rStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ rStm.Seek( nStmPos );
+
+ rStm >> n32;
+ if ( n32 == 0x38464947 )
+ {
+ rStm >> n16;
+ if ( ( n16 == 0x6137 ) || ( n16 == 0x6139 ) )
+ {
+ nFormat = GFF_GIF;
+ bRet = TRUE;
+
+ if ( bExtendedInfo )
+ {
+ UINT16 nTemp16;
+
+ // PixelBreite auslesen
+ rStm >> nTemp16;
+ aPixSize.Width() = nTemp16;
+
+ // PixelHoehe auslesen
+ rStm >> nTemp16;
+ aPixSize.Height() = nTemp16;
+
+ // Bits/Pixel auslesen
+ rStm >> cByte;
+ nBitsPerPixel = ( ( cByte & 112 ) >> 4 ) + 1;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectJPG( SvStream& rStm, BOOL bExtendedInfo )
+{
+ UINT32 nTemp32;
+ BOOL bRet = FALSE;
+ BYTE cByte = 0;
+ BOOL bM_COM;
+
+ rStm.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+ rStm.Seek( nStmPos );
+
+ rStm >> nTemp32;
+
+ // compare upper 28 bits
+ if( 0xffd8ff00 == ( nTemp32 & 0xffffff00 ) )
+ {
+ nFormat = GFF_JPG;
+ return TRUE;
+ }
+
+ bM_COM = ( nTemp32 == 0xffd8fffe );
+ if ( ( nTemp32 == 0xffd8ffe0 ) || bM_COM )
+ {
+ if( !bM_COM )
+ {
+ rStm.SeekRel( 2 );
+ rStm >> nTemp32;
+ }
+
+ if( bM_COM || ( nTemp32 == 0x4a464946 ) )
+ {
+ nFormat = GFF_JPG;
+ bRet = TRUE;
+
+ if( bExtendedInfo )
+ {
+ MapMode aMap;
+ UINT16 nTemp16;
+ ULONG nCount = 9;
+ ULONG nMax;
+ ULONG nResX;
+ ULONG nResY;
+ BYTE cUnit;
+
+ // Groesse des verbleibenden Puffers ermitteln
+ if ( bLinked )
+ nMax = static_cast< SvMemoryStream& >(rStm).GetEndOfData()
+ - 16;
+ else
+ nMax = DATA_SIZE - 16;
+
+ // max. 8K
+ nMax = Min( nMax, (ULONG) 8192 );
+
+ // Res-Unit ermitteln
+ rStm.SeekRel( 3 );
+ rStm >> cUnit;
+
+ // ResX ermitteln
+ rStm >> nTemp16;
+ nResX = nTemp16;
+
+ // ResY ermitteln
+ rStm >> nTemp16;
+ nResY = nTemp16;
+
+ // SOF0/1-Marker finden, aber dabei
+ // nicht mehr als DATA_SIZE Pixel lesen, falls
+ // kein WideSearch
+ do
+ {
+ while ( ( cByte != 0xff ) &&
+ ( bWideSearch || ( nCount++ < nMax ) ) )
+ {
+ rStm >> cByte;
+ }
+
+ while ( ( cByte == 0xff ) &&
+ ( bWideSearch || ( nCount++ < nMax ) ) )
+ {
+ rStm >> cByte;
+ }
+ }
+ while ( ( cByte != 0xc0 ) &&
+ ( cByte != 0xc1 ) &&
+ ( bWideSearch || ( nCount < nMax ) ) );
+
+ // wir haben den SOF0/1-Marker
+ if ( ( cByte == 0xc0 ) || ( cByte == 0xc1 ) )
+ {
+ // Hoehe einlesen
+ rStm.SeekRel( 3 );
+ rStm >> nTemp16;
+ aPixSize.Height() = nTemp16;
+
+ // Breite einlesen
+ rStm >> nTemp16;
+ aPixSize.Width() = nTemp16;
+
+ // Bit/Pixel einlesen
+ rStm >> cByte;
+ nBitsPerPixel = ( cByte == 3 ? 24 : cByte == 1 ? 8 : 0 );
+
+ // logische Groesse setzen
+ if ( cUnit && nResX && nResY )
+ {
+ aMap.SetMapUnit( cUnit == 1 ? MAP_INCH : MAP_CM );
+ aMap.SetScaleX( Fraction( 1, nResX ) );
+ aMap.SetScaleY( Fraction( 1, nResY ) );
+ aLogSize = OutputDevice::LogicToLogic( aPixSize, aMap,
+ MapMode( MAP_100TH_MM ) );
+ }
+
+ // Planes immer 1
+ nPlanes = 1;
+ }
+ }
+ }
+ }
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectPCD( SvStream& rStm, BOOL )
+{
+ BOOL bRet = FALSE;
+
+ rStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ rStm.Seek( nStmPos );
+
+ if ( bWideSearch )
+ {
+ UINT32 nTemp32;
+ UINT16 nTemp16;
+ BYTE cByte;
+
+ rStm.SeekRel( 2048 );
+ rStm >> nTemp32;
+ rStm >> nTemp16;
+ rStm >> cByte;
+
+ if ( ( nTemp32 == 0x5f444350 ) &&
+ ( nTemp16 == 0x5049 ) &&
+ ( cByte == 0x49 ) )
+ {
+ nFormat = GFF_PCD;
+ bRet = TRUE;
+ }
+ }
+ else
+ {
+ bRet = aPathExt.CompareToAscii( "pcd", 3 ) == COMPARE_EQUAL;
+ if ( bRet )
+ {
+ nFormat = GFF_PCD;
+ }
+ }
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectPCX( SvStream& rStm, BOOL bExtendedInfo )
+{
+ // ! Because 0x0a can be interpreted as LF too ...
+ // we cant be shure that this special sign represent a PCX file only.
+ // Every Ascii file is possible here :-(
+ // We must detect the whole header.
+ bExtendedInfo = TRUE;
+
+ BOOL bRet = FALSE;
+ BYTE cByte;
+
+ rStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ rStm.Seek( nStmPos );
+
+ rStm >> cByte;
+ if ( cByte == 0x0a )
+ {
+ nFormat = GFF_PCX;
+ bRet = TRUE;
+
+ if ( bExtendedInfo )
+ {
+ UINT16 nTemp16;
+ USHORT nXmin;
+ USHORT nXmax;
+ USHORT nYmin;
+ USHORT nYmax;
+ USHORT nDPIx;
+ USHORT nDPIy;
+
+
+ rStm.SeekRel( 1 );
+
+ // Kompression lesen
+ rStm >> cByte;
+ bCompressed = ( cByte > 0 );
+
+ bRet = (cByte==0 || cByte ==1);
+
+ // Bits/Pixel lesen
+ rStm >> cByte;
+ nBitsPerPixel = cByte;
+
+ // Bildabmessungen
+ rStm >> nTemp16;
+ nXmin = nTemp16;
+ rStm >> nTemp16;
+ nYmin = nTemp16;
+ rStm >> nTemp16;
+ nXmax = nTemp16;
+ rStm >> nTemp16;
+ nYmax = nTemp16;
+
+ aPixSize.Width() = nXmax - nXmin + 1;
+ aPixSize.Height() = nYmax - nYmin + 1;
+
+ // Aufloesung
+ rStm >> nTemp16;
+ nDPIx = nTemp16;
+ rStm >> nTemp16;
+ nDPIy = nTemp16;
+
+ // logische Groesse setzen
+ MapMode aMap( MAP_INCH, Point(),
+ Fraction( 1, nDPIx ), Fraction( 1, nDPIy ) );
+ aLogSize = OutputDevice::LogicToLogic( aPixSize, aMap,
+ MapMode( MAP_100TH_MM ) );
+
+
+ // Anzahl Farbebenen
+ rStm.SeekRel( 49 );
+ rStm >> cByte;
+ nPlanes = cByte;
+
+ bRet = (nPlanes<=4);
+ }
+ }
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectPNG( SvStream& rStm, BOOL bExtendedInfo )
+{
+ UINT32 nTemp32;
+ BOOL bRet = FALSE;
+
+ rStm.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+ rStm.Seek( nStmPos );
+
+ rStm >> nTemp32;
+ if ( nTemp32 == 0x89504e47 )
+ {
+ rStm >> nTemp32;
+ if ( nTemp32 == 0x0d0a1a0a )
+ {
+ nFormat = GFF_PNG;
+ bRet = TRUE;
+
+ if ( bExtendedInfo )
+ {
+ BYTE cByte;
+
+ // IHDR-Chunk
+ rStm.SeekRel( 8 );
+
+ // Breite einlesen
+ rStm >> nTemp32;
+ aPixSize.Width() = nTemp32;
+
+ // Hoehe einlesen
+ rStm >> nTemp32;
+ aPixSize.Height() = nTemp32;
+
+ // Bits/Pixel einlesen
+ rStm >> cByte;
+ nBitsPerPixel = cByte;
+
+ // Planes immer 1;
+ // Kompression immer
+ nPlanes = 1;
+ bCompressed = TRUE;
+
+ if ( bWideSearch )
+ {
+ UINT32 nLen32;
+
+ rStm.SeekRel( 8 );
+
+ // so lange ueberlesen, bis wir den pHYs-Chunk haben oder
+ // den Anfang der Bilddaten
+ rStm >> nLen32;
+ rStm >> nTemp32;
+ while( ( nTemp32 != 0x70485973 ) && ( nTemp32 != 0x49444154 ) )
+ {
+ rStm.SeekRel( 4 + nLen32 );
+ rStm >> nLen32;
+ rStm >> nTemp32;
+ }
+
+ if ( nTemp32 == 0x70485973 )
+ {
+ ULONG nXRes;
+ ULONG nYRes;
+
+ // horizontale Aufloesung
+ rStm >> nTemp32;
+ nXRes = nTemp32;
+
+ // vertikale Aufloesung
+ rStm >> nTemp32;
+ nYRes = nTemp32;
+
+ // Unit einlesen
+ rStm >> cByte;
+
+ if ( cByte )
+ {
+ if ( nXRes )
+ aLogSize.Width() = ( aPixSize.Width() * 100000 ) /
+ nTemp32;
+
+ if ( nYRes )
+ aLogSize.Height() = ( aPixSize.Height() * 100000 ) /
+ nTemp32;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectTIF( SvStream& rStm, BOOL bExtendedInfo )
+{
+ BOOL bDetectOk = FALSE;
+ BOOL bRet = FALSE;
+ BYTE cByte1;
+ BYTE cByte2;
+
+ rStm.Seek( nStmPos );
+ rStm >> cByte1;
+ rStm >> cByte2;
+ if ( cByte1 == cByte2 )
+ {
+ if ( cByte1 == 0x49 )
+ {
+ rStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ bDetectOk = TRUE;
+ }
+ else if ( cByte1 == 0x4d )
+ {
+ rStm.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+ bDetectOk = TRUE;
+ }
+
+ if ( bDetectOk )
+ {
+ UINT16 nTemp16;
+
+ rStm >> nTemp16;
+ if ( nTemp16 == 0x2a )
+ {
+ nFormat = GFF_TIF;
+ bRet = TRUE;
+
+ if ( bExtendedInfo )
+ {
+ ULONG nCount;
+ ULONG nMax = DATA_SIZE - 48;
+ UINT32 nTemp32;
+ BOOL bOk = FALSE;
+
+ // Offset des ersten IFD einlesen
+ rStm >> nTemp32;
+ rStm.SeekRel( ( nCount = ( nTemp32 + 2 ) ) - 0x08 );
+
+ if ( bWideSearch || ( nCount < nMax ) )
+ {
+ // Tag's lesen, bis wir auf Tag256 ( Width ) treffen
+ // nicht mehr Bytes als DATA_SIZE lesen
+ rStm >> nTemp16;
+ while ( nTemp16 != 256 )
+ {
+ bOk = bWideSearch || ( nCount < nMax );
+ if ( !bOk )
+ {
+ break;
+ }
+ rStm.SeekRel( 10 );
+ rStm >> nTemp16;
+ nCount += 12;
+ }
+
+ if ( bOk )
+ {
+ // Breite lesen
+ rStm >> nTemp16;
+ rStm.SeekRel( 4 );
+ if ( nTemp16 == 3 )
+ {
+ rStm >> nTemp16;
+ aPixSize.Width() = nTemp16;
+ rStm.SeekRel( 2 );
+ }
+ else
+ {
+ rStm >> nTemp32;
+ aPixSize.Width() = nTemp32;
+ }
+ nCount += 12;
+
+ // Hoehe lesen
+ rStm.SeekRel( 2 );
+ rStm >> nTemp16;
+ rStm.SeekRel( 4 );
+ if ( nTemp16 == 3 )
+ {
+ rStm >> nTemp16;
+ aPixSize.Height() = nTemp16;
+ rStm.SeekRel( 2 );
+ }
+ else
+ {
+ rStm >> nTemp32;
+ aPixSize.Height() = nTemp32;
+ }
+ nCount += 12;
+
+ // ggf. Bits/Pixel lesen
+ rStm >> nTemp16;
+ if ( nTemp16 == 258 )
+ {
+ rStm.SeekRel( 6 );
+ rStm >> nTemp16;
+ nBitsPerPixel = nTemp16;
+ rStm.SeekRel( 2 );
+ nCount += 12;
+ }
+ else
+ rStm.SeekRel( -2 );
+
+ // ggf. Compression lesen
+ rStm >> nTemp16;
+ if ( nTemp16 == 259 )
+ {
+ rStm.SeekRel( 6 );
+ rStm >> nTemp16;
+ bCompressed = ( nTemp16 > 1 );
+ rStm.SeekRel( 2 );
+ nCount += 12;
+ }
+ else
+ rStm.SeekRel( -2 );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectXBM( SvStream&, BOOL )
+{
+ BOOL bRet = aPathExt.CompareToAscii( "xbm", 3 ) == COMPARE_EQUAL;
+ if (bRet)
+ nFormat = GFF_XBM;
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectXPM( SvStream&, BOOL )
+{
+ BOOL bRet = aPathExt.CompareToAscii( "xpm", 3 ) == COMPARE_EQUAL;
+ if (bRet)
+ nFormat = GFF_XPM;
+
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectPBM( SvStream& rStm, BOOL )
+{
+ BOOL bRet = FALSE;
+
+ // erst auf Datei Extension pruefen, da diese aussagekraeftiger ist
+ // als die 2 ID Bytes
+
+ if ( aPathExt.CompareToAscii( "pbm", 3 ) == COMPARE_EQUAL )
+ bRet = TRUE;
+ else
+ {
+ BYTE nFirst, nSecond;
+ rStm.Seek( nStmPos );
+ rStm >> nFirst >> nSecond;
+ if ( nFirst == 'P' && ( ( nSecond == '1' ) || ( nSecond == '4' ) ) )
+ bRet = TRUE;
+ }
+
+ if ( bRet )
+ nFormat = GFF_PBM;
+
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectPGM( SvStream& rStm, BOOL )
+{
+ BOOL bRet = FALSE;
+
+ if ( aPathExt.CompareToAscii( "pgm", 3 ) == COMPARE_EQUAL )
+ bRet = TRUE;
+ else
+ {
+ BYTE nFirst, nSecond;
+ rStm.Seek( nStmPos );
+ rStm >> nFirst >> nSecond;
+ if ( nFirst == 'P' && ( ( nSecond == '2' ) || ( nSecond == '5' ) ) )
+ bRet = TRUE;
+ }
+
+ if ( bRet )
+ nFormat = GFF_PGM;
+
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectPPM( SvStream& rStm, BOOL )
+{
+ BOOL bRet = FALSE;
+
+ if ( aPathExt.CompareToAscii( "ppm", 3 ) == COMPARE_EQUAL )
+ bRet = TRUE;
+ else
+ {
+ BYTE nFirst, nSecond;
+ rStm.Seek( nStmPos );
+ rStm >> nFirst >> nSecond;
+ if ( nFirst == 'P' && ( ( nSecond == '3' ) || ( nSecond == '6' ) ) )
+ bRet = TRUE;
+ }
+
+ if ( bRet )
+ nFormat = GFF_PPM;
+
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectRAS( SvStream& rStm, BOOL )
+{
+ UINT32 nMagicNumber;
+ rStm.Seek( nStmPos );
+ rStm.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+ rStm >> nMagicNumber;
+ if ( nMagicNumber == 0x59a66a95 )
+ {
+ nFormat = GFF_RAS;
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectTGA( SvStream&, BOOL )
+{
+ BOOL bRet = aPathExt.CompareToAscii( "tga", 3 ) == COMPARE_EQUAL;
+ if (bRet)
+ nFormat = GFF_TGA;
+
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectPSD( SvStream& rStm, BOOL bExtendedInfo )
+{
+ BOOL bRet = FALSE;
+
+ UINT32 nMagicNumber;
+ rStm.Seek( nStmPos );
+ rStm.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+ rStm >> nMagicNumber;
+ if ( nMagicNumber == 0x38425053 )
+ {
+ UINT16 nVersion;
+ rStm >> nVersion;
+ if ( nVersion == 1 )
+ {
+ bRet = TRUE;
+ if ( bExtendedInfo )
+ {
+ UINT16 nChannels;
+ UINT32 nRows;
+ UINT32 nColumns;
+ UINT16 nDepth;
+ UINT16 nMode;
+ rStm.SeekRel( 6 ); // Pad
+ rStm >> nChannels >> nRows >> nColumns >> nDepth >> nMode;
+ if ( ( nDepth == 1 ) || ( nDepth == 8 ) || ( nDepth == 16 ) )
+ {
+ nBitsPerPixel = ( nDepth == 16 ) ? 8 : nDepth;
+ switch ( nChannels )
+ {
+ case 4 :
+ case 3 :
+ nBitsPerPixel = 24;
+ case 2 :
+ case 1 :
+ aPixSize.Width() = nColumns;
+ aPixSize.Height() = nRows;
+ break;
+ default:
+ bRet = FALSE;
+ }
+ }
+ else
+ bRet = FALSE;
+ }
+ }
+ }
+
+ if ( bRet )
+ nFormat = GFF_PSD;
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectEPS( SvStream& rStm, BOOL )
+{
+ // es wird die EPS mit Vorschaubild Variante und die Extensionuebereinstimmung
+ // geprueft
+
+ sal_uInt32 nFirstLong;
+ sal_uInt8 nFirstBytes[20];
+
+ rStm.Seek( nStmPos );
+ rStm.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+ rStm >> nFirstLong;
+ rStm.SeekRel( -4 );
+ rStm.Read( &nFirstBytes, 20 );
+
+ if ( ( nFirstLong == 0xC5D0D3C6 ) || ( aPathExt.CompareToAscii( "eps", 3 ) == COMPARE_EQUAL ) ||
+ ( ImplSearchEntry( nFirstBytes, (sal_uInt8*)"%!PS-Adobe", 10, 10 )
+ && ImplSearchEntry( &nFirstBytes[15], (sal_uInt8*)"EPS", 3, 3 ) ) )
+ {
+ nFormat = GFF_EPS;
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectDXF( SvStream&, BOOL )
+{
+ BOOL bRet = aPathExt.CompareToAscii( "dxf", 3 ) == COMPARE_EQUAL;
+ if (bRet)
+ nFormat = GFF_DXF;
+
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectMET( SvStream&, BOOL )
+{
+ BOOL bRet = aPathExt.CompareToAscii( "met", 3 ) == COMPARE_EQUAL;
+ if (bRet)
+ nFormat = GFF_MET;
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectPCT( SvStream& rStm, BOOL )
+{
+ BOOL bRet = aPathExt.CompareToAscii( "pct", 3 ) == COMPARE_EQUAL;
+ if (bRet)
+ nFormat = GFF_PCT;
+ else
+ {
+ BYTE sBuf[4];
+
+ rStm.Seek( nStmPos + 522 );
+ rStm.Read( sBuf, 3 );
+
+ if( !rStm.GetError() )
+ {
+ if ( ( sBuf[0] == 0x00 ) && ( sBuf[1] == 0x11 ) &&
+ ( ( sBuf[2] == 0x01 ) || ( sBuf[2] == 0x02 ) ) )
+ {
+ bRet = TRUE;
+ nFormat = GFF_PCT;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectSGF( SvStream& rStm, BOOL )
+{
+ BOOL bRet = FALSE;
+
+ if( aPathExt.CompareToAscii( "sgf", 3 ) == COMPARE_EQUAL )
+ bRet = TRUE;
+ else
+ {
+ BYTE nFirst, nSecond;
+
+ rStm.Seek( nStmPos );
+ rStm >> nFirst >> nSecond;
+
+ if( nFirst == 'J' && nSecond == 'J' )
+ bRet = TRUE;
+ }
+
+ if( bRet )
+ nFormat = GFF_SGF;
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectSGV( SvStream&, BOOL )
+{
+ BOOL bRet = aPathExt.CompareToAscii( "sgv", 3 ) == COMPARE_EQUAL;
+ if (bRet)
+ nFormat = GFF_SGV;
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectSVM( SvStream& rStm, BOOL bExtendedInfo )
+{
+ UINT32 n32;
+ BOOL bRet = FALSE;
+ BYTE cByte;
+
+ rStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ rStm.Seek( nStmPos );
+
+ rStm >> n32;
+ if ( n32 == 0x44475653 )
+ {
+ rStm >> cByte;
+ if ( cByte == 0x49 )
+ {
+ nFormat = GFF_SVM;
+ bRet = TRUE;
+
+ if ( bExtendedInfo )
+ {
+ UINT32 nTemp32;
+ UINT16 nTemp16;
+
+ rStm.SeekRel( 0x04 );
+
+ // Breite auslesen
+ rStm >> nTemp32;
+ aLogSize.Width() = nTemp32;
+
+ // Hoehe auslesen
+ rStm >> nTemp32;
+ aLogSize.Height() = nTemp32;
+
+ // Map-Unit auslesen und PrefSize ermitteln
+ rStm >> nTemp16;
+ aLogSize = OutputDevice::LogicToLogic( aLogSize,
+ MapMode( (MapUnit) nTemp16 ),
+ MapMode( MAP_100TH_MM ) );
+ }
+ }
+ }
+ else
+ {
+ rStm.SeekRel( -4L );
+ rStm >> n32;
+
+ if( n32 == 0x4D4C4356 )
+ {
+ UINT16 nTmp16;
+
+ rStm >> nTmp16;
+
+ if( nTmp16 == 0x4654 )
+ {
+ nFormat = GFF_SVM;
+ bRet = TRUE;
+
+ if( bExtendedInfo )
+ {
+ MapMode aMapMode;
+
+ rStm.SeekRel( 0x06 );
+ rStm >> aMapMode;
+ rStm >> aLogSize;
+ aLogSize = OutputDevice::LogicToLogic( aLogSize, aMapMode, MapMode( MAP_100TH_MM ) );
+ }
+ }
+ }
+ }
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectWMF( SvStream&, BOOL )
+{
+ BOOL bRet = aPathExt.CompareToAscii( "wmf",3 ) == COMPARE_EQUAL;
+ if (bRet)
+ nFormat = GFF_WMF;
+
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectEMF( SvStream&, BOOL )
+{
+ BOOL bRet = aPathExt.CompareToAscii( "emf", 3 ) == COMPARE_EQUAL;
+ if (bRet)
+ nFormat = GFF_EMF;
+
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+String GraphicDescriptor::GetImportFormatShortName( sal_uInt16 nFormat )
+{
+ ByteString aKeyName;
+
+ switch( nFormat )
+ {
+ case( GFF_BMP ) : aKeyName = "bmp"; break;
+ case( GFF_GIF ) : aKeyName = "gif"; break;
+ case( GFF_JPG ) : aKeyName = "jpg"; break;
+ case( GFF_PCD ) : aKeyName = "pcd"; break;
+ case( GFF_PCX ) : aKeyName = "pcx"; break;
+ case( GFF_PNG ) : aKeyName = "png"; break;
+ case( GFF_XBM ) : aKeyName = "xbm"; break;
+ case( GFF_XPM ) : aKeyName = "xpm"; break;
+ case( GFF_PBM ) : aKeyName = "pbm"; break;
+ case( GFF_PGM ) : aKeyName = "pgm"; break;
+ case( GFF_PPM ) : aKeyName = "ppm"; break;
+ case( GFF_RAS ) : aKeyName = "ras"; break;
+ case( GFF_TGA ) : aKeyName = "tga"; break;
+ case( GFF_PSD ) : aKeyName = "psd"; break;
+ case( GFF_EPS ) : aKeyName = "eps"; break;
+ case( GFF_TIF ) : aKeyName = "tif"; break;
+ case( GFF_DXF ) : aKeyName = "dxf"; break;
+ case( GFF_MET ) : aKeyName = "met"; break;
+ case( GFF_PCT ) : aKeyName = "pct"; break;
+ case( GFF_SGF ) : aKeyName = "sgf"; break;
+ case( GFF_SGV ) : aKeyName = "sgv"; break;
+ case( GFF_SVM ) : aKeyName = "svm"; break;
+ case( GFF_WMF ) : aKeyName = "wmf"; break;
+ case( GFF_EMF ) : aKeyName = "emf"; break;
+ }
+
+ return String( aKeyName, RTL_TEXTENCODING_ASCII_US );
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_fldll.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_fldll.cxx
new file mode 100644
index 000000000000..4d7d7f50fae7
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_fldll.cxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+#ifdef WIN
+
+#include <svwin.h>
+
+namespace binfilter
+{
+
+// Statische DLL-Verwaltungs-Variablen
+static HINSTANCE hDLLInst = 0; // HANDLE der DLL
+
+
+/***************************************************************************
+|*
+|* LibMain()
+|*
+|* Beschreibung Initialisierungsfunktion der DLL
+|* Ersterstellung TH 05.05.93
+|* Letzte Aenderung TH 05.05.93
+|*
+***************************************************************************/
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+/***************************************************************************
+|*
+|* WEP()
+|*
+|* Beschreibung DLL-Deinitialisierung
+|* Ersterstellung TH 05.05.93
+|* Letzte Aenderung TH 05.05.93
+|*
+***************************************************************************/
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_gradwrap.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_gradwrap.cxx
new file mode 100644
index 000000000000..75c94d9f07dc
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_gradwrap.cxx
@@ -0,0 +1,577 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <math.h>
+#include <svgrad.hxx>
+#include <svbmpacc.hxx>
+#include <gradwrap.hxx>
+
+namespace binfilter
+{
+
+// -------------------
+// - GradientWrapper -
+// -------------------
+
+GradientWrapper::GradientWrapper(const Link& rDrawPolyRecordHdl,
+ const Link& rDrawPolyPolyRecordHdl,
+ const Link& rSetFillInBrushRecordHdl) :
+ aDrawPolyRecordHdl (rDrawPolyRecordHdl),
+ aDrawPolyPolyRecordHdl (rDrawPolyPolyRecordHdl),
+ aSetFillInBrushRecordHdl(rSetFillInBrushRecordHdl)
+{
+}
+
+// ------------------------------------------------------------------------
+
+GradientWrapper::~GradientWrapper()
+{
+}
+
+// ------------------------------------------------------------------------
+
+void GradientWrapper::WriteLinearGradient(const Rectangle& rRect,
+ const Gradient& rGradient)
+{
+ USHORT nStepCount = 100;
+
+ Rectangle aRect = rRect;
+ aRect.Left()--;
+ aRect.Top()--;
+ aRect.Right()++;
+ aRect.Bottom()++;
+
+ // rotiertes BoundRect ausrechnen
+ double fAngle = (rGradient.GetAngle() % 3600) * F_PI1800;
+ double fWidth = aRect.GetWidth();
+ double fHeight = aRect.GetHeight();
+ double fDX = fWidth * fabs( cos( fAngle ) ) +
+ fHeight * fabs( sin( fAngle ) );
+ double fDY = fHeight * fabs( cos( fAngle ) ) +
+ fWidth * fabs( sin( fAngle ) );
+ fDX = (fDX - fWidth) * 0.5 + 0.5;
+ fDY = (fDY - fHeight) * 0.5 + 0.5;
+ aRect.Left() -= (long)fDX;
+ aRect.Right() += (long)fDX;
+ aRect.Top() -= (long)fDY;
+ aRect.Bottom() += (long)fDY;
+
+ // Rand berechnen und Rechteck neu setzen
+ Point aCenter = rRect.Center();
+ Rectangle aFullRect = aRect;
+ long nBorder = (long)rGradient.GetBorder() * aRect.GetHeight() / 100;
+ BOOL bLinear;
+
+ // Rand berechnen und Rechteck neu setzen fuer linearen Farbverlauf
+ if ( rGradient.GetStyle() == GRADIENT_LINEAR )
+ {
+ bLinear = TRUE;
+ aRect.Top() += nBorder;
+ }
+ // Rand berechnen und Rechteck neu setzen fuer axiale Farbverlauf
+ else
+ {
+ bLinear = FALSE;
+ nBorder >>= 1;
+
+ aRect.Top() += nBorder;
+ aRect.Bottom() -= nBorder;
+ }
+
+ // Top darf nicht groesser als Bottom sein
+ aRect.Top() = Min( aRect.Top(), (long)(aRect.Bottom() - 1) );
+
+ long nMinRect = aRect.GetHeight();
+
+ // Anzahl der Schritte berechnen, falls nichts uebergeben wurde
+ if ( !nStepCount )
+ {
+ long nInc = ((nMinRect >> 9) + 1) << 3;
+
+ if ( !nInc )
+ nInc = 1;
+
+ nStepCount = (USHORT)(nMinRect / nInc);
+ }
+ // minimal drei Schritte
+ long nSteps = Max( nStepCount, (USHORT)3 );
+
+ // Falls axialer Farbverlauf, muss die Schrittanzahl ungerade sein
+ if ( !bLinear && !(nSteps & 1) )
+ nSteps++;
+
+ // Berechnung ueber Double-Addition wegen Genauigkeit
+ double fScanLine = aRect.Top();
+ double fScanInc = (double)aRect.GetHeight() / (double)nSteps;
+
+ // Intensitaeten von Start- und Endfarbe ggf. aendern und
+ // Farbschrittweiten berechnen
+ long nFactor;
+ const Color& rStartCol = rGradient.GetStartColor();
+ const Color& rEndCol = rGradient.GetEndColor();
+ long nRed = rStartCol.GetRed();
+ long nGreen = rStartCol.GetGreen();
+ long nBlue = rStartCol.GetBlue();
+ long nEndRed = rEndCol.GetRed();
+ long nEndGreen = rEndCol.GetGreen();
+ long nEndBlue = rEndCol.GetBlue();
+ nFactor = rGradient.GetStartIntensity();
+ nRed = (nRed * nFactor) / 100;
+ nGreen = (nGreen * nFactor) / 100;
+ nBlue = (nBlue * nFactor) / 100;
+ nFactor = rGradient.GetEndIntensity();
+ nEndRed = (nEndRed * nFactor) / 100;
+ nEndGreen = (nEndGreen * nFactor) / 100;
+ nEndBlue = (nEndBlue * nFactor) / 100;
+ long nStepRed = (nEndRed - nRed) / nSteps;
+ long nStepGreen = (nEndGreen - nGreen) / nSteps;
+ long nStepBlue = (nEndBlue - nBlue) / nSteps;
+ long nSteps2;
+
+ if ( bLinear )
+ {
+ // Um 1 erhoeht, um die Border innerhalb der Schleife
+ // zeichnen zu koennen
+ nSteps2 = nSteps + 1;
+ }
+ else
+ {
+ nStepRed <<= 1;
+ nStepGreen <<= 1;
+ nStepBlue <<= 1;
+ nRed = nEndRed;
+ nGreen = nEndGreen;
+ nBlue = nEndBlue;
+
+ // Um 2 erhoeht, um die Border innerhalb der Schleife
+ // zeichnen zu koennen
+ nSteps2 = nSteps + 2;
+ }
+ Color aCol( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue );
+
+ // GDI-Objekte sichern und setzen
+ aSetFillInBrushRecordHdl.Call(&aCol);
+
+ // Startpolygon erzeugen (== Borderpolygon)
+ Polygon aPoly( 4 );
+ Polygon aTempPoly( 2 );
+ aPoly[0] = aFullRect.TopLeft();
+ aPoly[1] = aFullRect.TopRight();
+ aPoly[2] = aRect.TopRight();
+ aPoly[3] = aRect.TopLeft();
+ aPoly.Rotate( aCenter, rGradient.GetAngle() );
+
+ // Schleife, um rotierten Verlauf zu fuellen
+ for ( long i = 0; i < nSteps2; i++ )
+ {
+ Polygon aTempPoly = aPoly;
+ aTempPoly.Clip( rRect );
+ aDrawPolyRecordHdl.Call(&aTempPoly);
+ aTempPoly.SetSize( 2 );
+
+ // neues Polygon berechnen
+ aRect.Top() = (long)(fScanLine += fScanInc);
+
+ // unteren Rand komplett fuellen
+ if ( i == nSteps )
+ {
+ aTempPoly[0] = aFullRect.BottomLeft();
+ aTempPoly[1] = aFullRect.BottomRight();
+ }
+ else
+ {
+ aTempPoly[0] = aRect.TopLeft();
+ aTempPoly[1] = aRect.TopRight();
+ }
+ aTempPoly.Rotate( aCenter, rGradient.GetAngle() );
+
+ aPoly[0] = aPoly[3];
+ aPoly[1] = aPoly[2];
+ aPoly[2] = aTempPoly[1];
+ aPoly[3] = aTempPoly[0];
+
+ // Farbintensitaeten aendern...
+ // fuer lineare FV
+ if ( bLinear )
+ {
+ nRed += nStepRed;
+ nGreen += nStepGreen;
+ nBlue += nStepBlue;
+ }
+ // fuer radiale FV
+ else
+ {
+ if ( i <= (nSteps >> 1) )
+ {
+ nRed -= nStepRed;
+ nGreen -= nStepGreen;
+ nBlue -= nStepBlue;
+ }
+ // genau die Mitte und hoeher
+ else
+ {
+ nRed += nStepRed;
+ nGreen += nStepGreen;
+ nBlue += nStepBlue;
+ }
+ }
+
+ nRed = MinMax( nRed, 0, 255 );
+ nGreen = MinMax( nGreen, 0, 255 );
+ nBlue = MinMax( nBlue, 0, 255 );
+
+ // fuer lineare FV ganz normale Bestimmung der Farbe
+ if ( bLinear || (i <= nSteps) )
+ {
+ aCol = Color( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue );
+ }
+ // fuer axiale FV muss die letzte Farbe der ersten
+ // Farbe entsprechen
+ else
+ {
+ aCol = Color( (BYTE) nEndRed, (BYTE) nEndGreen, (BYTE) nEndBlue );
+ }
+
+ aSetFillInBrushRecordHdl.Call(&aCol);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GradientWrapper::WriteRadialGradient(const Rectangle& rRect,
+ const Gradient& rGradient)
+{
+ USHORT nStepCount = 100;
+ Rectangle aClipRect = rRect;
+ Rectangle aRect = rRect;
+ long nZWidth = aRect.GetWidth() * (long)rGradient.GetOfsX() / 100;
+ long nZHeight= aRect.GetHeight() * (long)rGradient.GetOfsY() / 100;
+ Size aSize = aRect.GetSize();
+ Point aCenter( aRect.Left() + nZWidth, aRect.Top() + nZHeight );
+
+ // Radien-Berechnung fuer Kreisausgabe (Kreis schliesst Rechteck ein)
+ if ( rGradient.GetStyle() == GRADIENT_RADIAL )
+ {
+ aSize.Width() = (long)(0.5 + sqrt((double)aSize.Width()*(double)aSize.Width() +
+ (double)aSize.Height()*(double)aSize.Height()));
+ aSize.Height() = aSize.Width();
+ }
+ // Radien-Berechnung fuer Ellipse
+ else
+ {
+ aSize.Width() = (long)(0.5 + (double)aSize.Width() * 1.4142);
+ aSize.Height() = (long)(0.5 + (double)aSize.Height() * 1.4142);
+ }
+
+ long nBorderX = (long)rGradient.GetBorder() * aSize.Width() / 100;
+ long nBorderY = (long)rGradient.GetBorder() * aSize.Height() / 100;
+ aSize.Width() -= nBorderX;
+ aSize.Height() -= nBorderY;
+ aRect.Left() = aCenter.X() - (aSize.Width() >> 1);
+ aRect.Top() = aCenter.Y() - (aSize.Height() >> 1);
+ aRect.SetSize( aSize );
+
+ long nMinRect = Min( aRect.GetWidth(), aRect.GetHeight() );
+
+ // Anzahl der Schritte berechnen, falls nichts uebergeben wurde
+ if ( !nStepCount )
+ {
+ long nInc = ((nMinRect >> 9) + 1) << 3;
+
+ if ( !nInc )
+ nInc = 1;
+
+ nStepCount = (USHORT)(nMinRect / nInc);
+ }
+ // minimal drei Schritte
+ long nSteps = Max( nStepCount, (USHORT)3 );
+
+ // Ausgabebegrenzungen und Schrittweite fuer jede Richtung festlegen
+ double fScanLeft = aRect.Left();
+ double fScanTop = aRect.Top();
+ double fScanRight = aRect.Right();
+ double fScanBottom = aRect.Bottom();
+ double fScanInc = (double)nMinRect / (double)nSteps * 0.5;
+
+ // Intensitaeten von Start- und Endfarbe ggf. aendern und
+ // Farbschrittweiten berechnen
+ long nFactor;
+ const Color& rStartCol = rGradient.GetStartColor();
+ const Color& rEndCol = rGradient.GetEndColor();
+ long nRed = rStartCol.GetRed();
+ long nGreen = rStartCol.GetGreen();
+ long nBlue = rStartCol.GetBlue();
+ long nEndRed = rEndCol.GetRed();
+ long nEndGreen = rEndCol.GetGreen();
+ long nEndBlue = rEndCol.GetBlue();
+ nFactor = rGradient.GetStartIntensity();
+ nRed = (nRed * nFactor) / 100;
+ nGreen = (nGreen * nFactor) / 100;
+ nBlue = (nBlue * nFactor) / 100;
+ nFactor = rGradient.GetEndIntensity();
+ nEndRed = (nEndRed * nFactor) / 100;
+ nEndGreen = (nEndGreen * nFactor) / 100;
+ nEndBlue = (nEndBlue * nFactor) / 100;
+ long nStepRed = (nEndRed - nRed) / nSteps;
+ long nStepGreen = (nEndGreen - nGreen) / nSteps;
+ long nStepBlue = (nEndBlue - nBlue) / nSteps;
+ Color aCol( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue );
+
+ // GDI-Objekte sichern und setzen
+ aSetFillInBrushRecordHdl.Call(&aCol);
+
+ // Recteck erstmal ausgeben
+ PolyPolygon aPolyPoly( 2 );
+ Polygon aPoly( rRect );
+
+ aPolyPoly.Insert( aPoly );
+ aPoly = Polygon( aRect );
+ aPoly.Rotate( aCenter, rGradient.GetAngle() );
+ aPolyPoly.Insert( aPoly );
+
+ // erstes Polygon zeichnen (entspricht Rechteck)
+ PolyPolygon aTempPolyPoly = aPolyPoly;
+ aTempPolyPoly.Clip( aClipRect );
+ aDrawPolyPolyRecordHdl.Call(&aTempPolyPoly);
+
+ for ( long i = 0; i < nSteps; i++ )
+ {
+ Color aCol( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue );
+ aSetFillInBrushRecordHdl.Call(&aCol);
+
+ // neues Polygon berechnen
+ aRect.Left() = (long)(fScanLeft += fScanInc);
+ aRect.Top() = (long)(fScanTop += fScanInc);
+ aRect.Right() = (long)(fScanRight -= fScanInc);
+ aRect.Bottom() = (long)(fScanBottom -= fScanInc);
+
+ if ( (aRect.GetWidth() < 2) || (aRect.GetHeight() < 2) )
+ break;
+
+ aPoly = Polygon( aRect.Center(),
+ aRect.GetWidth() >> 1, aRect.GetHeight() >> 1 );
+ aPoly.Rotate( aCenter, rGradient.GetAngle() );
+
+ aPolyPoly.Replace( aPolyPoly.GetObject( 1 ), 0 );
+ aPolyPoly.Replace( aPoly, 1 );
+
+ PolyPolygon aTempPolyPoly = aPolyPoly;
+ aTempPolyPoly.Clip( aClipRect );
+ aDrawPolyPolyRecordHdl.Call(&aTempPolyPoly);
+
+ // Farbe entsprechend anpassen
+ nRed += nStepRed;
+ nGreen += nStepGreen;
+ nBlue += nStepBlue;
+
+ nRed = MinMax( nRed, 0, 0xFF );
+ nGreen = MinMax( nGreen, 0, 0xFF );
+ nBlue = MinMax( nBlue, 0, 0xFF );
+ }
+
+ // Falls PolyPolygon-Ausgabe, muessen wir noch ein letztes
+ // inneres Polygon zeichnen
+ aCol = Color( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue );
+ aSetFillInBrushRecordHdl.Call(&aCol);
+
+ aPoly = aPolyPoly.GetObject( 1 );
+ if ( !aPoly.GetBoundRect().IsEmpty() )
+ {
+ aPoly.Clip( aClipRect );
+ aDrawPolyRecordHdl.Call(&aPoly);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GradientWrapper::WriteRectGradient(const Rectangle& rRect,
+ const Gradient& rGradient)
+{
+ USHORT nStepCount = 100;
+ Rectangle aClipRect = rRect;
+ Rectangle aRect = rRect;
+
+ aRect.Left()--;
+ aRect.Top()--;
+ aRect.Right()++;
+ aRect.Bottom()++;
+
+ // rotiertes BoundRect ausrechnen
+ double fAngle = (rGradient.GetAngle() % 3600) * F_PI1800;
+ double fWidth = aRect.GetWidth();
+ double fHeight = aRect.GetHeight();
+ double fDX = fWidth * fabs( cos( fAngle ) ) +
+ fHeight * fabs( sin( fAngle ) );
+ double fDY = fHeight * fabs( cos( fAngle ) ) +
+ fWidth * fabs( sin( fAngle ) );
+ fDX = (fDX - fWidth) * 0.5 + 0.5;
+ fDY = (fDY - fHeight) * 0.5 + 0.5;
+ aRect.Left() -= (long)fDX;
+ aRect.Right() += (long)fDX;
+ aRect.Top() -= (long)fDY;
+ aRect.Bottom() += (long)fDY;
+
+ // Quadratisch machen, wenn angefordert;
+ Size aSize = aRect.GetSize();
+ if ( rGradient.GetStyle() == GRADIENT_SQUARE )
+ {
+ if ( aSize.Width() > aSize.Height() )
+ aSize.Height() = aSize.Width();
+ else
+ aSize.Width() = aSize.Height();
+ }
+
+ // neue Mittelpunkte berechnen
+ long nZWidth = aRect.GetWidth() * (long)rGradient.GetOfsX() / 100;
+ long nZHeight = aRect.GetHeight() * (long)rGradient.GetOfsY() / 100;
+ long nBorderX = (long)rGradient.GetBorder() * aSize.Width() / 100;
+ long nBorderY = (long)rGradient.GetBorder() * aSize.Height() / 100;
+ Point aCenter( aRect.Left() + nZWidth, aRect.Top() + nZHeight );
+
+ // Rand beruecksichtigen
+ aSize.Width() -= nBorderX;
+ aSize.Height() -= nBorderY;
+
+ // Ausgaberechteck neu setzen
+ aRect.Left() = aCenter.X() - (aSize.Width() >> 1);
+ aRect.Top() = aCenter.Y() - (aSize.Height() >> 1);
+ aRect.SetSize( aSize );
+
+ long nMinRect = Min( aRect.GetWidth(), aRect.GetHeight() );
+
+ // Anzahl der Schritte berechnen, falls nichts uebergeben wurde
+ if ( !nStepCount )
+ {
+ long nInc = ((nMinRect >> 9) + 1) << 3;
+
+ if ( !nInc )
+ nInc = 1;
+
+ nStepCount = (USHORT)(nMinRect / nInc);
+ }
+ // minimal drei Schritte
+ long nSteps = Max( nStepCount, (USHORT)3 );
+
+ // Ausgabebegrenzungen und Schrittweite fuer jede Richtung festlegen
+ double fScanLeft = aRect.Left();
+ double fScanTop = aRect.Top();
+ double fScanRight = aRect.Right();
+ double fScanBottom = aRect.Bottom();
+ double fScanInc = (double)nMinRect / (double)nSteps * 0.5;
+
+ // Intensitaeten von Start- und Endfarbe ggf. aendern und
+ // Farbschrittweiten berechnen
+ long nFactor;
+ const Color& rStartCol = rGradient.GetStartColor();
+ const Color& rEndCol = rGradient.GetEndColor();
+ long nRed = rStartCol.GetRed();
+ long nGreen = rStartCol.GetGreen();
+ long nBlue = rStartCol.GetBlue();
+ long nEndRed = rEndCol.GetRed();
+ long nEndGreen = rEndCol.GetGreen();
+ long nEndBlue = rEndCol.GetBlue();
+ nFactor = rGradient.GetStartIntensity();
+ nRed = (nRed * nFactor) / 100;
+ nGreen = (nGreen * nFactor) / 100;
+ nBlue = (nBlue * nFactor) / 100;
+ nFactor = rGradient.GetEndIntensity();
+ nEndRed = (nEndRed * nFactor) / 100;
+ nEndGreen = (nEndGreen * nFactor) / 100;
+ nEndBlue = (nEndBlue * nFactor) / 100;
+ long nStepRed = (nEndRed - nRed) / nSteps;
+ long nStepGreen = (nEndGreen - nGreen) / nSteps;
+ long nStepBlue = (nEndBlue - nBlue) / nSteps;
+ Color aCol( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue );
+
+ // GDI-Objekte sichern und setzen
+ aSetFillInBrushRecordHdl.Call(&aCol);
+
+ // Recteck erstmal ausgeben
+ PolyPolygon aPolyPoly( 2 );
+ Polygon aPoly( rRect );
+
+ aPolyPoly.Insert( aPoly );
+ aPoly = Polygon( aRect );
+ aPoly.Rotate( aCenter, rGradient.GetAngle() );
+ aPolyPoly.Insert( aPoly );
+
+ PolyPolygon aTempPolyPoly = aPolyPoly;
+ aTempPolyPoly.Clip( aClipRect );
+ aDrawPolyPolyRecordHdl.Call(&aTempPolyPoly);
+
+ // Schleife, um nacheinander die Polygone/PolyPolygone auszugeben
+ for ( long i = 0; i < nSteps; i++ )
+ {
+ Color aCol( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue );
+ aSetFillInBrushRecordHdl.Call(&aCol);
+
+ // neues Polygon berechnen
+ aRect.Left() = (long)(fScanLeft += fScanInc);
+ aRect.Top() = (long)(fScanTop += fScanInc);
+ aRect.Right() = (long)(fScanRight -= fScanInc);
+ aRect.Bottom() = (long)(fScanBottom-= fScanInc);
+
+ if ( (aRect.GetWidth() < 2) || (aRect.GetHeight() < 2) )
+ break;
+
+ aPoly = Polygon( aRect );
+ aPoly.Rotate( aCenter, rGradient.GetAngle() );
+
+ aPolyPoly.Replace( aPolyPoly.GetObject( 1 ), 0 );
+ aPolyPoly.Replace( aPoly, 1 );
+
+ PolyPolygon aTempPolyPoly = aPolyPoly;
+ aTempPolyPoly.Clip( aClipRect );
+ aDrawPolyPolyRecordHdl.Call(&aTempPolyPoly);
+
+ // Farben aendern
+ nRed += nStepRed;
+ nGreen += nStepGreen;
+ nBlue += nStepBlue;
+
+ nRed = MinMax( nRed, 0, 0xFF );
+ nGreen = MinMax( nGreen, 0, 0xFF );
+ nBlue = MinMax( nBlue, 0, 0xFF );
+ }
+
+ aCol = Color( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue );
+ aSetFillInBrushRecordHdl.Call(&aCol);
+
+ aPoly = aPolyPoly.GetObject( 1 );
+ if ( !aPoly.GetBoundRect().IsEmpty() )
+ {
+ aPoly.Clip( aClipRect );
+ aDrawPolyRecordHdl.Call(&aPoly);
+ }
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgfbram.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgfbram.cxx
new file mode 100644
index 000000000000..40d994bb6c2f
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgfbram.cxx
@@ -0,0 +1,658 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <string.h>
+#include <osl/endian.h>
+#include <tools/stream.hxx>
+#include <vcl/gdimtf.hxx>
+#include <tools/color.hxx>
+#include <vcl/virdev.hxx>
+#include "sgffilt.hxx"
+#include "sgfbram.hxx"
+
+namespace binfilter
+{
+
+#if defined( WIN ) && defined( MSC )
+#pragma code_seg( "SVTOOLS_FILTER4", "SVTOOLS_CODE" )
+#endif
+
+/*************************************************************************
+|*
+|* operator>>( SvStream&, SgfHeader& )
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+SvStream& operator>>(SvStream& rIStream, SgfHeader& rHead)
+{
+ rIStream.Read((char*)&rHead.Magic,SgfHeaderSize);
+#if defined OSL_BIGENDIAN
+ rHead.Magic =SWAPSHORT(rHead.Magic );
+ rHead.Version=SWAPSHORT(rHead.Version);
+ rHead.Typ =SWAPSHORT(rHead.Typ );
+ rHead.Xsize =SWAPSHORT(rHead.Xsize );
+ rHead.Ysize =SWAPSHORT(rHead.Ysize );
+ rHead.Xoffs =SWAPSHORT(rHead.Xoffs );
+ rHead.Yoffs =SWAPSHORT(rHead.Yoffs );
+ rHead.Planes =SWAPSHORT(rHead.Planes );
+ rHead.SwGrCol=SWAPSHORT(rHead.SwGrCol);
+ rHead.OfsLo =SWAPSHORT(rHead.OfsLo );
+ rHead.OfsHi =SWAPSHORT(rHead.OfsHi );
+#endif
+ return rIStream;
+}
+
+
+/*************************************************************************
+|*
+|* SgfHeader::ChkMagic()
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+BOOL SgfHeader::ChkMagic()
+{ return Magic=='J'*256+'J'; }
+
+UINT32 SgfHeader::GetOffset()
+{ return UINT32(OfsLo)+0x00010000*UINT32(OfsHi); }
+
+
+/*************************************************************************
+|*
+|* operator>>( SvStream&, SgfEntry& )
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+SvStream& operator>>(SvStream& rIStream, SgfEntry& rEntr)
+{
+ rIStream.Read((char*)&rEntr.Typ,SgfEntrySize);
+#if defined OSL_BIGENDIAN
+ rEntr.Typ =SWAPSHORT(rEntr.Typ );
+ rEntr.iFrei=SWAPSHORT(rEntr.iFrei);
+ rEntr.lFreiLo=SWAPSHORT (rEntr.lFreiLo);
+ rEntr.lFreiHi=SWAPSHORT (rEntr.lFreiHi);
+ rEntr.OfsLo=SWAPSHORT(rEntr.OfsLo);
+ rEntr.OfsHi=SWAPSHORT(rEntr.OfsHi);
+#endif
+ return rIStream;
+}
+
+UINT32 SgfEntry::GetOffset()
+{ return UINT32(OfsLo)+0x00010000*UINT32(OfsHi); }
+
+
+/*************************************************************************
+|*
+|* operator>>( SvStream&, SgfVector& )
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+SvStream& operator>>(SvStream& rIStream, SgfVector& rVect)
+{
+ rIStream.Read((char*)&rVect,sizeof(rVect));
+#if defined OSL_BIGENDIAN
+ rVect.Flag =SWAPSHORT(rVect.Flag );
+ rVect.x =SWAPSHORT(rVect.x );
+ rVect.y =SWAPSHORT(rVect.y );
+ rVect.OfsLo=SWAPLONG (rVect.OfsLo);
+ rVect.OfsHi=SWAPLONG (rVect.OfsHi);
+#endif
+ return rIStream;
+}
+
+
+/*************************************************************************
+|*
+|* operator<<( SvStream&, BmpFileHeader& )
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+SvStream& operator<<(SvStream& rOStream, BmpFileHeader& rHead)
+{
+#if defined OSL_BIGENDIAN
+ rHead.Typ =SWAPSHORT(rHead.Typ );
+ rHead.SizeLo =SWAPSHORT(rHead.SizeLo );
+ rHead.SizeHi =SWAPSHORT(rHead.SizeHi );
+ rHead.Reserve1=SWAPSHORT(rHead.Reserve1);
+ rHead.Reserve2=SWAPSHORT(rHead.Reserve2);
+ rHead.OfsLo =SWAPSHORT(rHead.OfsLo );
+ rHead.OfsHi =SWAPSHORT(rHead.OfsHi );
+#endif
+ rOStream.Write((char*)&rHead,sizeof(rHead));
+#if defined OSL_BIGENDIAN
+ rHead.Typ =SWAPSHORT(rHead.Typ );
+ rHead.SizeLo =SWAPSHORT(rHead.SizeLo );
+ rHead.SizeHi =SWAPSHORT(rHead.SizeHi );
+ rHead.Reserve1=SWAPSHORT(rHead.Reserve1);
+ rHead.Reserve2=SWAPSHORT(rHead.Reserve2);
+ rHead.OfsLo =SWAPSHORT(rHead.OfsLo );
+ rHead.OfsHi =SWAPSHORT(rHead.OfsHi );
+#endif
+ return rOStream;
+}
+
+void BmpFileHeader::SetSize(UINT32 Size)
+{
+ SizeLo=UINT16(Size & 0x0000FFFF);
+ SizeHi=UINT16((Size & 0xFFFF0000)>>16);
+}
+
+void BmpFileHeader::SetOfs(UINT32 Ofs)
+{
+ OfsLo=UINT16(Ofs & 0x0000FFFF);
+ OfsHi=UINT16((Ofs & 0xFFFF0000)>>16);
+}
+
+UINT32 BmpFileHeader::GetOfs()
+{
+ return UINT32(OfsLo)+0x00010000*UINT32(OfsHi);
+}
+
+/*************************************************************************
+|*
+|* operator<<( SvStream&, BmpInfoHeader& )
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+SvStream& operator<<(SvStream& rOStream, BmpInfoHeader& rInfo)
+{
+#if defined OSL_BIGENDIAN
+ rInfo.Size =SWAPLONG (rInfo.Size );
+ rInfo.Width =SWAPLONG (rInfo.Width );
+ rInfo.Hight =SWAPLONG (rInfo.Hight );
+ rInfo.Planes =SWAPSHORT(rInfo.Planes );
+ rInfo.PixBits =SWAPSHORT(rInfo.PixBits );
+ rInfo.Compress=SWAPLONG (rInfo.Compress);
+ rInfo.ImgSize =SWAPLONG (rInfo.ImgSize );
+ rInfo.xDpmm =SWAPLONG (rInfo.xDpmm );
+ rInfo.yDpmm =SWAPLONG (rInfo.yDpmm );
+ rInfo.ColUsed =SWAPLONG (rInfo.ColUsed );
+ rInfo.ColMust =SWAPLONG (rInfo.ColMust );
+#endif
+ rOStream.Write((char*)&rInfo,sizeof(rInfo));
+#if defined OSL_BIGENDIAN
+ rInfo.Size =SWAPLONG (rInfo.Size );
+ rInfo.Width =SWAPLONG (rInfo.Width );
+ rInfo.Hight =SWAPLONG (rInfo.Hight );
+ rInfo.Planes =SWAPSHORT(rInfo.Planes );
+ rInfo.PixBits =SWAPSHORT(rInfo.PixBits );
+ rInfo.Compress=SWAPLONG (rInfo.Compress);
+ rInfo.ImgSize =SWAPLONG (rInfo.ImgSize );
+ rInfo.xDpmm =SWAPLONG (rInfo.xDpmm );
+ rInfo.yDpmm =SWAPLONG (rInfo.yDpmm );
+ rInfo.ColUsed =SWAPLONG (rInfo.ColUsed );
+ rInfo.ColMust =SWAPLONG (rInfo.ColMust );
+#endif
+ return rOStream;
+}
+
+
+/*************************************************************************
+|*
+|* operator<<( SvStream&, RGBQuad& )
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+SvStream& operator<<(SvStream& rOStream, const RGBQuad& rQuad)
+{
+ rOStream.Write((char*)&rQuad,sizeof(rQuad));
+ return rOStream;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// PcxExpand ///////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+class PcxExpand
+{
+private:
+ USHORT Count;
+ BYTE Data;
+public:
+ PcxExpand() { Count=0; }
+ BYTE GetByte(SvStream& rInp);
+};
+
+BYTE PcxExpand::GetByte(SvStream& rInp)
+{
+ if (Count>0) {
+ Count--;
+ } else {
+ rInp.Read((char*)&Data,1);
+ if ((Data & 0xC0) == 0xC0) {
+ Count=(Data & 0x3F) -1;
+ rInp.Read((char*)&Data,1);
+ }
+ }
+ return Data;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// SgfBMapFilter ///////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+/*************************************************************************
+|*
+|* SgfFilterBmp()
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+BOOL SgfFilterBMap(SvStream& rInp, SvStream& rOut, SgfHeader& rHead, SgfEntry&)
+{
+ BmpFileHeader aBmpHead;
+ BmpInfoHeader aBmpInfo;
+ USHORT nWdtInp=(rHead.Xsize+7)/8; // Breite der Input-Bitmap in Bytes
+ USHORT nWdtOut; // Breite der Output-Bitmap in Bytes
+ USHORT nColors; // Anzahl der Farben (1,16,256)
+ USHORT nColBits; // Anzahl der Bits/Pixel (2, 4, 8)
+ USHORT i,j,k; // Spaltenzaehler, Zeilenzaehler, Planezaehler
+ USHORT a,b; // Hilfsvariable
+ BYTE pl1 = 0,pl2= 0; // Masken fuer die Planes
+ BYTE* pBuf=NULL; // Buffer fuer eine Pixelzeile
+ PcxExpand aPcx;
+ ULONG nOfs;
+ BYTE cRGB[4];
+
+ if (rHead.Planes<=1) nColBits=1; else nColBits=4; if (rHead.Typ==4) nColBits=8;
+ nColors=1<<nColBits;
+ nWdtOut=((rHead.Xsize*nColBits+31)/32)*4;
+ aBmpHead.Typ='B'+'M'*256;
+ aBmpHead.SetOfs(sizeof(aBmpHead)+sizeof(aBmpInfo)+nColors*4);
+ aBmpHead.SetSize(aBmpHead.GetOfs()+nWdtOut*rHead.Ysize);
+ aBmpHead.Reserve1=0;
+ aBmpHead.Reserve2=0;
+ aBmpInfo.Size=sizeof(aBmpInfo);
+ aBmpInfo.Width=rHead.Xsize;
+ aBmpInfo.Hight=rHead.Ysize;
+ aBmpInfo.Planes=1;
+ aBmpInfo.PixBits=nColBits;
+ aBmpInfo.Compress=0;
+ aBmpInfo.ImgSize=0;
+ aBmpInfo.xDpmm=0;
+ aBmpInfo.yDpmm=0;
+ aBmpInfo.ColUsed=0;
+ aBmpInfo.ColMust=0;
+ pBuf=new BYTE[nWdtOut];
+ if (!pBuf) return FALSE; // Fehler: kein Speichel da
+ rOut<<aBmpHead<<aBmpInfo;
+ memset(pBuf,0,nWdtOut); // Buffer mit Nullen fuellen
+
+ if (nColors==2)
+ {
+
+ rOut<<RGBQuad(0x00,0x00,0x00); // Schwarz
+ rOut<<RGBQuad(0xFF,0xFF,0xFF); // Weiss
+ nOfs=rOut.Tell();
+ for (j=0;j<rHead.Ysize;j++)
+ rOut.Write((char*)pBuf,nWdtOut); // Datei erstmal komplett mit Nullen fuellen
+ for (j=0;j<rHead.Ysize;j++) {
+ for(i=0;i<nWdtInp;i++) {
+ pBuf[i]=aPcx.GetByte(rInp);
+ }
+ for(i=nWdtInp;i<nWdtOut;i++) pBuf[i]=0; // noch bis zu 3 Bytes
+ rOut.Seek(nOfs+((ULONG)rHead.Ysize-j-1L)*(ULONG)nWdtOut); // rueckwaerts schreiben!
+ rOut.Write((char*)pBuf,nWdtOut);
+ }
+ } else if (nColors==16) {
+ rOut<<RGBQuad(0x00,0x00,0x00); // Schwarz
+ rOut<<RGBQuad(0x24,0x24,0x24); // Grau 80%
+ rOut<<RGBQuad(0x49,0x49,0x49); // Grau 60%
+ rOut<<RGBQuad(0x92,0x92,0x92); // Grau 40%
+ rOut<<RGBQuad(0x6D,0x6D,0x6D); // Grau 30%
+ rOut<<RGBQuad(0xB6,0xB6,0xB6); // Grau 20%
+ rOut<<RGBQuad(0xDA,0xDA,0xDA); // Grau 10%
+ rOut<<RGBQuad(0xFF,0xFF,0xFF); // Weiss
+ rOut<<RGBQuad(0x00,0x00,0x00); // Schwarz
+ rOut<<RGBQuad(0xFF,0x00,0x00); // Rot
+ rOut<<RGBQuad(0x00,0x00,0xFF); // Blau
+ rOut<<RGBQuad(0xFF,0x00,0xFF); // Magenta
+ rOut<<RGBQuad(0x00,0xFF,0x00); // Gruen
+ rOut<<RGBQuad(0xFF,0xFF,0x00); // Gelb
+ rOut<<RGBQuad(0x00,0xFF,0xFF); // Cyan
+ rOut<<RGBQuad(0xFF,0xFF,0xFF); // Weiss
+
+ nOfs=rOut.Tell();
+ for (j=0;j<rHead.Ysize;j++)
+ rOut.Write((char*)pBuf,nWdtOut); // Datei erstmal komplett mit Nullen fuellen
+ for (j=0;j<rHead.Ysize;j++) {
+ memset(pBuf,0,nWdtOut);
+ for(k=0;k<4;k++) {
+ if (k==0) {
+ pl1=0x10; pl2=0x01;
+ } else {
+ pl1<<=1; pl2<<=1;
+ }
+ for(i=0;i<nWdtInp;i++) {
+ a=i*4;
+ b=aPcx.GetByte(rInp);
+ if (b & 0x80) pBuf[a ]|=pl1;
+ if (b & 0x40) pBuf[a ]|=pl2;
+ if (b & 0x20) pBuf[a+1]|=pl1;
+ if (b & 0x10) pBuf[a+1]|=pl2;
+ if (b & 0x08) pBuf[a+2]|=pl1;
+ if (b & 0x04) pBuf[a+2]|=pl2;
+ if (b & 0x02) pBuf[a+3]|=pl1;
+ if (b & 0x01) pBuf[a+3]|=pl2;
+ }
+ }
+ for(i=nWdtInp*4;i<nWdtOut;i++) pBuf[i]=0; // noch bis zu 3 Bytes
+ rOut.Seek(nOfs+((ULONG)rHead.Ysize-j-1L)*(ULONG)nWdtOut); // rueckwaerts schreiben!
+ rOut.Write((char*)pBuf,nWdtOut);
+ }
+ } else if (nColors==256) {
+ cRGB[3]=0; // der 4. Paletteneintrag fuer BMP
+ for (i=0;i<256;i++) { // Palette kopieren
+ rInp.Read((char*)cRGB,3);
+ pl1=cRGB[0]; // Rot mit Blau tauschen
+ cRGB[0]=cRGB[2];
+ cRGB[2]=pl1;
+ rOut.Write((char*)cRGB,4);
+ }
+
+ nOfs=rOut.Tell();
+ for (j=0;j<rHead.Ysize;j++)
+ rOut.Write((char*)pBuf,nWdtOut); // Datei erstmal komplett mit Nullen fuellen
+ for (j=0;j<rHead.Ysize;j++) {
+ for(i=0;i<rHead.Xsize;i++)
+ pBuf[i]=aPcx.GetByte(rInp);
+ for(i=rHead.Xsize;i<nWdtOut;i++) pBuf[i]=0; // noch bis zu 3 Bytes
+ rOut.Seek(nOfs+((ULONG)rHead.Ysize-j-1L)*(ULONG)nWdtOut); // rueckwaerts schreiben!
+ rOut.Write((char*)pBuf,nWdtOut);
+ }
+ }
+ delete[] pBuf;
+ return TRUE;
+}
+
+
+/*************************************************************************
+|*
+|* SgfBMapFilter()
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+BOOL SgfBMapFilter(SvStream& rInp, SvStream& rOut)
+{
+ ULONG nFileStart; // Offset des SgfHeaders. Im allgemeinen 0.
+ SgfHeader aHead;
+ SgfEntry aEntr;
+ ULONG nNext;
+ BOOL bRdFlag=FALSE; // Grafikentry gelesen ?
+ BOOL bRet=FALSE; // Returncode
+
+ nFileStart=rInp.Tell();
+ rInp>>aHead;
+ if (aHead.ChkMagic() && (aHead.Typ==SgfBitImag0 || aHead.Typ==SgfBitImag1 ||
+ aHead.Typ==SgfBitImag2 || aHead.Typ==SgfBitImgMo)) {
+ nNext=aHead.GetOffset();
+ while (nNext && !bRdFlag && !rInp.GetError() && !rOut.GetError()) {
+ rInp.Seek(nFileStart+nNext);
+ rInp>>aEntr;
+ nNext=aEntr.GetOffset();
+ if (aEntr.Typ==aHead.Typ) {
+ bRdFlag=TRUE;
+ switch(aEntr.Typ) {
+ case SgfBitImag0:
+ case SgfBitImag1:
+ case SgfBitImag2:
+ case SgfBitImgMo: bRet=SgfFilterBMap(rInp,rOut,aHead,aEntr); break;
+ }
+ }
+ } // while(nNext)
+ }
+ if (rInp.GetError()) bRet=FALSE;
+ return(bRet);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// SgfVectFilter ///////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+// Fuer StarDraw Embedded SGF-Vector
+long SgfVectXofs=0;
+long SgfVectYofs=0;
+long SgfVectXmul=0;
+long SgfVectYmul=0;
+long SgfVectXdiv=0;
+long SgfVectYdiv=0;
+BOOL SgfVectScal=FALSE;
+
+////////////////////////////////////////////////////////////
+// Hpgl2SvFarbe ////////////////////////////////////////////
+////////////////////////////////////////////////////////////
+
+Color Hpgl2SvFarbe( BYTE nFarb )
+{
+ ULONG nColor = COL_BLACK;
+
+ switch (nFarb & 0x07) {
+ case 0: nColor=COL_WHITE; break;
+ case 1: nColor=COL_YELLOW; break;
+ case 2: nColor=COL_LIGHTMAGENTA; break;
+ case 3: nColor=COL_LIGHTRED; break;
+ case 4: nColor=COL_LIGHTCYAN; break;
+ case 5: nColor=COL_LIGHTGREEN; break;
+ case 6: nColor=COL_LIGHTBLUE; break;
+ case 7: nColor=COL_BLACK; break;
+ }
+ Color aColor( nColor );
+ return aColor;
+}
+
+/*************************************************************************
+|*
+|* SgfFilterVect()
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+BOOL SgfFilterVect(SvStream& rInp, SgfHeader& rHead, SgfEntry&, GDIMetaFile& rMtf)
+{
+ VirtualDevice aOutDev;
+ SgfVector aVect;
+ BYTE nFarb;
+ BYTE nFrb0=7;
+ BYTE nLTyp;
+ BYTE nOTyp;
+ BOOL bEoDt=FALSE;
+ BOOL bPDwn=FALSE;
+ Point aP0(0,0);
+ Point aP1(0,0);
+ String Msg;
+ USHORT RecNr=0;
+
+ rMtf.Record(&aOutDev);
+ aOutDev.SetLineColor(Color(COL_BLACK));
+ aOutDev.SetFillColor(Color(COL_BLACK));
+
+ while (!bEoDt && !rInp.GetError()) {
+ rInp>>aVect; RecNr++;
+ nFarb=(BYTE) (aVect.Flag & 0x000F);
+ nLTyp=(BYTE)((aVect.Flag & 0x00F0) >>4);
+ nOTyp=(BYTE)((aVect.Flag & 0x0F00) >>8);
+ bEoDt=(aVect.Flag & 0x4000) !=0;
+ bPDwn=(aVect.Flag & 0x8000) !=0;
+
+ long x=aVect.x-rHead.Xoffs;
+ long y=rHead.Ysize-(aVect.y-rHead.Yoffs);
+ if (SgfVectScal) {
+ if (SgfVectXdiv==0) SgfVectXdiv=rHead.Xsize;
+ if (SgfVectYdiv==0) SgfVectYdiv=rHead.Ysize;
+ if (SgfVectXdiv==0) SgfVectXdiv=1;
+ if (SgfVectYdiv==0) SgfVectYdiv=1;
+ x=SgfVectXofs+ x *SgfVectXmul /SgfVectXdiv;
+ y=SgfVectYofs+ y *SgfVectXmul /SgfVectYdiv;
+ }
+ aP1=Point(x,y);
+ if (!bEoDt && !rInp.GetError()) {
+ if (bPDwn && nLTyp<=6) {
+ switch(nOTyp) {
+ case 1: if (nFarb!=nFrb0) {
+ switch(rHead.SwGrCol) {
+ case SgfVectFarb: aOutDev.SetLineColor(Hpgl2SvFarbe(nFarb)); break;
+ case SgfVectGray: break;
+ case SgfVectWdth: break;
+ }
+ }
+ aOutDev.DrawLine(aP0,aP1); break; // Linie
+ case 2: break; // Kreis
+ case 3: break; // Text
+ case 5: aOutDev.DrawRect(Rectangle(aP0,aP1)); break; // Rechteck (solid)
+ }
+ }
+ aP0=aP1;
+ nFrb0=nFarb;
+ }
+ }
+ rMtf.Stop();
+ rMtf.WindStart();
+ MapMode aMap( MAP_10TH_MM, Point(),
+ Fraction( 1, 4 ), Fraction( 1, 4 ) );
+ rMtf.SetPrefMapMode( aMap );
+ rMtf.SetPrefSize( Size( (short)rHead.Xsize, (short)rHead.Ysize ) );
+ return TRUE;
+}
+
+
+/*************************************************************************
+|*
+|* SgfVectFilter()
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+BOOL SgfVectFilter(SvStream& rInp, GDIMetaFile& rMtf)
+{
+ ULONG nFileStart; // Offset des SgfHeaders. Im allgemeinen 0.
+ SgfHeader aHead;
+ SgfEntry aEntr;
+ ULONG nNext;
+ BOOL bRdFlag=FALSE; // Grafikentry gelesen ?
+ BOOL bRet=FALSE; // Returncode
+
+ nFileStart=rInp.Tell();
+ rInp>>aHead;
+ if (aHead.ChkMagic() && aHead.Typ==SGF_SIMPVECT) {
+ nNext=aHead.GetOffset();
+ while (nNext && !bRdFlag && !rInp.GetError()) {
+ rInp.Seek(nFileStart+nNext);
+ rInp>>aEntr;
+ nNext=aEntr.GetOffset();
+ if (aEntr.Typ==aHead.Typ) {
+ bRet=SgfFilterVect(rInp,aHead,aEntr,rMtf);
+ }
+ } // while(nNext)
+ if (bRdFlag) {
+ if (!rInp.GetError()) bRet=TRUE; // Scheinbar Ok
+ }
+ }
+ return(bRet);
+}
+
+
+/*************************************************************************
+|*
+|* CheckSgfTyp()
+|*
+|* Beschreibung Feststellen, um was fuer ein SGF/SGV es sich handelt.
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+BYTE CheckSgfTyp(SvStream& rInp, USHORT& nVersion)
+{
+#if OSL_DEBUG_LEVEL > 1 // Recordgroessen checken. Neuer Compiler hat vielleichte anderes Allignment!
+ if (sizeof(SgfHeader)!=SgfHeaderSize ||
+ sizeof(SgfEntry) !=SgfEntrySize ||
+ sizeof(SgfVector)!=SgfVectorSize ||
+ sizeof(BmpFileHeader)!=BmpFileHeaderSize ||
+ sizeof(BmpInfoHeader)!=BmpInfoHeaderSize ||
+ sizeof(RGBQuad )!=RGBQuadSize ) return SGF_DONTKNOW;
+#endif
+
+ ULONG nPos;
+ SgfHeader aHead;
+ nVersion=0;
+ nPos=rInp.Tell();
+ rInp>>aHead;
+ rInp.Seek(nPos);
+ if (aHead.ChkMagic()) {
+ nVersion=aHead.Version;
+ switch(aHead.Typ) {
+ case SgfBitImag0:
+ case SgfBitImag1:
+ case SgfBitImag2:
+ case SgfBitImgMo: return SGF_BITIMAGE;
+ case SgfSimpVect: return SGF_SIMPVECT;
+ case SgfPostScrp: return SGF_POSTSCRP;
+ case SgfStarDraw: return SGF_STARDRAW;
+ default : return SGF_DONTKNOW;
+ }
+ } else {
+ return SGF_DONTKNOW;
+ }
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvmain.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvmain.cxx
new file mode 100644
index 000000000000..596d65268bfa
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvmain.cxx
@@ -0,0 +1,1144 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <osl/endian.h>
+#include <vcl/graph.hxx>
+#include <tools/poly.hxx>
+#include <bf_svtools/filter.hxx>
+#include "sgffilt.hxx"
+#include "sgfbram.hxx"
+#include "sgvmain.hxx"
+#include "sgvspln.hxx"
+#include <unotools/ucbstreamhelper.hxx>
+
+namespace binfilter
+{
+
+#define SWAPPOINT(p) { \
+ p.x=SWAPSHORT(p.x); \
+ p.y=SWAPSHORT(p.y); }
+
+#define SWAPPAGE(p) { \
+ p.Next =SWAPLONG (p.Next ); \
+ p.nList =SWAPLONG (p.nList ); \
+ p.ListEnd=SWAPLONG (p.ListEnd); \
+ p.Paper.Size.x=SWAPSHORT(p.Paper.Size.x); \
+ p.Paper.Size.y=SWAPSHORT(p.Paper.Size.y); \
+ p.Paper.RandL =SWAPSHORT(p.Paper.RandL ); \
+ p.Paper.RandR =SWAPSHORT(p.Paper.RandR ); \
+ p.Paper.RandO =SWAPSHORT(p.Paper.RandO ); \
+ p.Paper.RandU =SWAPSHORT(p.Paper.RandU ); \
+ SWAPPOINT(p.U); \
+ UINT16 iTemp; \
+ for (iTemp=0;iTemp<20;iTemp++) { \
+ rPage.HlpLnH[iTemp]=SWAPSHORT(rPage.HlpLnH[iTemp]); \
+ rPage.HlpLnV[iTemp]=SWAPSHORT(rPage.HlpLnV[iTemp]); }}
+
+#define SWAPOBJK(o) { \
+ o.Last =SWAPLONG (o.Last ); \
+ o.Next =SWAPLONG (o.Next ); \
+ o.MemSize =SWAPSHORT(o.MemSize ); \
+ SWAPPOINT(o.ObjMin); \
+ SWAPPOINT(o.ObjMax); }
+
+#define SWAPLINE(l) { \
+ l.LMSize=SWAPSHORT(l.LMSize); \
+ l.LDicke=SWAPSHORT(l.LDicke); }
+
+#define SWAPAREA(a) { \
+ a.FDummy2=SWAPSHORT(a.FDummy2); \
+ a.FMuster=SWAPSHORT(a.FMuster); }
+
+#define SWAPTEXT(t) { \
+ SWAPLINE(t.L); \
+ SWAPAREA(t.F); \
+ t.FontLo =SWAPSHORT(t.FontLo ); \
+ t.FontHi =SWAPSHORT(t.FontHi ); \
+ t.Grad =SWAPSHORT(t.Grad ); \
+ t.Breite =SWAPSHORT(t.Breite ); \
+ t.Schnitt=SWAPSHORT(t.Schnitt); \
+ t.LnFeed =SWAPSHORT(t.LnFeed ); \
+ t.Slant =SWAPSHORT(t.Slant ); \
+ SWAPLINE(t.ShdL); \
+ SWAPAREA(t.ShdF); \
+ SWAPPOINT(t.ShdVers); \
+ SWAPAREA(t.BackF); }
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Einschraenkungen:
+//
+// - Flaechenmuster werden den unter StarView verfuegbaren Mustern angenaehert.
+// - Linienenden werden unter StarView immer rund dargestellt und gehen ueber
+// den Endpunkt der Linie hinaus.
+// - Linienmuster werden den unter StarView verfuegbaren Mustern angenaehert.
+// Transparent/Opak wird zur Zeit noch nicht beruecksichtigt.
+// - Keine gedrehten Ellipsen
+//
+//
+//
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#if defined( WIN ) && defined( MSC )
+#pragma code_seg( "svtools", "AUTO_CODE" )
+#endif
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Fuer Fontuebersetzung ///////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+SgfFontLst* pSgfFonts = 0;
+
+#if defined( WIN ) && defined( MSC )
+#pragma code_seg( "SVTOOLS_FILTER3", "SVTOOLS_CODE" )
+static void AntiMscBug() {}
+#endif
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Fuer Kreisunterarten, Text und gedrehte Rechtecke ///////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+void RotatePoint(PointType& P, INT16 cx, INT16 cy, double sn, double cs)
+{
+ INT16 dx,dy;
+ double x1,y1;
+ dx=P.x-cx;
+ dy=P.y-cy;
+ x1=dx*cs-dy*sn;
+ y1=dy*cs+dx*sn;
+ P.x=cx+INT16(x1);
+ P.y=cy+INT16(y1);
+}
+
+void RotatePoint(Point& P, INT16 cx, INT16 cy, double sn, double cs)
+{
+ INT16 dx,dy;
+ double x1,y1;
+ dx=(INT16)(P.X()-cx);
+ dy=(INT16)(P.Y()-cy);
+ x1=dx*cs-dy*sn;
+ y1=dy*cs+dx*sn;
+ P=Point(cx+INT16(x1),cy+INT16(y1));
+}
+
+INT16 iMulDiv(INT16 a, INT16 Mul, INT16 Div)
+{
+ INT32 Temp;
+ Temp=INT32(a)*INT32(Mul)/INT32(Div);
+ return INT16(Temp);
+}
+
+UINT16 MulDiv(UINT16 a, UINT16 Mul, UINT16 Div)
+{
+ UINT32 Temp;
+ Temp=UINT32(a)*UINT32(Mul)/UINT32(Div);
+ return UINT16(Temp);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// SgfFilterSDrw ///////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SvStream& operator>>(SvStream& rIStream, DtHdType& rDtHd)
+{
+ rIStream.Read((char*)&rDtHd.Reserved[0],DtHdSize);
+ return rIStream;
+}
+
+void DtHdOverSeek(SvStream& rInp)
+{
+ ULONG FPos=rInp.Tell();
+ FPos+=(ULONG)DtHdSize;
+ rInp.Seek(FPos);
+// rInp.seekg(rInp.tellg()+(ULONG)DtHdSize);
+}
+
+
+SvStream& operator>>(SvStream& rIStream, PageType& rPage)
+{
+ rIStream.Read((char*)&rPage.Next,PageSize);
+#if defined OSL_BIGENDIAN
+ SWAPPAGE(rPage);
+#endif
+ return rIStream;
+}
+
+void ObjkOverSeek(SvStream& rInp, ObjkType& rObjk)
+{
+ ULONG Siz;
+ Siz=(ULONG)rObjk.MemSize+rObjk.Last; // ObjSize+ObjAnhSize
+ rInp.Seek(rInp.Tell()+Siz);
+}
+
+SvStream& operator>>(SvStream& rInp, ObjkType& rObjk)
+{ // Die Fileposition im Stream bleibt unveraendert!
+ ULONG nPos;
+ nPos=rInp.Tell();
+ rInp.Read((char*)&rObjk.Last,ObjkSize);
+#if defined OSL_BIGENDIAN
+ SWAPOBJK(rObjk);
+#endif
+#ifdef InArbeit
+ ULONG nPos1=rInp.Tell();
+ if(nPos == nPos1) InfoBox( NULL, "tellg funkt nich" ).Execute();
+#endif
+ rInp.Seek(nPos);
+#ifdef InArbeit
+ if (rInp.Tell() != nPos) InfoBox( NULL, "seekg funkt nich" ).Execute();
+#endif
+ return rInp;
+}
+SvStream& operator>>(SvStream& rInp, StrkType& rStrk)
+{
+ rInp.Read((char*)&rStrk.Last,StrkSize);
+#if defined OSL_BIGENDIAN
+ SWAPOBJK (rStrk);
+ SWAPLINE (rStrk.L);
+ SWAPPOINT(rStrk.Pos1);
+ SWAPPOINT(rStrk.Pos2);
+#endif
+ return rInp;
+}
+SvStream& operator>>(SvStream& rInp, RectType& rRect)
+{
+ rInp.Read((char*)&rRect.Last,RectSize);
+#if defined OSL_BIGENDIAN
+ SWAPOBJK (rRect);
+ SWAPLINE (rRect.L);
+ SWAPAREA (rRect.F);
+ SWAPPOINT(rRect.Pos1);
+ SWAPPOINT(rRect.Pos2);
+ rRect.Radius =SWAPSHORT(rRect.Radius );
+ rRect.DrehWink=SWAPSHORT(rRect.DrehWink);
+ rRect.Slant =SWAPSHORT(rRect.Slant );
+#endif
+ return rInp;
+}
+SvStream& operator>>(SvStream& rInp, PolyType& rPoly)
+{
+ rInp.Read((char*)&rPoly.Last,PolySize);
+#if defined OSL_BIGENDIAN
+ SWAPOBJK (rPoly);
+ SWAPLINE (rPoly.L);
+ SWAPAREA (rPoly.F);
+ // rPoly.EckP=SWAPLONG(rPoly.EckP);
+#endif
+ return rInp;
+}
+SvStream& operator>>(SvStream& rInp, SplnType& rSpln)
+{
+ rInp.Read((char*)&rSpln.Last,SplnSize);
+#if defined OSL_BIGENDIAN
+ SWAPOBJK (rSpln);
+ SWAPLINE (rSpln.L);
+ SWAPAREA (rSpln.F);
+ // rSpln.EckP=SWAPLONG(rSpln.EckP);
+#endif
+ return rInp;
+}
+SvStream& operator>>(SvStream& rInp, CircType& rCirc)
+{
+ rInp.Read((char*)&rCirc.Last,CircSize);
+#if defined OSL_BIGENDIAN
+ SWAPOBJK (rCirc);
+ SWAPLINE (rCirc.L);
+ SWAPAREA (rCirc.F);
+ SWAPPOINT(rCirc.Radius);
+ SWAPPOINT(rCirc.Center);
+ rCirc.DrehWink =SWAPSHORT(rCirc.DrehWink );
+ rCirc.StartWink=SWAPSHORT(rCirc.StartWink);
+ rCirc.RelWink =SWAPSHORT(rCirc.RelWink );
+#endif
+ return rInp;
+}
+SvStream& operator>>(SvStream& rInp, TextType& rText)
+{
+ rInp.Read((char*)&rText.Last,TextSize);
+#if defined OSL_BIGENDIAN
+ SWAPOBJK (rText);
+ SWAPTEXT (rText.T);
+ SWAPPOINT(rText.Pos1);
+ SWAPPOINT(rText.Pos2);
+ rText.TopOfs =SWAPSHORT(rText.TopOfs );
+ rText.DrehWink=SWAPSHORT(rText.DrehWink);
+ rText.BoxSlant=SWAPSHORT(rText.BoxSlant);
+ rText.BufSize =SWAPSHORT(rText.BufSize );
+ //rText.Buf =SWAPLONG (rText.Buf );
+ //rText.Ext =SWAPLONG (rText.Ext );
+ SWAPPOINT(rText.FitSize);
+ rText.FitBreit=SWAPSHORT(rText.FitBreit);
+#endif
+ rText.Buffer=NULL;
+ return rInp;
+}
+SvStream& operator>>(SvStream& rInp, BmapType& rBmap)
+{
+ rInp.Read((char*)&rBmap.Last,BmapSize);
+#if defined OSL_BIGENDIAN
+ SWAPOBJK (rBmap);
+ SWAPAREA (rBmap.F);
+ SWAPPOINT(rBmap.Pos1);
+ SWAPPOINT(rBmap.Pos2);
+ rBmap.DrehWink=SWAPSHORT(rBmap.DrehWink);
+ rBmap.Slant =SWAPSHORT(rBmap.Slant );
+ SWAPPOINT(rBmap.PixSize);
+#endif
+ return rInp;
+}
+SvStream& operator>>(SvStream& rInp, GrupType& rGrup)
+{
+ rInp.Read((char*)&rGrup.Last,GrupSize);
+#if defined OSL_BIGENDIAN
+ SWAPOBJK (rGrup);
+ rGrup.SbLo =SWAPSHORT(rGrup.SbLo );
+ rGrup.SbHi =SWAPSHORT(rGrup.SbHi );
+ rGrup.UpLo =SWAPSHORT(rGrup.UpLo );
+ rGrup.UpHi =SWAPSHORT(rGrup.UpHi );
+ rGrup.ChartSize=SWAPSHORT(rGrup.ChartSize);
+ rGrup.ChartPtr =SWAPLONG (rGrup.ChartPtr );
+#endif
+ return rInp;
+}
+
+
+
+/*************************************************************************
+|*
+|* Sgv2SvFarbe()
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+Color Sgv2SvFarbe(BYTE nFrb1, BYTE nFrb2, BYTE nInts)
+{
+ UINT16 r1=0,g1=0,b1=0,r2=0,g2=0,b2=0;
+ BYTE nInt2=100-nInts;
+ switch(nFrb1 & 0x07) {
+ case 0: r1=0xFF; g1=0xFF; b1=0xFF; break;
+ case 1: r1=0xFF; g1=0xFF; break;
+ case 2: g1=0xFF; b1=0xFF; break;
+ case 3: g1=0xFF; break;
+ case 4: r1=0xFF; b1=0xFF; break;
+ case 5: r1=0xFF; break;
+ case 6: b1=0xFF; break;
+ case 7: break;
+ }
+ switch(nFrb2 & 0x07) {
+ case 0: r2=0xFF; g2=0xFF; b2=0xFF; break;
+ case 1: r2=0xFF; g2=0xFF; break;
+ case 2: g2=0xFF; b2=0xFF; break;
+ case 3: g2=0xFF; break;
+ case 4: r2=0xFF; b2=0xFF; break;
+ case 5: r2=0xFF; break;
+ case 6: b2=0xFF; break;
+ case 7: break;
+ }
+ r1=(UINT16)((UINT32)r1*nInts/100+(UINT32)r2*nInt2/100);
+ g1=(UINT16)((UINT32)g1*nInts/100+(UINT32)g2*nInt2/100);
+ b1=(UINT16)((UINT32)b1*nInts/100+(UINT32)b2*nInt2/100);
+ Color aColor( (sal_uInt8)r1, (sal_uInt8)g1, (sal_uInt8)b1 );
+ return aColor;
+}
+
+void SetLine(ObjLineType& rLine, OutputDevice& rOut)
+{
+/* !!!
+ PenStyle aStyle=PEN_SOLID;
+ switch(rLine.LMuster & 0x07) {
+ case 0: aStyle=PEN_NULL; break;
+ case 1: aStyle=PEN_SOLID; break;
+ case 2: aStyle=PEN_DOT; break; // . . . . . . . . . . . . . .
+ case 3: aStyle=PEN_DASH; break; // __ __ __ __ __ __ __ __ __
+ case 4: aStyle=PEN_DASH; break; // ___ ___ ___ ___ ___ ___ ___
+ case 5: aStyle=PEN_DASHDOT; break; // __ . __ . __ . __ . __ . __
+ case 6: aStyle=PEN_DASHDOT; break; // __ _ __ _ __ _ __ _ __ _ __
+ case 7: aStyle=PEN_DASHDOT; break; // ___ _ _ ___ _ _ ___ _ _ ___
+ }
+ Pen aPen(Sgv2SvFarbe(rLine.LFarbe,rLine.LBFarbe,rLine.LIntens),rLine.LDicke,aStyle);
+ SetPen(aPen,rOut);
+*/
+ if( 0 == ( rLine.LMuster & 0x07 ) )
+ rOut.SetLineColor();
+ else
+ rOut.SetLineColor( Sgv2SvFarbe(rLine.LFarbe,rLine.LBFarbe,rLine.LIntens) );
+}
+
+void SetArea(ObjAreaType& rArea, OutputDevice& rOut)
+{
+/*
+ BrushStyle aStyle=BRUSH_SOLID;
+ switch(rArea.FMuster & 0x00FF) {
+ case 0: aStyle=BRUSH_NULL; break;
+ case 1: aStyle=BRUSH_SOLID; break;
+ case 2: case 4: case 6: case 8:
+ case 10: case 12: case 14: case 16:
+ case 43: case 45: aStyle=BRUSH_VERT; break;
+ case 3: case 5: case 7: case 9:
+ case 11: case 13: case 15: case 17:
+ case 42: case 44: aStyle=BRUSH_HORZ; break;
+ case 18: case 20: case 22: case 24:
+ case 26: case 28: case 30: case 32:
+ case 46: case 48: aStyle=BRUSH_UPDIAG; break;
+ case 19: case 21: case 23: case 25:
+ case 27: case 29: case 31: case 33:
+ case 47: case 49: aStyle=BRUSH_DOWNDIAG; break;
+ case 34: case 35: case 36: case 37: aStyle=BRUSH_CROSS; break;
+ case 38: case 39: case 40: case 41: aStyle=BRUSH_DIAGCROSS; break;
+ default: aStyle=BRUSH_DIAGCROSS; break;
+ }
+ Brush aBrush(Sgv2SvFarbe(rArea.FFarbe,rArea.FBFarbe,rArea.FIntens),aStyle);
+ aBrush.SetTransparent((rArea.FMuster & 0x80) !=0L);
+ SetBrush(aBrush,rOut);
+*/
+ if( 0 == ( rArea.FMuster & 0x00FF ) )
+ rOut.SetFillColor();
+ else
+ rOut.SetFillColor( Sgv2SvFarbe( rArea.FFarbe,rArea.FBFarbe,rArea.FIntens ) );
+}
+
+/*************************************************************************
+|*
+|* ObjkType::DrawObjekt()
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+void ObjkType::Draw(OutputDevice&)
+{
+// ShowSDObjk(*this);
+}
+
+void Obj0Type::Draw(OutputDevice&) {}
+
+/*************************************************************************
+|*
+|* StrkType::DrawObjekt()
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+void StrkType::Draw(OutputDevice& rOut)
+{
+ SetLine(L,rOut);
+ rOut.DrawLine(Point(Pos1.x,Pos1.y),Point(Pos2.x,Pos2.y)); // !!!
+}
+
+/*************************************************************************
+|*
+|* RectType::DrawObjekt()
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+void SgfAreaColorIntens(UINT16 Muster, BYTE Col1, BYTE Col2, BYTE Int, OutputDevice& rOut)
+{
+ ObjAreaType F;
+ F.FMuster=Muster;
+ F.FFarbe=Col2;
+ F.FBFarbe=Col1;
+ F.FIntens=Int;
+ SetArea(F,rOut);
+}
+
+void DrawSlideRect(INT16 x1, INT16 y1, INT16 x2, INT16 y2, ObjAreaType& F, OutputDevice& rOut)
+{
+ INT16 i,i0,b,b0;
+ INT16 Int1,Int2;
+ INT16 Col1,Col2;
+ // ClipMerk: HgdClipRec;
+ INT16 cx,cy;
+ INT16 MaxR;
+ INT32 dx,dy;
+
+ rOut.SetLineColor();
+ if (x1>x2) { i=x1; x1=x2; x2=i; }
+ if (y1>y2) { i=y1; y1=y2; y2=i; }
+ Col1=F.FBFarbe & 0x87; Col2=F.FFarbe & 0x87;
+ Int1=100-F.FIntens; Int2=F.FIntens;
+ if (Int1==Int2) {
+ SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)Int2,rOut);
+ rOut.DrawRect(Rectangle(x1,y1,x2,y2));
+ } else {
+ b0=Int1;
+ switch (F.FBFarbe & 0x38) {
+ case 0x08: { // vertikal
+ i0=y1;
+ i=y1;
+ while (i<=y2) {
+ b=Int1+INT16((INT32)(Int2-Int1)*(INT32)(i-y1) /(INT32)(y2-y1+1));
+ if (b!=b0) {
+ SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)b0,rOut);
+ rOut.DrawRect(Rectangle(x1,i0,x2,i-1));
+ i0=i; b0=b;
+ }
+ i++;
+ }
+ SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)Int2,rOut);
+ rOut.DrawRect(Rectangle(x1,i0,x2,y2));
+ } break;
+ case 0x28: { // horizontal
+ i0=x1;
+ i=x1;
+ while (i<=x2) {
+ b=Int1+INT16((INT32)(Int2-Int1)*(INT32)(i-x1) /(INT32)(x2-x1+1));
+ if (b!=b0) {
+ SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)b0,rOut);
+ rOut.DrawRect(Rectangle(i0,y1,i-1,y2));
+ i0=i; b0=b;
+ }
+ i++;
+ }
+ SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)Int2,rOut);
+ rOut.DrawRect(Rectangle(i0,y1,x2,y2));
+ } break;
+
+ case 0x18: case 0x38: { // Kreis
+ Region ClipMerk=rOut.GetClipRegion();
+ double a;
+
+ rOut.SetClipRegion(Region(Rectangle(x1,y1,x2,y2)));
+ cx=(x1+x2) /2;
+ cy=(y1+y2) /2;
+ dx=x2-x1+1;
+ dy=y2-y1+1;
+ a=sqrt((double)(dx*dx+dy*dy));
+ MaxR=INT16(a) /2 +1;
+ b0=Int2;
+ i0=MaxR; if (MaxR<1) MaxR=1;
+ i=MaxR;
+ while (i>=0) {
+ b=Int1+INT16((INT32(Int2-Int1)*INT32(i)) /INT32(MaxR));
+ if (b!=b0) {
+ SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)b0,rOut);
+ //if (i0>200 || (Col1 & $80)!=0 || (Col2 & $80)!=0) {
+ // then begin { Fallunterscheidung fuer etwas bessere Performance }
+ // s2:=i0-i+2;
+ // SetPenSize(s2);
+ // s2:=s2 div 2;
+ // Circle(cx,cy,i0-s2,i0-s2);{}
+ // else
+ rOut.DrawEllipse(Rectangle(cx-i0,cy-i0,cx+i0,cy+i0));
+ i0=i; b0=b;
+ }
+ i--;
+ }
+ SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)Int1,rOut);
+ rOut.DrawEllipse(Rectangle(cx-i0,cy-i0,cx+i0,cy+i0));
+ rOut.SetClipRegion(ClipMerk);
+ } break; // Kreis
+ }
+ }
+}
+
+
+void RectType::Draw(OutputDevice& rOut)
+{
+ if (L.LMuster!=0) L.LMuster=1; // keine Linienmuster hier, nur an oder aus
+ SetArea(F,rOut);
+ if (DrehWink==0) {
+ if ((F.FBFarbe & 0x38)==0 || Radius!=0) {
+ SetLine(L,rOut);
+ rOut.DrawRect(Rectangle(Pos1.x,Pos1.y,Pos2.x,Pos2.y),Radius,Radius);
+ } else {
+ DrawSlideRect(Pos1.x,Pos1.y,Pos2.x,Pos2.y,F,rOut);
+ if (L.LMuster!=0) {
+ SetLine(L,rOut);
+ rOut.SetFillColor();
+ rOut.DrawRect(Rectangle(Pos1.x,Pos1.y,Pos2.x,Pos2.y));
+ }
+ }
+ } else {
+ Point aPts[4];
+ USHORT i;
+ double sn,cs;
+ sn=sin(double(DrehWink)*3.14159265359/18000);
+ cs=cos(double(DrehWink)*3.14159265359/18000);
+ aPts[0]=Point(Pos1.x,Pos1.y);
+ aPts[1]=Point(Pos2.x,Pos1.y);
+ aPts[2]=Point(Pos2.x,Pos2.y);
+ aPts[3]=Point(Pos1.x,Pos2.y);
+ for (i=0;i<4;i++) {
+ RotatePoint(aPts[i],Pos1.x,Pos1.y,sn,cs);
+ }
+ SetLine(L,rOut);
+ Polygon aPoly(4,aPts);
+ rOut.DrawPolygon(aPoly);
+ }
+}
+
+/*************************************************************************
+|*
+|* PolyType::Draw()
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+void PolyType::Draw(OutputDevice& rOut)
+{
+ if ((Flags & PolyClosBit) !=0) SetArea(F,rOut);
+ SetLine(L,rOut);
+ Polygon aPoly(nPoints);
+ USHORT i;
+ for(i=0;i<nPoints;i++) aPoly.SetPoint(Point(EckP[i].x,EckP[i].y),i);
+ if ((Flags & PolyClosBit) !=0) {
+ rOut.DrawPolygon(aPoly);
+ } else {
+ rOut.DrawPolyLine(aPoly);
+ }
+}
+
+/*************************************************************************
+|*
+|* SplnType::Draw()
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+void SplnType::Draw(OutputDevice& rOut)
+{
+ if ((Flags & PolyClosBit) !=0) SetArea(F,rOut);
+ SetLine(L,rOut);
+ Polygon aPoly(0);
+ Polygon aSpln(nPoints);
+ USHORT i;
+ for(i=0;i<nPoints;i++) aSpln.SetPoint(Point(EckP[i].x,EckP[i].y),i);
+ if ((Flags & PolyClosBit) !=0) {
+ Spline2Poly(aSpln,TRUE,aPoly);
+ if (aPoly.GetSize()>0) rOut.DrawPolygon(aPoly);
+ } else {
+ Spline2Poly(aSpln,FALSE,aPoly);
+ if (aPoly.GetSize()>0) rOut.DrawPolyLine(aPoly);
+ }
+}
+
+/*************************************************************************
+|*
+|* CircType::Draw()
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+void DrawSlideCirc(INT16 cx, INT16 cy, INT16 rx, INT16 ry, ObjAreaType& F, OutputDevice& rOut)
+{
+ INT16 x1=cx-rx;
+ INT16 y1=cy-ry;
+ INT16 x2=cx+rx;
+ INT16 y2=cy+ry;
+
+ INT16 i,i0,b,b0;
+ INT16 Int1,Int2;
+ INT16 Col1,Col2;
+
+ rOut.SetLineColor();
+ Col1=F.FBFarbe & 0x87; Col2=F.FFarbe & 0x87;
+ Int1=100-F.FIntens; Int2=F.FIntens;
+ if (Int1==Int2) {
+ SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)Int2,rOut);
+ rOut.DrawEllipse(Rectangle(x1,y1,x2,y2));
+ } else {
+ b0=Int1;
+ switch (F.FBFarbe & 0x38) {
+ case 0x08: { // vertikal
+ Region ClipMerk=rOut.GetClipRegion();
+ i0=y1;
+ i=y1;
+ while (i<=y2) {
+ b=Int1+INT16((INT32)(Int2-Int1)*(INT32)(i-y1) /(INT32)(y2-y1+1));
+ if (b!=b0) {
+ SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)b0,rOut);
+ rOut.SetClipRegion(Rectangle(x1,i0,x2,i-1));
+ rOut.DrawEllipse(Rectangle(x1,y1,x2,y2));
+ i0=i; b0=b;
+ }
+ i++;
+ }
+ SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)Int2,rOut);
+ rOut.SetClipRegion(Rectangle(x1,i0,x2,y2));
+ rOut.DrawEllipse(Rectangle(x1,y1,x2,y2));
+ rOut.SetClipRegion(ClipMerk);
+ } break;
+ case 0x28: { // horizontal
+ Region ClipMerk=rOut.GetClipRegion();
+ i0=x1;
+ i=x1;
+ while (i<=x2) {
+ b=Int1+INT16((INT32)(Int2-Int1)*(INT32)(i-x1) /(INT32)(x2-x1+1));
+ if (b!=b0) {
+ SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)b0,rOut);
+ rOut.SetClipRegion(Rectangle(i0,y1,i-1,y2));
+ rOut.DrawEllipse(Rectangle(x1,y1,x2,y2));
+ i0=i; b0=b;
+ }
+ i++;
+ }
+ SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)Int2,rOut);
+ rOut.SetClipRegion(Rectangle(i0,y1,x2,y2));
+ rOut.DrawEllipse(Rectangle(x1,y1,x2,y2));
+ rOut.SetClipRegion(ClipMerk);
+ } break;
+
+ case 0x18: case 0x38: { // Kreis
+ INT16 MaxR;
+
+ if (rx<1) rx=1;
+ if (ry<1) ry=1;
+ MaxR=rx;
+ b0=Int2;
+ i0=MaxR; if (MaxR<1) MaxR=1;
+ i=MaxR;
+ while (i>=0) {
+ b=Int1+INT16((INT32(Int2-Int1)*INT32(i)) /INT32(MaxR));
+ if (b!=b0) {
+ INT32 temp=INT32(i0)*INT32(ry)/INT32(rx);
+ INT16 j0=INT16(temp);
+ SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)b0,rOut);
+ rOut.DrawEllipse(Rectangle(cx-i0,cy-j0,cx+i0,cy+j0));
+ i0=i; b0=b;
+ }
+ i--;
+ }
+ SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)Int1,rOut);
+ rOut.DrawEllipse(Rectangle(cx-i0,cy-i0,cx+i0,cy+i0));
+ } break; // Kreis
+ }
+ }
+}
+
+
+void CircType::Draw(OutputDevice& rOut)
+{
+ Rectangle aRect(Center.x-Radius.x,Center.y-Radius.y,Center.x+Radius.x,Center.y+Radius.y);
+
+ if (L.LMuster!=0) L.LMuster=1; // keine Linienmuster hier, nur an oder aus
+ SetArea(F,rOut);
+ if ((Flags & 0x03)==CircFull) {
+ if ((F.FBFarbe & 0x38)==0) {
+ SetLine(L,rOut);
+ rOut.DrawEllipse(aRect);
+ } else {
+ DrawSlideCirc(Center.x,Center.y,Radius.x,Radius.y,F,rOut);
+ if (L.LMuster!=0) {
+ SetLine(L,rOut);
+ rOut.SetFillColor();
+ rOut.DrawEllipse(aRect);
+ }
+ }
+ } else {
+ PointType a,b;
+ Point aStrt,aEnde;
+ double sn,cs;
+
+ a.x=Center.x+Radius.x; a.y=Center.y; b=a;
+ sn=sin(double(StartWink)*3.14159265359/18000);
+ cs=cos(double(StartWink)*3.14159265359/18000);
+ RotatePoint(a,Center.x,Center.y,sn,cs);
+ sn=sin(double(StartWink+RelWink)*3.14159265359/18000);
+ cs=cos(double(StartWink+RelWink)*3.14159265359/18000);
+ RotatePoint(b,Center.x,Center.y,sn,cs);
+ if (Radius.x!=Radius.y) {
+ if (Radius.x<1) Radius.x=1;
+ if (Radius.y<1) Radius.y=1;
+ a.y = a.y - Center.y;
+ b.y = b.y - Center.y;
+ a.y=iMulDiv(a.y,Radius.y,Radius.x);
+ b.y=iMulDiv(b.y,Radius.y,Radius.x);
+ a.y = a.y + Center.y;
+ b.y = b.y + Center.y;
+ }
+ aStrt=Point(a.x,a.y);
+ aEnde=Point(b.x,b.y);
+ SetLine(L,rOut);
+ switch (Flags & 0x03) {
+ case CircArc : rOut.DrawArc(aRect,aEnde,aStrt); break;
+ case CircSect:
+ case CircAbsn: rOut.DrawPie(aRect,aEnde,aStrt); break;
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* BmapType::Draw()
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+
+void BmapType::Draw(OutputDevice& rOut)
+{
+ //ifstream aInp;
+ unsigned char nSgfTyp;
+ USHORT nVersion;
+ String aStr(
+ reinterpret_cast< char const * >(&Filename[ 1 ]),
+ (xub_StrLen)Filename[ 0 ], RTL_TEXTENCODING_UTF8 );
+ INetURLObject aFNam( aStr );
+
+ SvStream* pInp = ::utl::UcbStreamHelper::CreateStream( aFNam.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
+ if ( pInp )
+ {
+ nSgfTyp=CheckSgfTyp( *pInp,nVersion);
+ switch(nSgfTyp) {
+ case SGF_BITIMAGE: {
+ GraphicFilter aFlt;
+ Graphic aGrf;
+ USHORT nRet;
+ nRet=aFlt.ImportGraphic(aGrf,aFNam);
+ aGrf.Draw(&rOut,Point(Pos1.x,Pos1.y),Size(Pos2.x-Pos1.x,Pos2.y-Pos1.y));
+ } break;
+ case SGF_SIMPVECT: {
+ GDIMetaFile aMtf;
+ SgfVectXofs=Pos1.x;
+ SgfVectYofs=Pos1.y;
+ SgfVectXmul=Pos2.x-Pos1.x;
+ SgfVectYmul=Pos2.y-Pos1.y;
+ SgfVectXdiv=0;
+ SgfVectYdiv=0;
+ SgfVectScal=TRUE;
+ SgfVectFilter(*pInp,aMtf);
+ SgfVectXofs=0;
+ SgfVectYofs=0;
+ SgfVectXmul=0;
+ SgfVectYmul=0;
+ SgfVectXdiv=0;
+ SgfVectYdiv=0;
+ SgfVectScal=FALSE;
+ aMtf.Play(&rOut);
+ } break;
+ }
+ delete pInp;
+ }
+}
+
+
+/*************************************************************************
+|*
+|* GrupType::...
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+UINT32 GrupType::GetSubPtr()
+{
+ return UINT32(SbLo)+0x00010000*UINT32(SbHi);
+}
+
+/*************************************************************************
+|*
+|* DrawObjkList()
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+void DrawObjkList( SvStream& rInp, OutputDevice& rOut )
+{
+ ObjkType aObjk;
+ USHORT nGrpCnt=0;
+ BOOL bEnde=FALSE;
+ do {
+ rInp>>aObjk;
+ if (!rInp.GetError()) {
+ switch(aObjk.Art) {
+ case ObjStrk: { StrkType aStrk; rInp>>aStrk; if (!rInp.GetError()) aStrk.Draw(rOut); } break;
+ case ObjRect: { RectType aRect; rInp>>aRect; if (!rInp.GetError()) aRect.Draw(rOut); } break;
+ case ObjCirc: { CircType aCirc; rInp>>aCirc; if (!rInp.GetError()) aCirc.Draw(rOut); } break;
+ case ObjText: {
+ TextType aText;
+ rInp>>aText;
+ if (!rInp.GetError()) {
+ aText.Buffer=new UCHAR[aText.BufSize+1]; // Ein mehr fuer LookAhead bei CK-Trennung
+ rInp.Read((char* )aText.Buffer,aText.BufSize);
+ if (!rInp.GetError()) aText.Draw(rOut);
+ delete[] aText.Buffer;
+ }
+ } break;
+ case ObjBmap: {
+ BmapType aBmap;
+ rInp>>aBmap;
+ if (!rInp.GetError()) {
+ aBmap.Draw(rOut);
+ }
+ } break;
+ case ObjPoly: {
+ PolyType aPoly;
+ rInp>>aPoly;
+ if (!rInp.GetError()) {
+ aPoly.EckP=new PointType[aPoly.nPoints];
+ rInp.Read((char*)aPoly.EckP,4*aPoly.nPoints);
+#if defined OSL_BIGENDIAN
+ for(short i=0;i<aPoly.nPoints;i++) SWAPPOINT(aPoly.EckP[i]);
+#endif
+ if (!rInp.GetError()) aPoly.Draw(rOut);
+ delete[] aPoly.EckP;
+ }
+ } break;
+ case ObjSpln: {
+ SplnType aSpln;
+ rInp>>aSpln;
+ if (!rInp.GetError()) {
+ aSpln.EckP=new PointType[aSpln.nPoints];
+ rInp.Read((char*)aSpln.EckP,4*aSpln.nPoints);
+#if defined OSL_BIGENDIAN
+ for(short i=0;i<aSpln.nPoints;i++) SWAPPOINT(aSpln.EckP[i]);
+#endif
+ if (!rInp.GetError()) aSpln.Draw(rOut);
+ delete[] aSpln.EckP;
+ }
+ } break;
+ case ObjGrup: {
+ GrupType aGrup;
+ rInp>>aGrup;
+ if (!rInp.GetError()) {
+ rInp.Seek(rInp.Tell()+aGrup.Last); // Obj-Anhaengsel
+ if(aGrup.GetSubPtr()!=0L) nGrpCnt++;// DrawObjkList(rInp,rOut );
+ }
+ } break;
+ default: {
+ aObjk.Draw(rOut); // Objektbezeichnung auf 2. Screen
+ ObjkOverSeek(rInp,aObjk); // zum naechsten Objekt
+ }
+ }
+ } // if rInp
+ if (!rInp.GetError()) {
+ if (aObjk.Next==0L) {
+ if (nGrpCnt==0) bEnde=TRUE;
+ else nGrpCnt--;
+ }
+ } else {
+ bEnde=TRUE; // Lesefehler
+ }
+ } while (!bEnde);
+}
+
+/*************************************************************************
+|*
+|* SkipObjkList()
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+void SkipObjkList(SvStream& rInp)
+{
+ ObjkType aObjk;
+ do
+ {
+ rInp>>aObjk;
+ if(aObjk.Art==ObjGrup) {
+ GrupType aGrup;
+ rInp>>aGrup;
+ rInp.Seek(rInp.Tell()+aGrup.Last); // Obj-Anhaengsel
+ if(aGrup.GetSubPtr()!=0L) SkipObjkList(rInp);
+ } else {
+ ObjkOverSeek(rInp,aObjk); // zum naechsten Objekt
+ }
+ } while (aObjk.Next!=0L && !rInp.GetError());
+}
+
+/*************************************************************************
+|*
+|* SgfFilterSDrw()
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+BOOL SgfFilterSDrw( SvStream& rInp, SgfHeader&, SgfEntry&, GDIMetaFile& rMtf )
+{
+ BOOL bRet = FALSE;
+ PageType aPage;
+ VirtualDevice aOutDev;
+ OutputDevice* pOutDev;
+ ULONG nStdPos;
+ ULONG nZchPos;
+ USHORT Num;
+
+ pOutDev=&aOutDev;
+ DtHdOverSeek(rInp); // DataHeader weglesen
+
+ nStdPos=rInp.Tell();
+ do { // Standardseiten weglesen
+ rInp>>aPage;
+ if (aPage.nList!=0) SkipObjkList(rInp);
+ } while (aPage.Next!=0L && !rInp.GetError());
+
+// ShowMsg("Zeichnungseite(n)\n");
+ nZchPos=rInp.Tell();
+ rInp>>aPage;
+
+ rMtf.Record(pOutDev);
+ Num=aPage.StdPg;
+ if (Num!=0) {
+ rInp.Seek(nStdPos);
+ while(Num>1 && aPage.Next!=0L && !rInp.GetError()) { // Standardseite suchen
+ rInp>>aPage;
+ if (aPage.nList!=0) SkipObjkList(rInp);
+ Num--;
+ }
+ rInp>>aPage;
+ if(Num==1 && aPage.nList!=0L) DrawObjkList( rInp,*pOutDev );
+ rInp.Seek(nZchPos);
+ nZchPos=rInp.Tell();
+ rInp>>aPage;
+ }
+ if (aPage.nList!=0L) DrawObjkList(rInp,*pOutDev );
+
+ rMtf.Stop();
+ rMtf.WindStart();
+ MapMode aMap(MAP_10TH_MM,Point(),Fraction(1,4),Fraction(1,4));
+ rMtf.SetPrefMapMode(aMap);
+ rMtf.SetPrefSize(Size((INT16)aPage.Paper.Size.x,(INT16)aPage.Paper.Size.y));
+ bRet=TRUE;
+ return bRet;
+}
+
+
+
+/*************************************************************************
+|*
+|* SgfSDrwFilter()
+|*
+|* Beschreibung
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+BOOL SgfSDrwFilter(SvStream& rInp, GDIMetaFile& rMtf, INetURLObject aIniPath )
+{
+#if OSL_DEBUG_LEVEL > 1 // Recordgroessen checken. Neuer Compiler hat vielleichte anderes Alignment!
+ if (sizeof(ObjTextType)!=ObjTextTypeSize) return FALSE;
+#endif
+
+ ULONG nFileStart; // Offset des SgfHeaders. Im allgemeinen 0.
+ SgfHeader aHead;
+ SgfEntry aEntr;
+ ULONG nNext;
+ BOOL bRdFlag=FALSE; // Grafikentry gelesen ?
+ BOOL bRet=FALSE; // Returncode
+
+ aIniPath.Append( String::CreateFromAscii( "sgf.ini", 7 ) );
+// aIniPath.ToAbs();
+
+ pSgfFonts = new SgfFontLst;
+
+ pSgfFonts->AssignFN( aIniPath.GetMainURL( INetURLObject::NO_DECODE ) );
+ nFileStart=rInp.Tell();
+ rInp>>aHead;
+ if (aHead.ChkMagic() && aHead.Typ==SgfStarDraw && aHead.Version==SGV_VERSION) {
+ nNext=aHead.GetOffset();
+ while (nNext && !bRdFlag && !rInp.GetError()) {
+ rInp.Seek(nFileStart+nNext);
+ rInp>>aEntr;
+ nNext=aEntr.GetOffset();
+ if (aEntr.Typ==aHead.Typ) {
+ bRet=SgfFilterSDrw( rInp,aHead,aEntr,rMtf );
+ }
+ } // while(nNext)
+ if (bRdFlag) {
+ if (!rInp.GetError()) bRet=TRUE; // Scheinbar Ok
+ }
+ }
+ delete pSgfFonts;
+ return(bRet);
+}
+
+/*
+Bitmap Dither(BYTE Intens)
+{
+ Bitmap aBmp;
+ BmpInfoHeader Info;
+
+
+const dmatrix: array[0..7,0..7] of byte =
+ (( 0, 48, 12, 60, 3, 51, 15, 63 ),
+ ( 32, 16, 44, 28, 35, 19, 47, 31 ),
+ ( 8, 56, 4, 52, 11, 59, 7, 55 ),
+ ( 40, 24, 36, 20, 43, 27, 39, 23 ),
+ ( 2, 50, 14, 62, 1, 49, 13, 61 ),
+ ( 34, 18, 46, 30, 33, 17, 45, 29 ),
+ ( 10, 58, 6, 54, 9, 57, 5, 53 ),
+ ( 42, 26, 38, 22, 41, 25, 37, 21 ));
+
+
+ cmatrix: array[0..7,0..7] of byte;
+ dmatrixn,dmatrixi: array[0..7] of byte;
+
+
+procedure SetColorIntens(col0,col1,bal: integer);
+var cmatrix0: array[0..63] of byte absolute cmatrix;
+ dmatrix0: array[0..63] of byte absolute dmatrix;
+ n,i: integer;
+ b,bit: byte;
+begin
+if col0=col1 then bal:=0;
+if bal<=32 then
+ begin
+ plotcolor0:=col0 and $1F; plotcolor1:=col1 and $1F;
+ plotbal:=bal;
+ end
+else
+ begin
+ plotcolor0:=col1 and $1F; plotcolor1:=col0 and $1F;
+ plotbal:=64-bal;
+ end;
+for n:=0 to 63 do
+ if plotbal<=dmatrix0[n] then cmatrix0[n]:=col0 else cmatrix0[n]:=col1;
+end;
+*/
+
+#if defined( WIN ) && defined( MSC )
+#pragma code_seg( "svtools", "AUTO_CODE" )
+#endif
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvspln.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvspln.cxx
new file mode 100644
index 000000000000..ac44fc8c8fea
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvspln.cxx
@@ -0,0 +1,902 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <math.h>
+
+
+#include <tools/poly.hxx>
+
+#if defined( WIN ) && defined( MSC )
+#pragma code_seg( "SVTOOLS_FILTER2", "SVTOOLS_CODE" )
+#pragma optimize( "", off )
+#endif
+
+#if defined( PM2 ) && defined( __BORLANDC__ )
+#pragma option -Od
+#endif
+
+namespace binfilter
+{
+
+extern "C" {
+
+/*.pn 277 */
+/*.hlAnhang: C - Programme*/
+/*.hrKonstanten- und Macro-Definitionen*/
+/*.fe Die Include-Datei u_const.h ist in das Verzeichnis zu stellen, */
+/*.fe wo der Compiler nach Include-Dateien sucht. */
+
+
+/*----------------------- FILE u_const.h ---------------------------*/
+
+#define IEEE
+
+/* IEEE - Norm fuer die Darstellung von Gleitkommazahlen:
+
+ 8 Byte lange Gleitkommazahlen, mit
+
+ 53 Bit Mantisse ==> Mantissenbereich: 2 hoch 52 versch. Zahlen
+ mit 0.1 <= Zahl < 1.0,
+ 1 Vorzeichen-Bit
+ 11 Bit Exponent ==> Exponentenbereich: -1024...+1023
+
+ Die 1. Zeile ( #define IEEE ) ist zu loeschen, falls die Maschine
+ bzw. der Compiler keine Gleitpunktzahlen gemaess der IEEE-Norm
+ benutzt. Zusaetzlich muessen die Zahlen MAXEXPON, MINEXPON
+ (s.u.) angepasst werden.
+ */
+
+#ifdef IEEE /*----------- Falls IEEE Norm --------------------*/
+
+#define MACH_EPS 2.220446049250313e-016 /* Maschinengenauigkeit */
+ /* IBM-AT: = 2 hoch -52 */
+/* MACH_EPS ist die kleinste positive, auf der Maschine darstellbare
+ Zahl x, die der Bedingung genuegt: 1.0 + x > 1.0 */
+
+#define EPSQUAD 4.930380657631324e-032
+#define EPSROOT 1.490116119384766e-008
+
+#define POSMAX 8.98846567431158e+307 /* groesste positive Zahl */
+#define POSMIN 5.56268464626800e-309 /* kleinste positive Zahl */
+#define MAXROOT 9.48075190810918e+153
+
+#define BASIS 2 /* Basis der Zahlendarst. */
+#ifndef PI
+#define PI 3.141592653589793e+000
+#endif
+#define EXP_1 2.718281828459045e+000
+
+#else /*------------------ sonst -----------------------*/
+
+double exp (double);
+double atan (double);
+double pow (double,double);
+double sqrt (double);
+
+double masch() /* MACH_EPS maschinenunabhaengig bestimmen */
+{
+ double eps = 1.0, x = 2.0, y = 1.0;
+ while ( y < x )
+ { eps *= 0.5;
+ x = 1.0 + eps;
+ }
+ eps *= 2.0; return (eps);
+}
+
+short basis() /* BASIS maschinenunabhaengig bestimmen */
+{
+ double x = 1.0, one = 1.0, b = 1.0;
+
+ while ( (x + one) - x == one ) x *= 2.0;
+ while ( (x + b) == x ) b *= 2.0;
+
+ return ( (short) ((x + b) - x) );
+}
+
+#define BASIS basis() /* Basis der Zahlendarst. */
+
+/* Falls die Maschine (der Compiler) keine IEEE-Darstellung fuer
+ Gleitkommazahlen nutzt, muessen die folgenden 2 Konstanten an-
+ gepasst werden.
+ */
+
+#define MAXEXPON 1023.0 /* groesster Exponent */
+#define MINEXPON -1024.0 /* kleinster Exponent */
+
+
+#define MACH_EPS masch()
+#define EPSQUAD MACH_EPS * MACH_EPS
+#define EPSROOT sqrt(MACH_EPS)
+
+#define POSMAX pow ((double) BASIS, MAXEXPON)
+#define POSMIN pow ((double) BASIS, MINEXPON)
+#define MAXROOT sqrt(POSMAX)
+
+#define PI 4.0 * atan (1.0)
+#define EXP_1 exp(1.0)
+
+#endif /*-------------- ENDE ifdef ----------------------*/
+
+
+#define NEGMAX -POSMIN /* groesste negative Zahl */
+#define NEGMIN -POSMAX /* kleinste negative Zahl */
+
+#define TRUE 1
+#define FALSE 0
+
+
+/* Definition von Funktionsmakros:
+ */
+
+#define abs(X) ((X) >= 0 ? (X) : -(X)) /* Absolutbetrag von X */
+#define sign(X, Y) (Y < 0 ? -abs(X) : abs(X)) /* Vorzeichen von */
+ /* Y mal abs(X) */
+#define sqr(X) ((X) * (X)) /* Quadrat von X */
+
+/*------------------- ENDE FILE u_const.h --------------------------*/
+
+
+
+
+
+
+
+
+
+/*.HL Anhang: C - Programme*/
+/*.HRGleichungssysteme fuer Tridiagonalmatrizen*/
+
+/*.FE P 3.7 TRIDIAGONALE GLEICHUNGSSYSTEME*/
+
+
+/*---------------------- MODUL TRIDIAGONAL ------------------------*/
+
+USHORT TriDiagGS(BOOL rep, USHORT n, double* lower,
+ double* diag, double* upper, double* b)
+ /************************/
+ /* GAUSS-Verfahren fuer */
+ /* Tridiagonalmatrizen */
+ /************************/
+
+/*====================================================================*/
+/* */
+/* trdiag bestimmt die Loesung x des linearen Gleichungssystems */
+/* A * x = b mit tridiagonaler n x n Koeffizientenmatrix A, die in */
+/* den 3 Vektoren lower, upper und diag wie folgt abgespeichert ist: */
+/* */
+/* ( diag[0] upper[0] 0 0 . . . 0 ) */
+/* ( lower[1] diag[1] upper[1] 0 . . . ) */
+/* ( 0 lower[2] diag[2] upper[2] 0 . ) */
+/* A = ( . 0 lower[3] . . . ) */
+/* ( . . . . . 0 ) */
+/* ( . . . . . ) */
+/* ( . . . upper[n-2] ) */
+/* ( 0 . . . 0 lower[n-1] diag[n-1] ) */
+/* */
+/*====================================================================*/
+/* */
+/* Anwendung: */
+/* ========= */
+/* Vorwiegend fuer diagonaldominante Tridiagonalmatrizen, wie */
+/* sie bei der Spline-Interpolation auftreten. */
+/* Fuer diagonaldominante Matrizen existiert immer eine LU- */
+/* Zerlegung; fuer nicht diagonaldominante Tridiagonalmatrizen */
+/* sollte die Funktion band vorgezogen werden, da diese mit */
+/* Spaltenpivotsuche arbeitet und daher numerisch stabiler ist. */
+/* */
+/*====================================================================*/
+/* */
+/* Eingabeparameter: */
+/* ================ */
+/* n Dimension der Matrix ( > 1 ) USHORT n */
+/* */
+/* lower untere Nebendiagonale double lower[n] */
+/* diag Hauptdiagonale double diag[n] */
+/* upper obere Nebendiagonale double upper[n] */
+/* */
+/* bei rep != 0 enthalten lower, diag und upper die */
+/* Dreieckzerlegung der Ausgangsmatrix. */
+/* */
+/* b rechte Seite des Systems double b[n] */
+/* rep = 0 erstmaliger Aufruf BOOL rep */
+/* !=0 wiederholter Aufruf */
+/* fuer gleiche Matrix, */
+/* aber verschiedenes b. */
+/* */
+/* Ausgabeparameter: */
+/* ================ */
+/* b Loesungsvektor des Systems; double b[n] */
+/* die urspruengliche rechte Seite wird ueberspeichert */
+/* */
+/* lower ) enthalten bei rep = 0 die Zerlegung der Matrix; */
+/* diag ) die urspruenglichen Werte von lower u. diag werden */
+/* upper ) ueberschrieben */
+/* */
+/* Die Determinante der Matrix ist bei rep = 0 durch */
+/* det A = diag[0] * ... * diag[n-1] bestimmt. */
+/* */
+/* Rueckgabewert: */
+/* ============= */
+/* = 0 alles ok */
+/* = 1 n < 2 gewaehlt */
+/* = 2 Die Dreieckzerlegung der Matrix existiert nicht */
+/* */
+/*====================================================================*/
+/* */
+/* Benutzte Funktionen: */
+/* =================== */
+/* */
+/* Aus der C Bibliothek: fabs() */
+/* */
+/*====================================================================*/
+
+/*.cp 5 */
+{
+ USHORT i;
+ short j;
+
+// double fabs(double);
+
+ if ( n < 2 ) return(1); /* n mindestens 2 */
+
+ /* Wenn rep = 0 ist, */
+ /* Dreieckzerlegung der */
+ if (rep == 0) /* Matrix u. det be- */
+ { /* stimmen */
+ for (i = 1; i < n; i++)
+ { if ( fabs(diag[i-1]) < MACH_EPS ) /* Wenn ein diag[i] = 0 */
+ return(2); /* ist, ex. keine Zerle- */
+ lower[i] /= diag[i-1]; /* gung. */
+ diag[i] -= lower[i] * upper[i-1];
+ }
+ }
+
+ if ( fabs(diag[n-1]) < MACH_EPS ) return(2);
+
+ for (i = 1; i < n; i++) /* Vorwaertselimination */
+ b[i] -= lower[i] * b[i-1];
+
+ b[n-1] /= diag[n-1]; /* Rueckwaertselimination */
+ for (j = n-2; j >= 0; j--) {
+ i=j;
+ b[i] = ( b[i] - upper[i] * b[i+1] ) / diag[i];
+ }
+ return(0);
+}
+
+/*----------------------- ENDE TRIDIAGONAL -------------------------*/
+
+
+
+
+
+
+
+
+
+/*.HL Anhang: C - Programme*/
+/*.HRGleichungssysteme mit zyklisch tridiagonalen Matrizen*/
+
+/*.FE P 3.8 SYSTEME MIT ZYKLISCHEN TRIDIAGONALMATRIZEN */
+
+
+/*---------------- MODUL ZYKLISCH TRIDIAGONAL ----------------------*/
+
+
+USHORT ZyklTriDiagGS(BOOL rep, USHORT n, double* lower, double* diag,
+ double* upper, double* lowrow, double* ricol, double* b)
+ /******************************/
+ /* Systeme mit zyklisch tri- */
+ /* diagonalen Matrizen */
+ /******************************/
+
+/*====================================================================*/
+/* */
+/* tzdiag bestimmt die Loesung x des linearen Gleichungssystems */
+/* A * x = b mit zyklisch tridiagonaler n x n Koeffizienten- */
+/* matrix A, die in den 5 Vektoren lower, upper, diag, lowrow und */
+/* ricol wie folgt abgespeichert ist: */
+/* */
+/* ( diag[0] upper[0] 0 0 . . 0 ricol[0] ) */
+/* ( lower[1] diag[1] upper[1] 0 . . 0 ) */
+/* ( 0 lower[2] diag[2] upper[2] 0 . ) */
+/* A = ( . 0 lower[3] . . . . ) */
+/* ( . . . . . 0 ) */
+/* ( . . . . . ) */
+/* ( 0 . . . upper[n-2] ) */
+/* ( lowrow[0] 0 . . 0 lower[n-1] diag[n-1] ) */
+/* */
+/* Speicherplatz fuer lowrow[1],..,lowrow[n-3] und ricol[1],..., */
+/* ricol[n-3] muss zusaetzlich bereitgestellt werden, da dieser */
+/* fuer die Aufnahme der Zerlegungsmatrix verfuegbar sein muss, die */
+/* auf die 5 genannten Vektoren ueberspeichert wird. */
+/* */
+/*====================================================================*/
+/* */
+/* Anwendung: */
+/* ========= */
+/* Vorwiegend fuer diagonaldominante zyklische Tridiagonalmatri- */
+/* zen wie sie bei der Spline-Interpolation auftreten. */
+/* Fuer diagonaldominante Matrizen existiert immer eine LU- */
+/* Zerlegung. */
+/* */
+/*====================================================================*/
+/* */
+/* Eingabeparameter: */
+/* ================ */
+/* n Dimension der Matrix ( > 2 ) USHORT n */
+/* lower untere Nebendiagonale double lower[n] */
+/* diag Hauptdiagonale double diag[n] */
+/* upper obere Nebendiagonale double upper[n] */
+/* b rechte Seite des Systems double b[n] */
+/* rep = 0 erstmaliger Aufruf BOOL rep */
+/* !=0 wiederholter Aufruf */
+/* fuer gleiche Matrix, */
+/* aber verschiedenes b. */
+/* */
+/* Ausgabeparameter: */
+/* ================ */
+/* b Loesungsvektor des Systems, double b[n] */
+/* die urspruengliche rechte Seite wird ueberspeichert */
+/* */
+/* lower ) enthalten bei rep = 0 die Zerlegung der Matrix; */
+/* diag ) die urspruenglichen Werte von lower u. diag werden */
+/* upper ) ueberschrieben */
+/* lowrow ) double lowrow[n-2] */
+/* ricol ) double ricol[n-2] */
+/* */
+/* Die Determinante der Matrix ist bei rep = 0 durch */
+/* det A = diag[0] * ... * diag[n-1] bestimmt. */
+/* */
+/* Rueckgabewert: */
+/* ============= */
+/* = 0 alles ok */
+/* = 1 n < 3 gewaehlt */
+/* = 2 Die Zerlegungsmatrix existiert nicht */
+/* */
+/*====================================================================*/
+/* */
+/* Benutzte Funktionen: */
+/* =================== */
+/* */
+/* Aus der C Bibliothek: fabs() */
+/* */
+/*====================================================================*/
+
+/*.cp 5 */
+{
+ double temp; // fabs(double);
+ USHORT i;
+ short j;
+
+ if ( n < 3 ) return(1);
+
+ if (rep == 0) /* Wenn rep = 0 ist, */
+ { /* Zerlegung der */
+ lower[0] = upper[n-1] = 0.0; /* Matrix berechnen. */
+
+ if ( fabs (diag[0]) < MACH_EPS ) return(2);
+ /* Ist ein Diagonalelement */
+ temp = 1.0 / diag[0]; /* betragsmaessig kleiner */
+ upper[0] *= temp; /* MACH_EPS, so ex. keine */
+ ricol[0] *= temp; /* Zerlegung. */
+
+ for (i = 1; i < n-2; i++)
+ { diag[i] -= lower[i] * upper[i-1];
+ if ( fabs(diag[i]) < MACH_EPS ) return(2);
+ temp = 1.0 / diag[i];
+ upper[i] *= temp;
+ ricol[i] = -lower[i] * ricol[i-1] * temp;
+ }
+
+ diag[n-2] -= lower[n-2] * upper[n-3];
+ if ( fabs(diag[n-2]) < MACH_EPS ) return(2);
+
+ for (i = 1; i < n-2; i++)
+ lowrow[i] = -lowrow[i-1] * upper[i-1];
+
+ lower[n-1] -= lowrow[n-3] * upper[n-3];
+ upper[n-2] = ( upper[n-2] - lower[n-2] * ricol[n-3] ) / diag[n-2];
+
+ for (temp = 0.0, i = 0; i < n-2; i++)
+ temp -= lowrow[i] * ricol[i];
+ diag[n-1] += temp - lower[n-1] * upper[n-2];
+
+ if ( fabs(diag[n-1]) < MACH_EPS ) return(2);
+ } /* end if ( rep == 0 ) */
+
+ b[0] /= diag[0]; /* Vorwaertselemination */
+ for (i = 1; i < n-1; i++)
+ b[i] = ( b[i] - b[i-1] * lower[i] ) / diag[i];
+
+ for (temp = 0.0, i = 0; i < n-2; i++)
+ temp -= lowrow[i] * b[i];
+
+ b[n-1] = ( b[n-1] + temp - lower[n-1] * b[n-2] ) / diag[n-1];
+
+ b[n-2] -= b[n-1] * upper[n-2]; /* Rueckwaertselimination */
+ for (j = n-3; j >= 0; j--) {
+ i=j;
+ b[i] -= upper[i] * b[i+1] + ricol[i] * b[n-1];
+ }
+ return(0);
+}
+
+/*------------------ ENDE ZYKLISCH TRIDIAGONAL ---------------------*/
+
+
+} // extern "C"
+
+
+/*************************************************************************
+|*
+|* NaturalSpline()
+|*
+|* Beschreibung Berechnet die Koeffizienten eines natuerlichen
+|* kubischen Polynomsplines mit n Stuetzstellen.
+|* Ersterstellung JOE 17-08.93
+|* Letzte Aenderung JOE 17-08.93
+|*
+*************************************************************************/
+
+USHORT NaturalSpline(USHORT n, double* x, double* y,
+ double Marg0, double MargN,
+ BYTE MargCond,
+ double* b, double* c, double* d)
+{
+ USHORT i;
+ double* a;
+ double* h;
+ USHORT error;
+
+ if (n<2) return 1;
+ if ( (MargCond & ~3) ) return 2;
+ a=new double[n+1];
+ h=new double[n+1];
+ for (i=0;i<n;i++) {
+ h[i]=x[i+1]-x[i];
+ if (h[i]<=0.0) { delete[] a; delete[] h; return 1; }
+ }
+ for (i=0;i<n-1;i++) {
+ a[i]=3.0*((y[i+2]-y[i+1])/h[i+1]-(y[i+1]-y[i])/h[i]);
+ b[i]=h[i];
+ c[i]=h[i+1];
+ d[i]=2.0*(h[i]+h[i+1]);
+ }
+ switch (MargCond) {
+ case 0: {
+ if (n==2) {
+ a[0]=a[0]/3.0;
+ d[0]=d[0]*0.5;
+ } else {
+ a[0] =a[0]*h[1]/(h[0]+h[1]);
+ a[n-2]=a[n-2]*h[n-2]/(h[n-1]+h[n-2]);
+ d[0] =d[0]-h[0];
+ d[n-2]=d[n-2]-h[n-1];
+ c[0] =c[0]-h[0];
+ b[n-2]=b[n-2]-h[n-1];
+ }
+ }
+ case 1: {
+ a[0] =a[0]-1.5*((y[1]-y[0])/h[0]-Marg0);
+ a[n-2]=a[n-2]-1.5*(MargN-(y[n]-y[n-1])/h[n-1]);
+ d[0] =d[0]-h[0]*0.5;
+ d[n-2]=d[n-2]-h[n-1]*0.5;
+ }
+ case 2: {
+ a[0] =a[0]-h[0]*Marg0*0.5;
+ a[n-2]=a[n-2]-h[n-1]*MargN*0.5;
+ }
+ case 3: {
+ a[0] =a[0]+Marg0*h[0]*h[0]*0.5;
+ a[n-2]=a[n-2]-MargN*h[n-1]*h[n-1]*0.5;
+ d[0] =d[0]+h[0];
+ d[n-2]=d[n-2]+h[n-1];
+ }
+ } // switch MargCond
+ if (n==2) {
+ c[1]=a[0]/d[0];
+ } else {
+ error=TriDiagGS(FALSE,n-1,b,d,c,a);
+ if (error!=0) { delete[] a; delete[] h; return error+2; }
+ for (i=0;i<n-1;i++) c[i+1]=a[i];
+ }
+ switch (MargCond) {
+ case 0: {
+ if (n==2) {
+ c[2]=c[1];
+ c[0]=c[1];
+ } else {
+ c[0]=c[1]+h[0]*(c[1]-c[2])/h[1];
+ c[n]=c[n-1]+h[n-1]*(c[n-1]-c[n-2])/h[n-2];
+ }
+ }
+ case 1: {
+ c[0]=1.5*((y[1]-y[0])/h[0]-Marg0);
+ c[0]=(c[0]-c[1]*h[0]*0.5)/h[0];
+ c[n]=1.5*((y[n]-y[n-1])/h[n-1]-MargN);
+ c[n]=(c[n]-c[n-1]*h[n-1]*0.5)/h[n-1];
+ }
+ case 2: {
+ c[0]=Marg0*0.5;
+ c[n]=MargN*0.5;
+ }
+ case 3: {
+ c[0]=c[1]-Marg0*h[0]*0.5;
+ c[n]=c[n-1]+MargN*h[n-1]*0.5;
+ }
+ } // switch MargCond
+ for (i=0;i<n;i++) {
+ b[i]=(y[i+1]-y[i])/h[i]-h[i]*(c[i+1]+2.0*c[i])/3.0;
+ d[i]=(c[i+1]-c[i])/(3.0*h[i]);
+ }
+ delete[] a;
+ delete[] h;
+ return 0;
+}
+
+
+/*************************************************************************
+|*
+|* PeriodicSpline()
+|*
+|* Beschreibung Berechnet die Koeffizienten eines periodischen
+|* kubischen Polynomsplines mit n Stuetzstellen.
+|* Ersterstellung JOE 17-08.93
+|* Letzte Aenderung JOE 17-08.93
+|*
+*************************************************************************/
+
+
+USHORT PeriodicSpline(USHORT n, double* x, double* y,
+ double* b, double* c, double* d)
+{ // Arrays muessen von [0..n] dimensioniert sein!
+ USHORT Error;
+ USHORT i,im1,nm1; //integer
+ double hr,hl;
+ double* a;
+ double* lowrow;
+ double* ricol;
+
+ if (n<2) return 4;
+ nm1=n-1;
+ for (i=0;i<=nm1;i++) if (x[i+1]<=x[i]) return 2; // muss streng nonoton fallend sein!
+ if (y[n]!=y[0]) return 3; // Anfang muss gleich Ende sein!
+
+ a =new double[n+1];
+ lowrow=new double[n+1];
+ ricol =new double[n+1];
+
+ if (n==2) {
+ c[1]=3.0*((y[2]-y[1])/(x[2]-x[1]));
+ c[1]=c[1]-3.0*((y[i]-y[0])/(x[1]-x[0]));
+ c[1]=c[1]/(x[2]-x[0]);
+ c[2]=-c[1];
+ } else {
+ for (i=1;i<=nm1;i++) {
+ im1=i-1;
+ hl=x[i]-x[im1];
+ hr=x[i+1]-x[i];
+ b[im1]=hl;
+ d[im1]=2.0*(hl+hr);
+ c[im1]=hr;
+ a[im1]=3.0*((y[i+1]-y[i])/hr-(y[i]-y[im1])/hl);
+ }
+ hl=x[n]-x[nm1];
+ hr=x[1]-x[0];
+ b[nm1]=hl;
+ d[nm1]=2.0*(hl+hr);
+ lowrow[0]=hr;
+ ricol[0]=hr;
+ a[nm1]=3.0*((y[1]-y[0])/hr-(y[n]-y[nm1])/hl);
+ Error=ZyklTriDiagGS(FALSE,n,b,d,c,lowrow,ricol,a);
+ if ( Error != 0 )
+ {
+ delete[] a;
+ delete[] lowrow;
+ delete[] ricol;
+ return(Error+4);
+ }
+ for (i=0;i<=nm1;i++) c[i+1]=a[i];
+ }
+ c[0]=c[n];
+ for (i=0;i<=nm1;i++) {
+ hl=x[i+1]-x[i];
+ b[i]=(y[i+1]-y[i])/hl;
+ b[i]=b[i]-hl*(c[i+1]+2.0*c[i])/3.0;
+ d[i]=(c[i+1]-c[i])/hl/3.0;
+ }
+ delete[] a;
+ delete[] lowrow;
+ delete[] ricol;
+ return 0;
+}
+
+
+
+/*************************************************************************
+|*
+|* ParaSpline()
+|*
+|* Beschreibung Berechnet die Koeffizienten eines parametrischen
+|* natuerlichen oder periodischen kubischen
+|* Polynomsplines mit n Stuetzstellen.
+|* Ersterstellung JOE 17-08.93
+|* Letzte Aenderung JOE 17-08.93
+|*
+*************************************************************************/
+
+USHORT ParaSpline(USHORT n, double* x, double* y, BYTE MargCond,
+ double Marg01, double Marg02,
+ double MargN1, double MargN2,
+ BOOL CondT, double* T,
+ double* bx, double* cx, double* dx,
+ double* by, double* cy, double* dy)
+{
+ USHORT Error,Marg;
+ USHORT i;
+ double deltX,deltY,delt,
+ alphX = 0,alphY = 0,
+ betX = 0,betY = 0;
+
+ if (n<2) return 1;
+ if ((MargCond & ~3) && (MargCond != 4)) return 2; // ungueltige Randbedingung
+ if (CondT==FALSE) {
+ T[0]=0.0;
+ for (i=0;i<n;i++) {
+ deltX=x[i+1]-x[i]; deltY=y[i+1]-y[i];
+ delt =deltX*deltX+deltY*deltY;
+ if (delt<=0.0) return 3; // zwei identische Punkte nacheinander!
+ T[i+1]=T[i]+sqrt(delt);
+ }
+ }
+ switch (MargCond) {
+ case 0: Marg=0; break;
+ case 1: case 2: {
+ Marg=MargCond;
+ alphX=Marg01; betX=MargN1;
+ alphY=Marg02; betY=MargN2;
+ } break;
+ case 3: {
+ if (x[n]!=x[0]) return 3;
+ if (y[n]!=y[0]) return 4;
+ } break;
+ case 4: {
+ Marg=1;
+ if (abs(Marg01)>=MAXROOT) {
+ alphX=0.0;
+ alphY=sign(1.0,y[1]-y[0]);
+ } else {
+ alphX=sign(sqrt(1.0/(1.0+Marg01*Marg01)),x[1]-x[0]);
+ alphY=alphX*Marg01;
+ }
+ if (abs(MargN1)>=MAXROOT) {
+ betX=0.0;
+ betY=sign(1.0,y[n]-y[n-1]);
+ } else {
+ betX=sign(sqrt(1.0/(1.0+MargN1*MargN1)),x[n]-x[n-1]);
+ betY=betX*MargN1;
+ }
+ }
+ } // switch MargCond
+ if (MargCond==3) {
+ Error=PeriodicSpline(n,T,x,bx,cx,dx);
+ if (Error!=0) return(Error+4);
+ Error=PeriodicSpline(n,T,y,by,cy,dy);
+ if (Error!=0) return(Error+10);
+ } else {
+ Error=NaturalSpline(n,T,x,alphX,betX,MargCond,bx,cx,dx);
+ if (Error!=0) return(Error+4);
+ Error=NaturalSpline(n,T,y,alphY,betY,MargCond,by,cy,dy);
+ if (Error!=0) return(Error+9);
+ }
+ return 0;
+}
+
+
+
+/*************************************************************************
+|*
+|* CalcSpline()
+|*
+|* Beschreibung Berechnet die Koeffizienten eines parametrischen
+|* natuerlichen oder periodischen kubischen
+|* Polynomsplines. Die Eckpunkte des uebergebenen
+|* Polygons werden als Stuetzstellen angenommen.
+|* n liefert die Anzahl der Teilpolynome.
+|* Ist die Berechnung fehlerfrei verlaufen, so
+|* liefert die Funktion TRUE. Nur in diesem Fall
+|* ist Speicher fuer die Koeffizientenarrays
+|* allokiert, der dann spaeter vom Aufrufer mittels
+|* delete freizugeben ist.
+|* Ersterstellung JOE 17-08.93
+|* Letzte Aenderung JOE 17-08.93
+|*
+*************************************************************************/
+
+BOOL CalcSpline(Polygon& rPoly, BOOL Periodic, USHORT& n,
+ double*& ax, double*& ay, double*& bx, double*& by,
+ double*& cx, double*& cy, double*& dx, double*& dy, double*& T)
+{
+ BYTE Marg;
+ double Marg01,Marg02;
+ double MargN1,MargN2;
+ USHORT i;
+ Point P0(-32768,-32768);
+ Point Pt;
+
+ n=rPoly.GetSize();
+ ax=new double[rPoly.GetSize()+2];
+ ay=new double[rPoly.GetSize()+2];
+
+ n=0;
+ for (i=0;i<rPoly.GetSize();i++) {
+ Pt=rPoly.GetPoint(i);
+ if (i==0 || Pt!=P0) {
+ ax[n]=Pt.X();
+ ay[n]=Pt.Y();
+ n++;
+ P0=Pt;
+ }
+ }
+
+ if (Periodic) {
+ Marg=3;
+ ax[n]=ax[0];
+ ay[n]=ay[0];
+ n++;
+ } else {
+ Marg=2;
+ }
+
+ bx=new double[n+1];
+ by=new double[n+1];
+ cx=new double[n+1];
+ cy=new double[n+1];
+ dx=new double[n+1];
+ dy=new double[n+1];
+ T =new double[n+1];
+
+ Marg01=0.0;
+ Marg02=0.0;
+ MargN1=0.0;
+ MargN2=0.0;
+ if (n>0) n--; // n Korregieren (Anzahl der Teilpolynome)
+
+ BOOL bRet = FALSE;
+ if ( ( Marg == 3 && n >= 3 ) || ( Marg == 2 && n >= 2 ) )
+ {
+ bRet = ParaSpline(n,ax,ay,Marg,Marg01,Marg01,MargN1,MargN2,FALSE,T,bx,cx,dx,by,cy,dy) == 0;
+ }
+ if ( bRet == FALSE )
+ {
+ delete[] ax;
+ delete[] ay;
+ delete[] bx;
+ delete[] by;
+ delete[] cx;
+ delete[] cy;
+ delete[] dx;
+ delete[] dy;
+ delete[] T;
+ n=0;
+ }
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|* Spline2Poly()
+|*
+|* Beschreibung Konvertiert einen parametrichen kubischen
+|* Polynomspline Spline (natuerlich oder periodisch)
+|* in ein angenaehertes Polygon.
+|* Die Funktion liefert FALSE, wenn ein Fehler bei
+|* der Koeffizientenberechnung aufgetreten ist oder
+|* das Polygon zu gross wird (>PolyMax=16380). Im 1.
+|* Fall hat das Polygon 0, im 2. Fall PolyMax Punkte.
+|* Um Koordinatenueberlaeufe zu vermeiden werden diese
+|* auf +/-32000 begrenzt.
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+BOOL Spline2Poly(Polygon& rSpln, BOOL Periodic, Polygon& rPoly)
+{
+ short MinKoord=-32000; // zur Vermeidung
+ short MaxKoord=32000; // von Ueberlaeufen
+
+ double* ax; // Koeffizienten der Polynome
+ double* ay;
+ double* bx;
+ double* by;
+ double* cx;
+ double* cy;
+ double* dx;
+ double* dy;
+ double* tv;
+
+ double Step; // Schrittweite fuer t
+ double dt1,dt2,dt3; // Delta t, y, ^3
+ double t;
+ BOOL bEnde; // Teilpolynom zu Ende?
+ USHORT n; // Anzahl der zu zeichnenden Teilpolynome
+ USHORT i; // aktuelles Teilpolynom
+ BOOL bOk; // noch alles ok?
+ USHORT PolyMax=16380;// Maximale Anzahl von Polygonpunkten
+ long x,y;
+
+ bOk=CalcSpline(rSpln,Periodic,n,ax,ay,bx,by,cx,cy,dx,dy,tv);
+ if (bOk) {
+ Step =10;
+
+ rPoly.SetSize(1);
+ rPoly.SetPoint(Point(short(ax[0]),short(ay[0])),0); // erster Punkt
+ i=0;
+ while (i<n) { // n Teilpolynome malen
+ t=tv[i]+Step;
+ bEnde=FALSE;
+ while (!bEnde) { // ein Teilpolynom interpolieren
+ bEnde=t>=tv[i+1];
+ if (bEnde) t=tv[i+1];
+ dt1=t-tv[i]; dt2=dt1*dt1; dt3=dt2*dt1;
+ x=long(ax[i]+bx[i]*dt1+cx[i]*dt2+dx[i]*dt3);
+ y=long(ay[i]+by[i]*dt1+cy[i]*dt2+dy[i]*dt3);
+ if (x<MinKoord) x=MinKoord; if (x>MaxKoord) x=MaxKoord;
+ if (y<MinKoord) y=MinKoord; if (y>MaxKoord) y=MaxKoord;
+ if (rPoly.GetSize()<PolyMax) {
+ rPoly.SetSize(rPoly.GetSize()+1);
+ rPoly.SetPoint(Point(short(x),short(y)),rPoly.GetSize()-1);
+ } else {
+ bOk=FALSE; // Fehler: Polygon wird zu gross
+ }
+ t=t+Step;
+ } // Ende von Teilpolynom
+ i++; // naechstes Teilpolynom
+ }
+ delete[] ax;
+ delete[] ay;
+ delete[] bx;
+ delete[] by;
+ delete[] cx;
+ delete[] cy;
+ delete[] dx;
+ delete[] dy;
+ delete[] tv;
+ return bOk;
+ } // Ende von if (bOk)
+ rPoly.SetSize(0);
+ return FALSE;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvtext.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvtext.cxx
new file mode 100644
index 000000000000..ddb15c3f8011
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvtext.cxx
@@ -0,0 +1,1295 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/config.hxx>
+#include <bf_svtools/filter.hxx>
+#include "sgffilt.hxx"
+#include "sgfbram.hxx"
+#include "sgvmain.hxx"
+
+namespace binfilter {
+
+extern SgfFontLst* pSgfFonts;
+
+#if defined( WIN ) && defined( MSC )
+#pragma code_seg( "SVTOOLS_FILTER1", "SVTOOLS_CODE" )
+#endif
+
+#ifndef abs
+#define abs(x) ((x)<0 ? -(x) : (x))
+#endif
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Einschraenkungen: Schatten nur grau, 2D und mit fixem Abstand.
+//
+//
+//
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+// AbsBase.Pas
+
+// die folgenden Werte sind in % vom maximalen Schriftgrad der Zeile */
+#define UndlSpace 5 /* Untersteichungsabstand von der Baseline */
+#define UndlWidth 6 /* Untersteichungsdicke */
+#define UndlSpac2 7 /* Zwischenraum bei doppelter Unterstreichung */
+#define StrkSpace 25 /* Abstand der Durchstreichlinie von der Baseline*/
+#define StrkWidth 5 /* Durchstreichungsliniendicke */
+#define StrkSpac2 7 /* Zwischenraum bei doppelter Durchstreichung */
+#define OutlWidth 2 /* Strichstaerke ist 2% vom Schriftgrad */
+
+// vvv Sonderzeichen im TextBuffer vvv
+#define TextEnd 0 /* ^@ Ende der Zeichenkette */
+#define HardSpace 6 /* ^F Hartspace (wird nicht umbrochen) ,' ' */
+#define GrafText 7 /* ^G Im Text eingebundene Grafik (future) */
+#define Tabulator 9 /* ^I Tabulatorzeichen, Pfeil */
+#define LineFeed 10 /* ^J Neue Zeile */
+#define SoftTrennK 11 /* ^K Zeichen fuer k-c-Austausch bei Trennung, 'k' */
+#define AbsatzEnd 13 /* ^M Neuer Absatz =CR */
+#define HardTrenn 16 /* ^P Hartes Trennzeichen (wird nicht umbrochen), '-' */
+#define SoftTrennAdd 19 /* ^S Zusatz-Zeichen Trennung von z.b."Schiff-fahrt" */
+#define Paragraf 21 /* ^U Zeichen welches fuer Paragraf-Zeichen */
+#define Escape 27 /* ^[ Escapesequenz einleiten */
+#define SoftTrenn 31 /* ^_ Weiches Trennzeichen, '-' nur Zeilenende */
+#define MaxEscValLen 8
+#define MaxEscLen (MaxEscValLen+3)
+
+//==============================================================================
+// Escapesequenzen: [Esc]<Ident><Value>[Esc] also mind. 4 Char
+// Max. Laenge von Value soll sein: 8 Char (7+Vorzeichen). Demnach max. Laenge
+// einer Escapesequenz: 11 Char.
+// Identifer:
+
+#define EscFont 'F' /* FontID, z.B. 92500 fuer CG Times */
+#define EscGrad 'G' /* Schriftgrad 1..255 fuer <<Pt-127<<Pt */
+#define EscBreit 'B' /* Breite 1..255% des Schriftgrades */
+#define EscKaptS 'K' /* Kapitaelchengroesse 1..255% des Schriftgrades */
+#define EscLFeed 'L' /* Zeilenabstand 1..32767% vom max. Schriftgrad der Zeile */
+ // oder 1..32767 fuer 1..16383<<Pt absolut (Wenn Bit 15=1)
+#define EscSlant 'S' /* Kursiv(Winkel) 1..8999 fuer 0.01deg..89.99deg */
+#define EscVPos 'V' /* Zeichen Vertikal-Position 1..255 fuer <<Pt..127<<Pt */
+#define EscZAbst 'Z' /* Zeichenabstand -128..127% */
+#define EscHJust 'A' /* H-Justify Absatz: Links, Zentr, Rechts, Block, Austreibend, Gesperrt (0..5)*/
+
+#define EscFarbe 'C' /* Farbe 0..7 */
+#define EscBFarb 'U' /* BackFarbe 0..7 */
+#define EscInts 'I' /* Farbintensitaet 0..100% */
+#define EscMustr 'M' /* Muster 0..? inkl. Transp... */
+#define EscMFarb 'O' /* Musterfarbe 0..7 */
+#define EscMBFrb 'P' /* 2. Musterfarbe 0..7 */
+#define EscMInts 'W' /* Musterintensitaet 0..7 */
+
+#define EscSMstr 'E' /* Schattenmuster 0..? inkl. Transp... */
+#define EscSFarb 'R' /* Schattenfarbe 0..7 */
+#define EscSBFrb 'T' /* 2. Schattenfarbe 0..7 */
+#define EscSInts 'Q' /* Schattenintensitaet 0..7 */
+
+#define EscSXDst 'X' /* Schattenversatz X 0..100% */
+#define EscSYDst 'Y' /* Schattenversatz Y 0..100% */
+#define EscSDist 'D' /* Schattenversatz X-Y 0..100% */
+
+#define EscBold 'f' /* Fett */
+#define EscLSlnt 'l' /* LKursiv */
+#define EscRSlnt 'r' /* RKursiv */
+#define EscUndln 'u' /* Unterstrichen */
+#define EscDbUnd 'p' /* doppelt Unterstrichen */
+#define EscKaptF 'k' /* Kapitaelchenflag */
+#define EscStrik 'd' /* Durchgestrichen */
+#define EscDbStk 'e' /* doppelt Durchgestrichen */
+#define EscSupSc 'h' /* Hochgestellt */
+#define EscSubSc 't' /* Tiefgestellt */
+#define Esc2DShd 's' /* 2D-Schatten */
+#define Esc3DShd 'j' /* 3D-Schatten */
+#define Esc4DShd 'i' /* 4D-Schatten */
+#define EscEbShd 'b' /* Embossed */
+
+// AllEscIdent =[EscFont, EscGrad, EscBreit,EscKaptS,EscLFeed,EscSlant,EscVPos, EscZAbst,EscHJust,
+// EscFarbe,EscBFarb,EscInts, EscMustr,EscMFarb,EscMBFrb,EscMInts,
+// EscSMstr,EscSFarb,EscSBFrb,EscSInts,EscSXDst,EscSYDst,EscSDist,
+// EscBold, EscLSlnt,EscRSlnt,EscUndln,EscDbUnd,EscKaptF,EscStrik,EscDbStk,
+// EscSupSc,EscSubSc,Esc2DShd,Esc3DShd,Esc4DShd];
+// Justify muss spaetestens am Anfang des Absatzes stehen
+#define EscSet '' /* Flag setzen */
+#define EscReset '' /* Flag loeschen */
+#define EscDeflt '\x11' /* Flag auf default setzen */
+#define EscToggl '' /* Flag Toggeln */
+#define EscRelat '%'
+#define EscNoFlg 0
+#define EscNoVal -2147483647 /* -MaxLongInt */
+//==============================================================================
+#define NoTrenn 0xFFFF /* Wert fuer Parameter 'Rest' von GetTextChar(), wenn auf keinen Fall getrennt werden soll */
+#define DoTrenn 0xFFFE /* Wert fuer Parameter 'Rest' von GetTextChar(), wenn getrennt werden soll */
+
+#define MaxLineChars 1024
+
+#define ChrXPosArrSize (MaxLineChars+1+1) /* 2k - Beginnt mit 0 im gegensatz zu StarDraw */
+#define CharLineSize (MaxLineChars+1+1)
+#define EscStr (UCHAR[MaxEscLen+1]);
+
+#define MinChar 32
+#define MaxChar 255
+
+
+//==============================================================================
+
+#define DefaultCharWidth 4800
+#define GradDiv 2
+#define CharTopToBase 100 /* wegen Apostrophe und Umlaute mehr als 75% */
+#define CharTopToBtm 120 /* Zeilenhoehe ist groesser als Schriftgrad */
+ // bei Avanti-Bold 'ue' eigentlich sogar 130%
+
+// end of AbsBase.Pas
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+
+
+
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+// DefBase.Pas
+
+#define TextBoldBit 0x0001 /* Fett */
+#define TextRSlnBit 0x0002 /* Kursiv */
+#define TextUndlBit 0x0004 /* Unterstrichen */
+#define TextStrkBit 0x0008 /* Durchgesteichen */
+#define TextSupSBit 0x0010 /* Hocgestellt */
+#define TextSubSBit 0x0020 /* Tiefgestellt */
+#define TextKaptBit 0x0040 /* Kapitaelchen */
+#define TextLSlnBit 0x0080 /* Linkskursiv */
+#define TextDbUnBit 0x0100 /* Doppelt unterstrichen */
+#define TextDbStBit 0x0200 /* Doppelt durchgestrichen */
+#define TextSh2DBit 0x0400 /* 2D-Schatten 2.0 */
+#define TextSh3DBit 0x0800 /* 3D-Schatten 2.0 */
+#define TextSh4DBit 0x1000 /* 4D-Schatten 2.0 */
+#define TextShEbBit 0x2000 /* Embossed-Schatten 2.0 */
+#define FontAtrBits (TextBoldBit | TextRSlnBit)
+
+#define THJustLeft 0x00
+#define THJustCenter 0x01
+#define THJustRight 0x02
+#define THJustBlock 0x03
+#define THJustDrvOut 0x04 /* Austreibend Formatiert */
+#define THJustLocked 0x05 /* A l s S p e r r s c h r i f t */
+#define TVJustTop 0x00 /* Future */
+#define TVJustCenter 0x10 /* Future */
+#define TVJustBottom 0x20 /* Future */
+#define TVJustBlock 0x30 /* Future */
+
+#define MaxCharSlant 4200 /* Maximal 42deg kursiv ! */
+
+// end of DefBase.Pas
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+
+BOOL CheckTextOutl(ObjAreaType& F, ObjLineType& L);
+
+BOOL CheckTextOutl(ObjAreaType& F, ObjLineType& L)
+{
+ return (F.FIntens!=L.LIntens) ||
+ ((F.FFarbe!=L.LFarbe) && (F.FIntens>0)) ||
+ ((F.FBFarbe!=L.LBFarbe) && (F.FIntens<100));
+}
+
+
+short hPoint2Sgf(short a)
+{
+ long b;
+ b=long(a)*127*SgfDpmm/(144*5);
+ return short(b);
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+// AbsRead.Pas
+
+// ======================================================================
+// Function GetTopToBaseLine() Function GetBaseLineToBtm()
+//
+// Abstand von Zeilenoberkante bis BaseLine bzw. von BaseLine bis
+// Unterkante berechnen. Alles in SGF-Units.
+// ======================================================================
+
+USHORT GetTopToBaseLine(USHORT MaxGrad)
+{
+ long ret;
+ ret=long(MaxGrad)*long(CharTopToBase) /long(100);
+ return USHORT(ret);
+}
+
+// ======================================================================
+// Function GetTextChar() Function GetTextCharConv()
+//
+// Liest ein Zeichen aus dem Textbuffer, wertet dabei eventuell
+// auftretende Escapesequenzen aus und setzt dementsprechend den
+// Ein-/Ausgabeparameter AktAtr. Index wird entsprechend erhoeht.
+// Der Parameter Rest muss immer die Anzahl der Zeichen beinhalten,
+// den angeforderten Zeichen in der aktuellen Zeile noch folgen.
+// Ansonsten funktioniert die Silbentrennung nicht richtig. Gibt man
+// stattdessen die Konstante NoTrenn an, wird in keinem Fall
+// getrennt, die Konstante DoTrenn bewirkt dagegen, dass ueberall dort
+// getrennt wird, wo ein SoftTrenner vorkommt.
+//
+// SoftTrenner werden immer in ein Minuszeichen konvertiert.
+// GetTextCharConv() konvertiert zusaetzlich HardSpace und AbsatzEnde
+// in Spaces sowie HardTrenner in Minuszeichen. TextEnde wird immer
+// als Char(0) geliefert.
+// ======================================================================
+
+
+
+UCHAR ConvertTextChar(UCHAR c)
+{
+ if (c<32) {
+ switch (c) {
+ case HardSpace : c=' '; break;
+ case AbsatzEnd : c=' '; break;
+ case SoftTrenn : c='-'; break;
+ case HardTrenn : c='-'; break;
+ case SoftTrennK : c='-'; break;
+ case SoftTrennAdd: c='-';
+ }
+ }
+ return c;
+}
+
+long ChgValue(long Def, long Min, long Max, UCHAR FlgVal, long NumVal)
+{
+ long r=0;
+
+ if (FlgVal==EscDeflt) {
+ r=Def; // zurueck auf Default
+ } else {
+ if (NumVal!=EscNoVal) r=NumVal; // Hart setzen
+ }
+
+ if (Min!=0 || Max!=0) {
+ if (r>Max) r=Max;
+ if (r<Min) r=Min;
+ }
+ return r;
+}
+
+
+
+void ChgSchnittBit(USHORT Bit, USHORT Radio1, USHORT Radio2, USHORT Radio3,
+ UCHAR FlgVal, USHORT Schnitt0, USHORT& Schnitt)
+{
+ USHORT All,Rad;
+
+ Rad=Radio1 | Radio2 | Radio3;
+ All=Bit | Rad;
+
+ switch (FlgVal) {
+ case EscSet : Schnitt=(Schnitt & ~All) | Bit; break;
+ case EscReset: Schnitt=(Schnitt & ~All); break;
+ case EscDeflt: Schnitt=(Schnitt & ~All) | (Schnitt0 & All); break;
+ case EscToggl: Schnitt=(Schnitt & ~Rad) ^ Bit;
+ }
+}
+
+
+
+UCHAR GetNextChar(UCHAR* TBuf, USHORT Index)
+{
+ USHORT Cnt;
+ while (TBuf[Index]==Escape) {
+ Index++;
+ Cnt=0;
+ while (TBuf[Index]!=Escape && Cnt<=MaxEscLen) {
+ Index++; Cnt++; }
+ Index++;
+ }
+ return TBuf[Index];
+}
+
+
+
+UCHAR ProcessOne(UCHAR* TBuf, USHORT& Index,
+ ObjTextType& Atr0, ObjTextType& AktAtr,
+ BOOL ScanEsc)
+{
+ UCHAR c;
+ UCHAR Ident;
+ BOOL Ende;
+ BOOL q;
+ UCHAR FlgVal;
+ long NumVal;
+ long Sgn;
+ short i;
+ BOOL EoVal;
+
+ do {
+ c=TBuf[Index]; Index++;
+ Ende=(c!=Escape);
+ if (Ende==FALSE) {
+ c=TBuf[Index]; Index++;
+ Ident=c; // Identifer merken
+ FlgVal=EscNoFlg;
+ NumVal=EscNoVal;
+ c=TBuf[Index]; Index++; // Hier faengt der Wert an
+ if (c==EscSet || c==EscReset || c==EscDeflt || c==EscToggl) FlgVal=c; else {
+ if (c=='-') Sgn=-1; else Sgn=1;
+ if (c=='+' || c=='-') { c=TBuf[Index]; Index++; }
+ i=MaxEscValLen;
+ NumVal=0;
+ do {
+ NumVal=10*NumVal+c-'0';
+ EoVal=(TBuf[Index]<'0' || TBuf[Index]>'9');
+ if (EoVal==FALSE) { c=TBuf[Index]; Index++; }
+ i--;
+ } while (i>0 && EoVal==FALSE);
+ NumVal=Sgn*NumVal;
+ }
+ q=!CheckTextOutl(AktAtr.F,AktAtr.L);
+
+ switch (Ident) {
+ case EscFont : AktAtr.SetFont(ULONG (ChgValue(Atr0.GetFont(),0,0 ,FlgVal,NumVal)));break;
+ case EscGrad : AktAtr.Grad =USHORT(ChgValue(Atr0.Grad, 2,2000 ,FlgVal,NumVal)); break;
+ case EscBreit: AktAtr.Breite =USHORT(ChgValue(Atr0.Breite, 1,1000 ,FlgVal,NumVal)); break;
+ case EscKaptS: AktAtr.Kapit =(BYTE)(ChgValue(Atr0.Kapit, 1,255 ,FlgVal,NumVal)); break;
+ case EscLFeed: AktAtr.LnFeed =USHORT(ChgValue(Atr0.LnFeed, 1,65535 ,FlgVal,NumVal)); break;
+ case EscSlant: AktAtr.Slant =USHORT(ChgValue(Atr0.Slant, 1,MaxCharSlant ,FlgVal,NumVal)); break;
+ case EscVPos : AktAtr.ChrVPos=char (ChgValue(Atr0.ChrVPos,-128,127 ,FlgVal,NumVal)); break;
+ case EscZAbst: AktAtr.ZAbst =(BYTE)(ChgValue(Atr0.ZAbst, 1,255 ,FlgVal,NumVal)); break;
+ case EscHJust: AktAtr.Justify=(BYTE)(ChgValue(Atr0.Justify & 0x0F,0,5 ,FlgVal,NumVal)); break;
+ case EscFarbe: { AktAtr.L.LFarbe =(BYTE)(ChgValue(Atr0.L.LFarbe,0,7 ,FlgVal,NumVal)); if (q) AktAtr.F.FFarbe =AktAtr.L.LFarbe; } break;
+ case EscBFarb: { AktAtr.L.LBFarbe=(BYTE)(ChgValue(Atr0.L.LBFarbe,0,255,FlgVal,NumVal)); if (q) AktAtr.F.FBFarbe=AktAtr.L.LBFarbe; } break;
+ case EscInts : { AktAtr.L.LIntens=(BYTE)(ChgValue(Atr0.L.LIntens,0,100,FlgVal,NumVal)); if (q) AktAtr.F.FIntens=AktAtr.L.LIntens; } break;
+
+ case EscMustr: { AktAtr.F.FMuster=USHORT(ChgValue(Atr0.F.FMuster,0,65535,FlgVal,NumVal)); } break;
+ case EscMFarb: { AktAtr.F.FFarbe =(BYTE)(ChgValue(Atr0.F.FFarbe,0,7 ,FlgVal,NumVal)); } break;
+ case EscMBFrb: { AktAtr.F.FBFarbe=(BYTE)(ChgValue(Atr0.F.FBFarbe,0,255,FlgVal,NumVal)); } break;
+ case EscMInts: { AktAtr.F.FIntens=(BYTE)(ChgValue(Atr0.F.FIntens,0,100,FlgVal,NumVal)); } break;
+
+ case EscSMstr: { AktAtr.ShdF.FMuster=USHORT(ChgValue(Atr0.ShdF.FMuster,0,65535,FlgVal,NumVal)); } break;
+ case EscSFarb: { AktAtr.ShdL.LFarbe =(BYTE)(ChgValue(Atr0.ShdL.LFarbe,0,7 ,FlgVal,NumVal)); AktAtr.ShdF.FFarbe =AktAtr.ShdL.LFarbe; } break;
+ case EscSBFrb: { AktAtr.ShdL.LBFarbe=(BYTE)(ChgValue(Atr0.ShdL.LBFarbe,0,255,FlgVal,NumVal)); AktAtr.ShdF.FBFarbe=AktAtr.ShdL.LBFarbe; } break;
+ case EscSInts: { AktAtr.ShdL.LIntens=(BYTE)(ChgValue(Atr0.ShdL.LIntens,0,100,FlgVal,NumVal)); AktAtr.ShdF.FIntens=AktAtr.ShdL.LIntens; } break;
+ case EscSDist: { AktAtr.ShdVers.x=(short)ChgValue(Atr0.ShdVers.x,0,30000,FlgVal,NumVal); AktAtr.ShdVers.y=AktAtr.ShdVers.x; } break;
+ case EscSXDst: { AktAtr.ShdVers.x=(short)ChgValue(Atr0.ShdVers.x,0,30000,FlgVal,NumVal); } break;
+ case EscSYDst: { AktAtr.ShdVers.y=(short)ChgValue(Atr0.ShdVers.y,0,30000,FlgVal,NumVal); } break;
+
+ case EscBold : ChgSchnittBit(TextBoldBit,0,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
+ case EscRSlnt: ChgSchnittBit(TextRSlnBit,TextLSlnBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
+ case EscUndln: ChgSchnittBit(TextUndlBit,TextDbUnBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
+ case EscStrik: ChgSchnittBit(TextStrkBit,TextDbStBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
+ case EscDbUnd: ChgSchnittBit(TextDbUnBit,TextUndlBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
+ case EscDbStk: ChgSchnittBit(TextDbStBit,TextStrkBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
+ case EscSupSc: ChgSchnittBit(TextSupSBit,TextSubSBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
+ case EscSubSc: ChgSchnittBit(TextSubSBit,TextSupSBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
+ case EscKaptF: ChgSchnittBit(TextKaptBit,0,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
+ case EscLSlnt: ChgSchnittBit(TextLSlnBit,TextRSlnBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
+ case Esc2DShd: ChgSchnittBit(TextSh2DBit,TextSh3DBit,TextSh4DBit,TextShEbBit,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
+ case Esc3DShd: ChgSchnittBit(TextSh3DBit,TextSh2DBit,TextSh4DBit,TextShEbBit,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
+ case Esc4DShd: ChgSchnittBit(TextSh4DBit,TextSh2DBit,TextSh3DBit,TextShEbBit,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
+ case EscEbShd: ChgSchnittBit(TextShEbBit,TextSh2DBit,TextSh3DBit,TextSh4DBit,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
+ } //endcase
+ if (TBuf[Index]==Escape) Index++; // zweites Esc weglesen }
+ } // if Ende==FALSE
+ } while (Ende==FALSE && ScanEsc==FALSE);
+ if (Ende==FALSE) c=Escape;
+ return c;
+} // end of ProcessOne
+
+
+UCHAR GetTextChar(UCHAR* TBuf, USHORT& Index,
+ ObjTextType& Atr0, ObjTextType& AktAtr,
+ USHORT Rest, BOOL ScanEsc)
+{
+ UCHAR c,c0,nc;
+
+ c=ProcessOne(TBuf,Index,Atr0,AktAtr,ScanEsc);
+ if (ScanEsc==FALSE) {
+ if (c==SoftTrennAdd || c==SoftTrennK || c==SoftTrenn) {
+ nc=GetNextChar(TBuf,Index);
+ c0=c;
+ if (Rest==0 || Rest==DoTrenn ||
+ nc==' ' || nc==AbsatzEnd || nc==TextEnd) c='-';
+ else {
+ c=ProcessOne(TBuf,Index,Atr0,AktAtr,ScanEsc); // den Trenner ueberspringen
+ if (c0==SoftTrennAdd) {
+ if (c>=32) c=ProcessOne(TBuf,Index,Atr0,AktAtr,ScanEsc); // und hier noch 'nen Buchstaben ueberspringen
+ }
+ }
+ }
+ if ((Rest==1 || Rest==DoTrenn) && GetNextChar(TBuf,Index)==SoftTrennK) {
+ if (c=='c') c='k';
+ else if (c=='C') c='K';
+ }
+ }
+ return c;
+}
+
+ // HardSpace und HardTrenn muessen explizit konvertiert werden ! }
+ // if AktAtr.Schnitt and TextKaptBit =TextKaptBit then c:=UpCase(c);(explizit) }
+
+ // Bei der Trennmethode SoftTrennAdd wird davon ausgegangen, dass der zu }
+ // trennende Konsonant bereits 3x mal im TextBuf vorhanden ist, z.b.: }
+ // "Schiff-fahrt". Wenn nicht getrennt, dann wird "-f" entfernt. }
+
+
+
+UCHAR GetTextCharConv(UCHAR* TBuf, USHORT& Index,
+ ObjTextType& Atr0, ObjTextType& AktAtr,
+ USHORT Rest, BOOL ScanEsc)
+{
+ UCHAR c;
+
+ c=GetTextChar(TBuf,Index,Atr0,AktAtr,Rest,ScanEsc);
+ if (c<32) {
+ switch (c) {
+ case HardSpace : c=' '; break;
+ case AbsatzEnd : c=' '; break;
+ case HardTrenn : c='-';
+ }
+ }
+ return c;
+}
+
+
+// ======================================================================
+// Function GetLineFeed()
+//
+// Benoetigter Zeilenabstand in SGF-Units. ChrVPos wird beruecksichtigt.
+// ======================================================================
+USHORT GetLineFeed(UCHAR* TBuf, USHORT Index, ObjTextType Atr0, ObjTextType AktAtr,
+ USHORT nChar, USHORT& LF, USHORT& MaxGrad)
+{
+ UCHAR c=0;
+ BOOL AbsEnd=FALSE;
+ ULONG LF100=0;
+ ULONG MaxLF100=0;
+ BOOL LFauto=0;
+ BOOL First=TRUE;
+ USHORT Grad;
+ USHORT i=0;
+ USHORT r=1;
+
+ MaxGrad=0;
+ while (!AbsEnd && nChar>0) {
+ nChar--;
+ c=GetTextChar(TBuf,Index,Atr0,AktAtr,nChar,FALSE);
+ i++;
+ AbsEnd=(c==TextEnd || c==AbsatzEnd);
+ if (First || (!AbsEnd && c!=' ' && c!=HardTrenn)) {
+ LFauto=(AktAtr.LnFeed & 0x8000)==0;
+ LF100=AktAtr.LnFeed & 0x7FFF;
+ if (LFauto) LF100=LF100*AktAtr.Grad; else LF100*=LF100;
+ if (AktAtr.ChrVPos>0) LF100-=AktAtr.ChrVPos*100;
+ if (LF100>MaxLF100) MaxLF100=LF100;
+ Grad=AktAtr.Grad;
+ if (AktAtr.ChrVPos>0) Grad=Grad-AktAtr.ChrVPos;
+ if (Grad>MaxGrad) MaxGrad=Grad;
+ First=FALSE;
+ }
+ if (!AbsEnd && c!=' ') r=i;
+ }
+ MaxGrad=hPoint2Sgf(MaxGrad);
+ if (MaxLF100<=4000) { // sonst Overflowgefahr
+ LF=USHORT(hPoint2Sgf(short(MaxLF100)) /100);
+ } else {
+ LF=USHORT(hPoint2Sgf(short(MaxLF100) /100));
+ }
+
+ return r;
+}
+
+// End of AbsRead.Pas
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+
+
+
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+// iFont.Pas
+
+#define DefaultSlant 1500 /* Default: Italic ist 15deg */
+#define SuperSubFact 60 /* SuperScript/SubScript: 60% vom Schriftgrad */
+#define DefaultSpace 40 /* Default: Space ist 40% vom SchriftGrad */
+
+USHORT SetTextContext(OutputDevice& rOut, ObjTextType& Atr, BOOL Kapt, USHORT Dreh,
+ USHORT FitXMul, USHORT FitXDiv, USHORT FitYMul, USHORT FitYDiv)
+{
+ SgfFontOne* pSgfFont; // Font aus dem IniFile
+ Font aFont;
+ Color aColor;
+ ULONG Grad;
+ ULONG Brei;
+ String FNam;
+ USHORT StdBrei=50; // Durchschnittliche Zeichenbreite in % von Schriftgrad
+ BOOL bFit=(FitXMul!=1 || FitXDiv!=1 || FitYMul!=1 || FitYDiv!=1);
+
+ pSgfFont = pSgfFonts->GetFontDesc(Atr.GetFont());
+
+ if ( pSgfFont!=NULL )
+ {
+ FNam =pSgfFont->SVFName;
+ StdBrei=pSgfFont->SVWidth;
+ if (pSgfFont->Fixd) aFont.SetPitch(PITCH_FIXED); else aFont.SetPitch(PITCH_VARIABLE);
+ aFont.SetFamily(pSgfFont->SVFamil);
+ aFont.SetCharSet(pSgfFont->SVChSet);
+ aFont.SetName(FNam);
+ }
+ else
+ { // Falls nich im Inifile, sind hier einige Fonts hart kodiert
+ aFont.SetPitch(PITCH_VARIABLE);
+ switch (Atr.GetFont()) {
+ case 92500: case 92501: case 92504: case 92505:
+ {
+#if defined(WIN) || defined(WNT) || defined(PM2)
+ FNam=String::CreateFromAscii( "Times New Roman" ); // CG Times ist unter Windows und OS/2 Times New Roman
+#else
+ FNam=String::CreateFromAscii( "Times" ); // ansonsten ist das einfach Times
+#endif
+ StdBrei=40;
+ aFont.SetFamily(FAMILY_ROMAN);
+ } break;
+ case 94021: case 94022: case 94023: case 94024: {
+#if defined(WIN) || defined(WNT)
+ FNam=String::CreateFromAscii( "Arial", 5 ); // Univers ist unter Windows Arial
+#else
+ FNam=String::CreateFromAscii( "Helvetica" ); // und ansonsten Helvetica
+#endif
+ aFont.SetFamily(FAMILY_SWISS);
+ StdBrei=47;
+ } break;
+ case 93950: case 93951: case 93952: case 93953: {
+#if defined(WIN) || defined(WNT)
+ FNam=String::CreateFromAscii( "Courier New" ); // Der Vector-Courierfont unter Windows heisst Courier New
+#else
+ FNam=String::CreateFromAscii( "Courier" ); // ansonsten ist und bleibt Courier immer Courier
+#endif
+ aFont.SetFamily(FAMILY_ROMAN);
+ aFont.SetPitch(PITCH_FIXED);
+ } break;
+ default: FNam=String::CreateFromAscii( "Helvetica", 9 );
+ }
+ aFont.SetName(FNam);
+ //aFont.SetCharSet(CHARSET_SYSTEM);
+ }
+
+ Grad=ULONG(Atr.Grad);
+ if ((Atr.Schnitt & TextKaptBit) !=0 && Kapt) Grad=Grad*ULONG(Atr.Kapit)/100;
+ if ((Atr.Schnitt & TextSupSBit) !=0 || (Atr.Schnitt & TextSubSBit) !=0) Grad=Grad*SuperSubFact/100;
+ Brei=Grad;
+ if (Atr.Breite!=100 || bFit) {
+ if (bFit) {
+ Grad=Grad*ULONG(FitYMul)/ULONG(FitYDiv);
+ Brei=Brei*ULONG(FitXMul)/ULONG(FitXDiv);
+ }
+ Brei=Brei*ULONG(Atr.Breite)/100;
+ Brei=Brei*ULONG(StdBrei)/100;
+ aFont.SetSize(Size(hPoint2Sgf(USHORT(Brei)),hPoint2Sgf(USHORT(Grad))));
+ } else {
+ aFont.SetSize(Size(0,hPoint2Sgf(USHORT(Grad))));
+ }
+
+ aColor=Sgv2SvFarbe(Atr.L.LFarbe,Atr.L.LBFarbe,Atr.L.LIntens); aFont.SetColor(aColor);
+ aColor=Sgv2SvFarbe(Atr.F.FFarbe,Atr.F.FBFarbe,Atr.F.FIntens); aFont.SetFillColor(aColor);
+ aFont.SetTransparent(TRUE);
+ aFont.SetAlign(ALIGN_BASELINE);
+
+ Dreh/=10; Dreh=3600-Dreh; if (Dreh==3600) Dreh=0;
+ aFont.SetOrientation(Dreh);
+
+ if ((Atr.Schnitt & TextBoldBit) !=0) aFont.SetWeight(WEIGHT_BOLD);
+ if ((Atr.Schnitt & TextRSlnBit) !=0) aFont.SetItalic(ITALIC_NORMAL);
+ if ((Atr.Schnitt & TextUndlBit) !=0) aFont.SetUnderline(UNDERLINE_SINGLE);
+ if ((Atr.Schnitt & TextDbUnBit) !=0) aFont.SetUnderline(UNDERLINE_DOUBLE);
+ if ((Atr.Schnitt & TextStrkBit) !=0) aFont.SetStrikeout(STRIKEOUT_SINGLE);
+ if ((Atr.Schnitt & TextDbStBit) !=0) aFont.SetStrikeout(STRIKEOUT_DOUBLE);
+ if ((Atr.Schnitt & TextSh2DBit) !=0) aFont.SetShadow(TRUE);
+ if ((Atr.Schnitt & TextSh3DBit) !=0) aFont.SetShadow(TRUE);
+ if ((Atr.Schnitt & TextSh4DBit) !=0) aFont.SetShadow(TRUE);
+ if ((Atr.Schnitt & TextShEbBit) !=0) aFont.SetShadow(TRUE);
+ if (CheckTextOutl(Atr.F,Atr.L)) aFont.SetOutline(TRUE);
+
+ if (aFont!=rOut.GetFont()) rOut.SetFont(aFont);
+
+ return 0;
+}
+
+// iFont.Pas
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+// Absatz.Pas
+
+struct ProcChrSta {
+ USHORT Index;
+ USHORT ChrXP;
+ UCHAR OutCh;
+ BOOL Kapt;
+ ObjTextType Attrib;
+};
+
+void InitProcessCharState(ProcChrSta& State, ObjTextType& AktAtr, USHORT IndexA)
+{
+ State.Attrib=AktAtr;
+ State.OutCh=0;
+ State.Index=IndexA;
+ State.ChrXP=0;
+ State.Kapt=FALSE;
+}
+
+BOOL UpcasePossible(UCHAR c)
+{
+ if ((c>='a' && c<='z') || c == 0xe4 || c == 0xf6 || c == 0xfc ) return TRUE;
+ else return FALSE;
+}
+
+UCHAR Upcase(UCHAR c)
+{
+ if ((c>=(UCHAR)'a' && c<=(UCHAR)'z')) c=(c-(UCHAR)'a')+(UCHAR)'A';
+ else if ( c == 0xe4 ) c = 0xc4;
+ else if ( c == 0xf6 ) c = 0xd6;
+ else if ( c == 0xfc ) c = 0xdc;
+ return c;
+}
+
+USHORT GetCharWidth(OutputDevice& rOut, UCHAR c)
+{
+ UCHAR c1;
+ USHORT ChrWidth;
+
+ c1 = ByteString::Convert((char)c,RTL_TEXTENCODING_IBM_437, gsl_getSystemTextEncoding() );
+ if (c==' ')
+ {
+ ChrWidth=(USHORT)rOut.GetTextWidth( String('A') );
+ if (rOut.GetFont().GetPitch()!=PITCH_FIXED) {
+ ChrWidth=MulDiv(ChrWidth,DefaultSpace,100);
+ }
+ } else {
+ // with MaxChar == 255 c cannot be greater than MaxChar
+ // assert if MaxChar is ever changed
+ OSL_ENSURE( MaxChar == 255, "MaxChar not 255" );
+ if (c>=MinChar /*&& c<=MaxChar*/)
+ {
+ ChrWidth=(USHORT)rOut.GetTextWidth(String((char)c1));
+ }
+ else
+ {
+ ChrWidth=(USHORT)rOut.GetTextWidth(String('A'));
+ }
+ }
+ return ChrWidth;
+}
+
+UCHAR ProcessChar(OutputDevice& rOut, UCHAR* TBuf, ProcChrSta& R, ObjTextType& Atr0,
+ USHORT& nChars, USHORT Rest,
+ short* Line, UCHAR* cLine)
+{
+ USHORT KernDist=0; // Wert fuer Kerning
+ USHORT ChrWidth;
+ UCHAR c;
+ UCHAR c1;
+ BOOL AbsEnd;
+
+ c=GetTextChar(TBuf,R.Index,Atr0,R.Attrib,Rest,FALSE); // versucht evtl. zu trennen, wenn Rest entsprechenden Wert besitzt
+
+ AbsEnd=(c==AbsatzEnd || c==TextEnd);
+ if (AbsEnd==FALSE) {
+ R.OutCh=ConvertTextChar(c); // von HardTrenn nach '-', ...
+ R.Kapt=(R.Attrib.Schnitt & TextKaptBit) !=0 && UpcasePossible(R.OutCh);
+ if (R.Kapt) R.OutCh=Upcase(R.OutCh);
+ SetTextContext(rOut,R.Attrib,R.Kapt,0,1,1,1,1);
+
+ if (R.Kapt) c1=Upcase(c); else c1=c;
+ ChrWidth=GetCharWidth(rOut,c1);
+
+ if (R.Attrib.ZAbst!=100) { // Spezial-Zeichenabstand ?
+ ULONG Temp;
+ Temp=ULONG(ChrWidth)*ULONG(R.Attrib.ZAbst)/100;
+ ChrWidth=USHORT(Temp);
+ }
+ nChars++;
+ if (R.ChrXP>32000) R.ChrXP=32000;
+ Line[nChars]=R.ChrXP-KernDist;
+ cLine[nChars]=c;
+ R.ChrXP+=ChrWidth-KernDist; // Position fuer den naechsten Character
+ }
+ return c;
+}
+
+void FormatLine(UCHAR* TBuf, USHORT& Index, ObjTextType& Atr0, ObjTextType& AktAtr,
+ USHORT UmbWdt, USHORT AdjWdt,
+ short* Line, USHORT& nChars,
+ double, double,
+ UCHAR* cLine, BOOL TextFit)
+{
+ VirtualDevice vOut;
+ UCHAR c,c0;
+ UCHAR ct;
+ BOOL First; // erster Char ?
+ BYTE Just = 0; // Absatzformatierung
+ BOOL Border; // Rand der Box erreicht ?
+ BOOL Border0;
+ BOOL AbsEnd; // Ende des Absatzes erreicht ?
+ ProcChrSta* R=new ProcChrSta;
+ ProcChrSta* R0=new ProcChrSta;
+ ProcChrSta* WErec=new ProcChrSta;
+ USHORT WEnChar;
+ ProcChrSta* WErec0=new ProcChrSta;
+ USHORT WEnChar0;
+ ProcChrSta* TRrec=new ProcChrSta;
+ USHORT TRnChar;
+
+ USHORT WordEndCnt; // Justieren und Trennen
+ BOOL WordEnd;
+ BOOL Trenn;
+
+ short BoxRest; // zum Quetschen und formatieren
+ USHORT i,j,k,h;
+ USHORT re,li;
+
+ vOut.SetMapMode(MapMode(MAP_10TH_MM,Point(),Fraction(1,4),Fraction(1,4)));
+
+ nChars=0;
+ SetTextContext(vOut,AktAtr,FALSE,0,1,1,1,1);
+ InitProcessCharState(*R,AktAtr,Index);
+ (*R0)=(*R); (*WErec)=(*R); WEnChar=0; c0=0; Border0=FALSE;
+ Border=FALSE; First=TRUE;
+ WordEndCnt=0;
+
+ do { // mal schauen, wieviele Worte so in die Zeile passen
+ if (Border) c=ProcessChar(vOut,TBuf,*R,Atr0,nChars,DoTrenn,Line,cLine);
+ else c=ProcessChar(vOut,TBuf,*R,Atr0,nChars,NoTrenn,Line,cLine);
+ AbsEnd=(c==AbsatzEnd || c==TextEnd);
+ //if not AbsEnd then
+ {
+ if (First) {
+ Just=R->Attrib.Justify & 0x0F; // Absatzformat steht wenn, dann am Anfang
+ }
+ Border=R->ChrXP>UmbWdt;
+ WordEnd=(AbsEnd || (c==' ')) && (c0!=' ') && (c0!=0);
+ Trenn=c=='-';
+ if (WordEnd && !Border0) {
+ WordEndCnt++;
+ (*WErec)=(*R0);
+ WEnChar=nChars-1;
+ }
+ if (Trenn && !Border) {
+ WordEndCnt++;
+ (*WErec)=(*R);
+ WEnChar=nChars;
+ }
+ }
+ (*R0)=(*R); c0=c;
+ Border0=Border;
+ First=FALSE;
+ AbsEnd=AbsEnd || (nChars>=MaxLineChars);
+ } while (!(AbsEnd || (Border && ((WordEndCnt>0) || WordEnd || Trenn))));
+
+ if (Border) { // Trennen und Quetschen
+ (*WErec0)=(*WErec); WEnChar0=WEnChar;
+ AbsEnd=FALSE; c0=0;
+ (*R)=(*WErec); nChars=WEnChar;
+ (*TRrec)=(*R); TRnChar=nChars;
+ Border0=FALSE; Border=FALSE;
+ do { // erst mal gucken wieviele Silben noch reinpassen
+ ct=ProcessChar(vOut,TBuf,*TRrec,Atr0,TRnChar,DoTrenn,Line,cLine);
+ c=ProcessChar(vOut,TBuf,*R,Atr0,nChars,NoTrenn,Line,cLine);
+ AbsEnd=(ct==AbsatzEnd) || (ct==TextEnd) || (nChars>=MaxLineChars);
+
+ Border=TRrec->ChrXP>UmbWdt;
+ WordEnd=AbsEnd || ((AbsEnd || (c==' ')) && (c0!=' ') && (c0!=0));
+ Trenn=ct=='-';
+ if (WordEnd && (!Border0 || (WordEndCnt==0))) {
+ WordEndCnt++;
+ (*WErec)=(*R0);
+ if (AbsEnd) WEnChar=nChars; else WEnChar=nChars-1;
+ (*TRrec)=(*R); TRnChar=nChars; // zum weitersuchen
+ }
+ if (Trenn && (!Border || (WordEndCnt==0))) {
+ WordEndCnt++; // merken, dass man hier trennen kann
+ (*WErec)=(*TRrec);
+ WEnChar=TRnChar;
+ (*TRrec)=(*R); TRnChar=nChars; // zum weitersuchen
+ }
+ (*R0)=(*R); c0=c;
+ Border0=Border;
+ Border=R->ChrXP>UmbWdt;
+ } while (!(AbsEnd || (Border && ((WordEndCnt>0) || WordEnd || Trenn))));
+
+ while (WErec0->Index<WErec->Index) { // damit Line[] auch garantiert stimmt }
+ c=ProcessChar(vOut,TBuf,*WErec0,Atr0,WEnChar0,WEnChar-WEnChar0-1,Line,cLine);
+ }
+
+ (*R)=(*WErec); nChars=WEnChar;
+
+ if (UmbWdt>=R->ChrXP) {
+ BoxRest=UmbWdt-R->ChrXP;
+ } else { // Zusammenquetschen
+ BoxRest=R->ChrXP-UmbWdt; // um soviel muss gequetscht werden
+ for (i=2;i<=nChars;i++) { // 1. CharPosition bleibt !
+ Line[i]-=(i-1)*(BoxRest) /(nChars-1);
+ }
+ R->ChrXP=UmbWdt;
+ Line[nChars+1]=UmbWdt;
+ }
+ }
+
+ if (!AbsEnd) {
+ do { // Leerzeichen weglesen
+ (*WErec)=(*R);
+ c=GetTextChar(TBuf,R->Index,Atr0,R->Attrib,NoTrenn,FALSE);
+ nChars++;
+ Line[nChars]=R->ChrXP;
+ cLine[nChars]=c;
+ } while (c==' ');
+ if (c!=' ' && c!=AbsatzEnd && c!=TextEnd) {
+ nChars--;
+ (*R)=(*WErec);
+ }
+ }
+
+ if (AbsEnd && nChars<MaxLineChars) { // Ausrichten, statt Blocksatz aber linksbuendig
+ if (Just==3) Just=0;
+ nChars++; Line[nChars]=R->ChrXP; // Damit AbsatzEnde auch weggelesen wird
+ Line[nChars+1]=R->ChrXP; // denn die Breite von CR oder #0 ist nun mal sehr klein
+ if (TBuf[R->Index-1]!=AbsatzEnd && TBuf[R->Index-1]!=TextEnd) {
+ c=GetTextChar(TBuf,R->Index,Atr0,R->Attrib,NoTrenn,FALSE); // Kleine Korrektur. Notig, wenn nur 1 Wort in
+ }
+ }
+
+ BoxRest=AdjWdt-R->ChrXP;
+ if (TextFit) Just=THJustLeft;
+
+ switch (Just) {
+ case THJustLeft: break; // Links
+ case THJustCenter: {
+ BoxRest=BoxRest /2; // Mitte
+ for (i=1;i<=nChars;i++) Line[i]=Line[i]+BoxRest;
+ } break;
+ case THJustRight: { // Rechts
+ for (i=1;i<=nChars;i++) Line[i]=Line[i]+BoxRest;
+ } break;
+ case THJustDrvOut:
+ case THJustBlock: { // Block und Austreibend
+ re=nChars;
+ if (Just==THJustDrvOut) re--;
+ while (re>=1 && (cLine[re]==' ' || cLine[re]==TextEnd || cLine[re]==AbsatzEnd)) re--;
+ li=1;
+ while (li<=re && (cLine[li]==' ' || cLine[li]==TextEnd || cLine[li]==AbsatzEnd)) li++;
+ if (Just==THJustDrvOut) BoxRest=AdjWdt-Line[re+1];
+
+ j=0; // Anzahl der Spaces ermitteln
+ for (i=li;i<=re;i++) {
+ if (cLine[i]==' ') {
+ j++;
+ }
+ }
+
+ if (j==0) { // nur 1 Wort ? -> Strecken !
+ for (i=li+1;i<=re;i++) { // von links nach rechts
+ Line[i]=Line[i]+MulDiv(i-li,BoxRest,re-li+1-1);
+ }
+ } else {
+ k=0; h=0;
+ for (i=li;i<=re;i++) { // j Spaces aufbohren !
+ if (cLine[i]==' ') { // Space gefunden !
+ k++;
+ h=MulDiv(k,BoxRest,j);
+ }
+ Line[i]=Line[i]+h;
+ }
+ }
+ for (i=re+1;i<=nChars;i++) Line[i]=Line[i]+BoxRest; // und den Rest anpassen
+ Line[nChars+1]=AdjWdt;
+ } break;
+ case THJustLocked: { //Gesperrt
+ re=nChars-1;
+ while (re>=1 && (cLine[re]==' ' || cLine[re]==TextEnd || cLine[re]==AbsatzEnd)) re--;
+ li=1;
+ while (li<=re && (cLine[li]==' ' || cLine[li]==TextEnd || cLine[li]==AbsatzEnd)) li++;
+ BoxRest=AdjWdt-Line[re+1];
+ for (i=li+1;i<=re;i++) { // Strecken von links nach rechts
+ Line[i]=Line[i]+MulDiv(i-li,BoxRest,re-li+1-1);
+ }
+ for (i=re+1;i<=nChars;i++) Line[i]=Line[i]+BoxRest; // und den Rest anpassen
+ Line[nChars+1]=AdjWdt;
+ } break;
+ }
+ Index=R->Index;
+ AktAtr=R->Attrib;
+ delete R;
+ delete R0;
+ delete WErec;
+ delete WErec0;
+ delete TRrec;
+}
+
+
+
+// End of Absatz.Pas
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+// DrawText.Pas
+
+void DrawChar(OutputDevice& rOut, UCHAR c, ObjTextType T, PointType Pos, USHORT DrehWink,
+ USHORT FitXMul, USHORT FitXDiv, USHORT FitYMul, USHORT FitYDiv)
+{
+ SetTextContext(rOut,T,UpcasePossible(c),DrehWink,FitXMul,FitXDiv,FitYMul,FitYDiv);
+ if ((T.Schnitt & TextKaptBit)!=0 && UpcasePossible(c)) c=Upcase(c);
+ String s( (char)c, RTL_TEXTENCODING_IBM_437 );
+ rOut.DrawText( Point( Pos.x, Pos.y ), s );
+}
+
+/*************************************************************************
+|*
+|* TextType::Draw()
+|*
+|* Beschreibung
+|* Ersterstellung JOE 09.08.93
+|* Letzte Aenderung JOE 09.08.93
+|*
+*************************************************************************/
+void TextType::Draw(OutputDevice& rOut)
+{
+ if ((Flags & TextOutlBit)!=0) return; // Sourcetext fuer Outliner !!
+
+ ObjTextType T1,T2;
+ USHORT Index1;
+ USHORT Index2;
+ UCHAR c = TextEnd;
+ USHORT l; // Anzahl der Zeichen in der Zeile
+ USHORT i;
+ short yPos0;
+ short xPos;
+ short yPos;
+ USHORT LF;
+ USHORT MaxGrad;
+ short xSize;
+ short xSAdj;
+ short ySize;
+ double sn,cs;
+ USHORT TopToBase;
+ BOOL Ende = 0;
+ USHORT lc;
+ BOOL LineFit; // FitSize.x=0? oder Flags -> jede Zeile stretchen
+ BOOL TextFit;
+ short* xLine;
+ UCHAR* cLine; // Buffer fuer FormatLine
+ USHORT FitXMul;
+ USHORT FitXDiv;
+ USHORT FitYMul;
+ USHORT FitYDiv;
+ BOOL Fehler;
+ UCHAR* Buf=Buffer; // Zeiger auf die Buchstaben
+
+ pSgfFonts->ReadList();
+ xLine=new short[ChrXPosArrSize];
+ cLine=new UCHAR[CharLineSize];
+
+ TextFit=(Flags & TextFitBits)!=0;
+ LineFit=FALSE;
+ LineFit=((Flags & TextFitZBit)!=0);
+ if (TextFit && FitSize.x==0) LineFit=TRUE;
+
+ if (DrehWink==0) {
+ sn=0.0;
+ cs=1.0;
+ } else {
+ sn=sin(double(DrehWink)*3.14159265359/18000);
+ cs=cos(double(DrehWink)*3.14159265359/18000);
+ }
+
+ T1=T; Index1=0; yPos=0; xPos=0;
+ if (TextFit) {
+ ySize=Pos2.y-Pos1.y;
+ xSize=32000 /2; // Umbruch
+ xSAdj=Pos2.x-Pos1.x; // zum Ausrichten bei Zentriert/Blocksatz
+ //if (xSize<=0) { xSize=32000 /2; LineFit=TRUE; }
+ FitXMul=sal::static_int_cast< USHORT >(abs(Pos2.x-Pos1.x)); FitXDiv=FitSize.x; if (FitXDiv==0) FitXDiv=1;
+ FitYMul=sal::static_int_cast< USHORT >(abs(Pos2.y-Pos1.y)); FitYDiv=FitSize.y; if (FitYDiv==0) FitYDiv=1;
+ } else {
+ xSize=Pos2.x-Pos1.x;
+ xSAdj=xSize;
+ ySize=Pos2.y-Pos1.y;
+ FitXMul=1; FitXDiv=1;
+ FitYMul=1; FitYDiv=1;
+ }
+ if (xSize<0) xSize=0;
+ if (xSAdj<0) xSAdj=0;
+
+ do {
+ T2=T1; Index2=Index1;
+ FormatLine(Buf,Index2,T,T2,xSize,xSAdj,xLine,l,sn,cs,cLine,LineFit);
+ Fehler=(Index2==Index1);
+ if (!Fehler) {
+ lc=GetLineFeed(Buf,Index1,T,T1,l,LF,MaxGrad);
+ if (TextFit) {
+ if (LineFit) FitXDiv=xLine[lc+1];
+ if (FitXDiv>0) {
+ long Temp;
+ for (i=1;i<=l+1;i++) {
+ Temp=long(xLine[i])*long(FitXMul) /long(FitXDiv);
+ xLine[i]=short(Temp);
+ }
+ LF=MulDiv(LF,FitYMul,FitYDiv);
+ MaxGrad=MulDiv(MaxGrad,FitYMul,FitYDiv);
+ } else {
+ FitXDiv=1; // 0 gibts nicht
+ }
+ }
+ yPos0=yPos;
+ TopToBase=GetTopToBaseLine(MaxGrad);
+ yPos=yPos+TopToBase;
+ Ende=(yPos0+short(MulDiv(MaxGrad,CharTopToBtm,100))>ySize) && !TextFit;
+ if (!Ende) {
+ T2=T1; Index2=Index1;
+ i=1;
+ while (i<=l) {
+ c=GetTextCharConv(Buf,Index2,T,T2,l-i,FALSE);
+ long xp1,yp1; // wegen Overflowgefahr
+ PointType Pos;
+ xp1=long(Pos1.x)+xPos+long(xLine[i]);
+ yp1=long(Pos1.y)+yPos;
+ if (xp1>32000) xp1=32000; if (xp1<-12000) xp1=-12000;
+ if (yp1>32000) yp1=32000; if (yp1<-12000) yp1=-12000;
+ Pos.x=short(xp1);
+ Pos.y=short(yp1);
+
+ if (DrehWink!=0) RotatePoint(Pos,Pos1.x,Pos1.y,sn,cs);
+ DrawChar(rOut,c,T2,Pos,DrehWink,FitXMul,FitXDiv,FitYMul,FitYDiv);
+ i++;
+ } // while i<=l
+ yPos=yPos0+LF;
+ T1=T2; Index1=Index2; // Fuer die naechste Zeile
+ } // if ObjMin.y+yPos<=Obj_Max.y
+ } // if !Fehler
+ } while (c!=TextEnd && !Ende && !Fehler);
+ delete[] cLine;
+ delete[] xLine;
+}
+
+// End of DrawText.Pas
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+
+// nicht mehr benoetigt, da der Pointer nun extra gefuehrt wird
+// (DEC Alpha hat naemlich 64Bit-Pointer!)
+//UCHAR* TextType::GetBufPtr()
+//{
+// ULONG Temp;
+// Temp=ULONG(BufLo)+0x00010000*ULONG(BufHi);
+// return (UCHAR*)Temp;
+//}
+//
+//void TextType::SetBufPtr(UCHAR* Ptr)
+//{
+// ULONG Temp=(ULONG)Ptr;
+// BufLo=USHORT(Temp & 0x0000FFFF);
+// BufHi=USHORT((Temp & 0xFFFF0000)>>16);
+//}
+
+UINT32 ObjTextType::GetFont()
+{
+ return ULONG(FontLo)+0x00010000*ULONG(FontHi);
+}
+
+void ObjTextType::SetFont(UINT32 FontID)
+{
+ FontLo=USHORT(FontID & 0x0000FFFF);
+ FontHi=USHORT((FontID & 0xFFFF0000)>>16);
+}
+
+
+/////////////////////////////////////////////////////////////////////////////////
+// SGF.Ini lesen ////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+SgfFontOne::SgfFontOne()
+{
+ Next=NULL;
+ IFID=0;
+ Bold=FALSE;
+ Ital=FALSE;
+ Sans=FALSE;
+ Serf=FALSE;
+ Fixd=FALSE;
+ SVFamil=FAMILY_DONTKNOW;
+ SVChSet=RTL_TEXTENCODING_DONTKNOW;
+ SVWidth=40;
+}
+
+void SgfFontOne::ReadOne( ByteString& ID, ByteString& Dsc )
+{
+ USHORT i,j,n;
+ ByteString s;
+
+ if ( Dsc.Len() < 4 || ( Dsc.GetChar( 0 ) != '(' ) )
+ return;
+ i=1; // Erster Buchstabe des IF-Fontnamen. Davor ist eine '('
+ while ( i < Dsc.Len() && ( Dsc.GetChar( i ) !=')' ) )
+ i++;
+ Dsc.Erase(0,i+1); // IF-Fontname loeschen inkl. ()
+
+ if ( Dsc.Len() < 2 || ( Dsc.GetChar( Dsc.Len() - 1 ) !=')' ) )
+ return;
+ i=Dsc.Len()-2; // hier ist die ')' des SV-Fontnames
+ j=0;
+ while ( i > 0 && ( Dsc.GetChar( i ) != '(' ) )
+ {
+ i--;
+ j++;
+ }
+ SVFName=String(Dsc,i+1,j); // SV-Fontname rausholen
+ Dsc.Erase(i,j);
+
+ IFID = (UINT32)ID.ToInt32();
+ n=Dsc.GetTokenCount(' ');
+ for (i=0;i<n;i++)
+ {
+ s = Dsc.GetToken( i,' ' );
+ if ( s.Len() )
+ {
+ s.ToUpperAscii();
+ if ( s.CompareTo( "BOLD", 4 ) == COMPARE_EQUAL ) Bold=TRUE;
+ else if ( s.CompareTo( "ITAL", 4 ) == COMPARE_EQUAL ) Ital=TRUE;
+ else if ( s.CompareTo( "SERF", 4 ) == COMPARE_EQUAL ) Serf=TRUE;
+ else if ( s.CompareTo( "SANS", 4 ) == COMPARE_EQUAL ) Sans=TRUE;
+ else if ( s.CompareTo( "FIXD", 4 ) == COMPARE_EQUAL ) Fixd=TRUE;
+ else if ( s.CompareTo( "ROMAN", 5 ) == COMPARE_EQUAL ) SVFamil=FAMILY_ROMAN;
+ else if ( s.CompareTo( "SWISS", 5 ) == COMPARE_EQUAL ) SVFamil=FAMILY_SWISS;
+ else if ( s.CompareTo( "MODERN", 6 ) == COMPARE_EQUAL ) SVFamil=FAMILY_MODERN;
+ else if ( s.CompareTo( "SCRIPT", 6 ) == COMPARE_EQUAL ) SVFamil=FAMILY_SCRIPT;
+ else if ( s.CompareTo( "DECORA", 6 ) == COMPARE_EQUAL ) SVFamil=FAMILY_DECORATIVE;
+ else if ( s.CompareTo( "ANSI", 4 ) == COMPARE_EQUAL ) SVChSet=RTL_TEXTENCODING_MS_1252;
+ else if ( s.CompareTo( "IBMPC", 5 ) == COMPARE_EQUAL ) SVChSet=RTL_TEXTENCODING_IBM_850;
+ else if ( s.CompareTo( "MAC", 3 ) == COMPARE_EQUAL ) SVChSet=RTL_TEXTENCODING_APPLE_ROMAN;
+ else if ( s.CompareTo( "SYMBOL", 6 ) == COMPARE_EQUAL ) SVChSet=RTL_TEXTENCODING_SYMBOL;
+ else if ( s.CompareTo( "SYSTEM", 6 ) == COMPARE_EQUAL ) SVChSet = gsl_getSystemTextEncoding();
+ else if ( s.IsNumericAscii() ) SVWidth=sal::static_int_cast< USHORT >(s.ToInt32());
+ }
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+
+SgfFontLst::SgfFontLst()
+{
+ pList=NULL;
+ Last=NULL;
+ LastID=0;
+ LastLn=NULL;
+ Tried=FALSE;
+}
+
+SgfFontLst::~SgfFontLst()
+{
+ RausList();
+}
+
+void SgfFontLst::RausList()
+{
+ SgfFontOne* P;
+ SgfFontOne* P1;
+ P=pList;
+ while (P!=NULL) {
+ P1=P->Next;
+ delete P;
+ P=P1;
+ }
+ pList=NULL;
+ Last=NULL;
+ Tried=FALSE;
+ LastID=0;
+ LastLn=NULL;
+}
+
+void SgfFontLst::AssignFN(const String& rFName)
+{ FNam=rFName; }
+
+void SgfFontLst::ReadList()
+{
+ if (!Tried) {
+ Tried=TRUE;
+ LastID=0;
+ LastLn=NULL;
+ SgfFontOne* P,P1;
+ Config aCfg(FNam);
+ aCfg.SetGroup("SGV Fonts fuer StarView");
+ USHORT Anz=aCfg.GetKeyCount();
+ USHORT i;
+ ByteString FID,Dsc;
+
+ for (i=0;i<Anz;i++)
+ {
+ FID = aCfg.GetKeyName( i );
+ FID = FID.EraseAllChars(); // Leerzeichen weg
+ Dsc = aCfg.ReadKey( i );
+ if ( FID.IsNumericAscii() )
+ {
+ P=new SgfFontOne; // neuer Eintrag
+ if (Last!=NULL) Last->Next=P; else pList=P; Last=P; // einklinken
+ P->ReadOne(FID,Dsc); // und Zeile interpretieren
+ }
+ }
+ }
+}
+
+SgfFontOne* SgfFontLst::GetFontDesc(UINT32 ID)
+{
+ if (ID!=LastID) {
+ SgfFontOne* P;
+ P=pList;
+ while (P!=NULL && P->IFID!=ID) P=P->Next;
+ LastID=ID;
+ LastLn=P;
+ }
+ return LastLn;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/igif/decode.hxx b/binfilter/bf_svtools/source/filter.vcl/igif/decode.hxx
new file mode 100644
index 000000000000..d31bc04d978a
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/igif/decode.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 _DECODE_HXX
+#define _DECODE_HXX
+
+#include <vcl/bmpacc.hxx>
+
+namespace binfilter
+{
+
+struct GIFLZWTableEntry;
+
+class GIFLZWDecompressor
+{
+ GIFLZWTableEntry* pTable;
+ HPBYTE pOutBuf;
+ HPBYTE pOutBufData;
+ HPBYTE pBlockBuf;
+ ULONG nInputBitsBuf;
+ USHORT nTableSize;
+ USHORT nClearCode;
+ USHORT nEOICode;
+ USHORT nCodeSize;
+ USHORT nOldCode;
+ USHORT nOutBufDataLen;
+ USHORT nInputBitsBufSize;
+ BOOL bEOIFound;
+ BYTE nDataSize;
+ BYTE nBlockBufSize;
+ BYTE nBlockBufPos;
+
+ void AddToTable(USHORT nPrevCode, USHORT nCodeFirstData);
+ BOOL ProcessOneCode();
+
+
+public:
+
+ GIFLZWDecompressor( BYTE cDataSize );
+ ~GIFLZWDecompressor();
+
+ HPBYTE DecompressBlock( HPBYTE pSrc, BYTE cBufSize, ULONG& rCount, BOOL& rEOI );
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/igif/makefile.mk b/binfilter/bf_svtools/source/filter.vcl/igif/makefile.mk
new file mode 100644
index 000000000000..16d0176adcb2
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/igif/makefile.mk
@@ -0,0 +1,44 @@
+#*************************************************************************
+#
+# DO NOT ALTER 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=binfilter
+TARGET=igif
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= $(SLO)$/svt_gifread.obj \
+ $(SLO)$/svt_decode.obj
+
+.INCLUDE : target.mk
+
diff --git a/binfilter/bf_svtools/source/filter.vcl/igif/svt_decode.cxx b/binfilter/bf_svtools/source/filter.vcl/igif/svt_decode.cxx
new file mode 100644
index 000000000000..73a64530ba25
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/igif/svt_decode.cxx
@@ -0,0 +1,221 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 "decode.hxx"
+
+namespace binfilter
+{
+
+// ------------------------------------------------------------------------
+
+struct GIFLZWTableEntry
+{
+ GIFLZWTableEntry* pPrev;
+ GIFLZWTableEntry* pFirst;
+ BYTE nData;
+};
+
+// ------------------------------------------------------------------------
+
+GIFLZWDecompressor::GIFLZWDecompressor( BYTE cDataSize ) :
+ nInputBitsBuf ( 0 ),
+ nOutBufDataLen ( 0 ),
+ nInputBitsBufSize ( 0 ),
+ bEOIFound ( FALSE ),
+ nDataSize ( cDataSize )
+{
+ pTable = new GIFLZWTableEntry[ 4096 ];
+ pOutBuf = new BYTE[ 4096 ];
+
+ nClearCode = 1 << nDataSize;
+ nEOICode = nClearCode + 1;
+ nTableSize = nEOICode + 1;
+ nCodeSize = nDataSize + 1;
+ nOldCode = 0xffff;
+ pOutBufData = pOutBuf + 4096;
+
+ for( USHORT i = 0; i < nTableSize; i++ )
+ {
+ pTable[i].pPrev = NULL;
+ pTable[i].pFirst = pTable + i;
+ pTable[i].nData = (BYTE) i;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+GIFLZWDecompressor::~GIFLZWDecompressor()
+{
+ delete[] pOutBuf;
+ delete[] pTable;
+}
+
+// ------------------------------------------------------------------------
+
+HPBYTE GIFLZWDecompressor::DecompressBlock( HPBYTE pSrc, BYTE cBufSize,
+ ULONG& rCount, BOOL& rEOI )
+{
+ ULONG nTargetSize = 4096;
+ ULONG nCount = 0;
+ HPBYTE pTarget = (HPBYTE) rtl_allocateMemory( nTargetSize );
+ HPBYTE pTmpTarget = pTarget;
+
+ nBlockBufSize = cBufSize;
+ nBlockBufPos = 0;
+ pBlockBuf = pSrc;
+
+ while( ProcessOneCode() )
+ {
+ nCount += nOutBufDataLen;
+
+ if( nCount > nTargetSize )
+ {
+ ULONG nNewSize = nTargetSize << 1;
+ ULONG nOffset = pTmpTarget - pTarget;
+ HPBYTE pTmp = (HPBYTE) rtl_allocateMemory( nNewSize );
+
+ memcpy( pTmp, pTarget, nTargetSize );
+ rtl_freeMemory( pTarget );
+
+ nTargetSize = nNewSize;
+ pTmpTarget = ( pTarget = pTmp ) + nOffset;
+ }
+
+ memcpy( pTmpTarget, pOutBufData, nOutBufDataLen );
+ pTmpTarget += nOutBufDataLen;
+ pOutBufData += nOutBufDataLen;
+ nOutBufDataLen = 0;
+
+ if ( bEOIFound )
+ break;
+ }
+
+ rCount = nCount;
+ rEOI = bEOIFound;
+
+ return pTarget;
+}
+
+// ------------------------------------------------------------------------
+
+void GIFLZWDecompressor::AddToTable( USHORT nPrevCode, USHORT nCodeFirstData )
+{
+ GIFLZWTableEntry* pE;
+
+ if( nTableSize < 4096 )
+ {
+ pE = pTable + nTableSize;
+ pE->pPrev = pTable + nPrevCode;
+ pE->pFirst = pE->pPrev->pFirst;
+ pE->nData = pTable[ nCodeFirstData ].pFirst->nData;
+ nTableSize++;
+
+ if ( ( nTableSize == (USHORT) (1 << nCodeSize) ) && ( nTableSize < 4096 ) )
+ nCodeSize++;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GIFLZWDecompressor::ProcessOneCode()
+{
+ GIFLZWTableEntry* pE;
+ USHORT nCode;
+ BOOL bRet = FALSE;
+ BOOL bEndOfBlock = FALSE;
+
+ while( nInputBitsBufSize < nCodeSize )
+ {
+ if( nBlockBufPos >= nBlockBufSize )
+ {
+ bEndOfBlock = TRUE;
+ break;
+ }
+
+ nInputBitsBuf |= ( (ULONG) pBlockBuf[ nBlockBufPos++ ] ) << nInputBitsBufSize;
+ nInputBitsBufSize += 8;
+ }
+
+ if ( !bEndOfBlock )
+ {
+ // Einen Code aus dem Eingabe-Buffer holen:
+ nCode = sal::static_int_cast< USHORT >(
+ ( (USHORT) nInputBitsBuf ) & ( ~( 0xffff << nCodeSize ) ));
+ nInputBitsBuf >>= nCodeSize;
+ nInputBitsBufSize = nInputBitsBufSize - nCodeSize;
+
+ if ( nCode < nClearCode )
+ {
+ if ( nOldCode != 0xffff )
+ AddToTable( nOldCode, nCode );
+ }
+ else if ( ( nCode > nEOICode ) && ( nCode <= nTableSize ) )
+ {
+ if ( nCode == nTableSize )
+ AddToTable( nOldCode, nOldCode );
+ else
+ AddToTable( nOldCode, nCode );
+ }
+ else
+ {
+ if ( nCode == nClearCode )
+ {
+ nTableSize = nEOICode + 1;
+ nCodeSize = nDataSize + 1;
+ nOldCode = 0xffff;
+ nOutBufDataLen = 0;
+ }
+ else
+ bEOIFound = TRUE;
+
+ return TRUE;
+ }
+
+ nOldCode = nCode;
+
+ // Zeichen(/-folge) des Codes nCode in den Ausgabe-Buffer schreiben:
+ pE = pTable + nCode;
+ do
+ {
+ nOutBufDataLen++;
+ *(--pOutBufData) = pE->nData;
+ pE = pE->pPrev;
+ }
+ while( pE );
+
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/igif/svt_gifread.cxx b/binfilter/bf_svtools/source/filter.vcl/igif/svt_gifread.cxx
new file mode 100644
index 000000000000..765d0dc6a992
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/igif/svt_gifread.cxx
@@ -0,0 +1,866 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+#define _GIFPRIVATE
+
+#include "decode.hxx"
+#include "gifread.hxx"
+
+namespace binfilter
+{
+
+// -----------
+// - Defines -
+// -----------
+
+#define NO_PENDING( rStm ) ( ( rStm ).GetError() != ERRCODE_IO_PENDING )
+
+// -------------
+// - GIFReader -
+// -------------
+
+GIFReader::GIFReader( SvStream& rStm ) :
+ aGPalette ( 256 ),
+ aLPalette ( 256 ),
+ rIStm ( rStm ),
+ pAcc8 ( NULL ),
+ pAcc1 ( NULL ),
+ nLastPos ( rStm.Tell() ),
+ nLogWidth100 ( 0UL ),
+ nLogHeight100 ( 0UL ),
+ nLoops ( 1 ),
+ eActAction ( GLOBAL_HEADER_READING ),
+ bGCTransparent ( FALSE ),
+ bImGraphicReady ( FALSE )
+{
+ maUpperName = UniString::CreateFromAscii( "SVIGIF", 6 );
+ pSrcBuf = new BYTE[ 256 ];
+ ClearImageExtensions();
+}
+
+// ------------------------------------------------------------------------
+
+GIFReader::~GIFReader()
+{
+ aImGraphic.SetContext( NULL );
+
+ if( pAcc1 )
+ aBmp1.ReleaseAccess( pAcc1 );
+
+ if( pAcc8 )
+ aBmp8.ReleaseAccess( pAcc8 );
+
+ delete[] pSrcBuf;
+}
+
+// ------------------------------------------------------------------------
+
+void GIFReader::ClearImageExtensions()
+{
+ nGCDisposalMethod = 0;
+ bGCTransparent = FALSE;
+ nTimer = 0;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GIFReader::CreateBitmaps( long nWidth, long nHeight, BitmapPalette* pPal,
+ BOOL bWatchForBackgroundColor )
+{
+ const Size aSize( nWidth, nHeight );
+
+ if( bGCTransparent )
+ {
+ const Color aWhite( COL_WHITE );
+
+ aBmp1 = Bitmap( aSize, 1 );
+
+ if( !aAnimation.Count() )
+ aBmp1.Erase( aWhite );
+
+ pAcc1 = aBmp1.AcquireWriteAccess();
+
+ if( pAcc1 )
+ {
+ cTransIndex1 = (BYTE) pAcc1->GetBestPaletteIndex( aWhite );
+ cNonTransIndex1 = cTransIndex1 ? 0 : 1;
+ }
+ else
+ bStatus = FALSE;
+ }
+
+ if( bStatus )
+ {
+ aBmp8 = Bitmap( aSize, 8, pPal );
+
+ if( !!aBmp8 && bWatchForBackgroundColor && aAnimation.Count() )
+ aBmp8.Erase( (*pPal)[ nBackgroundColor ] );
+ else
+ aBmp8.Erase( Color( COL_WHITE ) );
+
+ pAcc8 = aBmp8.AcquireWriteAccess();
+ bStatus = ( pAcc8 != NULL );
+ }
+
+ return bStatus;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GIFReader::ReadGlobalHeader()
+{
+ char pBuf[ 7 ];
+ BYTE nRF;
+ BYTE nAspect;
+ BOOL bRet = FALSE;
+
+ rIStm.Read( pBuf, 6 );
+ if( NO_PENDING( rIStm ) )
+ {
+ pBuf[ 6 ] = 0;
+ if( !strcmp( pBuf, "GIF87a" ) || !strcmp( pBuf, "GIF89a" ) )
+ {
+ rIStm.Read( pBuf, 7 );
+ if( NO_PENDING( rIStm ) )
+ {
+ SvMemoryStream aMemStm;
+
+ aMemStm.SetBuffer( pBuf, 7, FALSE, 7 );
+ aMemStm >> nGlobalWidth;
+ aMemStm >> nGlobalHeight;
+ aMemStm >> nRF;
+ aMemStm >> nBackgroundColor;
+ aMemStm >> nAspect;
+
+ bGlobalPalette = (BOOL) ( nRF & 0x80 );
+
+ if( bGlobalPalette )
+ ReadPaletteEntries( &aGPalette, 1 << ( ( nRF & 7 ) + 1 ) );
+ else
+ nBackgroundColor = 0;
+
+ if( NO_PENDING( rIStm ) )
+ bRet = TRUE;
+ }
+ }
+ else
+ bStatus = FALSE;
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+void GIFReader::ReadPaletteEntries( BitmapPalette* pPal, ULONG nCount )
+{
+ const ULONG nLen = 3UL * nCount;
+ BYTE* pBuf = new BYTE[ nLen ];
+
+ rIStm.Read( pBuf, nLen );
+ if( NO_PENDING( rIStm ) )
+ {
+ BYTE* pTmp = pBuf;
+
+ for( ULONG i = 0UL; i < nCount; )
+ {
+ BitmapColor& rColor = (*pPal)[ (USHORT) i++ ];
+
+ rColor.SetRed( *pTmp++ );
+ rColor.SetGreen( *pTmp++ );
+ rColor.SetBlue( *pTmp++ );
+ }
+
+ // nach Moeglichkeit noch einige Standardfarben unterbringen
+ if( nCount < 256UL )
+ {
+ (*pPal)[ 255UL ] = Color( COL_WHITE );
+
+ if( nCount < 255UL )
+ (*pPal)[ 254UL ] = Color( COL_BLACK );
+ }
+ }
+
+ delete[] pBuf;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GIFReader::ReadExtension()
+{
+ BYTE cFunction;
+ BYTE cSize;
+ BYTE cByte;
+ BOOL bRet = FALSE;
+ BOOL bOverreadDataBlocks = FALSE;
+
+ // Extension-Label
+ rIStm >> cFunction;
+ if( NO_PENDING( rIStm ) )
+ {
+ // Block-Laenge
+ rIStm >> cSize;
+
+ switch( cFunction )
+ {
+ // 'Graphic Control Extension'
+ case( 0xf9 ) :
+ {
+ BYTE cFlags;
+
+ rIStm >> cFlags;
+ rIStm >> nTimer;
+ rIStm >> nGCTransparentIndex;
+ rIStm >> cByte;
+
+ if ( NO_PENDING( rIStm ) )
+ {
+ nGCDisposalMethod = ( cFlags >> 2) & 7;
+ bGCTransparent = ( cFlags & 1 ) ? TRUE : FALSE;
+ bStatus = ( cSize == 4 ) && ( cByte == 0 );
+ bRet = TRUE;
+ }
+ }
+ break;
+
+ // Application-Extension
+ case ( 0xff ) :
+ {
+ if ( NO_PENDING( rIStm ) )
+ {
+ // default diese Extension ueberlesen
+ bOverreadDataBlocks = TRUE;
+
+ // Appl.-Extension hat Laenge 11
+ if ( cSize == 0x0b )
+ {
+ ByteString aAppId;
+ ByteString aAppCode;
+
+ rIStm.Read( aAppId.AllocBuffer( 8 ), 8 );
+ rIStm.Read( aAppCode.AllocBuffer( 3 ), 3 );
+ rIStm >> cSize;
+
+ // NetScape-Extension
+ if( aAppId == "NETSCAPE" && aAppCode == "2.0" && cSize == 3 )
+ {
+ rIStm >> cByte;
+
+ // Loop-Extension
+ if ( cByte == 0x01 )
+ {
+ rIStm >> cByte;
+ nLoops = cByte;
+ rIStm >> cByte;
+ nLoops |= ( (USHORT) cByte << 8 );
+ rIStm >> cByte;
+
+ bStatus = ( cByte == 0 );
+ bRet = NO_PENDING( rIStm );
+ bOverreadDataBlocks = FALSE;
+
+ // Netscape interpretiert den LoopCount
+ // als reine Anzahl der _Wiederholungen_;
+ // bei uns ist es die Gesamtanzahl der
+ // Durchlaeufe
+ if( nLoops )
+ nLoops++;
+ }
+ else
+ rIStm.SeekRel( -1 );
+ }
+ else if ( aAppId == "STARDIV " && aAppCode == "5.0" && cSize == 9 )
+ {
+ rIStm >> cByte;
+
+ // Loop-Extension
+ if ( cByte == 0x01 )
+ {
+ rIStm >> nLogWidth100 >> nLogHeight100;
+ rIStm >> cByte;
+ bStatus = ( cByte == 0 );
+ bRet = NO_PENDING( rIStm );
+ bOverreadDataBlocks = FALSE;
+ }
+ else
+ rIStm.SeekRel( -1 );
+ }
+
+ }
+ }
+ }
+ break;
+
+ // alles andere ueberlesen
+ default:
+ bOverreadDataBlocks = TRUE;
+ break;
+ }
+
+ // Sub-Blocks ueberlesen
+ if ( bOverreadDataBlocks )
+ {
+ bRet = TRUE;
+ while( cSize && bStatus && !rIStm.IsEof() )
+ {
+ USHORT nCount = (USHORT) cSize + 1;
+ char* pBuffer = new char[ nCount ];
+
+ bRet = FALSE;
+ rIStm.Read( pBuffer, nCount );
+ if( NO_PENDING( rIStm ) )
+ {
+ cSize = (BYTE) pBuffer[ cSize ];
+ bRet = TRUE;
+ }
+ else
+ cSize = 0;
+
+ delete[] pBuffer;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GIFReader::ReadLocalHeader()
+{
+ BYTE pBuf[ 9 ];
+ BOOL bRet = FALSE;
+
+ rIStm.Read( pBuf, 9 );
+ if( NO_PENDING( rIStm ) )
+ {
+ SvMemoryStream aMemStm;
+ BitmapPalette* pPal;
+ BYTE nFlags;
+
+ aMemStm.SetBuffer( (char*) pBuf, 9, FALSE, 9 );
+ aMemStm >> nImagePosX;
+ aMemStm >> nImagePosY;
+ aMemStm >> nImageWidth;
+ aMemStm >> nImageHeight;
+ aMemStm >> nFlags;
+
+ // Falls Interlaced, ersten Startwert vorgeben
+ bInterlaced = ( ( nFlags & 0x40 ) == 0x40 );
+ nLastInterCount = 7;
+ nLastImageY = 0;
+
+ if( nFlags & 0x80 )
+ {
+ pPal = &aLPalette;
+ ReadPaletteEntries( pPal, 1 << ( (nFlags & 7 ) + 1 ) );
+ }
+ else
+ pPal = &aGPalette;
+
+ // Falls alles soweit eingelesen werden konnte, kann
+ // nun das lokale Bild angelegt werden;
+ // es wird uebergeben, ob der BackgroundColorIndex evtl.
+ // beruecksichtigt werden soll ( wenn Globale Farbtab. und
+ // diese auch fuer dieses Bild gilt )
+ if( NO_PENDING( rIStm ) )
+ {
+ CreateBitmaps( nImageWidth, nImageHeight, pPal, bGlobalPalette && ( pPal == &aGPalette ) );
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+ULONG GIFReader::ReadNextBlock()
+{
+ ULONG nRet = 0UL;
+ ULONG nRead;
+ BYTE cBlockSize;
+
+ rIStm >> cBlockSize;
+
+ if ( rIStm.IsEof() )
+ nRet = 4UL;
+ else if ( NO_PENDING( rIStm ) )
+ {
+ if ( cBlockSize == 0 )
+ nRet = 2UL;
+ else
+ {
+ rIStm.Read( pSrcBuf, cBlockSize );
+
+ if( NO_PENDING( rIStm ) )
+ {
+ if( bOverreadBlock )
+ nRet = 3UL;
+ else
+ {
+ BOOL bEOI;
+ HPBYTE pTarget = pDecomp->DecompressBlock( pSrcBuf, cBlockSize, nRead, bEOI );
+
+ nRet = ( bEOI ? 3 : 1 );
+
+ if( nRead && !bOverreadBlock )
+ FillImages( pTarget, nRead );
+
+ rtl_freeMemory( pTarget );
+ }
+ }
+ }
+ }
+
+ return nRet;
+}
+
+// ------------------------------------------------------------------------
+
+void GIFReader::FillImages( HPBYTE pBytes, ULONG nCount )
+{
+ for( ULONG i = 0UL; i < nCount; i++ )
+ {
+ if( nImageX >= nImageWidth )
+ {
+ if( bInterlaced )
+ {
+ long nT1, nT2;
+
+ // falls Interlaced, werden die Zeilen kopiert
+ if( nLastInterCount )
+ {
+ long nMinY = Min( (long) nLastImageY + 1, (long) nImageHeight - 1 );
+ long nMaxY = Min( (long) nLastImageY + nLastInterCount, (long) nImageHeight - 1 );
+
+ // letzte gelesene Zeile kopieren, wenn Zeilen
+ // nicht zusanmmenfallen ( kommt vorm wenn wir am Ende des Bildes sind )
+ if( ( nMinY > nLastImageY ) && ( nLastImageY < ( nImageHeight - 1 ) ) )
+ {
+ HPBYTE pScanline8 = pAcc8->GetScanline( nYAcc );
+ ULONG nSize8 = pAcc8->GetScanlineSize();
+ HPBYTE pScanline1 = 0;
+ ULONG nSize1 = 0;
+
+ if( bGCTransparent )
+ {
+ pScanline1 = pAcc1->GetScanline( nYAcc );
+ nSize1 = pAcc1->GetScanlineSize();
+ }
+
+ for( long j = nMinY; j <= nMaxY; j++ )
+ {
+ memcpy( pAcc8->GetScanline( j ), pScanline8, nSize8 );
+
+ if( bGCTransparent )
+ memcpy( pAcc1->GetScanline( j ), pScanline1, nSize1 );
+ }
+ }
+ }
+
+ nT1 = ( ++nImageY ) << 3;
+ nLastInterCount = 7;
+
+ if( nT1 >= nImageHeight )
+ {
+ nT2 = nImageY - ( ( nImageHeight + 7 ) >> 3 );
+ nT1 = ( nT2 << 3 ) + 4;
+ nLastInterCount = 3;
+
+ if( nT1 >= nImageHeight )
+ {
+ nT2 -= ( nImageHeight + 3 ) >> 3;
+ nT1 = ( nT2 << 2 ) + 2;
+ nLastInterCount = 1;
+
+ if( nT1 >= nImageHeight )
+ {
+ nT2 -= ( nImageHeight + 1 ) >> 2;
+ nT1 = ( nT2 << 1 ) + 1;
+ nLastInterCount = 0;
+ }
+ }
+ }
+
+ nLastImageY = (USHORT) nT1;
+ nYAcc = nT1;
+ }
+ else
+ {
+ nLastImageY = ++nImageY;
+ nYAcc = nImageY;
+ }
+
+ // Zeile faengt von vorne an
+ nImageX = 0;
+ }
+
+ if( nImageY < nImageHeight )
+ {
+ const BYTE cTmp = pBytes[ i ];
+
+ if( bGCTransparent )
+ {
+ if( cTmp == nGCTransparentIndex )
+ pAcc1->SetPixel( nYAcc, nImageX++, cTransIndex1 );
+ else
+ {
+ pAcc8->SetPixel( nYAcc, nImageX, cTmp );
+ pAcc1->SetPixel( nYAcc, nImageX++, cNonTransIndex1 );
+ }
+ }
+ else
+ pAcc8->SetPixel( nYAcc, nImageX++, cTmp );
+ }
+ else
+ {
+ bOverreadBlock = TRUE;
+ break;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GIFReader::CreateNewBitmaps()
+{
+ AnimationBitmap aAnimBmp;
+
+ aBmp8.ReleaseAccess( pAcc8 );
+ pAcc8 = NULL;
+
+ if( bGCTransparent )
+ {
+ aBmp1.ReleaseAccess( pAcc1 );
+ pAcc1 = NULL;
+ aAnimBmp.aBmpEx = BitmapEx( aBmp8, aBmp1 );
+ }
+ else
+ aAnimBmp.aBmpEx = BitmapEx( aBmp8 );
+
+ aAnimBmp.aPosPix = Point( nImagePosX, nImagePosY );
+ aAnimBmp.aSizePix = Size( nImageWidth, nImageHeight );
+ aAnimBmp.nWait = ( nTimer != 65535 ) ? nTimer : ANIMATION_TIMEOUT_ON_CLICK;
+ aAnimBmp.bUserInput = FALSE;
+
+ if( nGCDisposalMethod == 2 )
+ aAnimBmp.eDisposal = DISPOSE_BACK;
+ else if( nGCDisposalMethod == 3 )
+ aAnimBmp.eDisposal = DISPOSE_PREVIOUS;
+ else
+ aAnimBmp.eDisposal = DISPOSE_NOT;
+
+ aAnimation.Insert( aAnimBmp );
+
+ if( aAnimation.Count() == 1 )
+ {
+ aAnimation.SetDisplaySizePixel( Size( nGlobalWidth, nGlobalHeight ) );
+ aAnimation.SetLoopCount( nLoops );
+ }
+}
+
+// ------------------------------------------------------------------------
+
+const Graphic& GIFReader::GetIntermediateGraphic()
+{
+ // Intermediate-Graphic nur erzeugen, wenn schon
+ // Daten vorliegen, aber die Graphic noch nicht
+ // vollstaendig eingelesen wurde
+ if ( bImGraphicReady && !aAnimation.Count() )
+ {
+ Bitmap aBmp;
+
+ aBmp8.ReleaseAccess( pAcc8 );
+
+ if ( bGCTransparent )
+ {
+ aBmp1.ReleaseAccess( pAcc1 );
+ aImGraphic = BitmapEx( aBmp8, aBmp1 );
+
+ pAcc1 = aBmp1.AcquireWriteAccess();
+ bStatus = bStatus && ( pAcc1 != NULL );
+ }
+ else
+ aImGraphic = aBmp8;
+
+ pAcc8 = aBmp8.AcquireWriteAccess();
+ bStatus = bStatus && ( pAcc8 != NULL );
+ }
+
+ return aImGraphic;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GIFReader::ProcessGIF()
+{
+ BOOL bRead = FALSE;
+ BOOL bEnd = FALSE;
+
+ if ( !bStatus )
+ eActAction = ABORT_READING;
+
+ // Stream an die richtige Stelle bringen
+ rIStm.Seek( nLastPos );
+
+ switch( eActAction )
+ {
+ // naechsten Marker lesen
+ case( MARKER_READING ):
+ {
+ BYTE cByte;
+
+ rIStm >> cByte;
+
+ if( rIStm.IsEof() )
+ eActAction = END_READING;
+ else if( NO_PENDING( rIStm ) )
+ {
+ bRead = TRUE;
+
+ if( cByte == '!' )
+ eActAction = EXTENSION_READING;
+ else if( cByte == ',' )
+ eActAction = LOCAL_HEADER_READING;
+ else if( cByte == ';' )
+ eActAction = END_READING;
+ else
+ eActAction = ABORT_READING;
+ }
+ }
+ break;
+
+ // ScreenDescriptor lesen
+ case( GLOBAL_HEADER_READING ):
+ {
+ if( ( bRead = ReadGlobalHeader() ) == TRUE )
+ {
+ ClearImageExtensions();
+ eActAction = MARKER_READING;
+ }
+ }
+ break;
+
+
+ // Extension lesen
+ case( EXTENSION_READING ):
+ {
+ if( ( bRead = ReadExtension() ) == TRUE )
+ eActAction = MARKER_READING;
+ }
+ break;
+
+
+ // Image-Descriptor lesen
+ case( LOCAL_HEADER_READING ):
+ {
+ if( ( bRead = ReadLocalHeader() ) == TRUE )
+ {
+ nYAcc = nImageX = nImageY = 0;
+ eActAction = FIRST_BLOCK_READING;
+ }
+ }
+ break;
+
+
+ // ersten Datenblock lesen
+ case( FIRST_BLOCK_READING ):
+ {
+ BYTE cDataSize;
+
+ rIStm >> cDataSize;
+
+ if( rIStm.IsEof() )
+ eActAction = ABORT_READING;
+ else if( cDataSize > 12 )
+ bStatus = FALSE;
+ else if( NO_PENDING( rIStm ) )
+ {
+ bRead = TRUE;
+ pDecomp = new GIFLZWDecompressor( cDataSize );
+ eActAction = NEXT_BLOCK_READING;
+ bOverreadBlock = FALSE;
+ }
+ else
+ eActAction = FIRST_BLOCK_READING;
+ }
+ break;
+
+ // naechsten Datenblock lesen
+ case( NEXT_BLOCK_READING ):
+ {
+ USHORT nLastX = nImageX;
+ USHORT nLastY = nImageY;
+ ULONG nRet = ReadNextBlock();
+
+ // Return: 0:Pending / 1:OK; / 2:OK und letzter Block: / 3:EOI / 4:HardAbort
+ if( nRet )
+ {
+ bRead = TRUE;
+
+ if ( nRet == 1UL )
+ {
+ bImGraphicReady = TRUE;
+ eActAction = NEXT_BLOCK_READING;
+ bOverreadBlock = FALSE;
+ }
+ else
+ {
+ if( nRet == 2UL )
+ {
+ delete pDecomp;
+ CreateNewBitmaps();
+ eActAction = MARKER_READING;
+ ClearImageExtensions();
+ }
+ else if( nRet == 3UL )
+ {
+ eActAction = NEXT_BLOCK_READING;
+ bOverreadBlock = TRUE;
+ }
+ else
+ {
+ delete pDecomp;
+ CreateNewBitmaps();
+ eActAction = ABORT_READING;
+ ClearImageExtensions();
+ }
+ }
+ }
+ else
+ {
+ nImageX = nLastX;
+ nImageY = nLastY;
+ }
+ }
+ break;
+
+ // ein Fehler trat auf
+ case( ABORT_READING ):
+ {
+ bEnd = TRUE;
+ eActAction = END_READING;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ // Stream an die richtige Stelle bringen,
+ // falls Daten gelesen werden konnten
+ // entweder alte Position oder aktuelle Position
+ if( bRead || bEnd )
+ nLastPos = rIStm.Tell();
+
+ return bRead;
+}
+
+// ------------------------------------------------------------------------
+
+ReadState GIFReader::ReadGIF( Graphic& rGraphic )
+{
+ ReadState eReadState;
+
+ bStatus = TRUE;
+
+ while( ProcessGIF() && ( eActAction != END_READING ) ) {}
+
+ if( !bStatus )
+ eReadState = GIFREAD_ERROR;
+ else if( eActAction == END_READING )
+ eReadState = GIFREAD_OK;
+ else
+ {
+ if ( rIStm.GetError() == ERRCODE_IO_PENDING )
+ rIStm.ResetError();
+
+ eReadState = GIFREAD_NEED_MORE;
+ }
+
+ if( aAnimation.Count() == 1 )
+ {
+ rGraphic = aAnimation.Get( 0 ).aBmpEx;
+
+ if( nLogWidth100 && nLogHeight100 )
+ {
+ rGraphic.SetPrefSize( Size( nLogWidth100, nLogHeight100 ) );
+ rGraphic.SetPrefMapMode( MAP_100TH_MM );
+ }
+ }
+ else
+ rGraphic = aAnimation;
+
+ return eReadState;
+}
+
+
+// -------------
+// - ImportGIF -
+// -------------
+
+BOOL ImportGIF( SvStream & rStm, Graphic& rGraphic )
+{
+ GIFReader* pGIFReader = (GIFReader*) rGraphic.GetContext();
+ USHORT nOldFormat = rStm.GetNumberFormatInt();
+ ReadState eReadState;
+ BOOL bRet = TRUE;
+
+ rStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+
+ if( !pGIFReader )
+ pGIFReader = new GIFReader( rStm );
+
+ rGraphic.SetContext( NULL );
+ eReadState = pGIFReader->ReadGIF( rGraphic );
+
+ if( eReadState == GIFREAD_ERROR )
+ {
+ bRet = FALSE;
+ delete pGIFReader;
+ }
+ else if( eReadState == GIFREAD_OK )
+ delete pGIFReader;
+ else
+ {
+ rGraphic = pGIFReader->GetIntermediateGraphic();
+ rGraphic.SetContext( pGIFReader );
+ }
+
+ rStm.SetNumberFormatInt( nOldFormat );
+
+ return bRet;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/ixbm/makefile.mk b/binfilter/bf_svtools/source/filter.vcl/ixbm/makefile.mk
new file mode 100644
index 000000000000..03e5c3a606a6
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/ixbm/makefile.mk
@@ -0,0 +1,43 @@
+#*************************************************************************
+#
+# DO NOT ALTER 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=binfilter
+TARGET=ixbm
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= $(SLO)$/svt_xbmread.obj
+
+.INCLUDE : target.mk
+
diff --git a/binfilter/bf_svtools/source/filter.vcl/ixbm/svt_xbmread.cxx b/binfilter/bf_svtools/source/filter.vcl/ixbm/svt_xbmread.cxx
new file mode 100644
index 000000000000..5e2e5a742e05
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/ixbm/svt_xbmread.cxx
@@ -0,0 +1,405 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+#define XBMMINREAD 512
+
+#define _XBMPRIVATE
+#include <ctype.h>
+#include "xbmread.hxx"
+
+// -------------
+// - XBMReader -
+// -------------
+
+namespace binfilter
+{
+
+XBMReader::XBMReader( SvStream& rStm ) :
+ rIStm ( rStm ),
+ pAcc1 ( NULL ),
+ nLastPos ( rStm.Tell() ),
+ nWidth ( 0 ),
+ nHeight ( 0 ),
+ bStatus ( TRUE )
+{
+ pHexTable = new short[ 256 ];
+ maUpperName = String::CreateFromAscii( "SVIXBM", 6 );
+ InitTable();
+}
+
+// ------------------------------------------------------------------------
+
+XBMReader::~XBMReader()
+{
+ delete[] pHexTable;
+
+ if( pAcc1 )
+ aBmp1.ReleaseAccess( pAcc1 );
+}
+
+// ------------------------------------------------------------------------
+
+void XBMReader::InitTable()
+{
+ memset( pHexTable, 0, sizeof( short ) );
+
+ pHexTable['0'] = 0;
+ pHexTable['1'] = 1;
+ pHexTable['2'] = 2;
+ pHexTable['3'] = 3;
+ pHexTable['4'] = 4;
+ pHexTable['5'] = 5;
+ pHexTable['6'] = 6;
+ pHexTable['7'] = 7;
+ pHexTable['8'] = 8;
+ pHexTable['9'] = 9;
+ pHexTable['A'] = 10;
+ pHexTable['B'] = 11;
+ pHexTable['C'] = 12;
+ pHexTable['D'] = 13;
+ pHexTable['E'] = 14;
+ pHexTable['F'] = 15;
+ pHexTable['X'] = 0;
+ pHexTable['a'] = 10;
+ pHexTable['b'] = 11;
+ pHexTable['c'] = 12;
+ pHexTable['d'] = 13;
+ pHexTable['e'] = 14;
+ pHexTable['f'] = 15;
+ pHexTable['x'] = 0;
+ pHexTable[' '] = -1;
+ pHexTable[','] = -1;
+ pHexTable['}'] = -1;
+ pHexTable['\n'] = -1;
+ pHexTable['\t'] = -1;
+ pHexTable['\0'] = -1;
+}
+
+// ------------------------------------------------------------------------
+
+ByteString XBMReader::FindTokenLine( SvStream* pInStm, const char* pTok1,
+ const char* pTok2, const char* pTok3 )
+{
+ ByteString aRet;
+ long nPos1;
+ long nPos2;
+ long nPos3;
+
+ bStatus = FALSE;
+
+ do
+ {
+ if( !pInStm->ReadLine( aRet ) )
+ break;
+
+ if( pTok1 )
+ {
+ if( ( nPos1 = aRet.Search( pTok1 ) ) != STRING_NOTFOUND )
+ {
+ bStatus = TRUE;
+
+ if( pTok2 )
+ {
+ bStatus = FALSE;
+
+ if( ( ( nPos2 = aRet.Search( pTok2 ) ) != STRING_NOTFOUND ) &&
+ ( nPos2 > nPos1 ) )
+ {
+ bStatus = TRUE;
+
+ if( pTok3 )
+ {
+ bStatus = FALSE;
+
+ if( ( ( nPos3 = aRet.Search( pTok3 ) ) != STRING_NOTFOUND ) && ( nPos3 > nPos2 ) )
+ bStatus = TRUE;
+ }
+ }
+ }
+ }
+ }
+ }
+ while( !bStatus );
+
+ return aRet;
+}
+
+// ------------------------------------------------------------------------
+
+long XBMReader::ParseDefine( const sal_Char* pDefine )
+{
+ long nRet = 0;
+ char* pTmp = (char*) pDefine;
+ int cTmp;
+
+ // bis zum Ende gehen
+ pTmp += ( strlen( pDefine ) - 1 );
+ cTmp = *pTmp--;
+
+ // letzte Ziffer suchen
+ while( pHexTable[ cTmp ] == -1 )
+ cTmp = *pTmp--;
+
+ // bis vor die Zahl laufen
+ while( pHexTable[ cTmp ] != -1 )
+ cTmp = *pTmp--;
+
+ // auf Anfang der Zahl gehen
+ pTmp += 2;
+
+ // Hex lesen
+ if( ( pTmp[0] == '0' ) && ( ( pTmp[1] == 'X' ) || ( pTmp[1] == 'x' ) ) )
+ {
+ pTmp += 2;
+ cTmp = *pTmp++;
+
+ while ( pHexTable[ cTmp ] != -1 )
+ {
+ nRet = ( nRet << 4 ) + pHexTable[ cTmp ];
+ cTmp = *pTmp++;
+ }
+ }
+ // Dezimal lesen
+ else
+ {
+ cTmp = *pTmp++;
+ while( ( cTmp >= '0' ) && ( cTmp <= '9' ) )
+ {
+ nRet = nRet * 10 + ( cTmp - '0' );
+ cTmp = *pTmp++;
+ }
+ }
+
+ return nRet;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL XBMReader::ParseData( SvStream* pInStm, const ByteString& aLastLine, XBMFormat eFormat )
+{
+ ByteString aLine;
+ long nRow = 0;
+ long nCol = 0;
+ long nBits = ( eFormat == XBM10 ) ? 16 : 8;
+ long nBit;
+ USHORT nValue;
+ USHORT nDigits;
+ BOOL bFirstLine = TRUE;
+
+ while( nRow < nHeight )
+ {
+ if( bFirstLine )
+ {
+ xub_StrLen nPos;
+
+ // einfuehrende geschweifte Klammer loeschen
+ if( (nPos = ( aLine = aLastLine ).Search( '{' ) ) != STRING_NOTFOUND )
+ aLine.Erase( 0, nPos + 1 );
+
+ bFirstLine = FALSE;
+ }
+ else if( !pInStm->ReadLine( aLine ) )
+ break;
+
+ if( aLine.Len() )
+ {
+ const USHORT nCount = aLine.GetTokenCount( ',' );
+
+ for( USHORT i = 0; ( i < nCount ) && ( nRow < nHeight ); i++ )
+ {
+ const ByteString aToken( aLine.GetToken( i, ',' ) );
+ const xub_StrLen nLen = aToken.Len();
+ BOOL bProcessed = FALSE;
+
+ nBit = nDigits = nValue = 0;
+
+ for( xub_StrLen n = 0UL; n < nLen; n++ )
+ {
+ const unsigned char cChar = aToken.GetChar( n );
+ const short nTable = pHexTable[ cChar ];
+
+ if( isxdigit( cChar ) || !nTable )
+ {
+ nValue = ( nValue << 4 ) + nTable;
+ nDigits++;
+ bProcessed = TRUE;
+ }
+ else if( ( nTable < 0 ) && nDigits )
+ {
+ bProcessed = TRUE;
+ break;
+ }
+ }
+
+ if( bProcessed )
+ {
+ while( ( nCol < nWidth ) && ( nBit < nBits ) )
+ pAcc1->SetPixel( nRow, nCol++, ( nValue & ( 1 << nBit++ ) ) ? aBlack : aWhite );
+
+ if( nCol == nWidth )
+ nCol = 0, nRow++;
+ }
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+// ------------------------------------------------------------------------
+
+ReadState XBMReader::ReadXBM( Graphic& rGraphic )
+{
+ ReadState eReadState;
+ BYTE cDummy;
+
+ // sehen, ob wir _alles_ lesen koennen
+ rIStm.Seek( STREAM_SEEK_TO_END );
+ rIStm >> cDummy;
+
+ // falls wir nicht alles lesen koennen
+ // kehren wir zurueck und warten auf neue Daten
+ if ( rIStm.GetError() != ERRCODE_IO_PENDING )
+ {
+ ByteString aLine;
+ int nValue;
+
+ rIStm.Seek( nLastPos );
+ bStatus = FALSE;
+ aLine = FindTokenLine( &rIStm, "#define", "_width" );
+
+ if ( bStatus )
+ {
+ if ( ( nValue = (int) ParseDefine( aLine.GetBuffer() ) ) > 0 )
+ {
+ nWidth = nValue;
+ aLine = FindTokenLine( &rIStm, "#define", "_height" );
+
+ // Falls die Hoehe nicht folgt, suchen wir noch
+ // einmal vom Anfang der Datei an
+ if ( !bStatus )
+ {
+ rIStm.Seek( nLastPos );
+ aLine = FindTokenLine( &rIStm, "#define", "_height" );
+ }
+ }
+ else
+ bStatus = FALSE;
+
+ if ( bStatus )
+ {
+ if ( ( nValue = (int) ParseDefine( aLine.GetBuffer() ) ) > 0 )
+ {
+ nHeight = nValue;
+ aLine = FindTokenLine( &rIStm, "static", "_bits" );
+
+ if ( bStatus )
+ {
+ XBMFormat eFormat = XBM10;
+
+ if ( aLine.Search( "short" ) != STRING_NOTFOUND )
+ eFormat = XBM10;
+ else if ( aLine.Search( "char" ) != STRING_NOTFOUND )
+ eFormat = XBM11;
+ else
+ bStatus = FALSE;
+
+ if ( bStatus && nWidth && nHeight )
+ {
+ aBmp1 = Bitmap( Size( nWidth, nHeight ), 1 );
+ pAcc1 = aBmp1.AcquireWriteAccess();
+
+ if( pAcc1 )
+ {
+ aWhite = pAcc1->GetBestMatchingColor( Color( COL_WHITE ) );
+ aBlack = pAcc1->GetBestMatchingColor( Color( COL_BLACK ) );
+ bStatus = ParseData( &rIStm, aLine, eFormat );
+ }
+ else
+ bStatus = FALSE;
+ }
+ }
+ }
+ }
+ }
+
+ if( bStatus )
+ {
+ Bitmap aBlackBmp( Size( pAcc1->Width(), pAcc1->Height() ), 1 );
+
+ aBmp1.ReleaseAccess( pAcc1 ), pAcc1 = NULL;
+ aBlackBmp.Erase( Color( COL_BLACK ) );
+ rGraphic = BitmapEx( aBlackBmp, aBmp1 );
+ eReadState = XBMREAD_OK;
+ }
+ else
+ eReadState = XBMREAD_ERROR;
+ }
+ else
+ {
+ rIStm.ResetError();
+ eReadState = XBMREAD_NEED_MORE;
+ }
+
+ return eReadState;
+}
+
+// -------------
+// - ImportXBM -
+// -------------
+
+BOOL ImportXBM( SvStream& rStm, Graphic& rGraphic )
+{
+ XBMReader* pXBMReader = (XBMReader*) rGraphic.GetContext();
+ ReadState eReadState;
+ BOOL bRet = TRUE;
+
+ if( !pXBMReader )
+ pXBMReader = new XBMReader( rStm );
+
+ rGraphic.SetContext( NULL );
+ eReadState = pXBMReader->ReadXBM( rGraphic );
+
+ if( eReadState == XBMREAD_ERROR )
+ {
+ bRet = FALSE;
+ delete pXBMReader;
+ }
+ else if( eReadState == XBMREAD_OK )
+ delete pXBMReader;
+ else
+ rGraphic.SetContext( pXBMReader );
+
+ return bRet;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/ixpm/makefile.mk b/binfilter/bf_svtools/source/filter.vcl/ixpm/makefile.mk
new file mode 100644
index 000000000000..66d257c0bf35
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/ixpm/makefile.mk
@@ -0,0 +1,42 @@
+#*************************************************************************
+#
+# DO NOT ALTER 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=binfilter
+TARGET=ixpm
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= $(SLO)$/svt_xpmread.obj
+
+.INCLUDE : target.mk
diff --git a/binfilter/bf_svtools/source/filter.vcl/ixpm/rgbtable.hxx b/binfilter/bf_svtools/source/filter.vcl/ixpm/rgbtable.hxx
new file mode 100644
index 000000000000..2846c077f0e0
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/ixpm/rgbtable.hxx
@@ -0,0 +1,702 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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.
+ *
+ ************************************************************************/
+
+namespace binfilter
+{
+
+struct XPMRGBTab
+{
+ const char* name;
+ BYTE red;
+ BYTE green;
+ BYTE blue;
+};
+
+static XPMRGBTab pRGBTable[] = {
+{ "white", 255, 255, 255 },
+{ "black", 0, 0, 0 },
+{ "snow", 255, 250, 250 },
+{ "GhostWhite", 248, 248, 255 },
+{ "WhiteSmoke", 245, 245, 245 },
+{ "gainsboro", 220, 220, 220 },
+{ "FloralWhite", 255, 250, 240 },
+{ "OldLace", 253, 245, 230 },
+{ "linen", 250, 240, 230 },
+{ "AntiqueWhite", 250, 235, 215 },
+{ "PapayaWhip", 255, 239, 213 },
+{ "BlanchedAlmond", 255, 235, 205 },
+{ "bisque", 255, 228, 196 },
+{ "PeachPuff", 255, 218, 185 },
+{ "NavajoWhite", 255, 222, 173 },
+{ "moccasin", 255, 228, 181 },
+{ "cornsilk", 255, 248, 220 },
+{ "ivory", 255, 255, 240 },
+{ "LemonChiffon", 255, 250, 205 },
+{ "seashell", 255, 245, 238 },
+{ "honeydew", 240, 255, 240 },
+{ "MintCream", 245, 255, 250 },
+{ "azure", 240, 255, 255 },
+{ "AliceBlue", 240, 248, 255 },
+{ "lavender", 230, 230, 250 },
+{ "LavenderBlush", 255, 240, 245 },
+{ "MistyRose", 255, 228, 225 },
+{ "DarkSlateGray", 47, 79, 79 },
+{ "DarkSlateGrey", 47, 79, 79 },
+{ "DimGray", 105, 105, 105 },
+{ "DimGrey", 105, 105, 105 },
+{ "SlateGray", 112, 128, 144 },
+{ "SlateGrey", 112, 128, 144 },
+{ "LightSlateGray", 119, 136, 153 },
+{ "LightSlateGrey", 119, 136, 153 },
+{ "gray", 190, 190, 190 },
+{ "grey", 190, 190, 190 },
+{ "LightGrey", 211, 211, 211 },
+{ "LightGray", 211, 211, 211 },
+{ "MidnightBlue", 25, 25, 112 },
+{ "navy", 0, 0, 128 },
+{ "NavyBlue", 0, 0, 128 },
+{ "CornflowerBlue", 100, 149, 237 },
+{ "DarkSlateBlue", 72, 61, 139 },
+{ "SlateBlue", 106, 90, 205 },
+{ "MediumSlateBlue", 123, 104, 238 },
+{ "LightSlateBlue", 132, 112, 255 },
+{ "MediumBlue", 0, 0, 205 },
+{ "RoyalBlue", 65, 105, 225 },
+{ "blue", 0, 0, 255 },
+{ "DodgerBlue", 30, 144, 255 },
+{ "DeepSkyBlue", 0, 191, 255 },
+{ "SkyBlue", 135, 206, 235 },
+{ "LightSkyBlue", 135, 206, 250 },
+{ "SteelBlue", 70, 130, 180 },
+{ "LightSteelBlue", 176, 196, 222 },
+{ "LightBlue", 173, 216, 230 },
+{ "PowderBlue", 176, 224, 230 },
+{ "PaleTurquoise", 175, 238, 238 },
+{ "DarkTurquoise", 0, 206, 209 },
+{ "MediumTurquoise", 72, 209, 204 },
+{ "turquoise", 64, 224, 208 },
+{ "cyan", 0, 255, 255 },
+{ "LightCyan", 224, 255, 255 },
+{ "CadetBlue", 95, 158, 160 },
+{ "MediumAquamarine", 102, 205, 170 },
+{ "aquamarine", 127, 255, 212 },
+{ "DarkGreen", 0, 100, 0 },
+{ "DarkOliveGreen", 85, 107, 47 },
+{ "DarkSeaGreen", 143, 188, 143 },
+{ "SeaGreen", 46, 139, 87 },
+{ "MediumSeaGreen", 60, 179, 113 },
+{ "LightSeaGreen", 32, 178, 170 },
+{ "PaleGreen", 152, 251, 152 },
+{ "SpringGreen", 0, 255, 127 },
+{ "LawnGreen", 124, 252, 0 },
+{ "green", 0, 255, 0 },
+{ "chartreuse", 127, 255, 0 },
+{ "MediumSpringGreen", 0, 250, 154 },
+{ "GreenYellow", 173, 255 , 47 },
+{ "LimeGreen", 50, 205, 50 },
+{ "YellowGreen", 154, 205, 50 },
+{ "ForestGreen", 34, 139, 34 },
+{ "OliveDrab", 107, 142, 35 },
+{ "DarkKhaki", 189, 183, 107 },
+{ "khaki", 240, 230, 140 },
+{ "PaleGoldenrod", 238, 232, 170 },
+{ "LightGoldenrodYellow", 250, 250, 210 },
+{ "LightYellow", 255, 255, 224 },
+{ "yellow", 255, 255, 0 },
+{ "gold", 255, 215, 0 },
+{ "LightGoldenrod", 238, 221, 130 },
+{ "goldenrod", 218, 165, 32 },
+{ "DarkGoldenrod", 184, 134, 11 },
+{ "RosyBrown", 188, 143, 143 },
+{ "IndianRed", 205, 92, 92 },
+{ "SaddleBrown", 139, 69, 19 },
+{ "sienna", 160, 82, 45 },
+{ "peru", 205, 133, 63 },
+{ "burlywood", 222, 184, 135 },
+{ "beige", 245, 245, 220 },
+{ "wheat", 245, 222, 179 },
+{ "SandyBrown", 244, 164, 96 },
+{ "tan", 210, 180, 140 },
+{ "chocolate", 210, 105, 30 },
+{ "firebrick", 178, 34, 34 },
+{ "brown", 165, 42, 42 },
+{ "DarkSalmon", 233, 150, 122 },
+{ "salmon", 250, 128, 114 },
+{ "LightSalmon", 255, 160, 122 },
+{ "orange", 255, 165, 0 },
+{ "DarkOrange", 255, 140, 0 },
+{ "coral", 255, 127, 80 },
+{ "LightCoral", 240, 128, 128 },
+{ "tomato", 255, 99, 71 },
+{ "OrangeRed", 255, 69, 0 },
+{ "red", 255, 0, 0 },
+{ "HotPink", 255, 105, 180 },
+{ "DeepPink", 255, 20, 147 },
+{ "pink", 255, 192, 203 },
+{ "LightPink", 255, 182, 193 },
+{ "PaleVioletRed", 219, 112, 147 },
+{ "maroon", 176, 48, 96 },
+{ "MediumVioletRed", 199, 21, 133 },
+{ "VioletRed", 208, 32, 144 },
+{ "magenta", 255, 0, 255 },
+{ "violet", 238, 130, 238 },
+{ "plum", 221, 160, 221 },
+{ "orchid", 218, 112, 214 },
+{ "MediumOrchid", 186, 85, 211 },
+{ "DarkOrchid", 153, 50, 204 },
+{ "DarkViolet", 148, 0, 211 },
+{ "BlueViolet", 138, 43, 226 },
+{ "purple", 160, 32, 240 },
+{ "MediumPurple", 147, 112, 219 },
+{ "thistle", 216, 191, 216 },
+{ "snow1", 255, 250, 250 },
+{ "snow2", 238, 233, 233 },
+{ "snow3", 205, 201, 201 },
+{ "snow4", 139, 137, 137 },
+{ "seashell1", 255, 245, 238 },
+{ "seashell2", 238, 229, 222 },
+{ "seashell3", 205, 197, 191 },
+{ "seashell4", 139, 134, 130 },
+{ "AntiqueWhite1", 255, 239, 219 },
+{ "AntiqueWhite2", 238, 223, 204 },
+{ "AntiqueWhite3", 205, 192, 176 },
+{ "AntiqueWhite4", 139, 131, 120 },
+{ "bisque1", 255, 228, 196 },
+{ "bisque2", 238, 213, 183 },
+{ "bisque3", 205, 183, 158 },
+{ "bisque4", 139, 125, 107 },
+{ "PeachPuff1", 255, 218, 185 },
+{ "PeachPuff2", 238, 203, 173 },
+{ "PeachPuff3", 205, 175, 149 },
+{ "PeachPuff4", 139, 119, 101 },
+{ "NavajoWhite1", 255, 222, 173 },
+{ "NavajoWhite2", 238, 207, 161 },
+{ "NavajoWhite3", 205, 179, 139 },
+{ "NavajoWhite4", 139, 121, 94 },
+{ "LemonChiffon1", 255, 250, 205 },
+{ "LemonChiffon2", 238, 233, 191 },
+{ "LemonChiffon3", 205, 201, 165 },
+{ "LemonChiffon4", 139, 137, 112 },
+{ "cornsilk1", 255, 248, 220 },
+{ "cornsilk2", 238, 232, 205 },
+{ "cornsilk3", 205, 200, 177 },
+{ "cornsilk4", 139, 136, 120 },
+{ "ivory1", 255, 255, 240 },
+{ "ivory2", 238, 238, 224 },
+{ "ivory3", 205, 205, 193 },
+{ "ivory4", 139, 139, 131 },
+{ "honeydew1", 240, 255, 240 },
+{ "honeydew2", 224, 238, 224 },
+{ "honeydew3", 193, 205, 193 },
+{ "honeydew4", 131, 139, 131 },
+{ "LavenderBlush1", 255, 240, 245 },
+{ "LavenderBlush2", 238, 224, 229 },
+{ "LavenderBlush3", 205, 193, 197 },
+{ "LavenderBlush4", 139, 131, 134 },
+{ "MistyRose1", 255, 228, 225 },
+{ "MistyRose2", 238, 213, 210 },
+{ "MistyRose3", 205, 183, 181 },
+{ "MistyRose4", 139, 125, 123 },
+{ "azure1", 240, 255, 255 },
+{ "azure2", 224, 238, 238 },
+{ "azure3", 193, 205, 205 },
+{ "azure4", 131, 139, 139 },
+{ "SlateBlue1", 131, 111, 255 },
+{ "SlateBlue2", 122, 103, 238 },
+{ "SlateBlue3", 105, 89, 205 },
+{ "SlateBlue4", 71, 60, 139 },
+{ "RoyalBlue1", 72, 118, 255 },
+{ "RoyalBlue2", 67, 110, 238 },
+{ "RoyalBlue3", 58, 95, 205 },
+{ "RoyalBlue4", 39, 64, 139 },
+{ "blue1", 0, 0, 255 },
+{ "blue2", 0, 0, 238 },
+{ "blue3", 0, 0, 205 },
+{ "blue4", 0, 0, 139 },
+{ "DodgerBlue1", 30, 144, 255 },
+{ "DodgerBlue2", 28, 134, 238 },
+{ "DodgerBlue3", 24, 116, 205 },
+{ "DodgerBlue4", 16, 78, 139 },
+{ "SteelBlue1", 99, 184, 255 },
+{ "SteelBlue2", 92, 172, 238 },
+{ "SteelBlue3", 79, 148, 205 },
+{ "SteelBlue4", 54, 100, 139 },
+{ "DeepSkyBlue1", 0, 191, 255 },
+{ "DeepSkyBlue2", 0, 178, 238 },
+{ "DeepSkyBlue3", 0, 154, 205 },
+{ "DeepSkyBlue4", 0, 104, 139 },
+{ "SkyBlue1", 135, 206, 255 },
+{ "SkyBlue2", 126, 192, 238 },
+{ "SkyBlue3", 108, 166, 205 },
+{ "SkyBlue4", 74, 112, 139 },
+{ "LightSkyBlue1", 176, 226, 255 },
+{ "LightSkyBlue2", 164, 211, 238 },
+{ "LightSkyBlue3", 141, 182, 205 },
+{ "LightSkyBlue4", 96, 123, 139 },
+{ "SlateGray1", 198, 226, 255 },
+{ "SlateGray2", 185, 211, 238 },
+{ "SlateGray3", 159, 182, 205 },
+{ "SlateGray4", 108, 123, 139 },
+{ "LightSteelBlue1", 202, 225, 255 },
+{ "LightSteelBlue2", 188, 210, 238 },
+{ "LightSteelBlue3", 162, 181, 205 },
+{ "LightSteelBlue4", 110, 123, 139 },
+{ "LightBlue1", 191, 239, 255 },
+{ "LightBlue2", 178, 223, 238 },
+{ "LightBlue3", 154, 192, 205 },
+{ "LightBlue4", 104, 131, 139 },
+{ "LightCyan1", 224, 255, 255 },
+{ "LightCyan2", 209, 238, 238 },
+{ "LightCyan3", 180, 205, 205 },
+{ "LightCyan4", 122, 139, 139 },
+{ "PaleTurquoise1", 187, 255, 255 },
+{ "PaleTurquoise2", 174, 238, 238 },
+{ "PaleTurquoise3", 150, 205, 205 },
+{ "PaleTurquoise4", 102, 139, 139 },
+{ "CadetBlue1", 152, 245, 255 },
+{ "CadetBlue2", 142, 229, 238 },
+{ "CadetBlue3", 122, 197, 205 },
+{ "CadetBlue4", 83, 134, 139 },
+{ "turquoise1", 0, 245, 255 },
+{ "turquoise2", 0, 229, 238 },
+{ "turquoise3", 0, 197, 205 },
+{ "turquoise4", 0, 134, 139 },
+{ "cyan1", 0, 255, 255 },
+{ "cyan2", 0, 238, 238 },
+{ "cyan3", 0, 205, 205 },
+{ "cyan4", 0, 139, 139 },
+{ "DarkSlateGray1", 151, 255, 255 },
+{ "DarkSlateGray2", 141, 238, 238 },
+{ "DarkSlateGray3", 121, 205, 205 },
+{ "DarkSlateGray4", 82, 139, 139 },
+{ "aquamarine1", 127, 255, 212 },
+{ "aquamarine2", 118, 238, 198 },
+{ "aquamarine3", 102, 205, 170 },
+{ "aquamarine4", 69, 139, 116 },
+{ "DarkSeaGreen1", 193, 255, 193 },
+{ "DarkSeaGreen2", 180, 238, 180 },
+{ "DarkSeaGreen3", 155, 205, 155 },
+{ "DarkSeaGreen4", 105, 139, 105 },
+{ "SeaGreen1", 84, 255, 159 },
+{ "SeaGreen2", 78, 238, 148 },
+{ "SeaGreen3", 67, 205, 128 },
+{ "SeaGreen4", 46, 139, 87 },
+{ "PaleGreen1", 154, 255, 154 },
+{ "PaleGreen2", 144, 238, 144 },
+{ "PaleGreen3", 124, 205, 124 },
+{ "PaleGreen4", 84, 139, 84 },
+{ "SpringGreen1", 0, 255, 127 },
+{ "SpringGreen2", 0, 238, 118 },
+{ "SpringGreen3", 0, 205, 102 },
+{ "SpringGreen4", 0, 139, 69 },
+{ "green1", 0, 255, 0 },
+{ "green2", 0, 238, 0 },
+{ "green3", 0, 205, 0 },
+{ "green4", 0, 139, 0 },
+{ "chartreuse1", 127, 255, 0 },
+{ "chartreuse2", 118, 238, 0 },
+{ "chartreuse3", 102, 205, 0 },
+{ "chartreuse4", 69, 139, 0 },
+{ "OliveDrab1", 192, 255, 62 },
+{ "OliveDrab2", 179, 238, 58 },
+{ "OliveDrab3", 154, 205, 50 },
+{ "OliveDrab4", 105, 139, 34 },
+{ "DarkOliveGreen1", 202, 255, 112 },
+{ "DarkOliveGreen2", 188, 238, 104 },
+{ "DarkOliveGreen3", 162, 205, 90 },
+{ "DarkOliveGreen4", 110, 139, 61 },
+{ "khaki1", 255, 246, 143 },
+{ "khaki2", 238, 230, 133 },
+{ "khaki3", 205, 198, 115 },
+{ "khaki4", 139, 134, 78 },
+{ "LightGoldenrod1", 255, 236, 139 },
+{ "LightGoldenrod2", 238, 220, 130 },
+{ "LightGoldenrod3", 205, 190, 112 },
+{ "LightGoldenrod4", 139, 129, 76 },
+{ "LightYellow1", 255, 255, 224 },
+{ "LightYellow2", 238, 238, 209 },
+{ "LightYellow3", 205, 205, 180 },
+{ "LightYellow4", 139, 139, 122 },
+{ "yellow1", 255, 255, 0 },
+{ "yellow2", 238, 238, 0 },
+{ "yellow3", 205, 205, 0 },
+{ "yellow4", 139, 139, 0 },
+{ "gold1", 255, 215, 0 },
+{ "gold2", 238, 201, 0 },
+{ "gold3", 205, 173, 0 },
+{ "gold4", 139, 117, 0 },
+{ "goldenrod1", 255, 193, 37 },
+{ "goldenrod2", 238, 180, 34 },
+{ "goldenrod3", 205, 155, 29 },
+{ "goldenrod4", 139, 105, 20 },
+{ "DarkGoldenrod1", 255, 185, 15 },
+{ "DarkGoldenrod2", 238, 173, 14 },
+{ "DarkGoldenrod3", 205, 149, 12 },
+{ "DarkGoldenrod4", 139, 101, 8 },
+{ "RosyBrown1", 255, 193, 193 },
+{ "RosyBrown2", 238, 180, 180 },
+{ "RosyBrown3", 205, 155, 155 },
+{ "RosyBrown4", 139, 105, 105 },
+{ "IndianRed1", 255, 106, 106 },
+{ "IndianRed2", 238, 99, 99 },
+{ "IndianRed3", 205, 85, 85 },
+{ "IndianRed4", 139, 58, 58 },
+{ "sienna1", 255, 130, 71 },
+{ "sienna2", 238, 121, 66 },
+{ "sienna3", 205, 104, 57 },
+{ "sienna4", 139, 71, 38 },
+{ "burlywood1", 255, 211, 155 },
+{ "burlywood2", 238, 197, 145 },
+{ "burlywood3", 205, 170, 125 },
+{ "burlywood4", 139, 115, 85 },
+{ "wheat1", 255, 231, 186 },
+{ "wheat2", 238, 216, 174 },
+{ "wheat3", 205, 186, 150 },
+{ "wheat4", 139, 126, 102 },
+{ "tan1", 255, 165, 79 },
+{ "tan2", 238, 154, 73 },
+{ "tan3", 205, 133, 63 },
+{ "tan4", 139 , 90, 43 },
+{ "chocolate1", 255, 127, 36 },
+{ "chocolate2", 238, 118, 33 },
+{ "chocolate3", 205, 102, 29 },
+{ "chocolate4", 139, 69, 19 },
+{ "firebrick1", 255, 48, 48 },
+{ "firebrick2", 238, 44, 44 },
+{ "firebrick3", 205, 38, 38 },
+{ "firebrick4", 139, 26, 26 },
+{ "brown1", 255, 64, 64 },
+{ "brown2", 238, 59, 59 },
+{ "brown3", 205, 51, 51 },
+{ "brown4", 139, 35, 35 },
+{ "salmon1", 255, 140, 105 },
+{ "salmon2", 238, 130, 98 },
+{ "salmon3", 205, 112, 84 },
+{ "salmon4", 139, 76, 57 },
+{ "LightSalmon1", 255, 160, 122 },
+{ "LightSalmon2", 238, 149, 114 },
+{ "LightSalmon3", 205, 129, 98 },
+{ "LightSalmon4", 139, 87, 66 },
+{ "orange1", 255, 165, 0 },
+{ "orange2", 238, 154, 0 },
+{ "orange3", 205, 133, 0 },
+{ "orange4", 139 , 90, 0 },
+{ "DarkOrange1", 255, 127, 0 },
+{ "DarkOrange2", 238, 118, 0 },
+{ "DarkOrange3", 205, 102, 0 },
+{ "DarkOrange4", 139 , 69, 0 },
+{ "coral1", 255, 114, 86 },
+{ "coral2", 238, 106, 80 },
+{ "coral3", 205, 91, 69 },
+{ "coral4", 139, 62, 47 },
+{ "tomato1", 255, 99, 71 },
+{ "tomato2", 238, 92, 66 },
+{ "tomato3", 205, 79, 57 },
+{ "tomato4", 139, 54, 38 },
+{ "OrangeRed1", 255, 69, 0 },
+{ "OrangeRed2", 238, 64, 0 },
+{ "OrangeRed3", 205, 55, 0 },
+{ "OrangeRed4", 139, 37, 0 },
+{ "red1", 255, 0, 0 },
+{ "red2", 238, 0, 0 },
+{ "red3", 205, 0, 0 },
+{ "red4", 139, 0, 0 },
+{ "DeepPink1", 255, 20, 147 },
+{ "DeepPink2", 238, 18, 137 },
+{ "DeepPink3", 205, 16, 118 },
+{ "DeepPink4", 139, 10, 80 },
+{ "HotPink1", 255, 110, 180 },
+{ "HotPink2", 238, 106, 167 },
+{ "HotPink3", 205, 96, 144 },
+{ "HotPink4", 139, 58, 98 },
+{ "pink1", 255, 181, 197 },
+{ "pink2", 238, 169, 184 },
+{ "pink3", 205, 145, 158 },
+{ "pink4", 139, 99, 108 },
+{ "LightPink1", 255, 174, 185 },
+{ "LightPink2", 238, 162, 173 },
+{ "LightPink3", 205, 140, 149 },
+{ "LightPink4", 139, 95, 101 },
+{ "PaleVioletRed1", 255, 130, 171 },
+{ "PaleVioletRed2", 238, 121, 159 },
+{ "PaleVioletRed3", 205, 104, 137 },
+{ "PaleVioletRed4", 139, 71, 93 },
+{ "maroon1", 255, 52, 179 },
+{ "maroon2", 238, 48, 167 },
+{ "maroon3", 205, 41, 144 },
+{ "maroon4", 139, 28, 98 },
+{ "VioletRed1", 255, 62, 150 },
+{ "VioletRed2", 238, 58, 140 },
+{ "VioletRed3", 205, 50, 120 },
+{ "VioletRed4", 139, 34, 82 },
+{ "magenta1", 255, 0, 255 },
+{ "magenta2", 238, 0, 238 },
+{ "magenta3", 205, 0, 205 },
+{ "magenta4", 139, 0, 139 },
+{ "orchid1", 255, 131, 250 },
+{ "orchid2", 238, 122, 233 },
+{ "orchid3", 205, 105, 201 },
+{ "orchid4", 139, 71, 137 },
+{ "plum1", 255, 187, 255 },
+{ "plum2", 238, 174, 238 },
+{ "plum3", 205, 150, 205 },
+{ "plum4", 139, 102, 139 },
+{ "MediumOrchid1", 224, 102, 255 },
+{ "MediumOrchid2", 209, 95, 238 },
+{ "MediumOrchid3", 180, 82, 205 },
+{ "MediumOrchid4", 122, 55, 139 },
+{ "DarkOrchid1", 191, 62, 255 },
+{ "DarkOrchid2", 178, 58, 238 },
+{ "DarkOrchid3", 154, 50, 205 },
+{ "DarkOrchid4", 104, 34, 139 },
+{ "purple1", 155, 48, 255 },
+{ "purple2", 145, 44, 238 },
+{ "purple3", 125, 38, 205 },
+{ "purple4", 85, 26, 139 },
+{ "MediumPurple1", 171, 130, 255 },
+{ "MediumPurple2", 159, 121, 238 },
+{ "MediumPurple3", 137, 104, 205 },
+{ "MediumPurple4", 93, 71, 139 },
+{ "thistle1", 255, 225, 255 },
+{ "thistle2", 238, 210, 238 },
+{ "thistle3", 205, 181, 205 },
+{ "thistle4", 139, 123, 139 },
+{ "gray0", 0, 0, 0 },
+{ "grey0", 0, 0, 0 },
+{ "gray1", 3, 3, 3 },
+{ "grey1", 3, 3, 3 },
+{ "gray2", 5, 5, 5 },
+{ "grey2", 5, 5, 5 },
+{ "gray3", 8, 8, 8 },
+{ "grey3", 8, 8, 8 },
+{ "gray4", 10, 10, 10 },
+{ "grey4", 10, 10, 10 },
+{ "gray5", 13, 13, 13 },
+{ "grey5", 13, 13, 13 },
+{ "gray6", 15, 15, 15 },
+{ "grey6", 15, 15, 15 },
+{ "gray7", 18, 18, 18 },
+{ "grey7", 18, 18, 18 },
+{ "gray8", 20, 20, 20 },
+{ "grey8", 20, 20, 20 },
+{ "gray9", 23, 23, 23 },
+{ "grey9", 23, 23, 23 },
+{ "gray10", 26, 26, 26 },
+{ "grey10", 26, 26, 26 },
+{ "gray11", 28, 28, 28 },
+{ "grey11", 28, 28, 28 },
+{ "gray12", 31, 31, 31 },
+{ "grey12", 31, 31, 31 },
+{ "gray13", 33, 33, 33 },
+{ "grey13", 33, 33, 33 },
+{ "gray14", 36, 36, 36 },
+{ "grey14", 36, 36, 36 },
+{ "gray15", 38, 38, 38 },
+{ "grey15", 38, 38, 38 },
+{ "gray16", 41, 41, 41 },
+{ "grey16", 41, 41, 41 },
+{ "gray17", 43, 43, 43 },
+{ "grey17", 43, 43, 43 },
+{ "gray18", 46, 46, 46 },
+{ "grey18", 46, 46, 46 },
+{ "gray19", 48, 48, 48 },
+{ "grey19", 48, 48, 48 },
+{ "gray20", 51, 51, 51 },
+{ "grey20", 51, 51, 51 },
+{ "gray21", 54, 54, 54 },
+{ "grey21", 54, 54, 54 },
+{ "gray22", 56, 56, 56 },
+{ "grey22", 56, 56, 56 },
+{ "gray23", 59, 59, 59 },
+{ "grey23", 59, 59, 59 },
+{ "gray24", 61, 61, 61 },
+{ "grey24", 61, 61, 61 },
+{ "gray25", 64, 64, 64 },
+{ "grey25", 64, 64, 64 },
+{ "gray26", 66, 66, 66 },
+{ "grey26", 66, 66, 66 },
+{ "gray27", 69, 69, 69 },
+{ "grey27", 69, 69, 69 },
+{ "gray28", 71, 71, 71 },
+{ "grey28", 71, 71, 71 },
+{ "gray29", 74, 74, 74 },
+{ "grey29", 74, 74, 74 },
+{ "gray30", 77, 77, 77 },
+{ "grey30", 77, 77, 77 },
+{ "gray31", 79, 79, 79 },
+{ "grey31", 79, 79, 79 },
+{ "gray32", 82, 82, 82 },
+{ "grey32", 82, 82, 82 },
+{ "gray33", 84, 84, 84 },
+{ "grey33", 84, 84, 84 },
+{ "gray34", 87, 87, 87 },
+{ "grey34", 87, 87, 87 },
+{ "gray35", 89, 89, 89 },
+{ "grey35", 89, 89, 89 },
+{ "gray36", 92, 92, 92 },
+{ "grey36", 92, 92, 92 },
+{ "gray37", 94, 94, 94 },
+{ "grey37", 94, 94, 94 },
+{ "gray38", 97, 97, 97 },
+{ "grey38", 97, 97, 97 },
+{ "gray39", 99, 99, 99 },
+{ "grey39", 99, 99, 99 },
+{ "gray40", 102, 102, 102 },
+{ "grey40", 102, 102, 102 },
+{ "gray41", 105, 105, 105 },
+{ "grey41", 105, 105, 105 },
+{ "gray42", 107, 107, 107 },
+{ "grey42", 107, 107, 107 },
+{ "gray43", 110, 110, 110 },
+{ "grey43", 110, 110, 110 },
+{ "gray44", 112, 112, 112 },
+{ "grey44", 112, 112, 112 },
+{ "gray45", 115, 115, 115 },
+{ "grey45", 115, 115, 115 },
+{ "gray46", 117, 117, 117 },
+{ "grey46", 117, 117, 117 },
+{ "gray47", 120, 120, 120 },
+{ "grey47", 120, 120, 120 },
+{ "gray48", 122, 122, 122 },
+{ "grey48", 122, 122, 122 },
+{ "gray49", 125, 125, 125 },
+{ "grey49", 125, 125, 125 },
+{ "gray50", 127, 127, 127 },
+{ "grey50", 127, 127, 127 },
+{ "gray51", 130, 130, 130 },
+{ "grey51", 130, 130, 130 },
+{ "gray52", 133, 133, 133 },
+{ "grey52", 133, 133, 133 },
+{ "gray53", 135, 135, 135 },
+{ "grey53", 135, 135, 135 },
+{ "gray54", 138, 138, 138 },
+{ "grey54", 138, 138, 138 },
+{ "gray55", 140, 140, 140 },
+{ "grey55", 140, 140, 140 },
+{ "gray56", 143, 143, 143 },
+{ "grey56", 143, 143, 143 },
+{ "gray57", 145, 145, 145 },
+{ "grey57", 145, 145, 145 },
+{ "gray58", 148, 148, 148 },
+{ "grey58", 148, 148, 148 },
+{ "gray59", 150, 150, 150 },
+{ "grey59", 150, 150, 150 },
+{ "gray60", 153, 153, 153 },
+{ "grey60", 153, 153, 153 },
+{ "gray61", 156, 156, 156 },
+{ "grey61", 156, 156, 156 },
+{ "gray62", 158, 158, 158 },
+{ "grey62", 158, 158, 158 },
+{ "gray63", 161, 161, 161 },
+{ "grey63", 161, 161, 161 },
+{ "gray64", 163, 163, 163 },
+{ "grey64", 163, 163, 163 },
+{ "gray65", 166, 166, 166 },
+{ "grey65", 166, 166, 166 },
+{ "gray66", 168, 168, 168 },
+{ "grey66", 168, 168, 168 },
+{ "gray67", 171, 171, 171 },
+{ "grey67", 171, 171, 171 },
+{ "gray68", 173, 173, 173 },
+{ "grey68", 173, 173, 173 },
+{ "gray69", 176, 176, 176 },
+{ "grey69", 176, 176, 176 },
+{ "gray70", 179, 179, 179 },
+{ "grey70", 179, 179, 179 },
+{ "gray71", 181, 181, 181 },
+{ "grey71", 181, 181, 181 },
+{ "gray72", 184, 184, 184 },
+{ "grey72", 184, 184, 184 },
+{ "gray73", 186, 186, 186 },
+{ "grey73", 186, 186, 186 },
+{ "gray74", 189, 189, 189 },
+{ "grey74", 189, 189, 189 },
+{ "gray75", 191, 191, 191 },
+{ "grey75", 191, 191, 191 },
+{ "gray76", 194, 194, 194 },
+{ "grey76", 194, 194, 194 },
+{ "gray77", 196, 196, 196 },
+{ "grey77", 196, 196, 196 },
+{ "gray78", 199, 199, 199 },
+{ "grey78", 199, 199, 199 },
+{ "gray79", 201, 201, 201 },
+{ "grey79", 201, 201, 201 },
+{ "gray80", 204, 204, 204 },
+{ "grey80", 204, 204, 204 },
+{ "gray81", 207, 207, 207 },
+{ "grey81", 207, 207, 207 },
+{ "gray82", 209, 209, 209 },
+{ "grey82", 209, 209, 209 },
+{ "gray83", 212, 212, 212 },
+{ "grey83", 212, 212, 212 },
+{ "gray84", 214, 214, 214 },
+{ "grey84", 214, 214, 214 },
+{ "gray85", 217, 217, 217 },
+{ "grey85", 217, 217, 217 },
+{ "gray86", 219, 219, 219 },
+{ "grey86", 219, 219, 219 },
+{ "gray87", 222, 222, 222 },
+{ "grey87", 222, 222, 222 },
+{ "gray88", 224, 224, 224 },
+{ "grey88", 224, 224, 224 },
+{ "gray89", 227, 227, 227 },
+{ "grey89", 227, 227, 227 },
+{ "gray90", 229, 229, 229 },
+{ "grey90", 229, 229, 229 },
+{ "gray91", 232, 232, 232 },
+{ "grey91", 232, 232, 232 },
+{ "gray92", 235, 235, 235 },
+{ "grey92", 235, 235, 235 },
+{ "gray93", 237, 237, 237 },
+{ "grey93", 237, 237, 237 },
+{ "gray94", 240, 240, 240 },
+{ "grey94", 240, 240, 240 },
+{ "gray95", 242, 242, 242 },
+{ "grey95", 242, 242, 242 },
+{ "gray96", 245, 245, 245 },
+{ "grey96", 245, 245, 245 },
+{ "gray97", 247, 247, 247 },
+{ "grey97", 247, 247, 247 },
+{ "gray98", 250, 250, 250 },
+{ "grey98", 250, 250, 250 },
+{ "gray99", 252, 252, 252 },
+{ "grey99", 252, 252, 252 },
+{ "gray100", 255, 255, 255 },
+{ "grey100", 255, 255, 255 },
+{ "DarkGrey", 169, 169, 169 },
+{ "DarkGray", 169, 169, 169 },
+{ "DarkBlue", 0, 0, 139 },
+{ "DarkCyan", 0, 139, 139 },
+{ "DarkMagenta", 139, 0, 139 },
+{ "DarkRed", 139, 0, 0 },
+{ "LightGreen", 144, 238, 144 },
+{ NULL, 0 , 0, 0}
+};
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/ixpm/svt_xpmread.cxx b/binfilter/bf_svtools/source/filter.vcl/ixpm/svt_xpmread.cxx
new file mode 100644
index 000000000000..d037f88a9e4b
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/ixpm/svt_xpmread.cxx
@@ -0,0 +1,698 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <vcl/bmpacc.hxx>
+#include <vcl/graph.hxx>
+#include "rgbtable.hxx"
+#define _XPMPRIVATE
+#include "xpmread.hxx"
+
+namespace binfilter
+{
+
+// -------------
+// - XPMReader -
+// -------------
+
+XPMReader::XPMReader( SvStream& rStm ) :
+ mrIStm ( rStm ),
+ mpAcc ( NULL ),
+ mpMaskAcc ( NULL ),
+ mnLastPos ( rStm.Tell() ),
+ mnWidth ( 0 ),
+ mnHeight ( 0 ),
+ mnColors ( 0 ),
+ mnCpp ( 0 ),
+ mbTransparent ( FALSE ),
+ mbStatus ( TRUE ),
+ mnStatus ( 0 ),
+ mnIdentifier ( XPMIDENTIFIER ),
+ mcThisByte ( 0 ),
+ mnTempAvail ( 0 ),
+ mpFastColorTable( NULL ),
+ mpColMap ( NULL )
+{
+
+}
+
+// ------------------------------------------------------------------------
+
+XPMReader::~XPMReader()
+{
+ if( mpAcc )
+ maBmp.ReleaseAccess( mpAcc );
+}
+
+// ------------------------------------------------------------------------
+
+#ifdef _MSC_VER
+#pragma optimize ("",off)
+#endif
+
+ReadState XPMReader::ReadXPM( Graphic& rGraphic )
+{
+ ReadState eReadState;
+ BYTE cDummy;
+
+ // sehen, ob wir _alles_ lesen koennen
+ mrIStm.Seek( STREAM_SEEK_TO_END );
+ mrIStm >> cDummy;
+
+ // falls wir nicht alles lesen koennen
+ // kehren wir zurueck und warten auf neue Daten
+ if ( mrIStm.GetError() != ERRCODE_IO_PENDING )
+ {
+ mrIStm.Seek( mnLastPos );
+ mbStatus = TRUE;
+
+ if ( mbStatus )
+ {
+ mpStringBuf = new BYTE [ XPMSTRINGBUF ];
+ mpTempBuf = new BYTE [ XPMTEMPBUFSIZE ];
+
+ if ( ( mbStatus = ImplGetString() ) == TRUE )
+ {
+ mnIdentifier = XPMVALUES; // Bitmap informationen einholen
+ mnWidth = ImplGetULONG( 0 );
+ mnHeight = ImplGetULONG( 1 );
+ mnColors = ImplGetULONG( 2 );
+ mnCpp = ImplGetULONG( 3 );
+ }
+ if ( mbStatus && mnWidth && mnHeight && mnColors && mnCpp )
+ {
+ mnIdentifier = XPMCOLORS;
+
+ // mpColMap beinhaltet fuer jede vorhandene
+ // Farbe: ( mnCpp )Byte(s)-> ASCII Eintrag der der Farbe zugeordnet ist
+ // 1 Byte -> 0xff wenn Farbe transparent ist
+ // 3 Bytes -> RGB Wert der Farbe
+ mpColMap = new BYTE[ mnColors * ( 4 + mnCpp ) ];
+
+ for ( ULONG i = 0; i < mnColors; i++ )
+ {
+ if ( ImplGetColor( i ) == FALSE )
+ {
+ mbStatus = FALSE;
+ break;
+ }
+ }
+ if ( mbStatus )
+ {
+ // bei mehr als 256 Farben wird eine 24 Bit Grafik erstellt
+ sal_uInt16 nBits = 1;
+ if ( mnColors > 256 )
+ nBits = 24;
+ else if ( mnColors > 16 )
+ nBits = 8;
+ else if ( mnColors > 4 )
+ nBits = 4;
+ else if ( mnColors > 2 )
+ nBits = 2;
+ else
+ nBits = 1;
+
+ maBmp = Bitmap( Size( mnWidth, mnHeight ), nBits );
+ mpAcc = maBmp.AcquireWriteAccess();
+
+ // mbTransparent ist TRUE wenn mindestens eine Farbe Transparent ist
+ if ( mbTransparent )
+ {
+ maMaskBmp = Bitmap( Size( mnWidth, mnHeight ), 1 );
+ if ( ( mpMaskAcc = maMaskBmp.AcquireWriteAccess() ) == NULL )
+ mbStatus = FALSE;
+ }
+ if( mpAcc && mbStatus )
+ {
+ ULONG i;
+ if ( mnColors <=256 ) // palette is only needed by using less than 257
+ { // colors
+
+ BYTE* pPtr = &mpColMap[mnCpp];
+
+ for ( i = 0; i < mnColors; i++ )
+ {
+ mpAcc->SetPaletteColor( (BYTE)i, Color( pPtr[1], pPtr[2], pPtr[3] ) );
+ pPtr += ( mnCpp + 4 );
+ }
+ // using 2 charakters per pixel and less than 257 Colors we speed up
+ if ( mnCpp == 2 ) // by using a 64kb indexing table
+ {
+ mpFastColorTable = new BYTE[ 256 * 256 ];
+ for ( pPtr = mpColMap, i = 0; i < mnColors; i++, pPtr += mnCpp + 4 )
+ {
+ ULONG j = pPtr[ 0 ] << 8;
+ j += pPtr[ 1 ];
+ mpFastColorTable[ j ] = (BYTE)i;
+ }
+ }
+ }
+ // now we get the bitmap data
+ mnIdentifier = XPMPIXELS;
+ for ( i = 0; i < mnHeight; i++ )
+ {
+ if ( ImplGetScanLine( i ) == FALSE )
+ {
+ mbStatus = FALSE;
+ break;
+ }
+ }
+ mnIdentifier = XPMEXTENSIONS;
+ }
+ }
+ }
+
+ delete[] mpFastColorTable;
+ delete[] mpColMap;
+ delete[] mpStringBuf;
+ delete[] mpTempBuf;
+
+ }
+ if( mbStatus )
+ {
+ if ( mpMaskAcc )
+ {
+ maMaskBmp.ReleaseAccess ( mpMaskAcc), mpMaskAcc = NULL;
+ maBmp.ReleaseAccess( mpAcc ), mpAcc = NULL;
+ rGraphic = Graphic( BitmapEx( maBmp, maMaskBmp ) );
+ }
+ else
+ {
+ maBmp.ReleaseAccess( mpAcc ), mpAcc = NULL;
+ rGraphic = maBmp;
+ }
+ eReadState = XPMREAD_OK;
+ }
+ else
+ {
+ if ( mpMaskAcc ) maMaskBmp.ReleaseAccess ( mpMaskAcc), mpMaskAcc = NULL;
+ if ( mpAcc ) maBmp.ReleaseAccess( mpAcc ), mpAcc = NULL;
+ eReadState = XPMREAD_ERROR;
+ }
+ }
+ else
+ {
+ mrIStm.ResetError();
+ eReadState = XPMREAD_NEED_MORE;
+ }
+ return eReadState;
+}
+
+#ifdef _MSC_VER
+#pragma optimize ("",on)
+#endif
+
+// ------------------------------------------------------------------------
+// ImplGetColor ermittelt saemtliche Farbwerte,
+// die Rueckgabe ist TRUE wenn saemtliche Farben zugeordnet werden konnten
+
+BOOL XPMReader::ImplGetColor( ULONG nNumb )
+{
+ BYTE* pString = mpStringBuf;
+ BYTE* pPtr = ( mpColMap + nNumb * ( 4 + mnCpp ) );
+ BOOL bStatus = ImplGetString();
+
+ if ( bStatus )
+ {
+ for ( ULONG i = 0; i < mnCpp; i++ )
+ *pPtr++ = *pString++;
+ bStatus = ImplGetColSub ( pPtr );
+ }
+ return bStatus;
+}
+
+// ------------------------------------------------------------------------
+// ImpGetScanLine liest den String mpBufSize aus und schreibt die Pixel in die
+// Bitmap. Der Parameter nY gibt die horizontale Position an.
+
+BOOL XPMReader::ImplGetScanLine( ULONG nY )
+{
+ BOOL bStatus = ImplGetString();
+ BYTE* pString = mpStringBuf;
+ BYTE* pColor;
+ BitmapColor aWhite;
+ BitmapColor aBlack;
+
+ if ( bStatus )
+ {
+ if ( mpMaskAcc )
+ {
+ aWhite = mpMaskAcc->GetBestMatchingColor( Color( COL_WHITE ) );
+ aBlack = mpMaskAcc->GetBestMatchingColor( Color( COL_BLACK ) );
+ }
+ if ( mnStringSize != ( mnWidth * mnCpp ))
+ bStatus = FALSE;
+ else
+ {
+ ULONG i, j;
+ if ( mpFastColorTable )
+ {
+ for ( i = 0; i < mnWidth; i++ )
+ {
+ j = (*pString++) << 8;
+ j += *pString++;
+ BYTE k = (BYTE)mpFastColorTable[ j ];
+ mpAcc->SetPixel( nY, i, BitmapColor( (BYTE)k ) );
+
+ if ( mpMaskAcc )
+ mpMaskAcc->SetPixel( nY, i,
+ ( mpColMap[ k * (mnCpp + 4) + mnCpp] ) ? aWhite : aBlack );
+ }
+ }
+ else for ( i = 0; i < mnWidth; i++ )
+ {
+ pColor = mpColMap;
+ for ( j = 0; j < mnColors; j++ )
+ {
+ if ( ImplCompare( pString, pColor, mnCpp, XPMCASESENSITIVE ) == TRUE )
+ {
+ if ( mnColors > 256 )
+ mpAcc->SetPixel( nY, i, Color ( pColor[3], pColor[4], pColor[5] ) );
+ else
+ mpAcc->SetPixel( nY, i, BitmapColor( (BYTE) j ) );
+
+ if ( mpMaskAcc )
+ mpMaskAcc->SetPixel( nY, i, (
+ pColor[ mnCpp ] ) ? aWhite : aBlack );
+
+ break;
+ }
+ pColor += ( mnCpp + 4 );
+ }
+ pString += mnCpp;
+ }
+
+ }
+ }
+ return bStatus;
+}
+
+// ------------------------------------------------------------------------
+// versucht aus mpStringBuf einen Farbwert zu uebermitteln
+// wurde eine Farbe gefunden wird an pDest[1]..pDest[2] der RGB wert geschrieben
+// pDest[0] enthaelt 0xff wenn die Farbe transparent ist sonst 0
+
+BOOL XPMReader::ImplGetColSub( BYTE* pDest )
+{
+ unsigned char cTransparent[] = "None";
+
+ BOOL bColStatus = FALSE;
+
+ if ( ImplGetColKey( 'c' ) || ImplGetColKey( 'm' ) || ImplGetColKey( 'g' ) )
+ {
+ // hexentry for RGB or HSV color ?
+ if ( *mpPara == '#' )
+ {
+ *pDest++ = 0;
+ bColStatus = TRUE;
+ switch ( mnParaSize )
+ {
+ case 25 :
+ ImplGetRGBHex ( pDest, 6 );
+ break;
+ case 13 :
+ ImplGetRGBHex ( pDest, 2 );
+ break;
+ case 7 :
+ ImplGetRGBHex ( pDest, 0 );
+ break;
+ default:
+ bColStatus = FALSE;
+ break;
+ }
+ }
+ // maybe pixel is transparent
+ else if ( ImplCompare( &cTransparent[0], mpPara, 4 ))
+ {
+ *pDest++ = 0xff;
+ bColStatus = TRUE;
+ mbTransparent = TRUE;
+ }
+ // last we will try to get the colorname
+ else if ( mnParaSize > 2 ) // name must enlarge the minimum size
+ {
+ ULONG i = 0;
+ while ( TRUE )
+ {
+ if ( pRGBTable[ i ].name == NULL )
+ break;
+ if ( pRGBTable[ i ].name[ mnParaSize ] == 0 )
+ {
+ if ( ImplCompare ( (unsigned char*)pRGBTable[ i ].name,
+ mpPara, mnParaSize, XPMCASENONSENSITIVE ) )
+ {
+ bColStatus = TRUE;
+ *pDest++ = 0;
+ *pDest++ = pRGBTable[ i ].red;
+ *pDest++ = pRGBTable[ i ].green;
+ *pDest++ = pRGBTable[ i ].blue;
+ }
+ }
+ i++;
+ }
+ }
+ }
+ return bColStatus;
+}
+
+// ------------------------------------------------------------------------
+// ImplGetColKey durchsuch den String mpStringBuf nach einem Parameter 'nKey'
+// und gibt einen BOOL zurueck. ( wenn TRUE werden mpPara und mnParaSize gesetzt )
+
+BOOL XPMReader::ImplGetColKey( BYTE nKey )
+{
+ BYTE nTemp, nPrev = ' ';
+
+ mpPara = mpStringBuf + mnCpp + 1;
+ mnParaSize = 0;
+
+ while ( *mpPara != 0 )
+ {
+ if ( *mpPara == nKey )
+ {
+ nTemp = *( mpPara + 1 );
+ if ( nTemp == ' ' || nTemp == 0x09 )
+ {
+ if ( nPrev == ' ' || nPrev == 0x09 )
+ break;
+ }
+ }
+ nPrev = *mpPara;
+ mpPara++;
+ }
+ if ( *mpPara )
+ {
+ mpPara++;
+ while ( (*mpPara == ' ') || (*mpPara == 0x09) )
+ {
+ mpPara++;
+ }
+ if ( *mpPara != 0 )
+ {
+ while ( *(mpPara+mnParaSize) != ' ' && *(mpPara+mnParaSize) != 0x09 &&
+ *(mpPara+mnParaSize) != 0 )
+ {
+ mnParaSize++;
+ }
+ }
+ }
+ return ( mnParaSize ) ? TRUE : FALSE;
+}
+
+// ------------------------------------------------------------------------
+// ImplGetRGBHex uebersetzt den ASCII-Hexadezimalwert der sich bei mpPara befindet
+// in einen RGB wert und schreibt diesen nach pDest
+// folgende Formate muessen sich bei mpPara befinden:
+// wenn nAdd = 0 : '#12ab12' -> RGB = 0x12, 0xab, 0x12
+// 2 : '#1234abcd1234' " " " "
+// 6 : '#12345678abcdefab12345678' " " " "
+
+
+void XPMReader::ImplGetRGBHex( BYTE* pDest,ULONG nAdd )
+{
+ BYTE* pPtr = mpPara+1;
+ BYTE nHex, nTemp;
+
+ for ( ULONG i = 0; i < 3; i++ )
+ {
+ nHex = (*pPtr++) - '0';
+ if ( nHex > 9 )
+ nHex = ((nHex - 'A' + '0') & 7) + 10;
+
+ nTemp = (*pPtr++) - '0';
+ if ( nTemp > 9 )
+ nTemp = ((nTemp - 'A' + '0') & 7) + 10;
+ nHex = ( nHex << 4 ) + nTemp;
+
+ pPtr += nAdd;
+ *pDest++ = (BYTE)nHex;
+ }
+}
+
+// ------------------------------------------------------------------------
+// ImplGetUlong gibt den wert einer bis zu 6stelligen ASCII-Dezimalzahl zurueck.
+
+ULONG XPMReader::ImplGetULONG( ULONG nPara )
+{
+ if ( ImplGetPara ( nPara ) )
+ {
+ ULONG nRetValue = 0;
+ BYTE* pPtr = mpPara;
+
+ if ( ( mnParaSize > 6 ) || ( mnParaSize == 0 ) ) return 0;
+ for ( ULONG i = 0; i < mnParaSize; i++ )
+ {
+ BYTE j = (*pPtr++) - 48;
+ if ( j > 9 ) return 0; // ascii is invalid
+ nRetValue*=10;
+ nRetValue+=j;
+ }
+ return nRetValue;
+ }
+ else return 0;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL XPMReader::ImplCompare( BYTE* pSource, BYTE* pDest, ULONG nSize, ULONG nMode )
+{
+ BOOL bRet = TRUE;
+
+ if ( nMode == XPMCASENONSENSITIVE )
+ {
+ for ( ULONG i = 0; i < nSize; i++ )
+ {
+ if ( ( pSource[i]&~0x20 ) != ( pDest[i]&~0x20 ) )
+ {
+ bRet = FALSE;
+ break;
+ }
+ }
+ }
+ else
+ {
+ for ( ULONG i = 0; i < nSize; i++ )
+ {
+ if ( pSource[i] != pDest[i] )
+ {
+ bRet = FALSE;
+ break;
+ }
+ }
+ }
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+// ImplGetPara versucht den nNumb ( 0...x ) Parameter aus mpStringBuf zu ermitteln.
+// Ein Parameter ist durch Spaces oder Tabs von den anderen getrennt.
+// Konnte der Parameter gefunden werden ist der Rueckgabewert TRUE und mpPara + mnParaSize
+// werden gesetzt.
+
+BOOL XPMReader::ImplGetPara ( ULONG nNumb )
+{
+ BYTE nByte;
+ ULONG pSize = 0;
+ BYTE* pPtr = mpStringBuf;
+ ULONG nCount = 0;
+
+ if ( ( *pPtr != ' ' ) && ( *pPtr != 0x09 ) )
+ {
+ mpPara = pPtr;
+ mnParaSize = 0;
+ nCount = 0;
+ }
+ else
+ {
+ mpPara = NULL;
+ nCount = 0xffffffff;
+ }
+
+ while ( pSize < mnStringSize )
+ {
+ nByte = *pPtr;
+
+ if ( mpPara )
+ {
+ if ( ( nByte == ' ' ) || ( nByte == 0x09 ) )
+ {
+ if ( nCount == nNumb )
+ break;
+ else
+ mpPara = NULL;
+ }
+ else
+ mnParaSize++;
+ }
+ else
+ {
+ if ( ( nByte != ' ' ) && ( nByte != 0x09 ) )
+ {
+ mpPara = pPtr;
+ mnParaSize = 1;
+ nCount++;
+ }
+ }
+ pSize++;
+ pPtr++;
+ }
+ return ( ( nCount == nNumb ) && ( mpPara ) ) ? TRUE : FALSE;
+}
+
+// ------------------------------------------------------------------------
+// Der naechste String wird ausgelesen und in mpStringBuf (mit 0 abgeschlossen) abgelegt;
+// mnStringSize enthaelt die Groesse des gelesenen Strings.
+// Bemerkungen wie '//' und '/*.....*/' werden uebersprungen.
+
+BOOL XPMReader::ImplGetString( void )
+{
+ BYTE sID[] = "/* XPM */";
+ BYTE* pString = mpStringBuf;
+
+ mnStringSize = 0;
+ mpStringBuf[0] = 0;
+
+ while( mbStatus && ( mnStatus != XPMFINISHED ) )
+ {
+ if ( mnTempAvail == 0 )
+ {
+ mnTempAvail = mrIStm.Read( mpTempBuf, XPMTEMPBUFSIZE );
+ if ( mnTempAvail == 0 )
+ break;
+
+ mpTempPtr = mpTempBuf;
+
+ if ( mnIdentifier == XPMIDENTIFIER )
+ {
+ if ( mnTempAvail <= 50 )
+ {
+ mbStatus = FALSE; // file is too short to be a correct XPM format
+ break;
+ }
+ for ( int i = 0; i < 9; i++ ) // searching for "/* XPM */"
+ if ( *mpTempPtr++ != sID[i] )
+ {
+ mbStatus = FALSE;
+ break;
+ }
+ mnTempAvail-=9;
+ mnIdentifier++;
+ }
+ }
+ mcLastByte = mcThisByte;
+ mcThisByte = *mpTempPtr++;
+ mnTempAvail--;
+
+ if ( mnStatus & XPMDOUBLE )
+ {
+ if ( mcThisByte == 0x0a )
+ mnStatus &=~XPMDOUBLE;
+ continue;
+ }
+ if ( mnStatus & XPMREMARK )
+ {
+ if ( ( mcThisByte == '/' ) && ( mcLastByte == '*' ) )
+ mnStatus &=~XPMREMARK;
+ continue;
+ }
+ if ( mnStatus & XPMSTRING ) // characters in string
+ {
+ if ( mcThisByte == '"' )
+ {
+ mnStatus &=~XPMSTRING; // end of parameter by eol
+ break;
+ }
+ if ( mnStringSize >= XPMSTRINGBUF )
+ {
+ mbStatus = FALSE;
+ break;
+ }
+ *pString++ = mcThisByte;
+ pString[0] = 0;
+ mnStringSize++;
+ continue;
+ }
+ else
+ { // characters beside string
+ switch ( mcThisByte )
+ {
+ case '*' :
+ if ( mcLastByte == '/' ) mnStatus |= XPMREMARK;
+ break;
+ case '/' :
+ if ( mcLastByte == '/' ) mnStatus |= XPMDOUBLE;
+ break;
+ case '"' : mnStatus |= XPMSTRING;
+ break;
+ case '{' :
+ if ( mnIdentifier == XPMDEFINITION )
+ mnIdentifier++;
+ break;
+ case '}' :
+ if ( mnIdentifier == XPMENDEXT )
+ mnStatus = XPMFINISHED;
+ break;
+ }
+ }
+ }
+ return mbStatus;
+}
+
+// -------------
+// - ImportXPM -
+// -------------
+
+BOOL ImportXPM( SvStream& rStm, Graphic& rGraphic )
+{
+ XPMReader* pXPMReader = (XPMReader*) rGraphic.GetContext();
+ ReadState eReadState;
+ BOOL bRet = TRUE;
+
+ if( !pXPMReader )
+ pXPMReader = new XPMReader( rStm );
+
+ rGraphic.SetContext( NULL );
+ eReadState = pXPMReader->ReadXPM( rGraphic );
+
+ if( eReadState == XPMREAD_ERROR )
+ {
+ bRet = FALSE;
+ delete pXPMReader;
+ }
+ else if( eReadState == XPMREAD_OK )
+ delete pXPMReader;
+ else
+ rGraphic.SetContext( pXPMReader );
+
+ return bRet;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/jpeg/jpeg.h b/binfilter/bf_svtools/source/filter.vcl/jpeg/jpeg.h
new file mode 100644
index 000000000000..f4caabd28ec9
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/jpeg/jpeg.h
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 _JPEG_H
+#define _JPEG_H
+
+#if defined( ICC )
+#include <stdio.h>
+#endif
+
+#if defined (UNX) || defined(__MINGW32__)
+#include <sys/types.h>
+#endif
+
+struct JPEGCreateBitmapParam
+{
+ unsigned long nWidth;
+ unsigned long nHeight;
+ unsigned long density_unit;
+ unsigned long X_density;
+ unsigned long Y_density;
+ long bGray;
+
+ long nAlignedWidth; // these members will be filled by the
+ long bTopDown; // CreateBitmap method in svtools
+};
+
+typedef struct my_error_mgr* my_error_ptr;
+typedef unsigned char BYTE;
+#ifdef WIN
+typedef unsigned char _huge* HPBYTE;
+#else
+typedef unsigned char* HPBYTE;
+#endif
+
+void* JPEGMalloc( size_t size );
+void JPEGFree( void *ptr );
+long JPEGCallback( void* pCallbackData, long nPercent );
+
+long WriteJPEG( void* pJPEGWriter, void* pOStm, long nWidth, long nHeight,
+ long nQualityPercent, void* pCallbackData );
+void* GetScanline( void* pJPEGWriter, long nY );
+
+void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines );
+void* CreateBitmap( void* pJPEGReader, void* pJPEGCreateBitmapParam );
+
+/* TODO: when incompatible changes are possible again
+ the preview size hint should be redone */
+void SetJpegPreviewSizeHint( int nWidth, int nHeight );
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/jpeg/makefile.mk b/binfilter/bf_svtools/source/filter.vcl/jpeg/makefile.mk
new file mode 100644
index 000000000000..522454dc71d1
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/jpeg/makefile.mk
@@ -0,0 +1,43 @@
+#*************************************************************************
+#
+# DO NOT ALTER 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=binfilter
+TARGET=jpeg
+
+# --- Settings -----------------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= $(SLO)$/svt_jpegc.obj \
+ $(SLO)$/svt_jpeg.obj
+
+.INCLUDE : target.mk
diff --git a/binfilter/bf_svtools/source/filter.vcl/jpeg/svt_jpeg.cxx b/binfilter/bf_svtools/source/filter.vcl/jpeg/svt_jpeg.cxx
new file mode 100644
index 000000000000..5ef7b3f056df
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/jpeg/svt_jpeg.cxx
@@ -0,0 +1,754 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/solar.h>
+
+extern "C"
+{
+ #define INT32 JPEG_INT32
+ #include "stdio.h"
+ #include "jpeg.h"
+ #include "jpeglib.h"
+ #include "jerror.h"
+ #undef INT32
+}
+
+#define _JPEGPRIVATE
+#include <vcl/bmpacc.hxx>
+#include "jpeg.hxx"
+#include <bf_svtools/FilterConfigItem.hxx>
+#include <bf_svtools/filter.hxx>
+
+// -----------
+// - Defines -
+// -----------
+
+using namespace ::com::sun::star;
+
+namespace binfilter
+{
+
+#define JPEGMINREAD 512
+
+// -------------
+// - (C-Calls) -
+// -------------
+
+// ------------------------------------------------------------------------
+
+extern "C" void* CreateBitmap( void* pJPEGReader, void* pJPEGCreateBitmapParam )
+{
+ return ( (JPEGReader*) pJPEGReader )->CreateBitmap( pJPEGCreateBitmapParam );
+}
+
+// ------------------------------------------------------------------------
+
+extern "C" void* GetScanline( void* pJPEGWriter, long nY )
+{
+ return ( (JPEGWriter*) pJPEGWriter )->GetScanline( nY );
+}
+
+// ------------------------------------------------------------------------
+
+struct JPEGCallbackStruct
+{
+ uno::Reference< task::XStatusIndicator > xStatusIndicator;
+};
+
+extern "C" long JPEGCallback( void* pCallbackData, long nPercent )
+{
+ JPEGCallbackStruct* pS = (JPEGCallbackStruct*)pCallbackData;
+ if ( pS && pS->xStatusIndicator.is() )
+ {
+ pS->xStatusIndicator->setValue( nPercent );
+ }
+ return 0L;
+}
+
+#define BUF_SIZE 4096
+
+typedef struct
+{
+ struct jpeg_destination_mgr pub; /* public fields */
+
+ SvStream* outfile; /* target stream */
+ JOCTET * buffer; /* start of buffer */
+} my_destination_mgr;
+
+typedef my_destination_mgr * my_dest_ptr;
+
+extern "C" void init_destination (j_compress_ptr cinfo)
+{
+ my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
+
+ /* Allocate the output buffer --- it will be released when done with image */
+ dest->buffer = (JOCTET *)
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
+ BUF_SIZE * sizeof(JOCTET));
+
+ dest->pub.next_output_byte = dest->buffer;
+ dest->pub.free_in_buffer = BUF_SIZE;
+}
+
+extern "C" int empty_output_buffer (j_compress_ptr cinfo)
+{
+ my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
+
+ if (dest->outfile->Write(dest->buffer, BUF_SIZE) !=
+ (size_t) BUF_SIZE)
+ ERREXIT(cinfo, JERR_FILE_WRITE);
+
+ dest->pub.next_output_byte = dest->buffer;
+ dest->pub.free_in_buffer = BUF_SIZE;
+
+ return TRUE;
+}
+
+extern "C" void term_destination (j_compress_ptr cinfo)
+{
+ my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
+ size_t datacount = BUF_SIZE - dest->pub.free_in_buffer;
+
+ /* Write any data remaining in the buffer */
+ if (datacount > 0) {
+ if (dest->outfile->Write(dest->buffer, datacount) != datacount)
+ ERREXIT(cinfo, JERR_FILE_WRITE);
+ }
+}
+
+extern "C" void jpeg_svstream_dest (j_compress_ptr cinfo, void* out)
+{
+ SvStream * outfile = (SvStream*)out;
+ my_dest_ptr dest;
+
+ /* The destination object is made permanent so that multiple JPEG images
+ * can be written to the same file without re-executing jpeg_svstream_dest.
+ * This makes it dangerous to use this manager and a different destination
+ * manager serially with the same JPEG object, because their private object
+ * sizes may be different. Caveat programmer.
+ */
+ if (cinfo->dest == NULL) { /* first time for this JPEG object? */
+ cinfo->dest = (struct jpeg_destination_mgr *)
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
+ sizeof(my_destination_mgr));
+ }
+
+ dest = (my_dest_ptr) cinfo->dest;
+ dest->pub.init_destination = init_destination;
+ dest->pub.empty_output_buffer = empty_output_buffer;
+ dest->pub.term_destination = term_destination;
+ dest->outfile = outfile;
+}
+
+/* Expanded data source object for stdio input */
+
+typedef struct {
+ struct jpeg_source_mgr pub; /* public fields */
+
+ SvStream * infile; /* source stream */
+ JOCTET * buffer; /* start of buffer */
+ boolean start_of_file; /* have we gotten any data yet? */
+} my_source_mgr;
+
+typedef my_source_mgr * my_src_ptr;
+
+/*
+ * Initialize source --- called by jpeg_read_header
+ * before any data is actually read.
+ */
+
+extern "C" void init_source (j_decompress_ptr cinfo)
+{
+ my_src_ptr src = (my_src_ptr) cinfo->src;
+
+ /* We reset the empty-input-file flag for each image,
+ * but we don't clear the input buffer.
+ * This is correct behavior for reading a series of images from one source.
+ */
+ src->start_of_file = TRUE;
+}
+
+long StreamRead( SvStream* pSvStm, void* pBuffer, long nBufferSize )
+{
+ long nRead;
+
+ if( pSvStm->GetError() != ERRCODE_IO_PENDING )
+ {
+ long nActPos = pSvStm->Tell();
+
+ nRead = (long) pSvStm->Read( pBuffer, nBufferSize );
+
+ if( pSvStm->GetError() == ERRCODE_IO_PENDING )
+ {
+ nRead = 0;
+
+ // Damit wir wieder an die alte Position
+ // seeken koennen, setzen wir den Error temp.zurueck
+ pSvStm->ResetError();
+ pSvStm->Seek( nActPos );
+ pSvStm->SetError( ERRCODE_IO_PENDING );
+ }
+ }
+ else
+ nRead = 0;
+
+ return nRead;
+}
+
+extern "C" int fill_input_buffer (j_decompress_ptr cinfo)
+{
+ my_src_ptr src = (my_src_ptr) cinfo->src;
+ size_t nbytes;
+
+ nbytes = StreamRead(src->infile, src->buffer, BUF_SIZE);
+
+ if (nbytes <= 0) {
+ if (src->start_of_file) /* Treat empty input file as fatal error */
+ ERREXIT(cinfo, JERR_INPUT_EMPTY);
+ WARNMS(cinfo, JWRN_JPEG_EOF);
+ /* Insert a fake EOI marker */
+ src->buffer[0] = (JOCTET) 0xFF;
+ src->buffer[1] = (JOCTET) JPEG_EOI;
+ nbytes = 2;
+ }
+
+ src->pub.next_input_byte = src->buffer;
+ src->pub.bytes_in_buffer = nbytes;
+ src->start_of_file = FALSE;
+
+ return TRUE;
+}
+
+extern "C" void skip_input_data (j_decompress_ptr cinfo, long num_bytes)
+{
+ my_src_ptr src = (my_src_ptr) cinfo->src;
+
+ /* Just a dumb implementation for now. Could use fseek() except
+ * it doesn't work on pipes. Not clear that being smart is worth
+ * any trouble anyway --- large skips are infrequent.
+ */
+ if (num_bytes > 0) {
+ while (num_bytes > (long) src->pub.bytes_in_buffer) {
+ num_bytes -= (long) src->pub.bytes_in_buffer;
+ (void) fill_input_buffer(cinfo);
+ /* note we assume that fill_input_buffer will never return FALSE,
+ * so suspension need not be handled.
+ */
+ }
+ src->pub.next_input_byte += (size_t) num_bytes;
+ src->pub.bytes_in_buffer -= (size_t) num_bytes;
+ }
+}
+
+extern "C" void term_source (j_decompress_ptr)
+{
+ /* no work necessary here */
+}
+
+extern "C" void jpeg_svstream_src (j_decompress_ptr cinfo, void * in)
+{
+ my_src_ptr src;
+ SvStream * infile = (SvStream*)in;
+
+ /* The source object and input buffer are made permanent so that a series
+ * of JPEG images can be read from the same file by calling jpeg_stdio_src
+ * only before the first one. (If we discarded the buffer at the end of
+ * one image, we'd likely lose the start of the next one.)
+ * This makes it unsafe to use this manager and a different source
+ * manager serially with the same JPEG object. Caveat programmer.
+ */
+ if (cinfo->src == NULL) { /* first time for this JPEG object? */
+ cinfo->src = (struct jpeg_source_mgr *)
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
+ sizeof(my_source_mgr));
+ src = (my_src_ptr) cinfo->src;
+ src->buffer = (JOCTET *)
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
+ BUF_SIZE * sizeof(JOCTET));
+ }
+
+ src = (my_src_ptr) cinfo->src;
+ src->pub.init_source = init_source;
+ src->pub.fill_input_buffer = fill_input_buffer;
+ src->pub.skip_input_data = skip_input_data;
+ src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */
+ src->pub.term_source = term_source;
+ src->infile = infile;
+ src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */
+ src->pub.next_input_byte = NULL; /* until buffer loaded */
+}
+
+// --------------
+// - JPEGReader -
+// --------------
+
+JPEGReader::JPEGReader( SvStream& rStm, void* /*pCallData*/, sal_Bool bSetLS ) :
+ rIStm ( rStm ),
+ pAcc ( NULL ),
+ pAcc1 ( NULL ),
+ pBuffer ( NULL ),
+ nLastPos ( rStm.Tell() ),
+ nLastLines ( 0 ),
+ bSetLogSize ( bSetLS )
+{
+ maUpperName = String::CreateFromAscii( "SVIJPEG", 7 );
+ nFormerPos = nLastPos;
+}
+
+// ------------------------------------------------------------------------
+
+JPEGReader::~JPEGReader()
+{
+ if( pBuffer )
+ rtl_freeMemory( pBuffer );
+
+ if( pAcc )
+ aBmp.ReleaseAccess( pAcc );
+
+ if( pAcc1 )
+ aBmp1.ReleaseAccess( pAcc1 );
+}
+
+// ------------------------------------------------------------------------
+
+void* JPEGReader::CreateBitmap( void* pParam )
+{
+ Size aSize( ((JPEGCreateBitmapParam*)pParam)->nWidth,
+ ((JPEGCreateBitmapParam*)pParam)->nHeight );
+ sal_Bool bGray = ((JPEGCreateBitmapParam*)pParam)->bGray != 0;
+
+ void* pBmpBuf = NULL;
+
+ if( pAcc )
+ aBmp.ReleaseAccess( pAcc );
+
+ if( bGray )
+ {
+ BitmapPalette aGrayPal( 256 );
+
+ for( USHORT n = 0; n < 256; n++ )
+ {
+ const BYTE cGray = (BYTE) n;
+ aGrayPal[ n ] = BitmapColor( cGray, cGray, cGray );
+ }
+
+ aBmp = Bitmap( aSize, 8, &aGrayPal );
+ }
+ else
+ aBmp = Bitmap( aSize, 24 );
+
+ if ( bSetLogSize )
+ {
+ unsigned long nUnit = ((JPEGCreateBitmapParam*)pParam)->density_unit;
+
+ if( ( ( 1 == nUnit ) || ( 2 == nUnit ) ) &&
+ ( (JPEGCreateBitmapParam*) pParam )->X_density &&
+ ( (JPEGCreateBitmapParam*) pParam )->Y_density )
+ {
+ Point aEmptyPoint;
+ Fraction aFractX( 1, ((JPEGCreateBitmapParam*)pParam)->X_density );
+ Fraction aFractY( 1, ((JPEGCreateBitmapParam*)pParam)->Y_density );
+ MapMode aMapMode( nUnit == 1 ? MAP_INCH : MAP_CM, aEmptyPoint, aFractX, aFractY );
+ Size aPrefSize = OutputDevice::LogicToLogic( aSize, aMapMode, MAP_100TH_MM );
+
+ aBmp.SetPrefSize( aPrefSize );
+ aBmp.SetPrefMapMode( MapMode( MAP_100TH_MM ) );
+ }
+ }
+
+ pAcc = aBmp.AcquireWriteAccess();
+
+ if( pAcc )
+ {
+ long nAlignedWidth;
+
+ const ULONG nFormat = pAcc->GetScanlineFormat();
+
+ if(
+ ( bGray && ( BMP_FORMAT_8BIT_PAL == nFormat ) ) ||
+ ( !bGray && ( BMP_FORMAT_24BIT_TC_RGB == nFormat ) )
+ )
+ {
+ pBmpBuf = pAcc->GetBuffer();
+ nAlignedWidth = pAcc->GetScanlineSize();
+ ((JPEGCreateBitmapParam*)pParam)->bTopDown = pAcc->IsTopDown();
+ }
+ else
+ {
+ nAlignedWidth = AlignedWidth4Bytes( aSize.Width() * ( bGray ? 8 : 24 ) );
+ ((JPEGCreateBitmapParam*)pParam)->bTopDown = TRUE;
+ pBmpBuf = pBuffer = rtl_allocateMemory( nAlignedWidth * aSize.Height() );
+ }
+ ((JPEGCreateBitmapParam*)pParam)->nAlignedWidth = nAlignedWidth;
+ }
+
+ return pBmpBuf;
+}
+
+// ------------------------------------------------------------------------
+
+void JPEGReader::FillBitmap()
+{
+ if( pBuffer && pAcc )
+ {
+ HPBYTE pTmp;
+ BitmapColor aColor;
+ long nAlignedWidth;
+ long nWidth = pAcc->Width();
+ long nHeight = pAcc->Height();
+
+ if( pAcc->GetBitCount() == 8 )
+ {
+ BitmapColor* pCols = new BitmapColor[ 256 ];
+
+ for( USHORT n = 0; n < 256; n++ )
+ {
+ const BYTE cGray = (BYTE) n;
+ pCols[ n ] = pAcc->GetBestMatchingColor( BitmapColor( cGray, cGray, cGray ) );
+ }
+
+ nAlignedWidth = AlignedWidth4Bytes( pAcc->Width() * 8L );
+
+ for( long nY = 0L; nY < nHeight; nY++ )
+ {
+ pTmp = (BYTE*) pBuffer + nY * nAlignedWidth;
+
+ for( long nX = 0L; nX < nWidth; nX++ )
+ pAcc->SetPixel( nY, nX, pCols[ *pTmp++ ] );
+ }
+
+ delete[] pCols;
+ }
+ else
+ {
+ nAlignedWidth = AlignedWidth4Bytes( pAcc->Width() * 24L );
+
+ for( long nY = 0L; nY < nHeight; nY++ )
+ {
+ pTmp = (BYTE*) pBuffer + nY * nAlignedWidth;
+
+ for( long nX = 0L; nX < nWidth; nX++ )
+ {
+ aColor.SetRed( *pTmp++ );
+ aColor.SetGreen( *pTmp++ );
+ aColor.SetBlue( *pTmp++ );
+ pAcc->SetPixel( nY, nX, aColor );
+ }
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+Graphic JPEGReader::CreateIntermediateGraphic( const Bitmap& rBitmap, long nLines )
+{
+ Graphic aGraphic;
+ const Size aSizePix( rBitmap.GetSizePixel() );
+
+ if( !nLastLines )
+ {
+ if( pAcc1 )
+ aBmp1.ReleaseAccess( pAcc1 );
+
+ aBmp1 = Bitmap( rBitmap.GetSizePixel(), 1 );
+ aBmp1.Erase( Color( COL_WHITE ) );
+ pAcc1 = aBmp1.AcquireWriteAccess();
+ }
+
+ if( nLines && ( nLines < aSizePix.Height() ) )
+ {
+ if( pAcc1 )
+ {
+ const long nNewLines = nLines - nLastLines;
+
+ if( nNewLines )
+ {
+ pAcc1->SetFillColor( Color( COL_BLACK ) );
+ pAcc1->FillRect( Rectangle( Point( 0, nLastLines ),
+ Size( pAcc1->Width(), nNewLines ) ) );
+ }
+
+ aBmp1.ReleaseAccess( pAcc1 );
+ aGraphic = BitmapEx( rBitmap, aBmp1 );
+ pAcc1 = aBmp1.AcquireWriteAccess();
+ }
+ else
+ aGraphic = rBitmap;
+ }
+ else
+ aGraphic = rBitmap;
+
+ nLastLines = nLines;
+
+ return aGraphic;
+}
+
+// ------------------------------------------------------------------------
+
+ReadState JPEGReader::Read( Graphic& rGraphic )
+{
+ long nEndPos;
+ long nLines;
+ ReadState eReadState;
+ BOOL bRet = FALSE;
+ BYTE cDummy;
+
+#if 1 // TODO: is it possible to get rid of this seek to the end?
+ // check if the stream's end is already available
+ rIStm.Seek( STREAM_SEEK_TO_END );
+ rIStm >> cDummy;
+ nEndPos = rIStm.Tell();
+
+ // else check if at least JPEGMINREAD bytes can be read
+ if( rIStm.GetError() == ERRCODE_IO_PENDING )
+ {
+ rIStm.ResetError();
+ if( ( nEndPos - nFormerPos ) < JPEGMINREAD )
+ {
+ rIStm.Seek( nLastPos );
+ return JPEGREAD_NEED_MORE;
+ }
+ }
+
+ // seek back to the original position
+ rIStm.Seek( nLastPos );
+#endif
+
+ Size aPreviewSize = GetPreviewSize();
+ SetJpegPreviewSizeHint( aPreviewSize.Width(), aPreviewSize.Height() );
+
+ // read the (partial) image
+ ReadJPEG( this, &rIStm, &nLines );
+
+ if( pAcc )
+ {
+ if( pBuffer )
+ {
+ FillBitmap();
+ rtl_freeMemory( pBuffer );
+ pBuffer = NULL;
+ }
+
+ aBmp.ReleaseAccess( pAcc );
+ pAcc = NULL;
+
+ if( rIStm.GetError() == ERRCODE_IO_PENDING )
+ rGraphic = CreateIntermediateGraphic( aBmp, nLines );
+ else
+ rGraphic = aBmp;
+
+ bRet = TRUE;
+ }
+ else if( rIStm.GetError() == ERRCODE_IO_PENDING )
+ bRet = TRUE;
+
+ // Status setzen ( Pending hat immer Vorrang )
+ if( rIStm.GetError() == ERRCODE_IO_PENDING )
+ {
+ eReadState = JPEGREAD_NEED_MORE;
+ rIStm.ResetError();
+ nFormerPos = rIStm.Tell();
+ }
+ else
+ {
+ if( bRet )
+ eReadState = JPEGREAD_OK;
+ else
+ eReadState = JPEGREAD_ERROR;
+ }
+
+ return eReadState;
+}
+
+
+// --------------
+// - JPEGWriter -
+// --------------
+
+JPEGWriter::JPEGWriter( SvStream& rStm, const uno::Sequence< beans::PropertyValue >* pFilterData ) :
+ rOStm ( rStm ),
+ pAcc ( NULL ),
+ pBuffer ( NULL )
+{
+ FilterConfigItem aConfigItem( (uno::Sequence< beans::PropertyValue >*)pFilterData );
+ bGreys = aConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "ColorMode" ) ), 0 ) != 0;
+ nQuality = aConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Quality" ) ), 75 );
+
+ if ( pFilterData )
+ {
+ int nArgs = pFilterData->getLength();
+ const beans::PropertyValue* pValues = pFilterData->getConstArray();
+ while( nArgs-- )
+ {
+ if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "StatusIndicator" ) ) )
+ {
+ pValues->Value >>= xStatusIndicator;
+ }
+ pValues++;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void* JPEGWriter::GetScanline( long nY )
+{
+ void* pScanline = NULL;
+
+ if( pAcc )
+ {
+ if( bNative )
+ pScanline = pAcc->GetScanline( nY );
+ else if( pBuffer )
+ {
+ BitmapColor aColor;
+ long nWidth = pAcc->Width();
+ BYTE* pTmp = pBuffer;
+
+ if( pAcc->HasPalette() )
+ {
+ for( long nX = 0L; nX < nWidth; nX++ )
+ {
+ aColor = pAcc->GetPaletteColor( (BYTE) pAcc->GetPixel( nY, nX ) );
+ *pTmp++ = aColor.GetRed();
+ *pTmp++ = aColor.GetGreen();
+ *pTmp++ = aColor.GetBlue();
+ }
+ }
+ else
+ {
+ for( long nX = 0L; nX < nWidth; nX++ )
+ {
+ aColor = pAcc->GetPixel( nY, nX );
+ *pTmp++ = aColor.GetRed();
+ *pTmp++ = aColor.GetGreen();
+ *pTmp++ = aColor.GetBlue();
+ }
+ }
+
+ pScanline = pBuffer;
+ }
+ }
+
+ return pScanline;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL JPEGWriter::Write( const Graphic& rGraphic )
+{
+ BOOL bRet = FALSE;
+
+ if ( xStatusIndicator.is() )
+ {
+ rtl::OUString aMsg;
+ xStatusIndicator->start( aMsg, 100 );
+ }
+
+ Bitmap aGraphicBmp( rGraphic.GetBitmap() );
+
+ if ( bGreys )
+ {
+ if ( !aGraphicBmp.Convert( BMP_CONVERSION_8BIT_GREYS ) )
+ aGraphicBmp = rGraphic.GetBitmap();
+ }
+
+ pAcc = aGraphicBmp.AcquireReadAccess();
+
+ if( pAcc )
+ {
+ bNative = ( pAcc->GetScanlineFormat() == BMP_FORMAT_24BIT_TC_RGB );
+
+ if( !bNative )
+ pBuffer = new BYTE[ AlignedWidth4Bytes( pAcc->Width() * 24L ) ];
+
+ JPEGCallbackStruct aCallbackData;
+ aCallbackData.xStatusIndicator = xStatusIndicator;
+ bRet = (BOOL) WriteJPEG( this, &rOStm, pAcc->Width(), pAcc->Height(), nQuality, &aCallbackData );
+
+ delete[] pBuffer;
+ pBuffer = NULL;
+
+ aGraphicBmp.ReleaseAccess( pAcc );
+ pAcc = NULL;
+ }
+ if ( xStatusIndicator.is() )
+ xStatusIndicator->end();
+
+ return bRet;
+}
+
+// --------------
+// - ImportJPEG -
+// --------------
+
+BOOL ImportJPEG( SvStream& rStm, Graphic& rGraphic, void* pCallerData, sal_Int32 nImportFlags )
+{
+ JPEGReader* pJPEGReader = (JPEGReader*) rGraphic.GetContext();
+ ReadState eReadState;
+ BOOL bRet = TRUE;
+
+ if( !pJPEGReader )
+ pJPEGReader = new JPEGReader( rStm, pCallerData, ( nImportFlags & GRFILTER_I_FLAGS_SET_LOGSIZE_FOR_JPEG ) != 0 );
+
+ if( nImportFlags & GRFILTER_I_FLAGS_FOR_PREVIEW )
+ pJPEGReader->SetPreviewSize( Size(128,128) );
+ else
+ pJPEGReader->DisablePreviewMode();
+
+ rGraphic.SetContext( NULL );
+ eReadState = pJPEGReader->Read( rGraphic );
+
+ if( eReadState == JPEGREAD_ERROR )
+ {
+ bRet = FALSE;
+ delete pJPEGReader;
+ }
+ else if( eReadState == JPEGREAD_OK )
+ delete pJPEGReader;
+ else
+ rGraphic.SetContext( pJPEGReader );
+
+ return bRet;
+}
+
+// --------------
+// - ExportJPEG -
+// --------------
+
+BOOL ExportJPEG( SvStream& rOStm, const Graphic& rGraphic, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >* pFilterData )
+{
+ JPEGWriter aJPEGWriter( rOStm, pFilterData );
+ return aJPEGWriter.Write( rGraphic );
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/jpeg/svt_jpegc.c b/binfilter/bf_svtools/source/filter.vcl/jpeg/svt_jpegc.c
new file mode 100644
index 000000000000..c9ba09fbe373
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/jpeg/svt_jpegc.c
@@ -0,0 +1,280 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <stdio.h>
+#include <stdlib.h>
+#include "setjmp.h"
+#include "jpeglib.h"
+#include "jerror.h"
+#include "jpeg.h"
+
+#include "rtl/alloc.h"
+#include "osl/diagnose.h"
+
+struct my_error_mgr
+{
+ struct jpeg_error_mgr pub;
+ jmp_buf setjmp_buffer;
+};
+
+void jpeg_svstream_src (j_decompress_ptr cinfo, void* infile);
+void jpeg_svstream_dest (j_compress_ptr cinfo, void* outfile);
+
+METHODDEF( void )
+my_error_exit (j_common_ptr cinfo)
+{
+ my_error_ptr myerr = (my_error_ptr) cinfo->err;
+ (*cinfo->err->output_message) (cinfo);
+ longjmp(myerr->setjmp_buffer, 1);
+}
+
+
+METHODDEF( void )
+my_output_message (j_common_ptr cinfo)
+{
+ char buffer[JMSG_LENGTH_MAX];
+ (*cinfo->err->format_message) (cinfo, buffer);
+}
+
+/* TODO: when incompatible changes are possible again
+ the preview size hint should be redone */
+static int nPreviewWidth = 0;
+static int nPreviewHeight = 0;
+void SetJpegPreviewSizeHint( int nWidth, int nHeight )
+{
+ nPreviewWidth = nWidth;
+ nPreviewHeight = nHeight;
+}
+
+void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines )
+{
+ struct jpeg_decompress_struct cinfo;
+ struct my_error_mgr jerr;
+ struct JPEGCreateBitmapParam aCreateBitmapParam;
+ HPBYTE pDIB;
+ HPBYTE pTmp;
+ long nWidth;
+ long nHeight;
+ long nAlignedWidth;
+ JSAMPLE * range_limit;
+ HPBYTE pScanLineBuffer = NULL;
+ long nScanLineBufferComponents = 0;
+ // declare bDecompCreated volatile because of gcc
+ // warning: variable 'bDecompCreated' might be clobbered by `longjmp' or `vfork'
+ volatile long bDecompCreated = 0;
+
+ /* Falls der Stream nicht ausreicht (IO_PENDING)
+ wird ueber ein longjmp in der Schleife nach Exit
+ gesprungen, wir geben dann die Anzahl
+ der bisher bearbeiteten Scanlines zurueck*/
+ if ( setjmp( jerr.setjmp_buffer ) )
+ goto Exit;
+
+ cinfo.err = jpeg_std_error( &jerr.pub );
+ jerr.pub.error_exit = my_error_exit;
+ jerr.pub.output_message = my_output_message;
+
+ jpeg_create_decompress( &cinfo );
+ bDecompCreated = 1;
+ jpeg_svstream_src( &cinfo, pIStm );
+ jpeg_read_header( &cinfo, TRUE );
+
+ cinfo.scale_num = 1;
+ cinfo.scale_denom = 1;
+ cinfo.output_gamma = 1.0;
+ cinfo.raw_data_out = FALSE;
+ cinfo.quantize_colors = FALSE;
+ if ( cinfo.jpeg_color_space == JCS_YCbCr )
+ cinfo.out_color_space = JCS_RGB;
+ else if ( cinfo.jpeg_color_space == JCS_YCCK )
+ cinfo.out_color_space = JCS_CMYK;
+
+ OSL_ASSERT(cinfo.out_color_space == JCS_CMYK || cinfo.out_color_space == JCS_GRAYSCALE || cinfo.out_color_space == JCS_RGB);
+
+ /* change scale for preview import */
+ if( nPreviewWidth || nPreviewHeight )
+ {
+ if( nPreviewWidth == 0 ) {
+ nPreviewWidth = ( cinfo.image_width*nPreviewHeight )/cinfo.image_height;
+ if( nPreviewWidth <= 0 )
+ nPreviewWidth = 1;
+ } else if( nPreviewHeight == 0 ) {
+ nPreviewHeight = ( cinfo.image_height*nPreviewWidth )/cinfo.image_width;
+ if( nPreviewHeight <= 0 )
+ nPreviewHeight = 1;
+ }
+
+ for( cinfo.scale_denom = 1; cinfo.scale_denom < 8; cinfo.scale_denom *= 2 )
+ {
+ if( cinfo.image_width < nPreviewWidth * cinfo.scale_denom )
+ break;
+ if( cinfo.image_height < nPreviewHeight * cinfo.scale_denom )
+ break;
+ }
+
+ if( cinfo.scale_denom > 1 )
+ {
+ cinfo.dct_method = JDCT_FASTEST;
+ cinfo.do_fancy_upsampling = FALSE;
+ cinfo.do_block_smoothing = FALSE;
+ }
+ }
+
+ jpeg_start_decompress( &cinfo );
+
+ nWidth = cinfo.output_width;
+ nHeight = cinfo.output_height;
+ aCreateBitmapParam.nWidth = nWidth;
+ aCreateBitmapParam.nHeight = nHeight;
+
+ aCreateBitmapParam.density_unit = cinfo.density_unit;
+ aCreateBitmapParam.X_density = cinfo.X_density;
+ aCreateBitmapParam.Y_density = cinfo.Y_density;
+ aCreateBitmapParam.bGray = cinfo.output_components == 1;
+ pDIB = CreateBitmap( pJPEGReader, &aCreateBitmapParam );
+ nAlignedWidth = aCreateBitmapParam.nAlignedWidth;
+ range_limit=cinfo.sample_range_limit;
+
+ if ( cinfo.out_color_space == JCS_CMYK )
+ {
+ nScanLineBufferComponents = cinfo.output_width * 4;
+ pScanLineBuffer = rtl_allocateMemory( nScanLineBufferComponents );
+ }
+
+ if( pDIB )
+ {
+ if( aCreateBitmapParam.bTopDown )
+ pTmp = pDIB;
+ else
+ {
+ pTmp = pDIB + ( nHeight - 1 ) * nAlignedWidth;
+ nAlignedWidth = -nAlignedWidth;
+ }
+
+ for ( *pLines = 0; *pLines < nHeight; (*pLines)++ )
+ {
+ if (pScanLineBuffer!=NULL) { // in other words cinfo.out_color_space == JCS_CMYK
+ int i;
+ int j;
+ jpeg_read_scanlines( &cinfo, (JSAMPARRAY) &pScanLineBuffer, 1 );
+ // convert CMYK to RGB
+ for( i=0, j=0; i < nScanLineBufferComponents; i+=4, j+=3 )
+ {
+ int c_=255-pScanLineBuffer[i+0];
+ int m_=255-pScanLineBuffer[i+1];
+ int y_=255-pScanLineBuffer[i+2];
+ int k_=255-pScanLineBuffer[i+3];
+ pTmp[j+0]=range_limit[ 255L - ( c_ + k_ ) ];
+ pTmp[j+1]=range_limit[ 255L - ( m_ + k_ ) ];
+ pTmp[j+2]=range_limit[ 255L - ( y_ + k_ ) ];
+ }
+ } else {
+ jpeg_read_scanlines( &cinfo, (JSAMPARRAY) &pTmp, 1 );
+ }
+ /* PENDING ??? */
+ if ( cinfo.err->msg_code == 113 )
+ break;
+
+ pTmp += nAlignedWidth;
+ }
+ }
+
+ jpeg_finish_decompress( &cinfo );
+ if (pScanLineBuffer!=NULL) {
+ rtl_freeMemory( pScanLineBuffer );
+ pScanLineBuffer=NULL;
+ }
+
+Exit:
+
+ if( bDecompCreated )
+ jpeg_destroy_decompress( &cinfo );
+}
+
+long WriteJPEG( void* pJPEGWriter, void* pOStm,
+ long nWidth, long nHeight,
+ long nQualityPercent, void* pCallbackData )
+{
+ struct jpeg_compress_struct cinfo;
+ struct my_error_mgr jerr;
+ void* pScanline;
+ long nY;
+ // declare bCompCreated, bRet volatile because of gcc
+ // warning: variable 'bCompCreated' might be clobbered by `longjmp' or `vfork'
+ volatile long bCompCreated = 0;
+ volatile long bRet = 0;
+
+ if ( setjmp( jerr.setjmp_buffer ) )
+ goto Exit;
+
+ cinfo.err = jpeg_std_error( &jerr.pub );
+ jerr.pub.error_exit = my_error_exit;
+ jerr.pub.output_message = my_output_message;
+
+ jpeg_create_compress( &cinfo );
+ bCompCreated = 1;
+
+ jpeg_svstream_dest( &cinfo, pOStm );
+
+ cinfo.image_width = (JDIMENSION) nWidth;
+ cinfo.image_height = (JDIMENSION) nHeight;
+ cinfo.input_components = 3;
+ cinfo.in_color_space = JCS_RGB;
+
+ jpeg_set_defaults( &cinfo );
+ jpeg_set_quality( &cinfo, (int) nQualityPercent, FALSE );
+
+ if ( ( nWidth > 128 ) || ( nHeight > 128 ) )
+ jpeg_simple_progression( &cinfo );
+
+ jpeg_start_compress( &cinfo, TRUE );
+
+ for( nY = 0; nY < nHeight; nY++ )
+ {
+ pScanline = GetScanline( pJPEGWriter, nY );
+
+ if( pScanline )
+ jpeg_write_scanlines( &cinfo, (JSAMPARRAY) &pScanline, 1 );
+
+ if( JPEGCallback( pCallbackData, nY * 100L / nHeight ) )
+ goto Exit;
+ }
+
+ bRet = 1;
+
+ jpeg_finish_compress(&cinfo);
+
+Exit:
+
+ if ( bCompCreated )
+ jpeg_destroy_compress( &cinfo );
+
+ return bRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/wmf/emfwr.hxx b/binfilter/bf_svtools/source/filter.vcl/wmf/emfwr.hxx
new file mode 100644
index 000000000000..0cc9dfcac41f
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/wmf/emfwr.hxx
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 _EMFWR_HXX
+#define _EMFWR_HXX
+
+#include <tools/debug.hxx>
+#include <vcl/metaact.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/gdimtf.hxx>
+#include <vcl/virdev.hxx>
+#include <bf_svtools/fltcall.hxx>
+
+// -------------
+// - EMFWriter -
+// -------------
+
+namespace binfilter
+{
+
+class EMFWriter
+{
+private:
+
+ VirtualDevice maVDev;
+ FilterConfigItem* mpFilterConfigItem;
+ SvStream* mpStm;
+ BOOL* mpHandlesUsed;
+ ULONG mnHandleCount;
+ ULONG mnLastPercent;
+ ULONG mnRecordCount;
+ ULONG mnRecordPos;
+ BOOL mbRecordOpen;
+ BOOL mbLineChanged;
+ sal_uInt32 mnLineHandle;
+ BOOL mbFillChanged;
+ sal_uInt32 mnFillHandle;
+ BOOL mbTextChanged;
+ sal_uInt32 mnTextHandle;
+
+ void ImplBeginRecord( sal_uInt32 nType );
+ void ImplEndRecord();
+
+ ULONG ImplAcquireHandle();
+ void ImplReleaseHandle( ULONG nHandle );
+
+ BOOL ImplPrepareHandleSelect( sal_uInt32& rHandle, ULONG nSelectType );
+ void ImplCheckLineAttr();
+ void ImplCheckFillAttr();
+ void ImplCheckTextAttr();
+
+ void ImplWriteColor( const Color& rColor );
+ void ImplWriteRasterOp( RasterOp eRop );
+ void ImplWriteExtent( long nExtent );
+ void ImplWritePoint( const Point& rPoint );
+ void ImplWriteSize( const Size& rSize);
+ void ImplWriteRect( const Rectangle& rRect );
+ void ImplWritePath( const PolyPolygon& rPolyPoly, sal_Bool bClose );
+ void ImplWritePolygonRecord( const Polygon& rPoly, BOOL bClose );
+ void ImplWritePolyPolygonRecord( const PolyPolygon& rPolyPoly );
+ void ImplWriteBmpRecord( const Bitmap& rBmp, const Point& rPt, const Size& rSz, UINT32 nROP );
+ void ImplWriteTextRecord( const Point& rPos, const String rText, const sal_Int32* pDXArray, sal_uInt32 nWidth );
+
+ void ImplWrite( const GDIMetaFile& rMtf );
+
+public:
+
+ EMFWriter() {}
+
+ BOOL WriteEMF( const GDIMetaFile& rMtf, SvStream& rOStm, FilterConfigItem* pConfigItem = NULL );
+};
+
+}
+
+#endif // _EMFWR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/wmf/makefile.mk b/binfilter/bf_svtools/source/filter.vcl/wmf/makefile.mk
new file mode 100644
index 000000000000..e3e66c20d3ac
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/wmf/makefile.mk
@@ -0,0 +1,50 @@
+#*************************************************************************
+#
+# DO NOT ALTER 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=binfilter
+TARGET=wmf
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= $(SLO)$/svt_wmf.obj \
+ $(SLO)$/svt_winmtf.obj \
+ $(SLO)$/svt_winwmf.obj \
+ $(SLO)$/svt_enhwmf.obj \
+ $(SLO)$/svt_emfwr.obj \
+ $(SLO)$/svt_wmfwr.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/binfilter/bf_svtools/source/filter.vcl/wmf/svt_emfwr.cxx b/binfilter/bf_svtools/source/filter.vcl/wmf/svt_emfwr.cxx
new file mode 100644
index 000000000000..74334daee541
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/wmf/svt_emfwr.cxx
@@ -0,0 +1,1292 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 "emfwr.hxx"
+#include <vcl/salbtype.hxx>
+
+// -----------
+// - Defines -
+// -----------
+
+namespace binfilter
+{
+
+#define WIN_EMR_HEADER 1
+#define WIN_EMR_POLYBEZIER 2
+#define WIN_EMR_POLYGON 3
+#define WIN_EMR_POLYLINE 4
+#define WIN_EMR_POLYBEZIERTO 5
+#define WIN_EMR_POLYLINETO 6
+#define WIN_EMR_POLYPOLYLINE 7
+#define WIN_EMR_POLYPOLYGON 8
+#define WIN_EMR_SETWINDOWEXTEX 9
+#define WIN_EMR_SETWINDOWORGEX 10
+#define WIN_EMR_SETVIEWPORTEXTEX 11
+#define WIN_EMR_SETVIEWPORTORGEX 12
+#define WIN_EMR_SETBRUSHORGEX 13
+#define WIN_EMR_EOF 14
+#define WIN_EMR_SETPIXELV 15
+#define WIN_EMR_SETMAPPERFLAGS 16
+#define WIN_EMR_SETMAPMODE 17
+#define WIN_EMR_SETBKMODE 18
+#define WIN_EMR_SETPOLYFILLMODE 19
+#define WIN_EMR_SETROP2 20
+#define WIN_EMR_SETSTRETCHBLTMODE 21
+#define WIN_EMR_SETTEXTALIGN 22
+#define WIN_EMR_SETCOLORADJUSTMENT 23
+#define WIN_EMR_SETTEXTCOLOR 24
+#define WIN_EMR_SETBKCOLOR 25
+#define WIN_EMR_OFFSETCLIPRGN 26
+#define WIN_EMR_MOVETOEX 27
+#define WIN_EMR_SETMETARGN 28
+#define WIN_EMR_EXCLUDECLIPRECT 29
+#define WIN_EMR_INTERSECTCLIPRECT 30
+#define WIN_EMR_SCALEVIEWPORTEXTEX 31
+#define WIN_EMR_SCALEWINDOWEXTEX 32
+#define WIN_EMR_SAVEDC 33
+#define WIN_EMR_RESTOREDC 34
+#define WIN_EMR_SETWORLDTRANSFORM 35
+#define WIN_EMR_MODIFYWORLDTRANSFORM 36
+#define WIN_EMR_SELECTOBJECT 37
+#define WIN_EMR_CREATEPEN 38
+#define WIN_EMR_CREATEBRUSHINDIRECT 39
+#define WIN_EMR_DELETEOBJECT 40
+#define WIN_EMR_ANGLEARC 41
+#define WIN_EMR_ELLIPSE 42
+#define WIN_EMR_RECTANGLE 43
+#define WIN_EMR_ROUNDRECT 44
+#define WIN_EMR_ARC 45
+#define WIN_EMR_CHORD 46
+#define WIN_EMR_PIE 47
+#define WIN_EMR_SELECTPALETTE 48
+#define WIN_EMR_CREATEPALETTE 49
+#define WIN_EMR_SETPALETTEENTRIES 50
+#define WIN_EMR_RESIZEPALETTE 51
+#define WIN_EMR_REALIZEPALETTE 52
+#define WIN_EMR_EXTFLOODFILL 53
+#define WIN_EMR_LINETO 54
+#define WIN_EMR_ARCTO 55
+#define WIN_EMR_POLYDRAW 56
+#define WIN_EMR_SETARCDIRECTION 57
+#define WIN_EMR_SETMITERLIMIT 58
+#define WIN_EMR_BEGINPATH 59
+#define WIN_EMR_ENDPATH 60
+#define WIN_EMR_CLOSEFIGURE 61
+#define WIN_EMR_FILLPATH 62
+#define WIN_EMR_STROKEANDFILLPATH 63
+#define WIN_EMR_STROKEPATH 64
+#define WIN_EMR_FLATTENPATH 65
+#define WIN_EMR_WIDENPATH 66
+#define WIN_EMR_SELECTCLIPPATH 67
+#define WIN_EMR_ABORTPATH 68
+
+#define WIN_EMR_GDICOMMENT 70
+#define WIN_EMR_FILLRGN 71
+#define WIN_EMR_FRAMERGN 72
+#define WIN_EMR_INVERTRGN 73
+#define WIN_EMR_PAINTRGN 74
+#define WIN_EMR_EXTSELECTCLIPRGN 75
+#define WIN_EMR_BITBLT 76
+#define WIN_EMR_STRETCHBLT 77
+#define WIN_EMR_MASKBLT 78
+#define WIN_EMR_PLGBLT 79
+#define WIN_EMR_SETDIBITSTODEVICE 80
+#define WIN_EMR_STRETCHDIBITS 81
+#define WIN_EMR_EXTCREATEFONTINDIRECTW 82
+#define WIN_EMR_EXTTEXTOUTA 83
+#define WIN_EMR_EXTTEXTOUTW 84
+#define WIN_EMR_POLYBEZIER16 85
+#define WIN_EMR_POLYGON16 86
+#define WIN_EMR_POLYLINE16 87
+#define WIN_EMR_POLYBEZIERTO16 88
+#define WIN_EMR_POLYLINETO16 89
+#define WIN_EMR_POLYPOLYLINE16 90
+#define WIN_EMR_POLYPOLYGON16 91
+#define WIN_EMR_POLYDRAW16 92
+#define WIN_EMR_CREATEMONOBRUSH 93
+#define WIN_EMR_CREATEDIBPATTERNBRUSHPT 94
+#define WIN_EMR_EXTCREATEPEN 95
+#define WIN_EMR_POLYTEXTOUTA 96
+#define WIN_EMR_POLYTEXTOUTW 97
+
+#define WIN_SRCCOPY 0x00CC0020L
+#define WIN_SRCPAINT 0x00EE0086L
+#define WIN_SRCAND 0x008800C6L
+#define WIN_SRCINVERT 0x00660046L
+
+#define HANDLE_INVALID 0xffffffff
+#define MAXHANDLES 65000
+
+#define LINE_SELECT 0x00000001
+#define FILL_SELECT 0x00000002
+#define TEXT_SELECT 0x00000004
+
+// -------------
+// - EMFWriter -
+// -------------
+
+BOOL EMFWriter::WriteEMF( const GDIMetaFile& rMtf, SvStream& rOStm, FilterConfigItem* pFilterConfigItem )
+{
+ const ULONG nHeaderPos = rOStm.Tell();
+
+ mpHandlesUsed = new BOOL[ MAXHANDLES ];
+ memset( mpHandlesUsed, 0, MAXHANDLES * sizeof( BOOL ) );
+ mnHandleCount = mnLastPercent = mnRecordPos = mnRecordCount = 0;
+ mnLineHandle = mnFillHandle = mnTextHandle = HANDLE_INVALID;
+ mbRecordOpen = FALSE;
+
+ mpStm = &rOStm;
+ maVDev.EnableOutput( FALSE );
+ maVDev.SetMapMode( rMtf.GetPrefMapMode() );
+ mpFilterConfigItem = pFilterConfigItem;
+
+ const Size aMtfSizePix( maVDev.LogicToPixel( rMtf.GetPrefSize(), rMtf.GetPrefMapMode() ) );
+ const Size aMtfSizeLog( maVDev.LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MAP_100TH_MM ) );
+
+ // seek over header
+ rOStm.SeekRel( 100 );
+
+ // write initial values
+ ImplBeginRecord( WIN_EMR_SETWINDOWORGEX );
+ (*mpStm) << (INT32) 0 << (INT32) 0;
+ ImplEndRecord();
+
+ ImplBeginRecord( WIN_EMR_SETWINDOWEXTEX );
+ (*mpStm) << (INT32) aMtfSizePix.Width() << (INT32) aMtfSizePix.Height();
+ ImplEndRecord();
+
+ ImplWriteRasterOp( ROP_OVERPAINT );
+
+ ImplBeginRecord( WIN_EMR_SETBKMODE );
+ (*mpStm) << (UINT32) 1; // TRANSPARENT
+ ImplEndRecord();
+
+ // write emf data
+ ImplWrite( rMtf );
+
+ ImplBeginRecord( WIN_EMR_EOF );
+ (*mpStm)<< (sal_uInt32)0 // nPalEntries
+ << (sal_uInt32)0x16 // offPalEntries
+ << (sal_uInt32)0x14; // nSizeLast
+ ImplEndRecord();
+
+
+ // write header
+ const ULONG nEndPos = mpStm->Tell(); mpStm->Seek( nHeaderPos );
+
+ (*mpStm) << (UINT32) 0x00000001 << (UINT32) 100;
+ (*mpStm) << (INT32) 0 << (INT32) 0 << (INT32) ( aMtfSizePix.Width() - 1 ) << (INT32) ( aMtfSizePix.Height() - 1 );
+ (*mpStm) << (INT32) 0 << (INT32) 0 << (INT32) ( aMtfSizeLog.Width() - 1 ) << (INT32) ( aMtfSizeLog.Height() - 1 );
+ (*mpStm) << (UINT32) 0x464d4520 << (UINT32) 0x10000 << (UINT32) ( nEndPos - nHeaderPos );
+ (*mpStm) << (UINT32) mnRecordCount << (UINT16) ( mnHandleCount + 1 ) << (UINT16) 0 << (UINT32) 0 << (UINT32) 0 << (UINT32) 0;
+ (*mpStm) << (INT32) aMtfSizePix.Width() << (INT32) aMtfSizePix.Height();
+ (*mpStm) << (INT32) ( aMtfSizeLog.Width() / 100 ) << (INT32) ( aMtfSizeLog.Height() / 100 );
+ (*mpStm) << (UINT32) 0 << (UINT32) 0 << (UINT32) 0;
+
+ mpStm->Seek( nEndPos );
+ delete[] mpHandlesUsed;
+
+ return( mpStm->GetError() == ERRCODE_NONE );
+}
+
+// -----------------------------------------------------------------------------
+
+ULONG EMFWriter::ImplAcquireHandle()
+{
+ ULONG nHandle = HANDLE_INVALID;
+
+ for( ULONG i = 0; i < MAXHANDLES && ( HANDLE_INVALID == nHandle ); i++ )
+ {
+ if( !mpHandlesUsed[ i ] )
+ {
+ mpHandlesUsed[ i ] = TRUE;
+
+ if( ( nHandle = i ) == mnHandleCount )
+ mnHandleCount++;
+ }
+ }
+
+ DBG_ASSERT( nHandle != HANDLE_INVALID, "No more handles available" );
+ return( nHandle != HANDLE_INVALID ? nHandle + 1 : HANDLE_INVALID );
+}
+
+// -----------------------------------------------------------------------------
+
+void EMFWriter::ImplReleaseHandle( ULONG nHandle )
+{
+ DBG_ASSERT( nHandle && ( nHandle < MAXHANDLES ), "Handle out of range" );
+ mpHandlesUsed[ nHandle - 1 ] = FALSE;
+}
+
+// -----------------------------------------------------------------------------
+
+void EMFWriter::ImplBeginRecord( sal_uInt32 nType )
+{
+ DBG_ASSERT( !mbRecordOpen, "Another record is already opened!" );
+
+ if( !mbRecordOpen )
+ {
+ mbRecordOpen = TRUE;
+ mnRecordPos = mpStm->Tell();
+
+ (*mpStm) << nType;
+ mpStm->SeekRel( 4 );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void EMFWriter::ImplEndRecord()
+{
+ DBG_ASSERT( mbRecordOpen, "Record was not opened!" );
+
+ if( mbRecordOpen )
+ {
+ sal_Int32 nFillBytes, nActPos = mpStm->Tell();
+ mpStm->Seek( mnRecordPos + 4 );
+ nFillBytes = nActPos - mnRecordPos;
+ nFillBytes += 3; // each record has to be dword aligned
+ nFillBytes ^= 3;
+ nFillBytes &= 3;
+ *mpStm << (sal_uInt32)( ( nActPos - mnRecordPos ) + nFillBytes );
+ mpStm->Seek( nActPos );
+ while( nFillBytes-- )
+ *mpStm << (sal_uInt8)0;
+ mnRecordCount++;
+ mbRecordOpen = FALSE;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL EMFWriter::ImplPrepareHandleSelect( sal_uInt32& rHandle, ULONG nSelectType )
+{
+ if( rHandle != HANDLE_INVALID )
+ {
+ UINT32 nStockObject = 0x80000000;
+
+ if( LINE_SELECT == nSelectType )
+ nStockObject |= 0x00000007;
+ else if( FILL_SELECT == nSelectType )
+ nStockObject |= 0x00000001;
+ else if( TEXT_SELECT == nSelectType )
+ nStockObject |= 0x0000000a;
+
+ // select stock object first
+ ImplBeginRecord( WIN_EMR_SELECTOBJECT );
+ ( *mpStm ) << nStockObject;
+ ImplEndRecord();
+
+ // destroy handle of created object
+ ImplBeginRecord( WIN_EMR_DELETEOBJECT );
+ ( *mpStm ) << rHandle;
+ ImplEndRecord();
+
+ // mark handle as free
+ ImplReleaseHandle( rHandle );
+ }
+
+ rHandle = ImplAcquireHandle();
+
+ return( HANDLE_INVALID != rHandle );
+}
+
+// -----------------------------------------------------------------------------
+
+void EMFWriter::ImplCheckLineAttr()
+{
+ if( mbLineChanged && ImplPrepareHandleSelect( mnLineHandle, LINE_SELECT ) )
+ {
+ sal_uInt32 nStyle = maVDev.IsLineColor() ? 0 : 5;
+ sal_uInt32 nWidth = 0, nHeight = 0;
+
+ ImplBeginRecord( WIN_EMR_CREATEPEN );
+ (*mpStm) << mnLineHandle << nStyle << nWidth << nHeight;
+ ImplWriteColor( maVDev.GetLineColor() );
+ ImplEndRecord();
+
+ ImplBeginRecord( WIN_EMR_SELECTOBJECT );
+ (*mpStm) << mnLineHandle;
+ ImplEndRecord();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void EMFWriter::ImplCheckFillAttr()
+{
+ if( mbFillChanged && ImplPrepareHandleSelect( mnFillHandle, FILL_SELECT ) )
+ {
+ sal_uInt32 nStyle = maVDev.IsFillColor() ? 0 : 1;
+ sal_uInt32 nPatternStyle = 0;
+
+ ImplBeginRecord( WIN_EMR_CREATEBRUSHINDIRECT );
+ (*mpStm) << mnFillHandle << nStyle;
+ ImplWriteColor( maVDev.GetFillColor() );
+ (*mpStm) << nPatternStyle;
+ ImplEndRecord();
+
+ ImplBeginRecord( WIN_EMR_SELECTOBJECT );
+ (*mpStm) << mnFillHandle;
+ ImplEndRecord();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void EMFWriter::ImplCheckTextAttr()
+{
+ if( mbTextChanged && ImplPrepareHandleSelect( mnTextHandle, TEXT_SELECT ) )
+ {
+ const Font& rFont = maVDev.GetFont();
+ String aFontName( rFont.GetName() );
+ sal_Int32 nWeight;
+ sal_uInt16 i;
+ sal_uInt8 nPitchAndFamily;
+
+ ImplBeginRecord( WIN_EMR_EXTCREATEFONTINDIRECTW );
+ (*mpStm) << mnTextHandle;
+ ImplWriteExtent( -rFont.GetSize().Height() );
+ ImplWriteExtent( rFont.GetSize().Width() );
+ (*mpStm) << (INT32) rFont.GetOrientation() << (INT32) rFont.GetOrientation();
+
+ switch( rFont.GetWeight() )
+ {
+ case WEIGHT_THIN: nWeight = 100; break;
+ case WEIGHT_ULTRALIGHT: nWeight = 200; break;
+ case WEIGHT_LIGHT: nWeight = 300; break;
+ case WEIGHT_SEMILIGHT: nWeight = 300; break;
+ case WEIGHT_NORMAL: nWeight = 400; break;
+ case WEIGHT_MEDIUM: nWeight = 500; break;
+ case WEIGHT_SEMIBOLD: nWeight = 600; break;
+ case WEIGHT_BOLD: nWeight = 700; break;
+ case WEIGHT_ULTRABOLD: nWeight = 800; break;
+ case WEIGHT_BLACK: nWeight = 900; break;
+ default: nWeight = 0; break;
+ }
+
+ (*mpStm) << nWeight;
+ (*mpStm) << (BYTE) ( ( ITALIC_NONE == rFont.GetItalic() ) ? 0 : 1 );
+ (*mpStm) << (BYTE) ( ( UNDERLINE_NONE == rFont.GetUnderline() ) ? 0 : 1 );
+ (*mpStm) << (BYTE) ( ( STRIKEOUT_NONE == rFont.GetStrikeout() ) ? 0 : 1 );
+ (*mpStm) << (BYTE) ( ( RTL_TEXTENCODING_SYMBOL == rFont.GetCharSet() ) ? 2 : 0 );
+ (*mpStm) << (BYTE) 0 << (BYTE) 0 << (BYTE) 0;
+
+ switch( rFont.GetPitch() )
+ {
+ case PITCH_FIXED: nPitchAndFamily = 0x01; break;
+ case PITCH_VARIABLE: nPitchAndFamily = 0x02; break;
+ default: nPitchAndFamily = 0x00; break;
+ }
+
+ switch( rFont.GetFamily() )
+ {
+ case FAMILY_DECORATIVE: nPitchAndFamily |= 0x50; break;
+ case FAMILY_MODERN: nPitchAndFamily |= 0x30; break;
+ case FAMILY_ROMAN: nPitchAndFamily |= 0x10; break;
+ case FAMILY_SCRIPT: nPitchAndFamily |= 0x40; break;
+ case FAMILY_SWISS: nPitchAndFamily |= 0x20; break;
+ default: break;
+ }
+
+ (*mpStm) << nPitchAndFamily;
+
+ for( i = 0; i < 32; i++ )
+ (*mpStm) << (sal_Unicode) ( ( i < aFontName.Len() ) ? aFontName.GetChar( i ) : 0 );
+
+ // dummy elfFullName
+ for( i = 0; i < 64; i++ )
+ (*mpStm) << (sal_Unicode) 0;
+
+ // dummy elfStyle
+ for( i = 0; i < 32; i++ )
+ (*mpStm) << (sal_Unicode) 0;
+
+ // dummy elfVersion, elfStyleSize, elfMatch, elfReserved
+ (*mpStm) << (UINT32) 0 << (UINT32) 0 << (UINT32) 0 << (UINT32) 0 ;
+
+ // dummy elfVendorId
+ (*mpStm) << (UINT32) 0;
+
+ // dummy elfCulture
+ (*mpStm) << (UINT32) 0;
+
+ // dummy elfPanose
+ (*mpStm) << (BYTE) 0 << (BYTE) 0 << (BYTE) 0 << (BYTE) 0 << (BYTE) 0 << (BYTE) 0 << (BYTE) 0 << (BYTE) 0 << (BYTE) 0 << (BYTE) 0;
+
+ // fill record to get a record size divideable by 4
+ (*mpStm) << (UINT16) 0;
+
+ ImplEndRecord();
+
+ // TextAlign
+ UINT32 nTextAlign;
+
+ switch( rFont.GetAlign() )
+ {
+ case ALIGN_TOP: nTextAlign = 0; break;
+ case ALIGN_BOTTOM: nTextAlign = 8; break;
+ default: nTextAlign = 24; break;
+ }
+
+ ImplBeginRecord( WIN_EMR_SETTEXTALIGN );
+ (*mpStm) << nTextAlign;
+ ImplEndRecord();
+
+ // Text color
+ ImplBeginRecord( WIN_EMR_SETTEXTCOLOR );
+ ImplWriteColor( maVDev.GetTextColor() );
+ ImplEndRecord();
+
+ ImplBeginRecord( WIN_EMR_SELECTOBJECT );
+ (*mpStm) << mnTextHandle;
+ ImplEndRecord();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void EMFWriter::ImplWriteColor( const Color& rColor )
+{
+ UINT32 nCol = rColor.GetRed();
+
+ nCol |= ( (UINT32) rColor.GetGreen() ) << 8;
+ nCol |= ( (UINT32) rColor.GetBlue() ) << 16;
+
+ (*mpStm) << nCol;
+}
+
+// -----------------------------------------------------------------------------
+
+void EMFWriter::ImplWriteRasterOp( RasterOp eRop )
+{
+ UINT32 nROP2;
+
+ switch( eRop )
+ {
+ case ROP_INVERT: nROP2 = 6; break;
+ case ROP_XOR: nROP2 = 7; break;
+ default: nROP2 = 13;break;
+ }
+
+ ImplBeginRecord( WIN_EMR_SETROP2 );
+ (*mpStm) << nROP2;
+ ImplEndRecord();
+}
+
+// -----------------------------------------------------------------------------
+
+void EMFWriter::ImplWriteExtent( long nExtent )
+{
+ const Size aSize( maVDev.LogicToPixel( Size( nExtent, nExtent ) ) );
+ (*mpStm) << (INT32) aSize.Width();
+}
+
+// -----------------------------------------------------------------------------
+
+void EMFWriter::ImplWritePoint( const Point& rPoint )
+{
+ const Point aPoint( maVDev.LogicToPixel( rPoint ) );
+
+ (*mpStm) << (INT32) aPoint.X() << (INT32) aPoint.Y();
+}
+
+// -----------------------------------------------------------------------------
+
+void EMFWriter::ImplWriteSize( const Size& rSize)
+{
+ const Size aSize( maVDev.LogicToPixel( rSize ) );
+
+ (*mpStm) << (INT32) aSize.Width() << (INT32) aSize.Height();
+}
+
+// -----------------------------------------------------------------------------
+
+void EMFWriter::ImplWriteRect( const Rectangle& rRect )
+{
+ const Rectangle aRect( maVDev.LogicToPixel( rRect ) );
+
+ (*mpStm) << aRect.Left() << aRect.Top() << aRect.Right() << aRect.Bottom();
+}
+
+// -----------------------------------------------------------------------------
+
+void EMFWriter::ImplWritePolygonRecord( const Polygon& rPoly, BOOL bClose )
+{
+ if( rPoly.GetSize() )
+ {
+ if( rPoly.HasFlags() )
+ ImplWritePath( rPoly, bClose );
+ else
+ {
+ if( bClose )
+ ImplCheckFillAttr();
+
+ ImplCheckLineAttr();
+
+ ImplBeginRecord( bClose ? WIN_EMR_POLYGON : WIN_EMR_POLYLINE );
+ ImplWriteRect( rPoly.GetBoundRect() );
+ (*mpStm) << (UINT32) rPoly.GetSize();
+
+ for( USHORT i = 0; i < rPoly.GetSize(); i++ )
+ ImplWritePoint( rPoly[ i ] );
+
+ ImplEndRecord();
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void EMFWriter::ImplWritePolyPolygonRecord( const PolyPolygon& rPolyPoly )
+{
+ sal_uInt16 n, i, nPolyCount = rPolyPoly.Count();
+
+ if( nPolyCount )
+ {
+ if( 1 == nPolyCount )
+ ImplWritePolygonRecord( rPolyPoly[ 0 ], TRUE );
+ else
+ {
+ sal_Bool bHasFlags = sal_False;
+ sal_uInt32 nTotalPoints = 0;
+
+ for( i = 0; i < nPolyCount; i++ )
+ {
+ nTotalPoints += rPolyPoly[ i ].GetSize();
+ if ( rPolyPoly[ i ].HasFlags() )
+ bHasFlags = sal_True;
+ }
+ if( nTotalPoints )
+ {
+ if ( bHasFlags )
+ ImplWritePath( rPolyPoly, sal_True );
+ else
+ {
+ ImplCheckFillAttr();
+ ImplCheckLineAttr();
+
+ ImplBeginRecord( WIN_EMR_POLYPOLYGON );
+ ImplWriteRect( rPolyPoly.GetBoundRect() );
+ (*mpStm) << (sal_uInt32)nPolyCount << nTotalPoints;
+
+ for( i = 0; i < nPolyCount; i++ )
+ (*mpStm) << (sal_uInt32)rPolyPoly[ i ].GetSize();
+
+ for( i = 0; i < nPolyCount; i++ )
+ {
+ const Polygon& rPoly = rPolyPoly[ i ];
+
+ for( n = 0; n < rPoly.GetSize(); n++ )
+ ImplWritePoint( rPoly[ n ] );
+ }
+ ImplEndRecord();
+ }
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void EMFWriter::ImplWritePath( const PolyPolygon& rPolyPoly, sal_Bool bClosed )
+{
+ if ( bClosed )
+ ImplCheckFillAttr();
+ ImplCheckLineAttr();
+
+ ImplBeginRecord( WIN_EMR_BEGINPATH );
+ ImplEndRecord();
+
+ sal_uInt16 i, n, o, nPolyCount = rPolyPoly.Count();
+ for ( i = 0; i < nPolyCount; i++ )
+ {
+ n = 0;
+ const Polygon& rPoly = rPolyPoly[ i ];
+ while ( n < rPoly.GetSize() )
+ {
+ sal_uInt16 nBezPoints = 0;
+ if ( n )
+ {
+ while ( ( ( nBezPoints + n + 2 ) < rPoly.GetSize() ) && ( rPoly.GetFlags( nBezPoints + n ) == POLY_CONTROL ) )
+ nBezPoints += 3;
+ }
+ if ( nBezPoints )
+ {
+ ImplBeginRecord( WIN_EMR_POLYBEZIERTO );
+ Polygon aNewPoly( nBezPoints + 1 );
+ aNewPoly[ 0 ] = rPoly[ n - 1 ];
+ for ( o = 0; o < nBezPoints; o++ )
+ aNewPoly[ o + 1 ] = rPoly[ n + o ];
+ ImplWriteRect( aNewPoly.GetBoundRect() );
+ (*mpStm) << (sal_uInt32)nBezPoints;
+ for( o = 1; o < aNewPoly.GetSize(); o++ )
+ ImplWritePoint( aNewPoly[ o ] );
+ ImplEndRecord();
+ n = n + nBezPoints;
+ }
+ else
+ {
+ sal_uInt16 nPoints = 1;
+ while( ( nPoints + n ) < rPoly.GetSize() && ( rPoly.GetFlags( nPoints + n ) != POLY_CONTROL ) )
+ nPoints++;
+ ImplBeginRecord( WIN_EMR_MOVETOEX );
+ ImplWritePoint( rPoly[ n ] );
+ ImplEndRecord();
+ if ( nPoints > 1 )
+ {
+ ImplBeginRecord( WIN_EMR_POLYLINETO );
+ Polygon aNewPoly( nPoints );
+ aNewPoly[ 0 ] = rPoly[ n ];
+ for ( o = 1; o < nPoints; o++ )
+ aNewPoly[ o ] = rPoly[ n + o ];
+ ImplWriteRect( aNewPoly.GetBoundRect() );
+ (*mpStm) << (sal_uInt32)( nPoints - 1 );
+ for( o = 1; o < aNewPoly.GetSize(); o++ )
+ ImplWritePoint( aNewPoly[ o ] );
+ ImplEndRecord();
+ }
+ n = n + nPoints;
+ }
+ if ( bClosed && ( n == rPoly.GetSize() ) )
+ {
+ ImplBeginRecord( WIN_EMR_CLOSEFIGURE );
+ ImplEndRecord();
+ }
+ }
+ }
+ ImplBeginRecord( WIN_EMR_ENDPATH );
+ ImplEndRecord();
+ ImplBeginRecord( bClosed ? WIN_EMR_FILLPATH : WIN_EMR_STROKEPATH );
+ ImplEndRecord();
+}
+
+// -----------------------------------------------------------------------------
+
+void EMFWriter::ImplWriteBmpRecord( const Bitmap& rBmp, const Point& rPt,
+ const Size& rSz, UINT32 nROP )
+{
+ if( !!rBmp )
+ {
+ SvMemoryStream aMemStm( 65535, 65535 );
+ const Size aBmpSizePixel( rBmp.GetSizePixel() );
+
+ ImplBeginRecord( WIN_EMR_STRETCHDIBITS );
+ ImplWriteRect( Rectangle( rPt, rSz ) );
+ ImplWritePoint( rPt );
+ (*mpStm) << (INT32) 0 << (INT32) 0 << (INT32) aBmpSizePixel.Width() << (INT32) aBmpSizePixel.Height();
+
+ // write offset positions and sizes later
+ const ULONG nOffPos = mpStm->Tell();
+ mpStm->SeekRel( 16 );
+
+ (*mpStm) << (UINT32) 0 << ( ( ROP_XOR == maVDev.GetRasterOp() && WIN_SRCCOPY == nROP ) ? WIN_SRCINVERT : nROP );
+ ImplWriteSize( rSz );
+
+ rBmp.Write( aMemStm, TRUE, FALSE );
+
+ UINT32 nDIBSize = aMemStm.Tell(), nHeaderSize, nCompression, nColsUsed, nPalCount, nImageSize;
+ UINT16 nBitCount;
+
+ // get DIB parameters
+ aMemStm.Seek( 0 );
+ aMemStm >> nHeaderSize;
+ aMemStm.SeekRel( 10 );
+ aMemStm >> nBitCount >> nCompression >> nImageSize;
+ aMemStm.SeekRel( 8 );
+ aMemStm >> nColsUsed;
+
+ nPalCount = ( nBitCount <= 8 ) ? ( nColsUsed ? nColsUsed : ( 1 << (UINT32) nBitCount ) ) :
+ ( ( 3 == nCompression ) ? 12 : 0 );
+
+ mpStm->Write( aMemStm.GetData(), nDIBSize );
+
+ const ULONG nEndPos = mpStm->Tell();
+ mpStm->Seek( nOffPos );
+ (*mpStm) << (UINT32) 80 << (UINT32)( nHeaderSize + ( nPalCount << 2 ) );
+ (*mpStm) << (UINT32)( 80 + ( nHeaderSize + ( nPalCount << 2 ) ) ) << nImageSize;
+ mpStm->Seek( nEndPos );
+
+ ImplEndRecord();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void EMFWriter::ImplWriteTextRecord( const Point& rPos, const String rText, const sal_Int32* pDXArray, sal_uInt32 nWidth )
+{
+ xub_StrLen nLen = rText.Len(), i;
+
+ if( nLen )
+ {
+ sal_uInt32 nNormWidth;
+ sal_Int32* pOwnArray;
+ sal_Int32* pDX;
+
+ // get text sizes
+ if( pDXArray )
+ {
+ pOwnArray = NULL;
+ nNormWidth = maVDev.GetTextWidth( rText );
+ pDX = (sal_Int32*) pDXArray;
+ }
+ else
+ {
+ pOwnArray = new sal_Int32[ nLen ];
+ nNormWidth = maVDev.GetTextArray( rText, pOwnArray );
+ pDX = pOwnArray;
+ }
+
+ if( nLen > 1 )
+ {
+ nNormWidth = pDX[ nLen - 2 ] + maVDev.GetTextWidth( rText.GetChar( nLen - 1 ) );
+
+ if( nWidth && nNormWidth && ( nWidth != nNormWidth ) )
+ {
+ const double fFactor = (double) nWidth / nNormWidth;
+
+ for( i = 0; i < ( nLen - 1 ); i++ )
+ pDX[ i ] = FRound( pDX[ i ] * fFactor );
+ }
+ }
+
+ // write text record
+ ImplBeginRecord( WIN_EMR_EXTTEXTOUTW );
+
+ ImplWriteRect( Rectangle( rPos, Size( nNormWidth, maVDev.GetTextHeight() ) ) );
+ (*mpStm) << (UINT32)1;
+ (*mpStm) << (INT32) 0 << (INT32) 0;
+ ImplWritePoint( rPos );
+ (*mpStm) << (UINT32) nLen << (UINT32) 76 << (UINT32) 2;
+ (*mpStm) << (INT32) 0 << (INT32) 0 << (INT32) 0 << (INT32) 0;
+ (*mpStm) << (UINT32) ( 76 + ( nLen << 1 ) + ( (nLen & 1 ) ? 2 : 0 ) );
+
+ // write text
+ for( i = 0; i < nLen; i++ )
+ (*mpStm) << (sal_Unicode)rText.GetChar( i );
+
+ // padding word
+ if( nLen & 1 )
+ (*mpStm) << (UINT16) 0;
+
+ // write DX array
+ ImplWriteExtent( pDX[ 0 ] );
+
+ if( nLen > 1 )
+ {
+ for( i = 1; i < ( nLen - 1 ); i++ )
+ ImplWriteExtent( pDX[ i ] - pDX[ i - 1 ] );
+
+ ImplWriteExtent( pDX[ nLen - 2 ] / ( nLen - 1 ) );
+ }
+
+ ImplEndRecord();
+ delete[] pOwnArray;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
+{
+ for( ULONG j = 0, nActionCount = rMtf.GetActionCount(); j < nActionCount; j++ )
+ {
+ const MetaAction* pAction = rMtf.GetAction( j );
+ const USHORT nType = pAction->GetType();
+
+ switch( nType )
+ {
+ case( META_PIXEL_ACTION ):
+ {
+ const MetaPixelAction* pA = (const MetaPixelAction*) pAction;
+
+ ImplCheckLineAttr();
+ ImplBeginRecord( WIN_EMR_SETPIXELV );
+ ImplWritePoint( pA->GetPoint() );
+ ImplWriteColor( pA->GetColor() );
+ ImplEndRecord();
+ }
+ break;
+
+ case( META_POINT_ACTION ):
+ {
+ if( maVDev.IsLineColor() )
+ {
+ const MetaPointAction* pA = (const MetaPointAction*) pAction;
+
+ ImplCheckLineAttr();
+ ImplBeginRecord( WIN_EMR_SETPIXELV );
+ ImplWritePoint( pA->GetPoint() );
+ ImplWriteColor( maVDev.GetLineColor() );
+ ImplEndRecord();
+ }
+ }
+ break;
+
+ case( META_LINE_ACTION ):
+ {
+ if( maVDev.IsLineColor() )
+ {
+ const MetaLineAction* pA = (const MetaLineAction*) pAction;
+
+ ImplCheckLineAttr();
+
+ ImplBeginRecord( WIN_EMR_MOVETOEX );
+ ImplWritePoint( pA->GetStartPoint() );
+ ImplEndRecord();
+
+ ImplBeginRecord( WIN_EMR_LINETO );
+ ImplWritePoint( pA->GetEndPoint() );
+ ImplEndRecord();
+
+ ImplBeginRecord( WIN_EMR_SETPIXELV );
+ ImplWritePoint( pA->GetEndPoint() );
+ ImplWriteColor( maVDev.GetLineColor() );
+ ImplEndRecord();
+ }
+ }
+ break;
+
+ case( META_RECT_ACTION ):
+ {
+ if( maVDev.IsLineColor() || maVDev.IsFillColor() )
+ {
+ const MetaRectAction* pA = (const MetaRectAction*) pAction;
+
+ ImplCheckFillAttr();
+ ImplCheckLineAttr();
+
+ ImplBeginRecord( WIN_EMR_RECTANGLE );
+ ImplWriteRect( pA->GetRect() );
+ ImplEndRecord();
+ }
+ }
+ break;
+
+ case( META_ROUNDRECT_ACTION ):
+ {
+ if( maVDev.IsLineColor() || maVDev.IsFillColor() )
+ {
+ const MetaRoundRectAction* pA = (const MetaRoundRectAction*) pAction;
+
+ ImplCheckFillAttr();
+ ImplCheckLineAttr();
+
+ ImplBeginRecord( WIN_EMR_ROUNDRECT );
+ ImplWriteRect( pA->GetRect() );
+ ImplWriteSize( Size( pA->GetHorzRound(), pA->GetVertRound() ) );
+ ImplEndRecord();
+ }
+ }
+ break;
+
+ case( META_ELLIPSE_ACTION ):
+ {
+ if( maVDev.IsLineColor() || maVDev.IsFillColor() )
+ {
+ const MetaEllipseAction* pA = (const MetaEllipseAction*) pAction;
+
+ ImplCheckFillAttr();
+ ImplCheckLineAttr();
+
+ ImplBeginRecord( WIN_EMR_ELLIPSE );
+ ImplWriteRect( pA->GetRect() );
+ ImplEndRecord();
+ }
+ }
+ break;
+
+ case( META_ARC_ACTION ):
+ case( META_PIE_ACTION ):
+ case( META_CHORD_ACTION ):
+ case( META_POLYGON_ACTION ):
+ {
+ if( maVDev.IsLineColor() || maVDev.IsFillColor() )
+ {
+ Polygon aPoly;
+
+ switch( nType )
+ {
+ case( META_ARC_ACTION ):
+ {
+ const MetaArcAction* pA = (const MetaArcAction*) pAction;
+ aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_ARC );
+ }
+ break;
+
+ case( META_PIE_ACTION ):
+ {
+ const MetaPieAction* pA = (const MetaPieAction*) pAction;
+ aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_PIE );
+ }
+ break;
+
+ case( META_CHORD_ACTION ):
+ {
+ const MetaChordAction* pA = (const MetaChordAction*) pAction;
+ aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_CHORD );
+ }
+ break;
+
+ case( META_POLYGON_ACTION ):
+ aPoly = ( (const MetaPolygonAction*) pAction )->GetPolygon();
+ break;
+ }
+
+ ImplWritePolygonRecord( aPoly, nType != META_ARC_ACTION );
+ }
+ }
+ break;
+
+ case( META_POLYLINE_ACTION ):
+ {
+ if( maVDev.IsLineColor() )
+ ImplWritePolygonRecord( ( (const MetaPolyLineAction*) pAction )->GetPolygon(), FALSE );
+ }
+ break;
+
+ case( META_POLYPOLYGON_ACTION ):
+ {
+ if( maVDev.IsLineColor() || maVDev.IsFillColor() )
+ ImplWritePolyPolygonRecord( ( (const MetaPolyPolygonAction*) pAction )->GetPolyPolygon() );
+ }
+ break;
+
+ case( META_GRADIENT_ACTION ):
+ {
+ const MetaGradientAction* pA = (const MetaGradientAction*) pAction;
+ GDIMetaFile aTmpMtf;
+
+ maVDev.AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf );
+ ImplWrite( aTmpMtf );
+ }
+ break;
+
+ case META_HATCH_ACTION:
+ {
+ const MetaHatchAction* pA = (const MetaHatchAction*) pAction;
+ GDIMetaFile aTmpMtf;
+
+ maVDev.AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf );
+ ImplWrite( aTmpMtf );
+ }
+ break;
+
+ case META_TRANSPARENT_ACTION:
+ {
+ ImplCheckFillAttr();
+ ImplCheckLineAttr();
+ ImplWritePolyPolygonRecord( ( (MetaTransparentAction*) pAction )->GetPolyPolygon() );
+ }
+ break;
+
+ case META_FLOATTRANSPARENT_ACTION:
+ {
+ const MetaFloatTransparentAction* pA = (const MetaFloatTransparentAction*) pAction;
+
+ GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() );
+ Point aSrcPt( aTmpMtf.GetPrefMapMode().GetOrigin() );
+ const Size aSrcSize( aTmpMtf.GetPrefSize() );
+ const Point aDestPt( pA->GetPoint() );
+ const Size aDestSize( pA->GetSize() );
+ const double fScaleX = aSrcSize.Width() ? (double) aDestSize.Width() / aSrcSize.Width() : 1.0;
+ const double fScaleY = aSrcSize.Height() ? (double) aDestSize.Height() / aSrcSize.Height() : 1.0;
+ long nMoveX, nMoveY;
+
+ if( fScaleX != 1.0 || fScaleY != 1.0 )
+ {
+ aTmpMtf.Scale( fScaleX, fScaleY );
+ aSrcPt.X() = FRound( aSrcPt.X() * fScaleX ), aSrcPt.Y() = FRound( aSrcPt.Y() * fScaleY );
+ }
+
+ nMoveX = aDestPt.X() - aSrcPt.X(), nMoveY = aDestPt.Y() - aSrcPt.Y();
+
+ if( nMoveX || nMoveY )
+ aTmpMtf.Move( nMoveX, nMoveY );
+
+ ImplCheckFillAttr();
+ ImplCheckLineAttr();
+ ImplCheckTextAttr();
+ ImplWrite( aTmpMtf );
+ }
+ break;
+
+ case( META_EPS_ACTION ):
+ {
+ const MetaEPSAction* pA = (const MetaEPSAction*) pAction;
+ const GDIMetaFile aSubstitute( pA->GetSubstitute() );
+
+ for( ULONG i = 0, nCount = aSubstitute.GetActionCount(); i < nCount; i++ )
+ {
+ const MetaAction* pSubstAct = aSubstitute.GetAction( i );
+ if( pSubstAct->GetType() == META_BMPSCALE_ACTION )
+ {
+ maVDev.Push( PUSH_ALL );
+ ImplBeginRecord( WIN_EMR_SAVEDC );
+ ImplEndRecord();
+
+ MapMode aMapMode( aSubstitute.GetPrefMapMode() );
+ Size aOutSize( maVDev.LogicToLogic( pA->GetSize(), maVDev.GetMapMode(), aMapMode ) );
+ aMapMode.SetScaleX( Fraction( aOutSize.Width(), aSubstitute.GetPrefSize().Width() ) );
+ aMapMode.SetScaleY( Fraction( aOutSize.Height(), aSubstitute.GetPrefSize().Height() ) );
+ aMapMode.SetOrigin( maVDev.LogicToLogic( pA->GetPoint(), maVDev.GetMapMode(), aMapMode ) );
+ maVDev.SetMapMode( aMapMode );
+ ImplWrite( aSubstitute );
+
+ maVDev.Pop();
+ ImplBeginRecord( WIN_EMR_RESTOREDC );
+ (*mpStm) << (INT32) -1;
+ ImplEndRecord();
+ break;
+ }
+ }
+ }
+ break;
+
+ case META_BMP_ACTION:
+ {
+ const MetaBmpAction* pA = (const MetaBmpAction *) pAction;
+ ImplWriteBmpRecord( pA->GetBitmap(), pA->GetPoint(), pA->GetBitmap().GetSizePixel(), WIN_SRCCOPY );
+ }
+ break;
+
+ case META_BMPSCALE_ACTION:
+ {
+ const MetaBmpScaleAction* pA = (const MetaBmpScaleAction*) pAction;
+ ImplWriteBmpRecord( pA->GetBitmap(), pA->GetPoint(), pA->GetSize(), WIN_SRCCOPY );
+ }
+ break;
+
+ case META_BMPSCALEPART_ACTION:
+ {
+ const MetaBmpScalePartAction* pA = (const MetaBmpScalePartAction*) pAction;
+ Bitmap aTmp( pA->GetBitmap() );
+
+ if( aTmp.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ) )
+ ImplWriteBmpRecord( aTmp, pA->GetDestPoint(), pA->GetDestSize(), WIN_SRCCOPY );
+ }
+ break;
+
+ case META_BMPEX_ACTION:
+ {
+ const MetaBmpExAction* pA = (const MetaBmpExAction *) pAction;
+ Bitmap aBmp( pA->GetBitmapEx().GetBitmap() );
+ Bitmap aMsk( pA->GetBitmapEx().GetMask() );
+
+ if( !!aMsk )
+ {
+ aBmp.Replace( aMsk, COL_WHITE );
+ aMsk.Invert();
+ ImplWriteBmpRecord( aMsk, pA->GetPoint(), aMsk.GetSizePixel(), WIN_SRCPAINT );
+ ImplWriteBmpRecord( aBmp, pA->GetPoint(), aBmp.GetSizePixel(), WIN_SRCAND );
+ }
+ else
+ ImplWriteBmpRecord( aBmp, pA->GetPoint(), aBmp.GetSizePixel(), WIN_SRCCOPY );
+ }
+ break;
+
+ case META_BMPEXSCALE_ACTION:
+ {
+ const MetaBmpExScaleAction* pA = (const MetaBmpExScaleAction*) pAction;
+ Bitmap aBmp( pA->GetBitmapEx().GetBitmap() );
+ Bitmap aMsk( pA->GetBitmapEx().GetMask() );
+
+ if( !!aMsk )
+ {
+ aBmp.Replace( aMsk, COL_WHITE );
+ aMsk.Invert();
+ ImplWriteBmpRecord( aMsk, pA->GetPoint(), pA->GetSize(), WIN_SRCPAINT );
+ ImplWriteBmpRecord( aBmp, pA->GetPoint(), pA->GetSize(), WIN_SRCAND );
+ }
+ else
+ ImplWriteBmpRecord( aBmp, pA->GetPoint(), pA->GetSize(), WIN_SRCCOPY );
+ }
+ break;
+
+ case META_BMPEXSCALEPART_ACTION:
+ {
+ const MetaBmpExScalePartAction* pA = (const MetaBmpExScalePartAction*) pAction;
+ BitmapEx aBmpEx( pA->GetBitmapEx() );
+ aBmpEx.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) );
+ Bitmap aBmp( aBmpEx.GetBitmap() );
+ Bitmap aMsk( aBmpEx.GetMask() );
+
+ if( !!aMsk )
+ {
+ aBmp.Replace( aMsk, COL_WHITE );
+ aMsk.Invert();
+ ImplWriteBmpRecord( aMsk, pA->GetDestPoint(), pA->GetDestSize(), WIN_SRCPAINT );
+ ImplWriteBmpRecord( aBmp, pA->GetDestPoint(), pA->GetDestSize(), WIN_SRCAND );
+ }
+ else
+ ImplWriteBmpRecord( aBmp, pA->GetDestPoint(), pA->GetDestSize(), WIN_SRCCOPY );
+ }
+ break;
+
+ case META_TEXT_ACTION:
+ {
+ const MetaTextAction* pA = (const MetaTextAction*) pAction;
+ const String aText( pA->GetText(), pA->GetIndex(), pA->GetLen() );
+
+ ImplCheckTextAttr();
+ ImplWriteTextRecord( pA->GetPoint(), aText, NULL, 0 );
+ }
+ break;
+
+ case META_TEXTRECT_ACTION:
+ {
+ const MetaTextRectAction* pA = (const MetaTextRectAction*) pAction;
+ const String aText( pA->GetText() );
+
+ ImplCheckTextAttr();
+ ImplWriteTextRecord( pA->GetRect().TopLeft(), aText, NULL, 0 );
+ }
+ break;
+
+ case META_TEXTARRAY_ACTION:
+ {
+ const MetaTextArrayAction* pA = (const MetaTextArrayAction*) pAction;
+ const String aText( pA->GetText(), pA->GetIndex(), pA->GetLen() );
+
+ ImplCheckTextAttr();
+ ImplWriteTextRecord( pA->GetPoint(), aText, pA->GetDXArray(), 0 );
+ }
+ break;
+
+ case META_STRETCHTEXT_ACTION:
+ {
+ const MetaStretchTextAction* pA = (const MetaStretchTextAction*) pAction;
+ const String aText( pA->GetText(), pA->GetIndex(), pA->GetLen() );
+
+ ImplCheckTextAttr();
+ ImplWriteTextRecord( pA->GetPoint(), aText, NULL, pA->GetWidth() );
+ }
+ break;
+
+ case( META_LINECOLOR_ACTION ):
+ {
+ ( (MetaAction*) pAction )->Execute( &maVDev );
+ mbLineChanged = TRUE;
+ }
+ break;
+
+ case( META_FILLCOLOR_ACTION ):
+ {
+ ( (MetaAction*) pAction )->Execute( &maVDev );
+ mbFillChanged = TRUE;
+ }
+ break;
+
+ case( META_TEXTCOLOR_ACTION ):
+ case( META_TEXTLINECOLOR_ACTION ):
+ case( META_TEXTFILLCOLOR_ACTION ):
+ case( META_TEXTALIGN_ACTION ):
+ case( META_FONT_ACTION ):
+ {
+ ( (MetaAction*) pAction )->Execute( &maVDev );
+ mbTextChanged = TRUE;
+ }
+ break;
+
+ case( META_ISECTRECTCLIPREGION_ACTION ):
+ {
+ ( (MetaAction*) pAction )->Execute( &maVDev );
+
+ ImplBeginRecord( WIN_EMR_INTERSECTCLIPRECT );
+ ImplWriteRect( ( (MetaISectRectClipRegionAction*) pAction )->GetRect() );
+ ImplEndRecord();
+ }
+ break;
+
+ case( META_CLIPREGION_ACTION ):
+ case( META_ISECTREGIONCLIPREGION_ACTION ):
+ case( META_MOVECLIPREGION_ACTION ):
+ {
+ ( (MetaAction*) pAction )->Execute( &maVDev );
+ }
+ break;
+
+ case( META_REFPOINT_ACTION ):
+ case( META_MAPMODE_ACTION ):
+ ( (MetaAction*) pAction )->Execute( &maVDev );
+ break;
+
+ case( META_PUSH_ACTION ):
+ {
+ ( (MetaAction*) pAction )->Execute( &maVDev );
+
+ ImplBeginRecord( WIN_EMR_SAVEDC );
+ ImplEndRecord();
+ }
+ break;
+
+ case( META_POP_ACTION ):
+ {
+ ( (MetaAction*) pAction )->Execute( &maVDev );
+
+ ImplBeginRecord( WIN_EMR_RESTOREDC );
+ (*mpStm) << (INT32) -1;
+ ImplEndRecord();
+
+ ImplWriteRasterOp( maVDev.GetRasterOp() );
+ mbLineChanged = mbFillChanged = mbTextChanged = TRUE;
+ }
+ break;
+
+ case( META_RASTEROP_ACTION ):
+ {
+ ( (MetaAction*) pAction )->Execute( &maVDev );
+ ImplWriteRasterOp( ( (MetaRasterOpAction*) pAction )->GetRasterOp() );
+ }
+ break;
+
+ case( META_MASK_ACTION ):
+ case( META_MASKSCALE_ACTION ):
+ case( META_MASKSCALEPART_ACTION ):
+ case( META_WALLPAPER_ACTION ):
+ case( META_TEXTLINE_ACTION ):
+ case( META_COMMENT_ACTION ):
+ case( META_GRADIENTEX_ACTION ):
+ case( META_LAYOUTMODE_ACTION ):
+ {
+ // !!! >>> we don't want to support these actions
+ }
+ break;
+
+ default:
+ DBG_ERROR( ( ByteString( "EMFWriter::ImplWriteActions: unsupported MetaAction #" ) += ByteString::CreateFromInt32( nType ) ).GetBuffer() );
+ break;
+ }
+ }
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/wmf/svt_enhwmf.cxx b/binfilter/bf_svtools/source/filter.vcl/wmf/svt_enhwmf.cxx
new file mode 100644
index 000000000000..1b79e7f1d746
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/wmf/svt_enhwmf.cxx
@@ -0,0 +1,1300 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 "winmtf.hxx"
+#include <osl/endian.h>
+
+namespace binfilter
+{
+
+//=========================== GDI-Array ===================================
+
+#define EMR_HEADER 1
+#define EMR_POLYBEZIER 2
+#define EMR_POLYGON 3
+#define EMR_POLYLINE 4
+#define EMR_POLYBEZIERTO 5
+#define EMR_POLYLINETO 6
+#define EMR_POLYPOLYLINE 7
+#define EMR_POLYPOLYGON 8
+#define EMR_SETWINDOWEXTEX 9
+#define EMR_SETWINDOWORGEX 10
+#define EMR_SETVIEWPORTEXTEX 11
+#define EMR_SETVIEWPORTORGEX 12
+#define EMR_SETBRUSHORGEX 13
+#define EMR_EOF 14
+#define EMR_SETPIXELV 15
+#define EMR_SETMAPPERFLAGS 16
+#define EMR_SETMAPMODE 17
+#define EMR_SETBKMODE 18
+#define EMR_SETPOLYFILLMODE 19
+#define EMR_SETROP2 20
+#define EMR_SETSTRETCHBLTMODE 21
+#define EMR_SETTEXTALIGN 22
+#define EMR_SETCOLORADJUSTMENT 23
+#define EMR_SETTEXTCOLOR 24
+#define EMR_SETBKCOLOR 25
+#define EMR_OFFSETCLIPRGN 26
+#define EMR_MOVETOEX 27
+#define EMR_SETMETARGN 28
+#define EMR_EXCLUDECLIPRECT 29
+#define EMR_INTERSECTCLIPRECT 30
+#define EMR_SCALEVIEWPORTEXTEX 31
+#define EMR_SCALEWINDOWEXTEX 32
+#define EMR_SAVEDC 33
+#define EMR_RESTOREDC 34
+#define EMR_SETWORLDTRANSFORM 35
+#define EMR_MODIFYWORLDTRANSFORM 36
+#define EMR_SELECTOBJECT 37
+#define EMR_CREATEPEN 38
+#define EMR_CREATEBRUSHINDIRECT 39
+#define EMR_DELETEOBJECT 40
+#define EMR_ANGLEARC 41
+#define EMR_ELLIPSE 42
+#define EMR_RECTANGLE 43
+#define EMR_ROUNDRECT 44
+#define EMR_ARC 45
+#define EMR_CHORD 46
+#define EMR_PIE 47
+#define EMR_SELECTPALETTE 48
+#define EMR_CREATEPALETTE 49
+#define EMR_SETPALETTEENTRIES 50
+#define EMR_RESIZEPALETTE 51
+#define EMR_REALIZEPALETTE 52
+#define EMR_EXTFLOODFILL 53
+#define EMR_LINETO 54
+#define EMR_ARCTO 55
+#define EMR_POLYDRAW 56
+#define EMR_SETARCDIRECTION 57
+#define EMR_SETMITERLIMIT 58
+#define EMR_BEGINPATH 59
+#define EMR_ENDPATH 60
+#define EMR_CLOSEFIGURE 61
+#define EMR_FILLPATH 62
+#define EMR_STROKEANDFILLPATH 63
+#define EMR_STROKEPATH 64
+#define EMR_FLATTENPATH 65
+#define EMR_WIDENPATH 66
+#define EMR_SELECTCLIPPATH 67
+#define EMR_ABORTPATH 68
+
+#define EMR_GDICOMMENT 70
+#define EMR_FILLRGN 71
+#define EMR_FRAMERGN 72
+#define EMR_INVERTRGN 73
+#define EMR_PAINTRGN 74
+#define EMR_EXTSELECTCLIPRGN 75
+#define EMR_BITBLT 76
+#define EMR_STRETCHBLT 77
+#define EMR_MASKBLT 78
+#define EMR_PLGBLT 79
+#define EMR_SETDIBITSTODEVICE 80
+#define EMR_STRETCHDIBITS 81
+#define EMR_EXTCREATEFONTINDIRECTW 82
+#define EMR_EXTTEXTOUTA 83
+#define EMR_EXTTEXTOUTW 84
+#define EMR_POLYBEZIER16 85
+#define EMR_POLYGON16 86
+#define EMR_POLYLINE16 87
+#define EMR_POLYBEZIERTO16 88
+#define EMR_POLYLINETO16 89
+#define EMR_POLYPOLYLINE16 90
+#define EMR_POLYPOLYGON16 91
+#define EMR_POLYDRAW16 92
+#define EMR_CREATEMONOBRUSH 93
+#define EMR_CREATEDIBPATTERNBRUSHPT 94
+#define EMR_EXTCREATEPEN 95
+#define EMR_POLYTEXTOUTA 96
+#define EMR_POLYTEXTOUTW 97
+
+// WINDOWS VERSION >= 0x400
+#define EMR_SETICMMODE 98
+#define EMR_CREATECOLORSPACE 99
+#define EMR_SETCOLORSPACE 100
+#define EMR_DELETECOLORSPACE 101
+#define EMR_GLSRECORD 102
+#define EMR_GLSBOUNDEDRECORD 103
+#define EMR_PIXELFORMAT 104
+
+// WINDOWS VERSION >= 0x500
+#define EMR_DRAWESCAPE 105
+#define EMR_EXTESCAPE 106
+#define EMR_STARTDOC 107
+#define EMR_SMALLTEXTOUT 108
+#define EMR_FORCEUFIMAPPING 109
+#define EMR_NAMEDESCAPE 110
+#define EMR_COLORCORRECTPALETTE 111
+#define EMR_SETICMPROFILEA 112
+#define EMR_SETICMPROFILEW 113
+#define EMR_ALPHABLEND 114
+#define EMR_ALPHADIBBLEND 115
+#define EMR_TRANSPARENTBLT 116
+#define EMR_TRANSPARENTDIB 117
+#define EMR_GRADIENTFILL 118
+#define EMR_SETLINKEDUFIS 119
+#define EMR_SETTEXTJUSTIFICATION 120
+
+
+//-----------------------------------------------------------------------------------
+
+#ifdef OSL_BIGENDIAN
+// currently unused
+static float GetSwapFloat( SvStream& rSt )
+{
+ float fTmp;
+ sal_Int8* pPtr = (sal_Int8*)&fTmp;
+ rSt >> pPtr[3] >> pPtr[2] >> pPtr[1] >> pPtr[0]; // Little Endian <-> Big Endian switch
+ return fTmp;
+}
+#endif
+
+SvStream& operator>>( SvStream& rIn, XForm& rXForm )
+{
+ if ( sizeof( float ) != 4 )
+ {
+ DBG_ERROR( "EnhWMFReader::sizeof( float ) != 4" );
+ rXForm = XForm();
+ }
+ else
+ {
+#ifdef OSL_BIGENDIAN
+ rXForm.eM11 = GetSwapFloat( rIn );
+ rXForm.eM12 = GetSwapFloat( rIn );
+ rXForm.eM21 = GetSwapFloat( rIn );
+ rXForm.eM22 = GetSwapFloat( rIn );
+ rXForm.eDx = GetSwapFloat( rIn );
+ rXForm.eDy = GetSwapFloat( rIn );
+#else
+ rIn >> rXForm.eM11 >> rXForm.eM12 >> rXForm.eM21 >> rXForm.eM22
+ >> rXForm.eDx >> rXForm.eDy;
+#endif
+ }
+ return rIn;
+}
+
+static sal_Bool ImplReadRegion( PolyPolygon& rPolyPoly, SvStream& rSt, sal_uInt32 nLen )
+{
+ sal_Bool bOk = sal_False;
+ if ( nLen )
+ {
+ sal_uInt32 nHdSize, nType, nCount, nRgnSize, i;
+ rSt >> nHdSize
+ >> nType
+ >> nCount
+ >> nRgnSize;
+
+ if ( nCount && ( nType == RDH_RECTANGLES ) &&
+ ( nLen >= ( ( nCount << 4 ) + ( nHdSize - 16 ) ) ) )
+ {
+ sal_Int32 nx1, ny1, nx2, ny2;
+
+ for ( i = 0; i < nCount; i++ )
+ {
+ rSt >> nx1 >> ny1 >> nx2 >> ny2;
+
+ Rectangle aRect( Point( nx1, ny1 ), Point( nx2, ny2 ) );
+ Polygon aPolygon( aRect );
+ PolyPolygon aPolyPolyOr1( aPolygon );
+ PolyPolygon aPolyPolyOr2( rPolyPoly );
+ rPolyPoly.GetUnion( aPolyPolyOr1, aPolyPolyOr2 );
+ rPolyPoly = aPolyPolyOr2;
+ }
+ bOk = sal_True;
+ }
+ }
+ return bOk;
+}
+
+BOOL EnhWMFReader::ReadEnhWMF()
+{
+ sal_uInt32 nStretchBltMode = 0;
+ sal_uInt32 nRecType, nRecSize, nNextPos,
+ nW, nH, nPoints, nColor, nIndex,
+ nDat32, nNom1, nDen1, nNom2, nDen2;
+ sal_Int32 nX32, nY32, nx32, ny32;
+ sal_Int16 nX16, nY16;
+
+ sal_Bool bFlag, bStatus = ReadHeader();
+
+ while( bStatus && nRecordCount-- )
+ {
+ *pWMF >> nRecType >> nRecSize;
+
+ if ( ( nRecSize < 8 ) || ( nRecSize & 3 ) ) // Parameter sind immer durch 4 teilbar
+ {
+ bStatus = FALSE;
+ break;
+ }
+
+ nNextPos = pWMF->Tell() + ( nRecSize - 8 );
+
+ if ( nNextPos > nEndPos )
+ {
+ bStatus = FALSE;
+ break;
+ }
+
+ if( aBmpSaveList.Count() && ( nRecType != EMR_STRETCHBLT ) && ( nRecType != EMR_STRETCHDIBITS ) )
+ pOut->ResolveBitmapActions( aBmpSaveList );
+
+ bFlag = sal_False;
+
+ switch( nRecType )
+ {
+ case EMR_POLYBEZIERTO :
+ bFlag = sal_True;
+ case EMR_POLYBEZIER :
+ {
+ pWMF->SeekRel( 16 );
+ *pWMF >> nPoints;
+ sal_uInt16 i = 0;
+ if ( bFlag )
+ {
+ i++;
+ nPoints++;
+ }
+ Polygon aPoly( (sal_uInt16)nPoints );
+ for( ; i < (sal_uInt16)nPoints; i++ )
+ {
+ *pWMF >> nX32 >> nY32;
+ aPoly[ i ] = Point( nX32, nY32 );
+ }
+ pOut->DrawPolyBezier( aPoly, bFlag, bRecordPath );
+ }
+ break;
+
+ case EMR_POLYGON :
+ {
+ pWMF->SeekRel( 16 );
+ *pWMF >> nPoints;
+ Polygon aPoly( (UINT16)nPoints );
+ for( UINT16 k = 0; k < (UINT16)nPoints; k++ )
+ {
+ *pWMF >> nX32 >> nY32;
+ aPoly[ k ] = Point( nX32, nY32 );
+ }
+ pOut->DrawPolygon( aPoly, bRecordPath );
+ }
+ break;
+
+ case EMR_POLYLINETO :
+ bFlag = sal_True;
+ case EMR_POLYLINE :
+ {
+ pWMF->SeekRel( 0x10 );
+ *pWMF >> nPoints;
+ UINT16 i = 0;
+ if ( bFlag )
+ {
+ i++;
+ nPoints++;
+ }
+ Polygon aPolygon( (UINT16)nPoints );
+ for ( ; i < (UINT16)nPoints; i++ )
+ {
+ *pWMF >> nX32 >> nY32;
+ aPolygon[ i ] = Point( nX32, nY32 );
+ }
+ pOut->DrawPolyLine( aPolygon, bFlag, bRecordPath );
+ }
+ break;
+
+ case EMR_POLYPOLYLINE :
+ {
+ UINT16* pnPoints;
+
+ INT32 i, nPoly;
+ pWMF->SeekRel( 0x10 );
+
+ // Anzahl der Polygone:
+ *pWMF >> nPoly >> i;
+
+ // Anzahl der Punkte eines jeden Polygons holen, Gesammtzahl der Punkte ermitteln:
+ pnPoints = new UINT16[ nPoly ];
+
+ for ( i = 0; i < nPoly; i++ )
+ {
+ *pWMF >> nPoints;
+ pnPoints[ i ] = (UINT16)nPoints;
+ }
+
+ // Polygonpunkte holen:
+
+ for ( i = 0; i < nPoly; i++ )
+ {
+ Polygon aPoly( pnPoints[ i ] );
+ for( UINT16 k = 0; k < pnPoints[ i ]; k++ )
+ {
+ *pWMF >> nX32 >> nY32;
+ aPoly[ k ] = Point( nX32, nY32 );
+ }
+ pOut->DrawPolyLine( aPoly, sal_False, bRecordPath );
+ }
+ delete[] pnPoints;
+ }
+ break;
+
+ case EMR_POLYPOLYGON :
+ {
+ UINT16* pnPoints;
+ Point* pPtAry;
+
+ UINT32 i, nPoly, nGesPoints;
+ pWMF->SeekRel( 0x10 );
+
+ // Anzahl der Polygone:
+ *pWMF >> nPoly >> nGesPoints;
+
+ if (nGesPoints < SAL_MAX_UINT32 / sizeof(Point))
+ {
+
+ // Anzahl der Punkte eines jeden Polygons holen, Gesammtzahl der Punkte ermitteln:
+ pnPoints = new UINT16[ nPoly ];
+
+ for ( i = 0; i < nPoly; i++ )
+ {
+ *pWMF >> nPoints;
+ pnPoints[ i ] = (UINT16)nPoints;
+ }
+ // Polygonpunkte holen:
+ pPtAry = (Point*) new char[ nGesPoints * sizeof(Point) ];
+
+ for ( i = 0; i < nGesPoints; i++ )
+ {
+ *pWMF >> nX32 >> nY32;
+ pPtAry[ i ] = Point( nX32, nY32 );
+ }
+ // PolyPolygon Actions erzeugen
+ PolyPolygon aPolyPoly( (UINT16)nPoly, pnPoints, pPtAry );
+ pOut->DrawPolyPolygon( aPolyPoly, bRecordPath );
+ delete[] (char*) pPtAry;
+ delete[] pnPoints;
+ }
+ }
+ break;
+
+ case EMR_SETWINDOWEXTEX :
+ { // #75383#
+ *pWMF >> nW >> nH;
+ pOut->SetWinExt( Size( nW, nH ) );
+ }
+ break;
+
+ case EMR_SETWINDOWORGEX :
+ {
+ *pWMF >> nX32 >> nY32;
+ pOut->SetWinOrg( Point( nX32, nY32 ) );
+ }
+ break;
+
+ case EMR_SCALEWINDOWEXTEX :
+ {
+ *pWMF >> nNom1 >> nDen1 >> nNom2 >> nDen2;
+ pOut->ScaleWinExt( (double)nNom1 / nDen1, (double)nNom2 / nDen2 );
+ }
+ break;
+
+ case EMR_SETVIEWPORTORGEX :
+ {
+ *pWMF >> nX32 >> nY32;
+ pOut->SetDevOrg( Point( nX32, nY32 ) );
+ }
+ break;
+
+ case EMR_SCALEVIEWPORTEXTEX :
+ {
+ *pWMF >> nNom1 >> nDen1 >> nNom2 >> nDen2;
+ pOut->ScaleDevExt( (double)nNom1 / nDen1, (double)nNom2 / nDen2 );
+ }
+ break;
+
+ case EMR_SETVIEWPORTEXTEX :
+ {
+ *pWMF >> nW >> nH;
+ pOut->SetDevExt( Size( nW, nH ) );
+ }
+ break;
+
+ case EMR_EOF :
+ nRecordCount = 0; // #76846#
+ break;
+
+ case EMR_SETPIXELV :
+ {
+ *pWMF >> nX32 >> nY32;
+ pOut->DrawPixel( Point( nX32, nY32 ), ReadColor() );
+ }
+ break;
+
+ case EMR_SETMAPMODE :
+ {
+ sal_uInt32 nMapMode;
+ *pWMF >> nMapMode;
+ pOut->SetMapMode( nMapMode );
+ }
+ break;
+
+ case EMR_SETBKMODE :
+ {
+ *pWMF >> nDat32;
+ pOut->SetBkMode( nDat32 );
+ }
+ break;
+
+ case EMR_SETPOLYFILLMODE :
+ break;
+
+ case EMR_SETROP2 :
+ {
+ *pWMF >> nDat32;
+ pOut->SetRasterOp( nDat32 );
+ }
+ break;
+
+ case EMR_SETSTRETCHBLTMODE :
+ {
+ *pWMF >> nStretchBltMode;
+ }
+ break;
+
+ case EMR_SETTEXTALIGN :
+ {
+ *pWMF >> nDat32;
+ pOut->SetTextAlign( nDat32 );
+ }
+ break;
+
+ case EMR_SETTEXTCOLOR :
+ {
+ pOut->SetTextColor( ReadColor() );
+ }
+ break;
+
+ case EMR_SETBKCOLOR :
+ {
+ pOut->SetBkColor( ReadColor() );
+ }
+ break;
+
+ case EMR_OFFSETCLIPRGN :
+ {
+ *pWMF >> nX32 >> nY32;
+ pOut->MoveClipRegion( Size( nX32, nY32 ) );
+ }
+ break;
+
+ case EMR_MOVETOEX :
+ {
+ *pWMF >> nX32 >> nY32;
+ pOut->MoveTo( Point( nX32, nY32 ), bRecordPath );
+ }
+ break;
+
+ case EMR_INTERSECTCLIPRECT :
+ {
+ *pWMF >> nX32 >> nY32 >> nx32 >> ny32;
+ pOut->IntersectClipRect( ReadRectangle( nX32, nY32, nx32, ny32 ) );
+ }
+ break;
+
+ case EMR_SAVEDC :
+ {
+ pOut->Push();
+ }
+ break;
+
+ case EMR_RESTOREDC :
+ {
+ pOut->Pop();
+ }
+ break;
+
+ case EMR_SETWORLDTRANSFORM :
+ {
+ XForm aTempXForm;
+ *pWMF >> aTempXForm;
+ pOut->SetWorldTransform( aTempXForm );
+ }
+ break;
+
+ case EMR_MODIFYWORLDTRANSFORM :
+ {
+ UINT32 nMode;
+ XForm aTempXForm;
+ *pWMF >> aTempXForm >> nMode;
+ pOut->ModifyWorldTransform( aTempXForm, nMode );
+ }
+ break;
+
+ case EMR_SELECTOBJECT :
+ {
+ *pWMF >> nIndex;
+ pOut->SelectObject( nIndex );
+ }
+ break;
+
+ case EMR_CREATEPEN :
+ {
+ *pWMF >> nIndex;
+ if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
+ {
+
+ LineInfo aLineInfo;
+ UINT32 nStyle;
+ Size aSize;
+
+ *pWMF >> nStyle >> aSize.Width() >> aSize.Height();
+
+ if ( aSize.Width() )
+ aLineInfo.SetWidth( aSize.Width() );
+
+ BOOL bTransparent = FALSE;
+ UINT16 nDashCount = 0;
+ UINT16 nDotCount = 0;
+ switch( nStyle )
+ {
+ case PS_DASHDOTDOT :
+ nDotCount++;
+ case PS_DASHDOT :
+ nDashCount++;
+ case PS_DOT :
+ nDotCount++;
+ break;
+ case PS_DASH :
+ nDashCount++;
+ break;
+ case PS_NULL :
+ bTransparent = TRUE;
+ aLineInfo.SetStyle( LINE_NONE );
+ break;
+ default :
+ case PS_INSIDEFRAME :
+ case PS_SOLID :
+ aLineInfo.SetStyle( LINE_SOLID );
+ }
+ if ( nDashCount | nDotCount )
+ {
+ aLineInfo.SetStyle( LINE_DASH );
+ aLineInfo.SetDashCount( nDashCount );
+ aLineInfo.SetDotCount( nDotCount );
+ }
+ pOut->CreateObject( nIndex, GDI_PEN, new WinMtfLineStyle( ReadColor(), aLineInfo, bTransparent ) );
+ }
+ }
+ break;
+
+ case EMR_EXTCREATEPEN :
+ {
+ sal_Int32 elpHatch;
+ sal_uInt32 offBmi, cbBmi, offBits, cbBits, nStyle, nWidth, nBrushStyle, elpNumEntries;
+ Color aColorRef;
+
+ *pWMF >> nIndex;
+ if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
+ {
+ *pWMF >> offBmi >> cbBmi >> offBits >> cbBits >> nStyle >> nWidth >> nBrushStyle;
+ aColorRef = ReadColor();
+ *pWMF >> elpHatch >> elpNumEntries;
+
+ LineInfo aLineInfo;
+ if ( nWidth )
+ aLineInfo.SetWidth( nWidth );
+
+ sal_Bool bTransparent = sal_False;
+ sal_uInt16 nDashCount = 0;
+ sal_uInt16 nDotCount = 0;
+
+ switch( nStyle & PS_STYLE_MASK )
+ {
+ case PS_DASHDOTDOT :
+ nDotCount++;
+ case PS_DASHDOT :
+ nDashCount++;
+ case PS_DOT :
+ nDotCount++;
+ break;
+ case PS_DASH :
+ nDashCount++;
+ break;
+ case PS_NULL :
+ bTransparent = sal_True;
+ aLineInfo.SetStyle( LINE_NONE );
+ break;
+
+ default :
+ case PS_INSIDEFRAME :
+ case PS_SOLID :
+ aLineInfo.SetStyle( LINE_SOLID );
+ }
+ if ( nDashCount | nDotCount )
+ {
+ aLineInfo.SetStyle( LINE_DASH );
+ aLineInfo.SetDashCount( nDashCount );
+ aLineInfo.SetDotCount( nDotCount );
+ }
+ pOut->CreateObject( nIndex, GDI_PEN, new WinMtfLineStyle( aColorRef, aLineInfo, bTransparent ) );
+ }
+ }
+ break;
+
+ case EMR_CREATEBRUSHINDIRECT :
+ {
+ UINT32 nStyle;
+ *pWMF >> nIndex;
+ if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
+ {
+ *pWMF >> nStyle;
+ pOut->CreateObject( nIndex, GDI_BRUSH, new WinMtfFillStyle( ReadColor(), ( nStyle == BS_HOLLOW ) ? TRUE : FALSE ) );
+ }
+ }
+ break;
+
+ case EMR_DELETEOBJECT :
+ {
+ *pWMF >> nIndex;
+ if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
+ pOut->DeleteObject( nIndex );
+ }
+ break;
+
+ case EMR_ELLIPSE :
+ {
+ *pWMF >> nX32 >> nY32 >> nx32 >> ny32;
+ pOut->DrawEllipse( ReadRectangle( nX32, nY32, nx32, ny32 ) );
+ }
+ break;
+
+ case EMR_RECTANGLE :
+ {
+ *pWMF >> nX32 >> nY32 >> nx32 >> ny32;
+ pOut->DrawRect( ReadRectangle( nX32, nY32, nx32, ny32 ) );
+ }
+ break;
+
+ case EMR_ROUNDRECT :
+ {
+ *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nW >> nH;
+ Size aSize( Size( nW, nH ) );
+ pOut->DrawRoundRect( ReadRectangle( nX32, nY32, nx32, ny32 ), aSize );
+ }
+ break;
+
+ case EMR_ARC :
+ {
+ UINT32 nStartX, nStartY, nEndX, nEndY;
+ *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nStartX >> nStartY >> nEndX >> nEndY;
+ pOut->DrawArc( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ) );
+ }
+ break;
+
+ case EMR_CHORD :
+ {
+ UINT32 nStartX, nStartY, nEndX, nEndY;
+ *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nStartX >> nStartY >> nEndX >> nEndY;
+ pOut->DrawChord( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ) );
+ }
+ break;
+
+ case EMR_PIE :
+ {
+ UINT32 nStartX, nStartY, nEndX, nEndY;
+ *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nStartX >> nStartY >> nEndX >> nEndY;
+ const Rectangle aRect( ReadRectangle( nX32, nY32, nx32, ny32 ));
+
+ // #i73608# OutputDevice deviates from WMF
+ // semantics. start==end means full ellipse here.
+ if( nStartX == nEndX && nStartY == nEndY )
+ pOut->DrawEllipse( aRect );
+ else
+ pOut->DrawPie( aRect, Point( nStartX, nStartY ), Point( nEndX, nEndY ) );
+ }
+ break;
+
+ case EMR_LINETO :
+ {
+ *pWMF >> nX32 >> nY32;
+ pOut->LineTo( Point( nX32, nY32 ), bRecordPath );
+ }
+ break;
+
+ case EMR_ARCTO :
+ {
+ UINT32 nStartX, nStartY, nEndX, nEndY;
+ *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nStartX >> nStartY >> nEndX >> nEndY;
+ pOut->DrawArc( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ), TRUE );
+ }
+ break;
+
+ case EMR_BEGINPATH :
+ {
+ pOut->ClearPath();
+ bRecordPath = sal_True;
+ }
+ break;
+
+ case EMR_ABORTPATH :
+ pOut->ClearPath();
+ case EMR_ENDPATH :
+ bRecordPath = sal_False;
+ break;
+
+ case EMR_CLOSEFIGURE :
+ pOut->ClosePath();
+ break;
+
+ case EMR_FILLPATH :
+ pOut->StrokeAndFillPath( sal_False, sal_True );
+ break;
+
+ case EMR_STROKEANDFILLPATH :
+ pOut->StrokeAndFillPath( sal_True, sal_True );
+ break;
+
+ case EMR_STROKEPATH :
+ pOut->StrokeAndFillPath( sal_True, sal_False );
+ break;
+
+ case EMR_SELECTCLIPPATH :
+ {
+ sal_Int32 nClippingMode;
+ *pWMF >> nClippingMode;
+ pOut->SetClipPath( pOut->GetPathObj(), nClippingMode, sal_True );
+ }
+ break;
+
+ case EMR_EXTSELECTCLIPRGN :
+ {
+ sal_Int32 iMode, cbRgnData;
+ *pWMF >> cbRgnData
+ >> iMode;
+
+ PolyPolygon aPolyPoly;
+ if ( cbRgnData )
+ ImplReadRegion( aPolyPoly, *pWMF, nRecSize );
+ pOut->SetClipPath( aPolyPoly, iMode, sal_False );
+ }
+ break;
+
+ case EMR_BITBLT : // PASSTHROUGH INTENDED
+ case EMR_STRETCHBLT :
+ {
+ INT32 xDest, yDest, cxDest, cyDest, xSrc, ySrc, cxSrc, cySrc;
+ UINT32 dwRop, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc;
+ XForm xformSrc;
+
+ UINT32 nStart = pWMF->Tell() - 8;
+
+ pWMF->SeekRel( 0x10 );
+ *pWMF >> xDest >> yDest >> cxDest >> cyDest >> dwRop >> xSrc >> ySrc
+ >> xformSrc >> nColor >> iUsageSrc >> offBmiSrc >> cbBmiSrc
+ >> offBitsSrc >> cbBitsSrc;
+
+ if ( nRecType == EMR_STRETCHBLT )
+ *pWMF >> cxSrc >> cySrc;
+ else
+ cxSrc = cySrc = 0;
+
+ Bitmap aBitmap;
+ Rectangle aRect( Point( xDest, yDest ), Size( cxDest+1, cyDest+1 ) );
+
+ cxDest = abs( (int)cxDest ); // sj: i37894, size can be negative
+ cyDest = abs( (int)cyDest ); // and also 122889
+
+ if ( offBmiSrc )
+ {
+ UINT32 nSize = cbBmiSrc + cbBitsSrc + 14;
+ char* pBuf = new char[ nSize ];
+
+ SvMemoryStream aTmp( pBuf, nSize, STREAM_READ | STREAM_WRITE );
+ aTmp.ObjectOwnsMemory( TRUE );
+ aTmp << (BYTE)'B'
+ << (BYTE)'M'
+ << (UINT32)cbBitsSrc
+ << (UINT16)0
+ << (UINT16)0
+ << (UINT32)cbBmiSrc + 14;
+ pWMF->Seek( nStart + offBmiSrc );
+ pWMF->Read( pBuf + 14, cbBmiSrc );
+ pWMF->Seek( nStart + offBitsSrc );
+ pWMF->Read( pBuf + 14 + cbBmiSrc, cbBitsSrc );
+ aTmp.Seek( 0 );
+ aBitmap.Read( aTmp, TRUE );
+
+ // test if it is sensible to crop
+ if ( ( cxSrc > 0 ) && ( cySrc > 0 ) &&
+ ( xSrc >= 0 ) && ( ySrc >= 0 ) &&
+ ( xSrc + cxSrc <= aBitmap.GetSizePixel().Width() ) &&
+ ( ySrc + cySrc <= aBitmap.GetSizePixel().Height() ) )
+ {
+ Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) );
+ aBitmap.Crop( aCropRect );
+ }
+ }
+ aBmpSaveList.Insert( new BSaveStruct( aBitmap, aRect, dwRop ), LIST_APPEND );
+ }
+ break;
+
+ case EMR_STRETCHDIBITS :
+ {
+ INT32 xDest, yDest, xSrc, ySrc, cxSrc, cySrc, cxDest, cyDest;
+ UINT32 offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, iUsageSrc, dwRop;
+ UINT32 nStart = pWMF->Tell() - 8;
+
+ pWMF->SeekRel( 0x10 );
+ *pWMF >> xDest >> yDest >> xSrc >> ySrc >> cxSrc >> cySrc >> offBmiSrc >> cbBmiSrc >> offBitsSrc
+ >> cbBitsSrc >> iUsageSrc >> dwRop >> cxDest >> cyDest;
+
+ Bitmap aBitmap;
+ Rectangle aRect( Point( xDest, yDest ), Size( cxDest+1, cyDest+1 ) );
+
+ cxDest = abs( (int)cxDest ); // sj: i37894, size can be negative
+ cyDest = abs( (int)cyDest ); // and also 122889
+
+ UINT32 nSize = cbBmiSrc + cbBitsSrc + 14;
+ char* pBuf = new char[ nSize ];
+ SvMemoryStream aTmp( pBuf, nSize, STREAM_READ | STREAM_WRITE );
+ aTmp.ObjectOwnsMemory( TRUE );
+ aTmp << (BYTE)'B'
+ << (BYTE)'M'
+ << (UINT32)cbBitsSrc
+ << (UINT16)0
+ << (UINT16)0
+ << (UINT32)cbBmiSrc + 14;
+ pWMF->Seek( nStart + offBmiSrc );
+ pWMF->Read( pBuf + 14, cbBmiSrc );
+ pWMF->Seek( nStart + offBitsSrc );
+ pWMF->Read( pBuf + 14 + cbBmiSrc, cbBitsSrc );
+ aTmp.Seek( 0 );
+ aBitmap.Read( aTmp, TRUE );
+
+ // test if it is sensible to crop
+ if ( ( cxSrc > 0 ) && ( cySrc > 0 ) &&
+ ( xSrc >= 0 ) && ( ySrc >= 0 ) &&
+ ( xSrc + cxSrc <= aBitmap.GetSizePixel().Width() ) &&
+ ( ySrc + cySrc <= aBitmap.GetSizePixel().Height() ) )
+ {
+ Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) );
+ aBitmap.Crop( aCropRect );
+ }
+
+ aBmpSaveList.Insert( new BSaveStruct( aBitmap, aRect, dwRop ), LIST_APPEND );
+ }
+ break;
+
+ case EMR_EXTCREATEFONTINDIRECTW :
+ {
+ *pWMF >> nIndex;
+ if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
+ {
+ LOGFONTW aLogFont;
+ *pWMF >> aLogFont.lfHeight >> aLogFont.lfWidth >> aLogFont.lfEscapement >> aLogFont.lfOrientation >> aLogFont.lfWeight >> aLogFont.lfItalic
+ >> aLogFont.lfUnderline >> aLogFont.lfStrikeOut >> aLogFont.lfCharSet >> aLogFont.lfOutPrecision >> aLogFont.lfClipPrecision
+ >> aLogFont.lfQuality >> aLogFont.lfPitchAndFamily;
+
+ sal_Unicode lfFaceName[ LF_FACESIZE ];
+
+ for ( int i = 0; i < LF_FACESIZE; i++ )
+ {
+ UINT16 nChar;
+ *pWMF >> nChar;
+ lfFaceName[ i ] = nChar;
+ }
+ aLogFont.alfFaceName = UniString( lfFaceName );
+ pOut->CreateObject( nIndex, GDI_FONT, new WinMtfFontStyle( aLogFont ) );
+ }
+ }
+ break;
+
+ case EMR_EXTTEXTOUTA :
+ bFlag = sal_True;
+ case EMR_EXTTEXTOUTW :
+ {
+ sal_Int32 nLeft, nTop, nRight, nBottom, ptlReferenceX, ptlReferenceY, nGfxMode, nXScale, nYScale;
+ sal_uInt32 nCurPos, nLen, nOffString, nOptions, offDx;
+ sal_Int32* pDX = NULL;
+
+ nCurPos = pWMF->Tell() - 8;
+
+ *pWMF >> nLeft >> nTop >> nRight >> nBottom >> nGfxMode >> nXScale >> nYScale
+ >> ptlReferenceX >> ptlReferenceY >> nLen >> nOffString >> nOptions;
+
+ pWMF->SeekRel( 0x10 );
+ *pWMF >> offDx;
+
+ sal_Int32 nTextLayoutMode = TEXT_LAYOUT_DEFAULT;
+ if ( nOptions & ETO_RTLREADING )
+ nTextLayoutMode = TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_TEXTORIGIN_LEFT;
+ pOut->SetTextLayoutMode( nTextLayoutMode );
+ DBG_ASSERT( ( nOptions & ( ETO_PDY | ETO_GLYPH_INDEX ) ) == 0, "SJ: ETO_PDY || ETO_GLYPH_INDEX in EMF" );
+
+ Point aPos( ptlReferenceX, ptlReferenceY );
+ if ( nLen )
+ {
+ if ( offDx && (( nCurPos + offDx + nLen * 4 ) <= nNextPos ) )
+ {
+ pWMF->Seek( nCurPos + offDx );
+ pDX = new sal_Int32[ nLen ];
+ sal_uInt32 i;
+ for ( i = 0; i < nLen; i++ )
+ *pWMF >> pDX[ i ];
+ }
+ pWMF->Seek( nCurPos + nOffString );
+ String aText;
+ if ( bFlag )
+ {
+ sal_Char* pBuf = new sal_Char[ nLen ];
+ pWMF->Read( pBuf, nLen );
+ aText = String( pBuf, (sal_uInt16)nLen, pOut->GetCharSet() );
+ delete[] pBuf;
+
+ if ( aText.Len() != nLen )
+ {
+ sal_uInt16 i, j, k;
+ sal_Int32* pOldDx = pDX;
+ pDX = new sal_Int32[ aText.Len() ];
+ for ( i = 0, j = 0; i < aText.Len(); i++ )
+ {
+ ByteString aCharacter( aText.GetChar( i ), pOut->GetCharSet() );
+ pDX[ i ] = 0;
+ for ( k = 0; ( k < aCharacter.Len() ) && ( j < nLen ) && ( i < aText.Len() ); k++ )
+ pDX[ i ] += pOldDx[ j++ ];
+ }
+ delete[] pOldDx;
+ }
+ }
+ else
+ {
+ sal_Unicode* pBuf = new sal_Unicode[ nLen ];
+ pWMF->Read( pBuf, nLen << 1 );
+#ifdef OSL_BIGENDIAN
+ sal_Char nTmp, *pTmp = (sal_Char*)( pBuf + nLen );
+ while ( pTmp-- != (sal_Char*)pBuf )
+ {
+ nTmp = *pTmp--;
+ pTmp[ 1 ] = *pTmp;
+ *pTmp = nTmp;
+ }
+#endif
+ aText = String( pBuf, (xub_StrLen)nLen );
+ delete[] pBuf;
+ }
+ pOut->DrawText( aPos, aText, pDX, bRecordPath, nGfxMode );
+ }
+ delete[] pDX;
+ }
+ break;
+
+ case EMR_POLYBEZIERTO16 :
+ bFlag = sal_True;
+ case EMR_POLYBEZIER16 :
+ {
+ pWMF->SeekRel( 16 );
+ *pWMF >> nPoints;
+ UINT16 i = 0;
+ if ( bFlag )
+ {
+ i++;
+ nPoints++;
+ }
+ Polygon aPoly( (UINT16)nPoints );
+ for( ; i < (UINT16)nPoints; i++ )
+ {
+ *pWMF >> nX16 >> nY16;
+ aPoly[ i ] = Point( nX16, nY16 );
+ }
+ pOut->DrawPolyBezier( aPoly, bFlag, bRecordPath ); // Line( aPoly, bFlag );
+ }
+ break;
+
+ case EMR_POLYGON16 :
+ {
+ pWMF->SeekRel( 16 );
+ *pWMF >> nPoints;
+ Polygon aPoly( (UINT16)nPoints );
+ for( UINT16 k = 0; k < (UINT16)nPoints; k++ )
+ {
+ *pWMF >> nX16 >> nY16;
+ aPoly[ k ] = Point( nX16, nY16 );
+ }
+ pOut->DrawPolygon( aPoly, bRecordPath );
+ }
+ break;
+
+ case EMR_POLYLINETO16 :
+ bFlag = sal_True;
+ case EMR_POLYLINE16 :
+ {
+ pWMF->SeekRel( 16 );
+ *pWMF >> nPoints;
+ UINT16 i = 0;
+ if ( bFlag )
+ {
+ i++;
+ nPoints++;
+ }
+
+ Polygon aPoly( (UINT16)nPoints );
+ for( ; i < (UINT16)nPoints; i++ )
+ {
+ *pWMF >> nX16 >> nY16;
+ aPoly[ i ] = Point( nX16, nY16 );
+ }
+ pOut->DrawPolyLine( aPoly, bFlag, bRecordPath );
+ }
+ break;
+
+ case EMR_POLYPOLYLINE16 :
+ {
+ UINT16* pnPoints;
+
+ INT32 i, nPoly, nGesPoints;
+ pWMF->SeekRel( 0x10 );
+ // Anzahl der Polygone:
+ *pWMF >> nPoly >> nGesPoints;
+ // Anzahl der Punkte eines jeden Polygons holen, Gesammtzahl der Punkte ermitteln:
+ pnPoints = new UINT16[ nPoly ];
+ for ( i = 0; i < nPoly; i++ )
+ {
+ *pWMF >> nPoints;
+ pnPoints[ i ] = (UINT16)nPoints;
+ }
+ // Polygonpunkte holen:
+ for ( i = 0; i < nPoly; i++ )
+ {
+ Polygon aPolygon( pnPoints[ i ] );
+ for ( UINT16 k = 0; k < pnPoints[ i ]; k++ )
+ {
+ *pWMF >> nX16 >> nY16;
+ aPolygon[ k ] = Point( nX16, nY16 );
+ }
+ pOut->DrawPolyLine( aPolygon, sal_False, bRecordPath );
+ }
+ delete[] pnPoints;
+ }
+ break;
+
+ case EMR_POLYPOLYGON16 :
+ {
+ UINT16* pnPoints;
+ Point* pPtAry;
+
+ UINT32 i, nPoly, nGesPoints;
+ pWMF->SeekRel( 0x10 );
+ // Anzahl der Polygone:
+ *pWMF >> nPoly >> nGesPoints;
+ if (nGesPoints < SAL_MAX_UINT32 / sizeof(Point))
+ {
+ // Anzahl der Punkte eines jeden Polygons holen, Gesammtzahl der Punkte ermitteln:
+ pnPoints = new UINT16[ nPoly ];
+ for ( i = 0; i < nPoly; i++ )
+ {
+ *pWMF >> nPoints;
+ pnPoints[ i ] = (UINT16)nPoints;
+ }
+ // Polygonpunkte holen:
+ pPtAry = (Point*) new char[ nGesPoints * sizeof(Point) ];
+ for ( i = 0; i < nGesPoints; i++ )
+ {
+ *pWMF >> nX16 >> nY16;
+ pPtAry[ i ] = Point( nX16, nY16 );
+ }
+
+ // PolyPolygon Actions erzeugen
+ PolyPolygon aPolyPoly( (UINT16)nPoly, pnPoints, pPtAry );
+ pOut->DrawPolyPolygon( aPolyPoly, bRecordPath );
+ delete[] (char*) pPtAry;
+ delete[] pnPoints;
+ }
+ }
+ break;
+
+ case EMR_FILLRGN :
+ {
+ sal_uInt32 nLen;
+ PolyPolygon aPolyPoly;
+ pWMF->SeekRel( 0x10 );
+ *pWMF >> nLen >> nIndex;
+
+ if ( ImplReadRegion( aPolyPoly, *pWMF, nRecSize ) )
+ {
+ pOut->Push();
+ pOut->SelectObject( nIndex );
+ pOut->DrawPolyPolygon( aPolyPoly, sal_False );
+ pOut->Pop();
+ }
+ }
+ break;
+
+
+#ifdef WIN_MTF_ASSERT
+ default : WinMtfAssertHandler( "Unknown Meta Action" ); break;
+ case EMR_MASKBLT : WinMtfAssertHandler( "MaskBlt" ); break;
+ case EMR_PLGBLT : WinMtfAssertHandler( "PlgBlt" ); break;
+ case EMR_SETDIBITSTODEVICE : WinMtfAssertHandler( "SetDIBitsToDevice" ); break;
+ case EMR_FRAMERGN : WinMtfAssertHandler( "FrameRgn" ); break;
+ case EMR_INVERTRGN : WinMtfAssertHandler( "InvertRgn" ); break;
+ case EMR_PAINTRGN : WinMtfAssertHandler( "PaintRgn" ); break;
+ case EMR_FLATTENPATH : WinMtfAssertHandler( "FlattenPath" ); break;
+ case EMR_WIDENPATH : WinMtfAssertHandler( "WidenPath" ); break;
+ case EMR_POLYDRAW : WinMtfAssertHandler( "Polydraw" ); break;
+ case EMR_SETARCDIRECTION : WinMtfAssertHandler( "SetArcDirection" ); break;
+ case EMR_SETPALETTEENTRIES : WinMtfAssertHandler( "SetPaletteEntries" ); break;
+ case EMR_RESIZEPALETTE : WinMtfAssertHandler( "ResizePalette" ); break;
+ case EMR_EXTFLOODFILL : WinMtfAssertHandler( "ExtFloodFill" ); break;
+ case EMR_ANGLEARC : WinMtfAssertHandler( "AngleArc" ); break;
+ case EMR_SETCOLORADJUSTMENT : WinMtfAssertHandler( "SetColorAdjustment" ); break;
+ case EMR_POLYDRAW16 : WinMtfAssertHandler( "PolyDraw16" ); break;
+ case EMR_CREATEDIBPATTERNBRUSHPT : WinMtfAssertHandler( "CreateDibPatternBrushPt" ); break;
+ case EMR_POLYTEXTOUTA : WinMtfAssertHandler( "PolyTextOutA" ); break;
+ case EMR_POLYTEXTOUTW : WinMtfAssertHandler( "PolyTextOutW" ); break;
+ case EMR_CREATECOLORSPACE : WinMtfAssertHandler( "CreateColorSpace" ); break;
+ case EMR_SETCOLORSPACE : WinMtfAssertHandler( "SetColorSpace" ); break;
+ case EMR_DELETECOLORSPACE : WinMtfAssertHandler( "DeleteColorSpace" ); break;
+ case EMR_GLSRECORD : WinMtfAssertHandler( "GlsRecord" ); break;
+ case EMR_GLSBOUNDEDRECORD : WinMtfAssertHandler( "GlsBoundRecord" ); break;
+ case EMR_PIXELFORMAT : WinMtfAssertHandler( "PixelFormat" ); break;
+ case EMR_DRAWESCAPE : WinMtfAssertHandler( "DrawEscape" ); break;
+ case EMR_EXTESCAPE : WinMtfAssertHandler( "ExtEscape" ); break;
+ case EMR_STARTDOC : WinMtfAssertHandler( "StartDoc" ); break;
+ case EMR_SMALLTEXTOUT : WinMtfAssertHandler( "SmallTextOut" ); break;
+ case EMR_FORCEUFIMAPPING : WinMtfAssertHandler( "ForceUFIMapping" ); break;
+ case EMR_NAMEDESCAPE : WinMtfAssertHandler( "NamedEscape" ); break;
+ case EMR_COLORCORRECTPALETTE : WinMtfAssertHandler( "ColorCorrectPalette" ); break;
+ case EMR_SETICMPROFILEA : WinMtfAssertHandler( "SetICMProfileA" ); break;
+ case EMR_SETICMPROFILEW : WinMtfAssertHandler( "SetICMProfileW" ); break;
+ case EMR_ALPHABLEND : WinMtfAssertHandler( "Alphablend" ); break;
+ case EMR_TRANSPARENTBLT : WinMtfAssertHandler( "TransparenBlt" ); break;
+ case EMR_TRANSPARENTDIB : WinMtfAssertHandler( "TransparenDib" ); break;
+ case EMR_GRADIENTFILL : WinMtfAssertHandler( "GradientFill" ); break;
+ case EMR_SETLINKEDUFIS : WinMtfAssertHandler( "SetLinkedUFIS" ); break;
+
+ case EMR_SETMAPPERFLAGS : WinMtfAssertHandler( "SetMapperFlags", 0 ); break;
+ case EMR_SETICMMODE : WinMtfAssertHandler( "SetICMMode", 0 ); break;
+ case EMR_CREATEMONOBRUSH : WinMtfAssertHandler( "CreateMonoBrush", 0 ); break;
+ case EMR_SETBRUSHORGEX : WinMtfAssertHandler( "SetBrushOrgEx", 0 ); break;
+ case EMR_SETMETARGN : WinMtfAssertHandler( "SetMetArgn", 0 ); break;
+ case EMR_SETMITERLIMIT : WinMtfAssertHandler( "SetMiterLimit", 0 ); break;
+ case EMR_EXCLUDECLIPRECT : WinMtfAssertHandler( "ExcludeClipRect", 0 ); break;
+ case EMR_REALIZEPALETTE : WinMtfAssertHandler( "RealizePalette", 0 ); break;
+ case EMR_SELECTPALETTE : WinMtfAssertHandler( "SelectPalette", 0 ); break;
+ case EMR_CREATEPALETTE : WinMtfAssertHandler( "CreatePalette", 0 ); break;
+ case EMR_ALPHADIBBLEND : WinMtfAssertHandler( "AlphaDibBlend", 0 ); break;
+ case EMR_SETTEXTJUSTIFICATION : WinMtfAssertHandler( "SetTextJustification", 0 ); break;
+
+ case EMR_GDICOMMENT :
+ case EMR_HEADER : // has already been read at ReadHeader()
+ break;
+#endif
+ }
+ pWMF->Seek( nNextPos );
+ }
+ if( aBmpSaveList.Count() )
+ pOut->ResolveBitmapActions( aBmpSaveList );
+
+ if ( bStatus )
+ pWMF->Seek(nEndPos);
+
+ return bStatus;
+};
+
+//-----------------------------------------------------------------------------------
+
+BOOL EnhWMFReader::ReadHeader()
+{
+ UINT32 nUINT32, nHeaderSize, nPalEntries;
+ INT32 nLeft, nTop, nRight, nBottom;
+
+ // METAFILEHEADER SPARE ICH MIR HIER
+ // Einlesen des METAHEADER
+ *pWMF >> nUINT32 >> nHeaderSize;
+ if ( nUINT32 != 1 ) // Typ
+ return FALSE;
+
+ // bound size
+ Rectangle rclBounds; // rectangle in logical units 1/100th mm
+ *pWMF >> nLeft >> nTop >> nRight >> nBottom;
+ rclBounds.Left() = nLeft;
+ rclBounds.Top() = nTop;
+ rclBounds.Right() = nRight;
+ rclBounds.Bottom() = nBottom;
+
+ // picture frame size
+ Rectangle rclFrame; // rectangle in device units
+ *pWMF >> nLeft >> nTop >> nRight >> nBottom;
+ rclFrame.Left() = nLeft;
+ rclFrame.Top() = nTop;
+ rclFrame.Right() = nRight;
+ rclFrame.Bottom() = nBottom;
+
+ *pWMF >> nUINT32; // signature
+
+ if ( nUINT32 != 0x464d4520 )
+ return FALSE;
+
+ *pWMF >> nUINT32; // nVersion
+ *pWMF >> nEndPos; // size of metafile
+ nEndPos += nStartPos;
+ *pWMF >> nRecordCount;
+
+ if ( !nRecordCount )
+ return FALSE;
+
+ pWMF->SeekRel( 0xc );
+
+ sal_Int32 nPixX, nPixY, nMillX, nMillY;
+ *pWMF >> nPalEntries >> nPixX >> nPixY >> nMillX >> nMillY;
+
+ pOut->SetrclFrame( rclFrame );
+ pOut->SetrclBounds( rclBounds );
+ pOut->SetRefPix( Size( nPixX, nPixY ) );
+ pOut->SetRefMill( Size( nMillX, nMillY ) );
+
+ pWMF->Seek( nStartPos + nHeaderSize );
+ return TRUE;
+}
+
+//-----------------------------------------------------------------------------------
+
+Rectangle EnhWMFReader::ReadRectangle( INT32 x1, INT32 y1, INT32 x2, INT32 y2 )
+{
+ Point aTL ( Point( x1, y1 ) );
+ Point aBR( Point( --x2, --y2 ) );
+ return Rectangle( aTL, aBR );
+}
+
+EnhWMFReader::~EnhWMFReader()
+{
+
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/wmf/svt_winmtf.cxx b/binfilter/bf_svtools/source/filter.vcl/wmf/svt_winmtf.cxx
new file mode 100644
index 000000000000..4f0694088d96
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/wmf/svt_winmtf.cxx
@@ -0,0 +1,2178 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 "winmtf.hxx"
+#include <vcl/metaact.hxx>
+#include <vcl/metric.hxx>
+#include <rtl/tencinfo.h>
+
+namespace binfilter
+{
+
+// ------------------------------------------------------------------------
+
+#define WIN_MTF_MAX_POLYPOLYCOUNT 16
+
+void WinMtfClipPath::ImpUpdateType()
+{
+ if ( !aPolyPoly.Count() )
+ eType = EMPTY;
+ else if ( aPolyPoly.IsRect() )
+ eType = RECTANGLE;
+ else
+ eType = COMPLEX;
+
+ bNeedsUpdate = sal_True;
+}
+
+void WinMtfClipPath::IntersectClipRect( const Rectangle& rRect )
+{
+ if ( !aPolyPoly.Count() )
+ aPolyPoly = Polygon( rRect );
+ else if ( aPolyPoly.Count() < WIN_MTF_MAX_POLYPOLYCOUNT )
+ {
+ Polygon aPolygon( rRect );
+ PolyPolygon aIntersection;
+ PolyPolygon aPolyPolyRect( aPolygon );
+ aPolyPoly.GetIntersection( aPolyPolyRect, aIntersection );
+ aPolyPoly = aIntersection;
+ }
+ ImpUpdateType();
+}
+
+void WinMtfClipPath::ExcludeClipRect( const Rectangle& rRect )
+{
+ if ( aPolyPoly.Count() && ( aPolyPoly.Count() < WIN_MTF_MAX_POLYPOLYCOUNT ) )
+ {
+ Polygon aPolygon( rRect );
+ PolyPolygon aPolyPolyRect( aPolygon );
+ PolyPolygon aDifference;
+ aPolyPoly.GetDifference( aPolyPolyRect, aDifference );
+ aPolyPoly = aDifference;
+ }
+ ImpUpdateType();
+}
+
+void WinMtfClipPath::SetClipPath( const PolyPolygon& rPolyPolygon, sal_Int32 nClippingMode )
+{
+ if ( !rPolyPolygon.Count() )
+ aPolyPoly = rPolyPolygon;
+ else if ( rPolyPolygon.Count() < WIN_MTF_MAX_POLYPOLYCOUNT )
+ {
+ PolyPolygon aNewClipPath;
+
+ // #115345# Watch out for empty aPolyPoly here - conceptually,
+ // an empty clip path is a rectangle of infinite size, but it
+ // is represented by an empty aPolyPoly. When intersecting
+ // rPolyPolygon with this _empty_ aPolyPoly, set algebra
+ // guarantees wrong results.
+ switch ( nClippingMode )
+ {
+ case RGN_OR :
+ // #115345# clip stays empty, when ORing an arbitrary
+ // rPolyPolygon. Thus, we can save us the unnecessary
+ // clipper call.
+ if( aPolyPoly.Count() )
+ aPolyPoly.GetUnion( rPolyPolygon, aNewClipPath );
+ break;
+ case RGN_XOR :
+ // TODO:
+ // #115345# Cannot handle this case, for the time being
+ aPolyPoly.GetXOR( rPolyPolygon, aNewClipPath );
+ break;
+ case RGN_DIFF :
+ // TODO:
+ // #115345# Cannot handle this case, for the time being
+ aPolyPoly.GetDifference( rPolyPolygon, aNewClipPath );
+ break;
+ case RGN_AND :
+ // #115345# Clip becomes rPolyPolygon, when ANDing
+ // with an arbitrary rPolyPolygon
+ if( aPolyPoly.Count() )
+ aPolyPoly.GetIntersection( rPolyPolygon, aNewClipPath );
+ else
+ aNewClipPath = rPolyPolygon;
+ break;
+ case RGN_COPY :
+ aNewClipPath = rPolyPolygon;
+ break;
+ }
+ aPolyPoly = aNewClipPath;
+ }
+ ImpUpdateType();
+}
+
+void WinMtfClipPath::MoveClipRegion( const Size& rSize )
+{
+ aPolyPoly.Move( rSize.Width(), rSize.Height() );
+ bNeedsUpdate = sal_True;
+}
+
+// ------------------------------------------------------------------------
+
+void WinMtfPathObj::AddPoint( const Point& rPoint )
+{
+ if ( bClosed )
+ Insert( Polygon(), POLYPOLY_APPEND );
+ Polygon& rPoly = ((PolyPolygon&)*this)[ Count() - 1 ];
+ rPoly.Insert( rPoly.GetSize(), rPoint, POLY_NORMAL );
+ bClosed = sal_False;
+}
+
+void WinMtfPathObj::AddPolyLine( const Polygon& rPolyLine )
+{
+ if ( bClosed )
+ Insert( Polygon(), POLYPOLY_APPEND );
+ Polygon& rPoly = ((PolyPolygon&)*this)[ Count() - 1 ];
+ rPoly.Insert( rPoly.GetSize(), rPolyLine );
+ bClosed = sal_False;
+}
+
+void WinMtfPathObj::AddPolygon( const Polygon& rPoly )
+{
+ Insert( rPoly, POLYPOLY_APPEND );
+ bClosed = sal_True;
+}
+
+void WinMtfPathObj::AddPolyPolygon( const PolyPolygon& rPolyPoly )
+{
+ sal_uInt16 i, nCount = rPolyPoly.Count();
+ for ( i = 0; i < nCount; i++ )
+ Insert( rPolyPoly[ i ], POLYPOLY_APPEND );
+ bClosed = sal_True;
+}
+
+void WinMtfPathObj::ClosePath()
+{
+ if ( Count() )
+ {
+ Polygon& rPoly = ((PolyPolygon&)*this)[ Count() - 1 ];
+ if ( rPoly.GetSize() > 2 )
+ {
+ Point aFirst( rPoly[ 0 ] );
+ if ( aFirst != rPoly[ rPoly.GetSize() - 1 ] )
+ rPoly.Insert( rPoly.GetSize(), aFirst, POLY_NORMAL );
+ }
+ }
+ bClosed = sal_True;
+}
+
+// ------------------------------------------------------------------------
+
+WinMtfFontStyle::WinMtfFontStyle( LOGFONTW& rFont )
+{
+ CharSet eCharSet;
+ if ( ( rFont.lfCharSet == OEM_CHARSET ) || ( rFont.lfCharSet == DEFAULT_CHARSET ) )
+ eCharSet = gsl_getSystemTextEncoding();
+ else
+ eCharSet = rtl_getTextEncodingFromWindowsCharset( rFont.lfCharSet );
+ if ( eCharSet == RTL_TEXTENCODING_DONTKNOW )
+ eCharSet = gsl_getSystemTextEncoding();
+ aFont.SetCharSet( eCharSet );
+ aFont.SetName( rFont.alfFaceName );
+ FontFamily eFamily;
+ switch ( rFont.lfPitchAndFamily & 0xf0 )
+ {
+ case FF_ROMAN:
+ eFamily = FAMILY_ROMAN;
+ break;
+
+ case FF_SWISS:
+ eFamily = FAMILY_SWISS;
+ break;
+
+ case FF_MODERN:
+ eFamily = FAMILY_MODERN;
+ break;
+
+ case FF_SCRIPT:
+ eFamily = FAMILY_SCRIPT;
+ break;
+
+ case FF_DECORATIVE:
+ eFamily = FAMILY_DECORATIVE;
+ break;
+
+ default:
+ eFamily = FAMILY_DONTKNOW;
+ break;
+ }
+ aFont.SetFamily( eFamily );
+
+ FontPitch ePitch;
+ switch ( rFont.lfPitchAndFamily & 0x0f )
+ {
+ case FIXED_PITCH:
+ ePitch = PITCH_FIXED;
+ break;
+
+ case DEFAULT_PITCH:
+ case VARIABLE_PITCH:
+ default:
+ ePitch = PITCH_VARIABLE;
+ break;
+ }
+ aFont.SetPitch( ePitch );
+
+ FontWeight eWeight;
+ if( rFont.lfWeight <= FW_THIN )
+ eWeight = WEIGHT_THIN;
+ else if( rFont.lfWeight <= FW_ULTRALIGHT )
+ eWeight = WEIGHT_ULTRALIGHT;
+ else if( rFont.lfWeight <= FW_LIGHT )
+ eWeight = WEIGHT_LIGHT;
+ else if( rFont.lfWeight < FW_MEDIUM )
+ eWeight = WEIGHT_NORMAL;
+ else if( rFont.lfWeight == FW_MEDIUM )
+ eWeight = WEIGHT_MEDIUM;
+ else if( rFont.lfWeight <= FW_SEMIBOLD )
+ eWeight = WEIGHT_SEMIBOLD;
+ else if( rFont.lfWeight <= FW_BOLD )
+ eWeight = WEIGHT_BOLD;
+ else if( rFont.lfWeight <= FW_ULTRABOLD )
+ eWeight = WEIGHT_ULTRABOLD;
+ else
+ eWeight = WEIGHT_BLACK;
+ aFont.SetWeight( eWeight );
+
+ if( rFont.lfItalic )
+ aFont.SetItalic( ITALIC_NORMAL );
+
+ if( rFont.lfUnderline )
+ aFont.SetUnderline( UNDERLINE_SINGLE );
+
+ if( rFont.lfStrikeOut )
+ aFont.SetStrikeout( STRIKEOUT_SINGLE );
+
+ if ( rFont.lfOrientation )
+ aFont.SetOrientation( (short)rFont.lfOrientation );
+ else
+ aFont.SetOrientation( (short)rFont.lfEscapement );
+
+ Size aFontSize( Size( rFont.lfWidth, rFont.lfHeight ) );
+ if ( rFont.lfHeight > 0 )
+ {
+ // converting the cell height into a font height
+ VirtualDevice aVDev;
+ aFont.SetSize( aFontSize );
+ aVDev.SetFont( aFont );
+ FontMetric aMetric( aVDev.GetFontMetric() );
+ long nHeight = aMetric.GetAscent() + aMetric.GetDescent();
+ if ( nHeight )
+ {
+ double fHeight = ((double)aFontSize.Height() * rFont.lfHeight ) / nHeight;
+ aFontSize.Height() = (sal_Int32)( fHeight + 0.5 );
+ }
+ }
+ else if ( aFontSize.Height() < 0 )
+ aFontSize.Height() *= -1;
+
+ if ( !rFont.lfWidth )
+ {
+ VirtualDevice aVDev;
+ aFont.SetSize( aFontSize );
+ aVDev.SetFont( aFont );
+ FontMetric aMetric( aVDev.GetFontMetric() );
+ aFontSize.Width() = aMetric.GetWidth();
+ }
+
+ aFont.SetSize( aFontSize );
+};
+
+// ------------------------------------------------------------------------
+
+#ifdef WIN_MTF_ASSERT
+void WinMtfAssertHandler( const sal_Char* pAction, sal_uInt32 nFlags )
+{
+ static sal_Bool bOnlyOnce;
+ static sal_Int32 nAssertCount;
+
+ if ( nFlags & WIN_MTF_ASSERT_INIT )
+ nAssertCount = 0;
+ if ( nFlags & WIN_MTF_ASSERT_ONCE )
+ bOnlyOnce = sal_True;
+ if ( nFlags & WIN_MTF_ASSERT_MIFE )
+ {
+ if ( ( nAssertCount == 0 ) || ( bOnlyOnce == sal_False ) )
+ {
+ ByteString aText( "WMF/EMF Import: " );
+ if ( pAction )
+ {
+ ByteString aAction( pAction );
+ aText.Append( aAction );
+ }
+ aText.Append( " needs to be implemented (SJ)" );
+ DBG_ASSERT( 0, aText.GetBuffer() );
+ }
+ nAssertCount++;
+ }
+}
+#endif
+
+// ------------------------------------------------------------------------
+
+WinMtf::WinMtf( WinMtfOutput* pWinMtfOutput, SvStream& rStreamWMF, FilterConfigItem* pConfigItem ) :
+ pOut ( pWinMtfOutput ),
+ pWMF ( &rStreamWMF ),
+ pFilterConfigItem ( pConfigItem )
+{
+#ifdef WIN_MTF_ASSERT
+ // we want to assert not implemented features, but we do this
+ // only once, so that nobody is handicaped by getting too much assertions
+ // I hope this will bring more testdocuments, without support of these
+ // testdocuments the implementation of missing features won't be possible. (SJ)
+ WinMtfAssertHandler( NULL, WIN_MTF_ASSERT_INIT | WIN_MTF_ASSERT_ONCE );
+#endif
+
+ SvLockBytes *pLB = pWMF->GetLockBytes();
+ if ( pLB )
+ pLB->SetSynchronMode( TRUE );
+
+ nStartPos = pWMF->Tell();
+
+ pOut->SetDevOrg( Point() );
+ if ( pFilterConfigItem )
+ {
+ xStatusIndicator = pFilterConfigItem->GetStatusIndicator();
+ if ( xStatusIndicator.is() )
+ {
+ rtl::OUString aMsg;
+ xStatusIndicator->start( aMsg, 100 );
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+WinMtf::~WinMtf()
+{
+ delete pOut;
+
+ if ( xStatusIndicator.is() )
+ xStatusIndicator->end();
+}
+
+// ------------------------------------------------------------------------
+
+void WinMtf::Callback( USHORT nPercent )
+{
+ if ( xStatusIndicator.is() )
+ xStatusIndicator->setValue( nPercent );
+}
+
+// ------------------------------------------------------------------------
+
+Color WinMtf::ReadColor()
+{
+ UINT32 nColor;
+ *pWMF >> nColor;
+ return Color( (BYTE)nColor, (BYTE)( nColor >> 8 ), (BYTE)( nColor >> 16 ) );
+};
+
+//-----------------------------------------------------------------------------------
+//-----------------------------------------------------------------------------------
+//-----------------------------------------------------------------------------------
+
+Point WinMtfOutput::ImplMap( const Point& rPt )
+{
+ if ( mnWinExtX && mnWinExtY )
+ {
+ double fX2, fX = rPt.X();
+ double fY2, fY = rPt.Y();
+
+ fX2 = fX * maXForm.eM11 + fY * maXForm.eM21 + maXForm.eDx;
+ fY2 = fX * maXForm.eM12 + fY * maXForm.eM22 + maXForm.eDy;
+
+ if ( mnGfxMode == GM_COMPATIBLE )
+ {
+ switch( mnMapMode )
+ {
+ case MM_LOENGLISH :
+ {
+ fX2 -= mnWinOrgX;
+ fY2 = mnWinOrgY-fY2;
+ fX2 *= 25.40;
+ fY2 *= 25.40;
+ fX2 += mnDevOrgX;
+ fY2 += mnDevOrgY;
+ }
+ break;
+ case MM_HIENGLISH :
+ {
+ fX2 -= mnWinOrgX;
+ fY2 = mnWinOrgY-fY2;
+ fX2 *= 2.540;
+ fY2 *= 2.540;
+ fX2 += mnDevOrgX;
+ fY2 += mnDevOrgY;
+ }
+ break;
+ case MM_LOMETRIC :
+ {
+ fX2 -= mnWinOrgX;
+ fY2 = mnWinOrgY-fY2;
+ fX2 *= 10;
+ fY2 *= 10;
+ fX2 += mnDevOrgX;
+ fY2 += mnDevOrgY;
+ }
+ break;
+ case MM_HIMETRIC :
+ {
+ fX2 -= mnWinOrgX;
+ fY2 = mnWinOrgY-fY2;
+ fX2 += mnDevOrgX;
+ fY2 += mnDevOrgY;
+ }
+ break;
+ default :
+ {
+ fX2 -= mnWinOrgX;
+ fY2 -= mnWinOrgY;
+ fX2 /= mnWinExtX;
+ fY2 /= mnWinExtY;
+ fX2 *= mnDevWidth;
+ fY2 *= mnDevHeight;
+ fX2 += mnDevOrgX;
+ fY2 += mnDevOrgY; // fX2, fY2 now in device units
+ fX2 *= (double)mnMillX * 100.0 / (double)mnPixX;
+ fY2 *= (double)mnMillY * 100.0 / (double)mnPixY;
+ }
+ break;
+ }
+ fX2 -= mrclFrame.Left();
+ fY2 -= mrclFrame.Top();
+ }
+ return Point( FRound( fX2 ), FRound( fY2 ) );
+ }
+ else
+ return Point();
+};
+
+// ------------------------------------------------------------------------
+
+Size WinMtfOutput::ImplMap( const Size& rSz )
+{
+ if ( mnWinExtX && mnWinExtY )
+ {
+ double fWidth = rSz.Width() * maXForm.eM11;
+ double fHeight = rSz.Height() * maXForm.eM22;
+
+ if ( mnGfxMode == GM_COMPATIBLE )
+ {
+ switch( mnMapMode )
+ {
+ case MM_LOENGLISH :
+ {
+ fWidth *= 25.40;
+ fHeight*=-25.40;
+ }
+ break;
+ case MM_HIENGLISH :
+ {
+ fWidth *= 2.540;
+ fHeight*=-2.540;
+ }
+ break;
+ case MM_LOMETRIC :
+ {
+ fWidth *= 10;
+ fHeight*=-10;
+ }
+ break;
+ case MM_HIMETRIC :
+ {
+ fHeight *= -1;
+ }
+ break;
+ default :
+ {
+ fWidth /= mnWinExtX;
+ fHeight /= mnWinExtY;
+ fWidth *= mnDevWidth;
+ fHeight *= mnDevHeight;
+ fWidth *= (double)mnMillX * 100 / (double)mnPixX;
+ fHeight *= (double)mnMillY * 100 / (double)mnPixY;
+ }
+ break;
+ }
+ }
+ return Size( FRound( fWidth ), FRound( fHeight ) );
+ }
+ else
+ return Size();
+}
+
+//-----------------------------------------------------------------------------------
+
+Rectangle WinMtfOutput::ImplMap( const Rectangle& rRect )
+{
+ return Rectangle( ImplMap( rRect.TopLeft() ), ImplMap( rRect.GetSize() ) );
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::ImplMap( Font& rFont )
+{
+ // !!! HACK: Wir setzen die Breite jetzt immer auf Null,
+ // da OS die Breite unterschiedlich interpretieren;
+ // muss spaeter in SV portabel gemacht werden ( KA 08.02.96 )
+ Size aFontSize = ImplMap ( rFont.GetSize() );
+
+ if( aFontSize.Height() < 0 )
+ aFontSize.Height() *= -1;
+
+ rFont.SetSize( aFontSize );
+
+ if( ( mnWinExtX * mnWinExtY ) < 0 )
+ rFont.SetOrientation( 3600 - rFont.GetOrientation() );
+}
+
+//-----------------------------------------------------------------------------------
+
+Polygon& WinMtfOutput::ImplMap( Polygon& rPolygon )
+{
+ UINT16 nPoints = rPolygon.GetSize();
+ for ( UINT16 i = 0; i < nPoints; i++ )
+ {
+ rPolygon[ i ] = ImplMap( rPolygon[ i ] );
+ }
+ return rPolygon;
+}
+
+//-----------------------------------------------------------------------------------
+
+PolyPolygon& WinMtfOutput::ImplMap( PolyPolygon& rPolyPolygon )
+{
+ UINT16 nPolys = rPolyPolygon.Count();
+ for ( UINT16 i = 0; i < nPolys; ImplMap( rPolyPolygon[ i++ ] ) ) ;
+ return rPolyPolygon;
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::SelectObject( INT32 nIndex )
+{
+ GDIObj* pGDIObj = NULL;
+
+ if ( nIndex & ENHMETA_STOCK_OBJECT )
+ pGDIObj = new GDIObj();
+ else
+ {
+ nIndex &= 0xffff; // zur Sicherheit: mehr als 65535 nicht zulassen
+
+ if ( (UINT32)nIndex < vGDIObj.size() )
+ pGDIObj = vGDIObj[ nIndex ];
+ }
+
+ if( pGDIObj == NULL )
+ return;
+
+ if ( nIndex & ENHMETA_STOCK_OBJECT )
+ {
+ UINT16 nStockId = (BYTE)nIndex;
+ switch( nStockId )
+ {
+ case WHITE_BRUSH :
+ {
+ pGDIObj->Set( GDI_BRUSH, new WinMtfFillStyle( Color( COL_WHITE ) ) );
+ }
+ break;
+ case LTGRAY_BRUSH :
+ {
+ pGDIObj->Set( GDI_BRUSH, new WinMtfFillStyle( Color( COL_LIGHTGRAY ) ) );
+ }
+ break;
+ case GRAY_BRUSH :
+ case DKGRAY_BRUSH :
+ {
+ pGDIObj->Set( GDI_BRUSH, new WinMtfFillStyle( Color( COL_GRAY ) ) );
+ }
+ break;
+ case BLACK_BRUSH :
+ {
+ pGDIObj->Set( GDI_BRUSH, new WinMtfFillStyle( Color( COL_BLACK ) ) );
+ }
+ break;
+ case NULL_BRUSH :
+ {
+ pGDIObj->Set( GDI_BRUSH, new WinMtfFillStyle( Color( COL_TRANSPARENT ), TRUE ) );
+ }
+ break;
+ case WHITE_PEN :
+ {
+ pGDIObj->Set( GDI_PEN, new WinMtfLineStyle( Color( COL_WHITE ) ) );
+ }
+ break;
+ case BLACK_PEN :
+ {
+ pGDIObj->Set( GDI_PEN, new WinMtfLineStyle( Color( COL_BLACK ) ) );
+ }
+ break;
+ case NULL_PEN :
+ {
+ pGDIObj->Set( GDI_PEN, new WinMtfLineStyle( Color( COL_TRANSPARENT ), TRUE ) );
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ if ( pGDIObj->pStyle )
+ {
+ switch( pGDIObj->eType )
+ {
+ case GDI_PEN :
+ maLineStyle = (WinMtfLineStyle*)pGDIObj->pStyle;
+ break;
+ case GDI_BRUSH :
+ {
+ maFillStyle = (WinMtfFillStyle*)pGDIObj->pStyle;
+ mbFillStyleSelected = sal_True;
+ }
+ break;
+ case GDI_FONT :
+ maFont = ((WinMtfFontStyle*)pGDIObj->pStyle)->aFont;
+ break;
+ default:
+ break; // -Wall many options not handled.
+ }
+ }
+ if ( nIndex & ENHMETA_STOCK_OBJECT )
+ delete pGDIObj;
+}
+
+//-----------------------------------------------------------------------------------
+
+const Font& WinMtfOutput::GetFont() const
+{
+ return maFont;
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::SetTextLayoutMode( const sal_uInt32 nTextLayoutMode )
+{
+ mnTextLayoutMode = nTextLayoutMode;
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::SetBkMode( UINT32 nMode )
+{
+ mnBkMode = nMode;
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::SetBkColor( const Color& rColor )
+{
+ maBkColor = rColor;
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::SetTextColor( const Color& rColor )
+{
+ maTextColor = rColor;
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::SetTextAlign( UINT32 nAlign )
+{
+ mnTextAlign = nAlign;
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::ImplResizeObjectArry( UINT32 nNewEntrys )
+{
+ sal_uInt32 i = vGDIObj.size();
+ vGDIObj.resize( nNewEntrys );
+ for ( ; i < nNewEntrys ; i++ )
+ vGDIObj[ i ] = NULL;
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::ImplDrawClippedPolyPolygon( const PolyPolygon& rPolyPoly )
+{
+ if ( rPolyPoly.Count() )
+ {
+ ImplSetNonPersistentLineColorTransparenz();
+ if ( rPolyPoly.Count() == 1 )
+ {
+ if ( rPolyPoly.IsRect() )
+ mpGDIMetaFile->AddAction( new MetaRectAction( rPolyPoly.GetBoundRect() ) );
+ else
+ {
+ Polygon aPoly( rPolyPoly[ 0 ] );
+ sal_uInt16 nCount = aPoly.GetSize();
+ if ( nCount )
+ {
+ if ( aPoly[ nCount - 1 ] != aPoly[ 0 ] )
+ {
+ Point aPoint( aPoly[ 0 ] );
+ aPoly.Insert( nCount, aPoint );
+ }
+ mpGDIMetaFile->AddAction( new MetaPolygonAction( aPoly ) );
+ }
+ }
+ }
+ else
+ mpGDIMetaFile->AddAction( new MetaPolyPolygonAction( rPolyPoly ) );
+ }
+}
+
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::CreateObject( GDIObjectType eType, void* pStyle )
+{
+ if ( pStyle )
+ {
+ if ( eType == GDI_FONT )
+ {
+ ImplMap( ((WinMtfFontStyle*)pStyle)->aFont );
+ if (!((WinMtfFontStyle*)pStyle)->aFont.GetHeight() )
+ ((WinMtfFontStyle*)pStyle)->aFont.SetHeight( 423 ); // defaulting to 12pt
+ }
+ else if ( eType == GDI_PEN )
+ {
+ Size aSize( ((WinMtfLineStyle*)pStyle)->aLineInfo.GetWidth(), 0 );
+ ((WinMtfLineStyle*)pStyle)->aLineInfo.SetWidth( ImplMap( aSize ).Width() );
+ if ( ((WinMtfLineStyle*)pStyle)->aLineInfo.GetStyle() == LINE_DASH )
+ {
+ aSize.Width() += 1;
+ long nDotLen = ImplMap( aSize ).Width();
+ ((WinMtfLineStyle*)pStyle)->aLineInfo.SetDistance( nDotLen );
+ ((WinMtfLineStyle*)pStyle)->aLineInfo.SetDotLen( nDotLen );
+ ((WinMtfLineStyle*)pStyle)->aLineInfo.SetDashLen( nDotLen * 4 );
+ }
+ }
+ }
+ UINT32 nIndex;
+ for ( nIndex = 0; nIndex < vGDIObj.size(); nIndex++ )
+ {
+ if ( vGDIObj[ nIndex ] == NULL )
+ break;
+ }
+ if ( nIndex == vGDIObj.size() )
+ ImplResizeObjectArry( vGDIObj.size() + 16 );
+
+ vGDIObj[ nIndex ] = new GDIObj( eType, pStyle );
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::CreateObject( INT32 nIndex, GDIObjectType eType, void* pStyle )
+{
+ if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
+ {
+ nIndex &= 0xffff; // zur Sicherheit: mehr als 65535 nicht zulassen
+ if ( pStyle )
+ {
+ if ( eType == GDI_FONT )
+ ImplMap( ((WinMtfFontStyle*)pStyle)->aFont );
+ else if ( eType == GDI_PEN )
+ {
+ Size aSize( ((WinMtfLineStyle*)pStyle)->aLineInfo.GetWidth(), 0 );
+ ((WinMtfLineStyle*)pStyle)->aLineInfo.SetWidth( ImplMap( aSize ).Width() );
+ if ( ((WinMtfLineStyle*)pStyle)->aLineInfo.GetStyle() == LINE_DASH )
+ {
+ aSize.Width() += 1;
+ long nDotLen = ImplMap( aSize ).Width();
+ ((WinMtfLineStyle*)pStyle)->aLineInfo.SetDistance( nDotLen );
+ ((WinMtfLineStyle*)pStyle)->aLineInfo.SetDotLen( nDotLen );
+ ((WinMtfLineStyle*)pStyle)->aLineInfo.SetDashLen( nDotLen * 4 );
+ }
+ }
+ }
+ if ( (UINT32)nIndex >= vGDIObj.size() )
+ ImplResizeObjectArry( nIndex + 16 );
+
+ if ( vGDIObj[ nIndex ] != NULL )
+ delete vGDIObj[ nIndex ];
+
+ vGDIObj[ nIndex ] = new GDIObj( eType, pStyle );
+ }
+ else
+ {
+ switch ( eType )
+ {
+ case GDI_PEN :
+ delete (WinMtfLineStyle*)pStyle;
+ break;
+ case GDI_BRUSH :
+ delete (WinMtfFillStyle*)pStyle;
+ break;
+ case GDI_FONT :
+ delete (WinMtfFontStyle*)pStyle;
+ break;
+
+ default:
+ DBG_ERROR( "unsupported style not deleted" );
+ break;
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::DeleteObject( sal_Int32 nIndex )
+{
+ if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
+ {
+ if ( (sal_uInt32)nIndex < vGDIObj.size() )
+ {
+ delete vGDIObj[ nIndex ];
+ vGDIObj[ nIndex ] = NULL;
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::IntersectClipRect( const Rectangle& rRect )
+{
+ aClipPath.IntersectClipRect( ImplMap( rRect ) );
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::ExcludeClipRect( const Rectangle& rRect )
+{
+ aClipPath.ExcludeClipRect( ImplMap( rRect ) );
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::MoveClipRegion( const Size& rSize )
+{
+ aClipPath.MoveClipRegion( ImplMap( rSize ) );
+}
+
+void WinMtfOutput::SetClipPath( const PolyPolygon& rPolyPolygon, sal_Int32 nClippingMode, sal_Bool bIsMapped )
+{
+ if ( bIsMapped )
+ aClipPath.SetClipPath( rPolyPolygon, nClippingMode );
+ else
+ {
+ PolyPolygon aPP( rPolyPolygon );
+ aClipPath.SetClipPath( ImplMap( aPP ), nClippingMode );
+ }
+}
+
+//-----------------------------------------------------------------------------------
+//-----------------------------------------------------------------------------------
+//-----------------------------------------------------------------------------------
+
+WinMtfOutput::WinMtfOutput( GDIMetaFile& rGDIMetaFile ) :
+ mnLatestTextAlign ( 0 ),
+ mnTextAlign ( TA_LEFT | TA_TOP | TA_NOUPDATECP ),
+ maLatestBkColor ( 0x12345678 ),
+ maBkColor ( COL_WHITE ),
+ mnLatestTextLayoutMode( TEXT_LAYOUT_DEFAULT ),
+ mnTextLayoutMode ( TEXT_LAYOUT_DEFAULT ),
+ mnLatestBkMode ( 0 ),
+ mnBkMode ( OPAQUE ),
+ meLatestRasterOp ( ROP_INVERT ),
+ meRasterOp ( ROP_OVERPAINT ),
+ maActPos ( Point() ),
+ mbNopMode ( sal_False ),
+ mbFillStyleSelected ( sal_False ),
+ mnGfxMode ( GM_COMPATIBLE ),
+ mnMapMode ( MM_TEXT ),
+ mnDevOrgX ( 0 ),
+ mnDevOrgY ( 0 ),
+ mnDevWidth ( 1 ),
+ mnDevHeight ( 1 ),
+ mnWinOrgX ( 0 ),
+ mnWinOrgY ( 0 ),
+ mnWinExtX ( 1 ),
+ mnWinExtY ( 1 ),
+ mnPixX ( 100 ),
+ mnPixY ( 100 ),
+ mnMillX ( 1 ),
+ mnMillY ( 1 ),
+ mpGDIMetaFile ( &rGDIMetaFile )
+{
+ mpGDIMetaFile->AddAction( new MetaPushAction( PUSH_CLIPREGION ) ); // The original clipregion has to be on top
+ // of the stack so it can always be restored
+ // this is necessary to be able to support
+ // SetClipRgn( NULL ) and similar ClipRgn actions (SJ)
+
+ maFont.SetName( String( RTL_CONSTASCII_USTRINGPARAM( "Arial" )) ); // sj: #i57205#, we do have some scaling problems if using
+ maFont.SetCharSet( gsl_getSystemTextEncoding() ); // the default font then most times a x11 font is used, we
+ maFont.SetHeight( 423 ); // will prevent this defining a font
+
+ maLatestLineStyle.aLineColor = Color( 0x12, 0x34, 0x56 );
+ maLatestFillStyle.aFillColor = Color( 0x12, 0x34, 0x56 );
+
+ mnRop = R2_BLACK + 1;
+ SetRasterOp( R2_BLACK );
+};
+
+//-----------------------------------------------------------------------------------
+
+WinMtfOutput::~WinMtfOutput()
+{
+ mpGDIMetaFile->AddAction( new MetaPopAction() );
+ mpGDIMetaFile->SetPrefMapMode( MAP_100TH_MM );
+ if ( mrclFrame.IsEmpty() )
+ mpGDIMetaFile->SetPrefSize( Size( mnDevWidth, mnDevHeight ) );
+ else
+ mpGDIMetaFile->SetPrefSize( mrclFrame.GetSize() );
+
+ for ( UINT32 i = 0; i < vGDIObj.size(); i++ )
+ delete vGDIObj[ i ];
+};
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::UpdateClipRegion()
+{
+ if ( aClipPath.bNeedsUpdate )
+ {
+ aClipPath.bNeedsUpdate = sal_False;
+
+ mpGDIMetaFile->AddAction( new MetaPopAction() ); // taking the orignal clipregion
+ mpGDIMetaFile->AddAction( new MetaPushAction( PUSH_CLIPREGION ) ); //
+
+ switch ( aClipPath.GetType() )
+ {
+ case RECTANGLE :
+ case COMPLEX :
+ {
+// we will not generate a RegionClipRegion Action, because this action
+// cannot be saved to the wmf format - saving to wmf always happens
+// if the placeholder graphic for ole objects is generated. (SJ)
+
+// Region aClipRegion( aClipPath.GetClipPath() );
+// mpGDIMetaFile->AddAction( new MetaISectRegionClipRegionAction( aClipRegion ) );
+
+ Rectangle aClipRect( aClipPath.GetClipPath().GetBoundRect() );
+ mpGDIMetaFile->AddAction( new MetaISectRectClipRegionAction( aClipRect ) );
+ }
+ break;
+ case EMPTY:
+ break; // -Wall not handled.
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::ImplSetNonPersistentLineColorTransparenz()
+{
+ Color aColor( COL_TRANSPARENT);
+ WinMtfLineStyle aTransparentLine( aColor, TRUE );
+ if ( ! ( maLatestLineStyle == aTransparentLine ) )
+ {
+ maLatestLineStyle = aTransparentLine;
+ mpGDIMetaFile->AddAction( new MetaLineColorAction( aTransparentLine.aLineColor, !aTransparentLine.bTransparent ) );
+ }
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::UpdateLineStyle()
+{
+ if (!( maLatestLineStyle == maLineStyle ) )
+ {
+ maLatestLineStyle = maLineStyle;
+ mpGDIMetaFile->AddAction( new MetaLineColorAction( maLineStyle.aLineColor, !maLineStyle.bTransparent ) );
+ }
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::UpdateFillStyle()
+{
+ if ( !mbFillStyleSelected ) // SJ: #i57205# taking care of bkcolor if no brush is selected
+ maFillStyle = WinMtfFillStyle( maBkColor, mnBkMode == TRANSPARENT );
+ if (!( maLatestFillStyle == maFillStyle ) )
+ {
+ maLatestFillStyle = maFillStyle;
+ mpGDIMetaFile->AddAction( new MetaFillColorAction( maFillStyle.aFillColor, !maFillStyle.bTransparent ) );
+ }
+}
+
+//-----------------------------------------------------------------------------------
+
+sal_uInt32 WinMtfOutput::SetRasterOp( UINT32 nRasterOp )
+{
+ sal_uInt32 nRetROP = mnRop;
+ if ( nRasterOp != mnRop )
+ {
+ mnRop = nRasterOp;
+ static WinMtfFillStyle aNopFillStyle;
+ static WinMtfLineStyle aNopLineStyle;
+
+ if ( mbNopMode && ( nRasterOp != R2_NOP ) )
+ { // beim uebergang von R2_NOP auf anderen Modus
+ // gesetzten Pen und Brush aktivieren
+ maFillStyle = aNopFillStyle;
+ maLineStyle = aNopLineStyle;
+ mbNopMode = sal_False;
+ }
+ switch( nRasterOp )
+ {
+ case R2_NOT:
+ meRasterOp = ROP_INVERT;
+ break;
+
+ case R2_XORPEN:
+ meRasterOp = ROP_XOR;
+ break;
+
+ case R2_NOP:
+ {
+ meRasterOp = ROP_OVERPAINT;
+ if( mbNopMode == sal_False )
+ {
+ aNopFillStyle = maFillStyle;
+ aNopLineStyle = maLineStyle;
+ maFillStyle = WinMtfFillStyle( Color( COL_TRANSPARENT ), TRUE );
+ maLineStyle = WinMtfLineStyle( Color( COL_TRANSPARENT ), TRUE );
+ mbNopMode = sal_True;
+ }
+ }
+ break;
+
+ default:
+ meRasterOp = ROP_OVERPAINT;
+ break;
+ }
+ }
+ if ( nRetROP != nRasterOp )
+ mpGDIMetaFile->AddAction( new MetaRasterOpAction( meRasterOp ) );
+ return nRetROP;
+};
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::StrokeAndFillPath( sal_Bool bStroke, sal_Bool bFill )
+{
+ if ( aPathObj.Count() )
+ {
+ UpdateClipRegion();
+ UpdateLineStyle();
+ UpdateFillStyle();
+ if ( bFill )
+ {
+ if ( !bStroke )
+ {
+ mpGDIMetaFile->AddAction( new MetaPushAction( PUSH_LINECOLOR ) );
+ mpGDIMetaFile->AddAction( new MetaLineColorAction( Color(), FALSE ) );
+ }
+ if ( aPathObj.Count() == 1 )
+ mpGDIMetaFile->AddAction( new MetaPolygonAction( aPathObj.GetObject( 0 ) ) );
+ else
+ mpGDIMetaFile->AddAction( new MetaPolyPolygonAction( aPathObj ) );
+
+ if ( !bStroke )
+ mpGDIMetaFile->AddAction( new MetaPopAction() );
+ }
+ else
+ {
+ sal_uInt16 i, nCount = aPathObj.Count();
+ for ( i = 0; i < nCount; i++ )
+ mpGDIMetaFile->AddAction( new MetaPolyLineAction( aPathObj[ i ], maLineStyle.aLineInfo ) );
+ }
+ ClearPath();
+ }
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::DrawPixel( const Point& rSource, const Color& rColor )
+{
+ mpGDIMetaFile->AddAction( new MetaPixelAction( ImplMap( rSource), rColor ) );
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::MoveTo( const Point& rPoint, sal_Bool bRecordPath )
+{
+ Point aDest( ImplMap( rPoint ) );
+ if ( bRecordPath )
+ aPathObj.AddPoint( aDest );
+ maActPos = aDest;
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::LineTo( const Point& rPoint, sal_Bool bRecordPath )
+{
+ UpdateClipRegion();
+
+ Point aDest( ImplMap( rPoint ) );
+ if ( bRecordPath )
+ aPathObj.AddPoint( aDest );
+ else
+ {
+ UpdateLineStyle();
+ mpGDIMetaFile->AddAction( new MetaLineAction( maActPos, aDest, maLineStyle.aLineInfo ) );
+ }
+ maActPos = aDest;
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::DrawRect( const Rectangle& rRect, BOOL bEdge )
+{
+ UpdateClipRegion();
+ UpdateFillStyle();
+
+ if ( aClipPath.GetType() == COMPLEX )
+ {
+ Polygon aPoly( ImplMap( rRect ) );
+ PolyPolygon aPolyPolyRect( aPoly );
+ PolyPolygon aDest;
+ aClipPath.GetClipPath().GetIntersection( aPolyPolyRect, aDest );
+ ImplDrawClippedPolyPolygon( aDest );
+ }
+ else
+ {
+ if ( bEdge )
+ {
+ if ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LINE_DASH ) )
+ {
+ ImplSetNonPersistentLineColorTransparenz();
+ mpGDIMetaFile->AddAction( new MetaRectAction( ImplMap( rRect ) ) );
+ UpdateLineStyle();
+ mpGDIMetaFile->AddAction( new MetaPolyLineAction( Polygon( ImplMap( rRect ) ),maLineStyle.aLineInfo ) );
+ }
+ else
+ {
+ UpdateLineStyle();
+ mpGDIMetaFile->AddAction( new MetaRectAction( ImplMap( rRect ) ) );
+ }
+ }
+ else
+ {
+ ImplSetNonPersistentLineColorTransparenz();
+ mpGDIMetaFile->AddAction( new MetaRectAction( ImplMap( rRect ) ) );
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::DrawRoundRect( const Rectangle& rRect, const Size& rSize )
+{
+ UpdateClipRegion();
+ UpdateLineStyle();
+ UpdateFillStyle();
+ mpGDIMetaFile->AddAction( new MetaRoundRectAction( ImplMap( rRect ), labs( ImplMap( rSize ).Width() ), labs( ImplMap( rSize ).Height() ) ) );
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::DrawEllipse( const Rectangle& rRect )
+{
+ UpdateClipRegion();
+ UpdateFillStyle();
+
+ if ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LINE_DASH ) )
+ {
+ Point aCenter( ImplMap( rRect.Center() ) );
+ Size aRad( ImplMap( Size( rRect.GetWidth() / 2, rRect.GetHeight() / 2 ) ) );
+
+ ImplSetNonPersistentLineColorTransparenz();
+ mpGDIMetaFile->AddAction( new MetaEllipseAction( ImplMap( rRect ) ) );
+ UpdateLineStyle();
+ mpGDIMetaFile->AddAction( new MetaPolyLineAction( Polygon( aCenter, aRad.Width(), aRad.Height() ), maLineStyle.aLineInfo ) );
+ }
+ else
+ {
+ UpdateLineStyle();
+ mpGDIMetaFile->AddAction( new MetaEllipseAction( ImplMap( rRect ) ) );
+ }
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::DrawArc( const Rectangle& rRect, const Point& rStart, const Point& rEnd, BOOL bTo )
+{
+ UpdateClipRegion();
+ UpdateLineStyle();
+ UpdateFillStyle();
+
+ Rectangle aRect( ImplMap( rRect ) );
+ Point aStart( ImplMap( rStart ) );
+ Point aEnd( ImplMap( rEnd ) );
+
+ if ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LINE_DASH ) )
+ {
+ if ( aStart == aEnd )
+ { // SJ: #i53768# if start & end is identical, then we have to draw a full ellipse
+ Point aCenter( aRect.Center() );
+ Size aRad( aRect.GetWidth() / 2, aRect.GetHeight() / 2 );
+
+ mpGDIMetaFile->AddAction( new MetaPolyLineAction( Polygon( aCenter, aRad.Width(), aRad.Height() ), maLineStyle.aLineInfo ) );
+ }
+ else
+ mpGDIMetaFile->AddAction( new MetaPolyLineAction( Polygon( aRect, aStart, aEnd, POLY_ARC ), maLineStyle.aLineInfo ) );
+ }
+ else
+ mpGDIMetaFile->AddAction( new MetaArcAction( aRect, aStart, aEnd ) );
+
+ if ( bTo )
+ maActPos = aEnd;
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::DrawPie( const Rectangle& rRect, const Point& rStart, const Point& rEnd )
+{
+ UpdateClipRegion();
+ UpdateFillStyle();
+
+ Rectangle aRect( ImplMap( rRect ) );
+ Point aStart( ImplMap( rStart ) );
+ Point aEnd( ImplMap( rEnd ) );
+
+ if ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LINE_DASH ) )
+ {
+ ImplSetNonPersistentLineColorTransparenz();
+ mpGDIMetaFile->AddAction( new MetaPieAction( aRect, aStart, aEnd ) );
+ UpdateLineStyle();
+ mpGDIMetaFile->AddAction( new MetaPolyLineAction( Polygon( aRect, aStart, aEnd, POLY_PIE ), maLineStyle.aLineInfo ) );
+ }
+ else
+ {
+ UpdateLineStyle();
+ mpGDIMetaFile->AddAction( new MetaPieAction( aRect, aStart, aEnd ) );
+ }
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::DrawChord( const Rectangle& rRect, const Point& rStart, const Point& rEnd )
+{
+ UpdateClipRegion();
+ UpdateFillStyle();
+
+ Rectangle aRect( ImplMap( rRect ) );
+ Point aStart( ImplMap( rStart ) );
+ Point aEnd( ImplMap( rEnd ) );
+
+ if ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LINE_DASH ) )
+ {
+ ImplSetNonPersistentLineColorTransparenz();
+ mpGDIMetaFile->AddAction( new MetaChordAction( aRect, aStart, aEnd ) );
+ UpdateLineStyle();
+ mpGDIMetaFile->AddAction( new MetaPolyLineAction( Polygon( aRect, aStart, aEnd, POLY_CHORD ), maLineStyle.aLineInfo ) );
+ }
+ else
+ {
+ UpdateLineStyle();
+ mpGDIMetaFile->AddAction( new MetaChordAction( aRect, aStart, aEnd ) );
+ }
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::DrawPolygon( Polygon& rPolygon, sal_Bool bRecordPath )
+{
+ UpdateClipRegion();
+ ImplMap( rPolygon );
+ if ( bRecordPath )
+ aPathObj.AddPolygon( rPolygon );
+ else
+ {
+ UpdateFillStyle();
+
+ if ( aClipPath.GetType() == COMPLEX )
+ {
+ PolyPolygon aPolyPoly( rPolygon );
+ PolyPolygon aDest;
+ aClipPath.GetClipPath().GetIntersection( aPolyPoly, aDest );
+ ImplDrawClippedPolyPolygon( aDest );
+ }
+ else
+ {
+ if ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LINE_DASH ) )
+ {
+ USHORT nCount = rPolygon.GetSize();
+ if ( nCount )
+ {
+ if ( rPolygon[ nCount - 1 ] != rPolygon[ 0 ] )
+ {
+ Point aPoint( rPolygon[ 0 ] );
+ rPolygon.Insert( nCount, aPoint );
+ }
+ }
+ ImplSetNonPersistentLineColorTransparenz();
+ mpGDIMetaFile->AddAction( new MetaPolygonAction( rPolygon ) );
+ UpdateLineStyle();
+ mpGDIMetaFile->AddAction( new MetaPolyLineAction( rPolygon, maLineStyle.aLineInfo ) );
+ }
+ else
+ {
+ UpdateLineStyle();
+ mpGDIMetaFile->AddAction( new MetaPolygonAction( rPolygon ) );
+ }
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::DrawPolyPolygon( PolyPolygon& rPolyPolygon, sal_Bool bRecordPath )
+{
+ UpdateClipRegion();
+
+ ImplMap( rPolyPolygon );
+
+ if ( bRecordPath )
+ aPathObj.AddPolyPolygon( rPolyPolygon );
+ else
+ {
+ UpdateFillStyle();
+
+ if ( aClipPath.GetType() == COMPLEX )
+ {
+ PolyPolygon aDest;
+ aClipPath.GetClipPath().GetIntersection( rPolyPolygon, aDest );
+ ImplDrawClippedPolyPolygon( aDest );
+ }
+ else
+ {
+ UpdateLineStyle();
+ mpGDIMetaFile->AddAction( new MetaPolyPolygonAction( rPolyPolygon ) );
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::DrawPolyLine( Polygon& rPolygon, sal_Bool bTo, sal_Bool bRecordPath )
+{
+ UpdateClipRegion();
+
+ ImplMap( rPolygon );
+ if ( bTo )
+ {
+ rPolygon[ 0 ] = maActPos;
+ maActPos = rPolygon[ rPolygon.GetSize() - 1 ];
+ }
+ if ( bRecordPath )
+ aPathObj.AddPolyLine( rPolygon );
+ else
+ {
+ UpdateLineStyle();
+ mpGDIMetaFile->AddAction( new MetaPolyLineAction( rPolygon, maLineStyle.aLineInfo ) );
+ }
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::DrawPolyBezier( Polygon& rPolygon, sal_Bool bTo, sal_Bool bRecordPath )
+{
+ UpdateClipRegion();
+
+ sal_uInt16 nPoints = rPolygon.GetSize();
+ if ( ( nPoints >= 4 ) && ( ( ( nPoints - 4 ) % 3 ) == 0 ) )
+ {
+ ImplMap( rPolygon );
+ if ( bTo )
+ {
+ rPolygon[ 0 ] = maActPos;
+ maActPos = rPolygon[ nPoints - 1 ];
+ }
+ sal_uInt16 i;
+ for ( i = 0; ( i + 2 ) < nPoints; )
+ {
+ rPolygon.SetFlags( i++, POLY_NORMAL );
+ rPolygon.SetFlags( i++, POLY_CONTROL );
+ rPolygon.SetFlags( i++, POLY_CONTROL );
+ }
+ if ( bRecordPath )
+ aPathObj.AddPolyLine( rPolygon );
+ else
+ {
+ UpdateLineStyle();
+ mpGDIMetaFile->AddAction( new MetaPolyLineAction( rPolygon, maLineStyle.aLineInfo ) );
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::DrawText( Point& rPosition, String& rText, sal_Int32* pDXArry, sal_Bool bRecordPath, sal_Int32 nGfxMode )
+{
+ UpdateClipRegion();
+
+ VirtualDevice* pVDev = NULL;
+
+ rPosition = ImplMap( rPosition );
+
+ sal_Int32 nOldGfxMode = GetGfxMode();
+ SetGfxMode( GM_COMPATIBLE );
+ if ( pDXArry )
+ {
+ sal_Int32 i, nSum, nLen = rText.Len();
+
+ for( i = 0, nSum = 0; i < nLen; i++ )
+ {
+ sal_Int32 nTemp = ImplMap( Size( pDXArry[ i ], 0 ) ).Width();
+ nSum += nTemp;
+ pDXArry[ i ] = nSum;
+ }
+ }
+ if ( mnLatestTextLayoutMode != mnTextLayoutMode )
+ {
+ mnLatestTextLayoutMode = mnTextLayoutMode;
+ mpGDIMetaFile->AddAction( new MetaLayoutModeAction( mnTextLayoutMode ) );
+ }
+ SetGfxMode( nGfxMode );
+ sal_Bool bChangeFont = sal_False;
+ if ( mnLatestTextAlign != mnTextAlign )
+ {
+ bChangeFont = sal_True;
+ mnLatestTextAlign = mnTextAlign;
+ TextAlign eTextAlign;
+ if ( ( mnTextAlign & TA_BASELINE) == TA_BASELINE )
+ eTextAlign = ALIGN_BASELINE;
+ else if( ( mnTextAlign & TA_BOTTOM) == TA_BOTTOM )
+ eTextAlign = ALIGN_BOTTOM;
+ else
+ eTextAlign = ALIGN_TOP;
+ mpGDIMetaFile->AddAction( new MetaTextAlignAction( eTextAlign ) );
+ }
+ if ( maLatestTextColor != maTextColor )
+ {
+ bChangeFont = sal_True;
+ maLatestTextColor = maTextColor;
+ mpGDIMetaFile->AddAction( new MetaTextColorAction( maTextColor ) );
+ }
+ sal_Bool bChangeFillColor = sal_False;
+ if ( maLatestBkColor != maBkColor )
+ {
+ bChangeFillColor = sal_True;
+ maLatestBkColor = maBkColor;
+ }
+ if ( mnLatestBkMode != mnBkMode )
+ {
+ bChangeFillColor = sal_True;
+ mnLatestBkMode = mnBkMode;
+ }
+ if ( bChangeFillColor )
+ {
+ bChangeFont = sal_True;
+ mpGDIMetaFile->AddAction( new MetaTextFillColorAction( maFont.GetFillColor(), !maFont.IsTransparent() ) );
+ }
+ Font aTmp( maFont );
+ aTmp.SetColor( maTextColor );
+ aTmp.SetFillColor( maBkColor );
+
+ if( mnBkMode == TRANSPARENT )
+ maFont.SetTransparent( sal_True );
+ else
+ maFont.SetTransparent( sal_False );
+
+ if ( ( mnTextAlign & TA_BASELINE) == TA_BASELINE )
+ aTmp.SetAlign( ALIGN_BASELINE );
+ else if( ( mnTextAlign & TA_BOTTOM) == TA_BOTTOM )
+ aTmp.SetAlign( ALIGN_BOTTOM );
+ else
+ aTmp.SetAlign( ALIGN_TOP );
+
+ if ( nGfxMode == GM_ADVANCED )
+ {
+ // check whether there is a font rotation applied via transformation
+ Point aP1( ImplMap( Point() ) );
+ Point aP2( ImplMap( Point( 0, 100 ) ) );
+ aP2.X() -= aP1.X();
+ aP2.Y() -= aP1.Y();
+ double fX = aP2.X();
+ double fY = aP2.Y();
+ if ( fX )
+ {
+ double fOrientation = acos( fX / sqrt( fX * fX + fY * fY ) ) * 57.29577951308;
+ if ( fY > 0 )
+ fOrientation = 360 - fOrientation;
+ fOrientation += 90;
+ fOrientation *= 10;
+ fOrientation += aTmp.GetOrientation();
+ aTmp.SetOrientation( sal_Int16( fOrientation ) );
+ }
+ }
+
+ if( mnTextAlign & ( TA_UPDATECP | TA_RIGHT_CENTER ) )
+ {
+ if ( !pVDev )
+ pVDev = new VirtualDevice;
+ sal_Int32 nTextWidth;
+ pVDev->SetMapMode( MapMode( MAP_100TH_MM ) );
+ pVDev->SetFont( maFont );
+ if( pDXArry )
+ {
+ UINT32 nLen = rText.Len();
+ nTextWidth = pVDev->GetTextWidth( rText.GetChar( (sal_uInt16)( nLen - 1 ) ) );
+ if( nLen > 1 )
+ nTextWidth += pDXArry[ nLen - 2 ];
+ }
+ else
+ nTextWidth = pVDev->GetTextWidth( rText );
+
+ if( mnTextAlign & TA_UPDATECP )
+ rPosition = maActPos;
+
+ if ( mnTextAlign & TA_RIGHT_CENTER )
+ {
+ double fLenght = ( ( mnTextAlign & TA_RIGHT_CENTER ) == TA_RIGHT ) ? nTextWidth : nTextWidth >> 1;
+ rPosition.X() -= (sal_Int32)( fLenght * cos( maFont.GetOrientation() * F_PI1800 ) );
+ rPosition.Y() -= (sal_Int32)(-( fLenght * sin( maFont.GetOrientation() * F_PI1800 ) ) );
+ }
+
+ if( mnTextAlign & TA_UPDATECP )
+ maActPos.X() = rPosition.X() + nTextWidth;
+ }
+ if ( bChangeFont || ( maLatestFont != aTmp ) )
+ {
+ maLatestFont = aTmp;
+ mpGDIMetaFile->AddAction( new MetaFontAction( aTmp ) );
+ mpGDIMetaFile->AddAction( new MetaTextAlignAction( aTmp.GetAlign() ) );
+ mpGDIMetaFile->AddAction( new MetaTextColorAction( aTmp.GetColor() ) );
+ mpGDIMetaFile->AddAction( new MetaTextFillColorAction( aTmp.GetFillColor(), !aTmp.IsTransparent() ) );
+ }
+ if ( bRecordPath )
+ {
+ // ToDo
+ }
+ else
+ {
+ /* because text without dx array is badly scaled, we
+ will create such an array if necessary */
+ sal_Int32* pDX = pDXArry;
+ if ( !pDXArry )
+ {
+ pDX = new sal_Int32[ rText.Len() ];
+ if ( !pVDev )
+ pVDev = new VirtualDevice;
+ pVDev->SetMapMode( MAP_100TH_MM );
+ pVDev->SetFont( maLatestFont );
+ pVDev->GetTextArray( rText, pDX, 0, STRING_LEN );
+ }
+ mpGDIMetaFile->AddAction( new MetaTextArrayAction( rPosition, rText, pDX, 0, STRING_LEN ) );
+ if ( !pDXArry ) // this means we have created our own array
+ delete[] pDX; // which must be deleted
+ }
+ SetGfxMode( nOldGfxMode );
+ delete pVDev;
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::ImplDrawBitmap( const Point& rPos, const Size& rSize, const BitmapEx rBitmap )
+{
+ BitmapEx aBmpEx( rBitmap );
+ if ( aClipPath.GetType() == COMPLEX )
+ {
+ VirtualDevice aVDev;
+ MapMode aMapMode( MAP_100TH_MM );
+ aMapMode.SetOrigin( Point( -rPos.X(), -rPos.Y() ) );
+ const Size aOutputSizePixel( aVDev.LogicToPixel( rSize, aMapMode ) );
+ const Size aSizePixel( rBitmap.GetSizePixel() );
+ if ( aOutputSizePixel.Width() && aOutputSizePixel.Height() )
+ {
+ aMapMode.SetScaleX( Fraction( aSizePixel.Width(), aOutputSizePixel.Width() ) );
+ aMapMode.SetScaleY( Fraction( aSizePixel.Height(), aOutputSizePixel.Height() ) );
+ }
+ aVDev.SetMapMode( aMapMode );
+ aVDev.SetOutputSizePixel( aSizePixel );
+ aVDev.SetFillColor( Color( COL_BLACK ) );
+ const PolyPolygon aClip( aClipPath.GetClipPath() );
+ aVDev.DrawPolyPolygon( aClip );
+ const Point aEmptyPoint;
+
+ // #i50672# Extract whole VDev content (to match size of rBitmap)
+ aVDev.EnableMapMode( FALSE );
+ Bitmap aMask( aVDev.GetBitmap( aEmptyPoint, aSizePixel ).CreateMask( Color( COL_WHITE ) ) );
+
+ if ( aBmpEx.IsTransparent() )
+ {
+ if ( rBitmap.GetTransparentColor() == Color( COL_WHITE ) )
+ aMask.CombineSimple( rBitmap.GetMask(), BMP_COMBINE_OR );
+ else
+ aMask.CombineSimple( rBitmap.GetMask(), BMP_COMBINE_AND );
+ aBmpEx = BitmapEx( rBitmap.GetBitmap(), aMask );
+ }
+ else
+ aBmpEx = BitmapEx( rBitmap.GetBitmap(), aMask );
+ }
+ if ( aBmpEx.IsTransparent() )
+ mpGDIMetaFile->AddAction( new MetaBmpExScaleAction( rPos, rSize, aBmpEx ) );
+ else
+ mpGDIMetaFile->AddAction( new MetaBmpScaleAction( rPos, rSize, aBmpEx.GetBitmap() ) );
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::ResolveBitmapActions( List& rSaveList )
+{
+ UpdateClipRegion();
+
+ sal_uInt32 nObjects = rSaveList.Count();
+ sal_uInt32 nObjectsLeft = nObjects;
+
+ while ( nObjectsLeft )
+ {
+ sal_uInt32 i, nObjectsOfSameSize = 0;
+ sal_uInt32 nObjectStartIndex = nObjects - nObjectsLeft;
+
+ BSaveStruct* pSave = (BSaveStruct*)rSaveList.GetObject( nObjectStartIndex );
+ Rectangle aRect( pSave->aOutRect );
+
+ for ( i = nObjectStartIndex; i < nObjects; )
+ {
+ nObjectsOfSameSize++;
+ if ( ++i < nObjects )
+ {
+ pSave = (BSaveStruct*)rSaveList.GetObject( i );
+ if ( pSave->aOutRect != aRect )
+ break;
+ }
+ }
+ Point aPos( ImplMap( aRect.TopLeft() ) );
+ Size aSize( ImplMap( aRect.GetSize() ) );
+
+ for ( i = nObjectStartIndex; i < ( nObjectStartIndex + nObjectsOfSameSize ); i++ )
+ {
+ pSave = (BSaveStruct*)rSaveList.GetObject( i );
+
+ sal_uInt32 nWinRop = pSave->nWinRop;
+ sal_uInt8 nRasterOperation = (sal_uInt8)( nWinRop >> 16 );
+
+ sal_uInt32 nUsed = 0;
+ if ( ( nRasterOperation & 0xf ) != ( nRasterOperation >> 4 ) )
+ nUsed |= 1; // pattern is used
+ if ( ( nRasterOperation & 0x33 ) != ( ( nRasterOperation & 0xcc ) >> 2 ) )
+ nUsed |= 2; // source is used
+ if ( ( nRasterOperation & 0xaa ) != ( ( nRasterOperation & 0x55 ) << 1 ) )
+ nUsed |= 4; // destination is used
+
+ if ( (nUsed & 1) && (( nUsed & 2 ) == 0) )
+ { // patterns aren't well supported yet
+ sal_uInt32 nOldRop = SetRasterOp( ROP_OVERPAINT ); // in this case nRasterOperation is either 0 or 0xff
+ UpdateFillStyle();
+ DrawRect( aRect, FALSE );
+ SetRasterOp( nOldRop );
+ }
+ else
+ {
+ sal_Bool bDrawn = sal_False;
+
+ if ( i == nObjectStartIndex ) // optimizing, sometimes it is possible to create just one transparent bitmap
+ {
+ if ( nObjectsOfSameSize == 2 )
+ {
+ BSaveStruct* pSave2 = (BSaveStruct*)rSaveList.GetObject( i + 1 );
+ if ( ( pSave->aBmp.GetPrefSize() == pSave2->aBmp.GetPrefSize() ) &&
+ ( pSave->aBmp.GetPrefMapMode() == pSave2->aBmp.GetPrefMapMode() ) )
+ {
+ // TODO: Strictly speaking, we should
+ // check whether mask is monochrome, and
+ // whether image is black (upper branch)
+ // or white (lower branch). Otherwise, the
+ // effect is not the same as a masked
+ // bitmap.
+ if ( ( nWinRop == SRCPAINT ) && ( pSave2->nWinRop == SRCAND ) )
+ {
+ Bitmap aMask( pSave->aBmp ); aMask.Invert();
+ BitmapEx aBmpEx( pSave2->aBmp, aMask );
+ ImplDrawBitmap( aPos, aSize, aBmpEx );
+ bDrawn = sal_True;
+ i++;
+ }
+ // #i20085# This is just the other way
+ // around as above. Only difference: mask
+ // is inverted
+ else if ( ( nWinRop == SRCAND ) && ( pSave2->nWinRop == SRCPAINT ) )
+ {
+ Bitmap aMask( pSave->aBmp );
+ BitmapEx aBmpEx( pSave2->aBmp, aMask );
+ ImplDrawBitmap( aPos, aSize, aBmpEx );
+ bDrawn = sal_True;
+ i++;
+ }
+ }
+ }
+ }
+
+ if ( !bDrawn )
+ {
+ Push();
+ sal_uInt32 nOldRop = SetRasterOp( R2_COPYPEN );
+ Bitmap aBitmap( pSave->aBmp );
+ sal_uInt32 nOperation = ( nRasterOperation & 0xf );
+ switch( nOperation )
+ {
+ case 0x1 :
+ case 0xe :
+ {
+ SetRasterOp( R2_XORPEN );
+ ImplDrawBitmap( aPos, aSize, aBitmap );
+ SetRasterOp( R2_COPYPEN );
+ Bitmap aMask( aBitmap );
+ aMask.Invert();
+ BitmapEx aBmpEx( aBitmap, aMask );
+ ImplDrawBitmap( aPos, aSize, aBmpEx );
+ if ( nOperation == 0x1 )
+ {
+ SetRasterOp( R2_NOT );
+ DrawRect( aRect, FALSE );
+ }
+ }
+ break;
+ case 0x7 :
+ case 0x8 :
+ {
+ Bitmap aMask( aBitmap );
+ if ( ( nUsed & 1 ) && ( nRasterOperation & 0xb0 ) == 0xb0 ) // pattern used
+ {
+ aBitmap.Convert( BMP_CONVERSION_24BIT );
+ aBitmap.Erase( maFillStyle.aFillColor );
+ }
+ BitmapEx aBmpEx( aBitmap, aMask );
+ ImplDrawBitmap( aPos, aSize, aBmpEx );
+ if ( nOperation == 0x7 )
+ {
+ SetRasterOp( R2_NOT );
+ DrawRect( aRect, FALSE );
+ }
+ }
+ break;
+
+ case 0x4 :
+ case 0xb :
+ {
+ SetRasterOp( R2_NOT );
+ DrawRect( aRect, FALSE );
+ SetRasterOp( R2_COPYPEN );
+ Bitmap aMask( aBitmap );
+ aBitmap.Invert();
+ BitmapEx aBmpEx( aBitmap, aMask );
+ ImplDrawBitmap( aPos, aSize, aBmpEx );
+ SetRasterOp( R2_XORPEN );
+ ImplDrawBitmap( aPos, aSize, aBitmap );
+ if ( nOperation == 0xb )
+ {
+ SetRasterOp( R2_NOT );
+ DrawRect( aRect, FALSE );
+ }
+ }
+ break;
+
+ case 0x2 :
+ case 0xd :
+ {
+ Bitmap aMask( aBitmap );
+ aMask.Invert();
+ BitmapEx aBmpEx( aBitmap, aMask );
+ ImplDrawBitmap( aPos, aSize, aBmpEx );
+ SetRasterOp( R2_XORPEN );
+ ImplDrawBitmap( aPos, aSize, aBitmap );
+ if ( nOperation == 0xd )
+ {
+ SetRasterOp( R2_NOT );
+ DrawRect( aRect, FALSE );
+ }
+ }
+ break;
+ case 0x6 :
+ case 0x9 :
+ {
+ SetRasterOp( R2_XORPEN );
+ ImplDrawBitmap( aPos, aSize, aBitmap );
+ if ( nOperation == 0x9 )
+ {
+ SetRasterOp( R2_NOT );
+ DrawRect( aRect, FALSE );
+ }
+ }
+ break;
+
+ case 0x0 : // WHITENESS
+ case 0xf : // BLACKNESS
+ { // in this case nRasterOperation is either 0 or 0xff
+ maFillStyle = WinMtfFillStyle( Color( nRasterOperation, nRasterOperation, nRasterOperation ) );
+ UpdateFillStyle();
+ DrawRect( aRect, FALSE );
+ }
+ break;
+
+ case 0x3 : // only source is used
+ case 0xc :
+ {
+ if ( nRasterOperation == 0x33 )
+ aBitmap.Invert();
+ ImplDrawBitmap( aPos, aSize, aBitmap );
+ }
+ break;
+
+ case 0x5 : // only destination is used
+ {
+ SetRasterOp( R2_NOT );
+ DrawRect( aRect, FALSE );
+ }
+ case 0xa : // no operation
+ break;
+ }
+ SetRasterOp( nOldRop );
+ Pop();
+ }
+ }
+ }
+ nObjectsLeft -= nObjectsOfSameSize;
+ }
+
+ void* pPtr;
+ for ( pPtr = rSaveList.First(); pPtr; pPtr = rSaveList.Next() )
+ delete (BSaveStruct*)pPtr;
+ rSaveList.Clear();
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::SetDevOrg( const Point& rPoint )
+{
+ mnDevOrgX = rPoint.X();
+ mnDevOrgY = rPoint.Y();
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::SetDevOrgOffset( INT32 nXAdd, INT32 nYAdd )
+{
+ mnDevOrgX += nXAdd;
+ mnDevOrgY += nYAdd;
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::SetDevExt( const Size& rSize )
+{
+ if ( rSize.Width() && rSize.Height() )
+ {
+ switch( mnMapMode )
+ {
+ case MM_ISOTROPIC :
+ case MM_ANISOTROPIC :
+ {
+ mnDevWidth = rSize.Width();
+ mnDevHeight = rSize.Height();
+ }
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::ScaleDevExt( double fX, double fY )
+{
+ mnDevWidth = FRound( mnDevWidth * fX );
+ mnDevHeight = FRound( mnDevHeight * fY );
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::SetWinOrg( const Point& rPoint )
+{
+ mnWinOrgX = rPoint.X();
+ mnWinOrgY = rPoint.Y();
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::SetWinOrgOffset( INT32 nXAdd, INT32 nYAdd )
+{
+ mnWinOrgX += nXAdd;
+ mnWinOrgY += nYAdd;
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::SetWinExt( const Size& rSize )
+{
+
+ if( rSize.Width() && rSize.Height() )
+ {
+ switch( mnMapMode )
+ {
+ case MM_ISOTROPIC :
+ case MM_ANISOTROPIC :
+ {
+ mnWinExtX = rSize.Width();
+ mnWinExtY = rSize.Height();
+ }
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::ScaleWinExt( double fX, double fY )
+{
+ mnWinExtX = FRound( mnWinExtX * fX );
+ mnWinExtY = FRound( mnWinExtY * fY );
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::SetrclBounds( const Rectangle& rRect )
+{
+ mrclBounds = rRect;
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::SetrclFrame( const Rectangle& rRect )
+{
+ mrclFrame = rRect;
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::SetRefPix( const Size& rSize )
+{
+ mnPixX = rSize.Width();
+ mnPixY = rSize.Height();
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::SetRefMill( const Size& rSize )
+{
+ mnMillX = rSize.Width();
+ mnMillY = rSize.Height();
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::SetMapMode( sal_uInt32 nMapMode )
+{
+ mnMapMode = nMapMode;
+ if ( nMapMode == MM_TEXT )
+ {
+ mnWinExtX = mnDevWidth;
+ mnWinExtY = mnDevHeight;
+ }
+ else if ( mnMapMode == MM_HIMETRIC )
+ {
+ mnWinExtX = mnMillX * 100;
+ mnWinExtY = mnMillY * 100;
+ }
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::SetWorldTransform( const XForm& rXForm )
+{
+ maXForm.eM11 = rXForm.eM11;
+ maXForm.eM12 = rXForm.eM12;
+ maXForm.eM21 = rXForm.eM21;
+ maXForm.eM22 = rXForm.eM22;
+ maXForm.eDx = rXForm.eDx;
+ maXForm.eDy = rXForm.eDy;
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::ModifyWorldTransform( const XForm& rXForm, UINT32 nMode )
+{
+ switch( nMode )
+ {
+ case MWT_IDENTITY :
+ {
+ maXForm.eM11 = maXForm.eM12 = maXForm.eM21 = maXForm.eM22 = 1.0f;
+ maXForm.eDx = maXForm.eDy = 0.0f;
+ }
+ break;
+
+ case MWT_RIGHTMULTIPLY :
+ case MWT_LEFTMULTIPLY :
+ {
+ const XForm* pLeft;
+ const XForm* pRight;
+
+ if ( nMode == MWT_LEFTMULTIPLY )
+ {
+ pLeft = &rXForm;
+ pRight = &maXForm;
+ }
+ else
+ {
+ pLeft = &maXForm;
+ pRight = &rXForm;
+ }
+
+ float aF[3][3];
+ float bF[3][3];
+ float cF[3][3];
+
+ aF[0][0] = pLeft->eM11;
+ aF[0][1] = pLeft->eM12;
+ aF[0][2] = 0;
+ aF[1][0] = pLeft->eM21;
+ aF[1][1] = pLeft->eM22;
+ aF[1][2] = 0;
+ aF[2][0] = pLeft->eDx;
+ aF[2][1] = pLeft->eDy;
+ aF[2][2] = 1;
+
+ bF[0][0] = pRight->eM11;
+ bF[0][1] = pRight->eM12;
+ bF[0][2] = 0;
+ bF[1][0] = pRight->eM21;
+ bF[1][1] = pRight->eM22;
+ bF[1][2] = 0;
+ bF[2][0] = pRight->eDx;
+ bF[2][1] = pRight->eDy;
+ bF[2][2] = 1;
+
+ int i, j, k;
+ for ( i = 0; i < 3; i++ )
+ {
+ for ( j = 0; j < 3; j++ )
+ {
+ cF[i][j] = 0;
+ for ( k = 0; k < 3; k++ )
+ cF[i][j] += aF[i][k] * bF[k][j];
+ }
+ }
+ maXForm.eM11 = cF[0][0];
+ maXForm.eM12 = cF[0][1];
+ maXForm.eM21 = cF[1][0];
+ maXForm.eM22 = cF[1][1];
+ maXForm.eDx = cF[2][0];
+ maXForm.eDy = cF[2][1];
+ }
+ break;
+ }
+ }
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::Push() // !! to be able to access the original ClipRegion it
+{ // is not allowed to use the MetaPushAction()
+ UpdateClipRegion(); // (the original clip region is on top of the stack) (SJ)
+ SaveStructPtr pSave( new SaveStruct );
+
+ pSave->aLineStyle = maLineStyle;
+ pSave->aFillStyle = maFillStyle;
+
+ pSave->aFont = maFont;
+ pSave->aTextColor = maTextColor;
+ pSave->nTextAlign = mnTextAlign;
+ pSave->nTextLayoutMode = mnTextLayoutMode;
+ pSave->nMapMode = mnMapMode;
+ pSave->nGfxMode = mnGfxMode;
+ pSave->nBkMode = mnBkMode;
+ pSave->aBkColor = maBkColor;
+ pSave->bFillStyleSelected = mbFillStyleSelected;
+
+ pSave->aActPos = maActPos;
+ pSave->aXForm = maXForm;
+ pSave->eRasterOp = meRasterOp;
+
+ pSave->nWinOrgX = mnWinOrgX;
+ pSave->nWinOrgY = mnWinOrgY;
+ pSave->nWinExtX = mnWinExtX;
+ pSave->nWinExtY = mnWinExtY;
+ pSave->nDevOrgX = mnDevOrgX;
+ pSave->nDevOrgY = mnDevOrgY;
+ pSave->nDevWidth = mnDevWidth;
+ pSave->nDevHeight = mnDevHeight;
+
+ pSave->aPathObj = aPathObj;
+ pSave->aClipPath = aClipPath;
+
+ vSaveStack.push_back( pSave );
+}
+
+//-----------------------------------------------------------------------------------
+
+void WinMtfOutput::Pop()
+{
+ // Die aktuellen Daten vom Stack holen
+ if( vSaveStack.size() )
+ {
+ // Die aktuelle Daten auf dem Stack sichern
+ SaveStructPtr pSave( vSaveStack.back() );
+
+ maLineStyle = pSave->aLineStyle;
+ maFillStyle = pSave->aFillStyle;
+
+ maFont = pSave->aFont;
+ maTextColor = pSave->aTextColor;
+ mnTextAlign = pSave->nTextAlign;
+ mnTextLayoutMode = pSave->nTextLayoutMode;
+ mnBkMode = pSave->nBkMode;
+ mnGfxMode = pSave->nGfxMode;
+ mnMapMode = pSave->nMapMode;
+ maBkColor = pSave->aBkColor;
+ mbFillStyleSelected = pSave->bFillStyleSelected;
+
+ maActPos = pSave->aActPos;
+ maXForm = pSave->aXForm;
+ meRasterOp = pSave->eRasterOp;
+
+ mnWinOrgX = pSave->nWinOrgX;
+ mnWinOrgY = pSave->nWinOrgY;
+ mnWinExtX = pSave->nWinExtX;
+ mnWinExtY = pSave->nWinExtY;
+ mnDevOrgX = pSave->nDevOrgX;
+ mnDevOrgY = pSave->nDevOrgY;
+ mnDevWidth = pSave->nDevWidth;
+ mnDevHeight = pSave->nDevHeight;
+
+ aPathObj = pSave->aPathObj;
+ if ( ! ( aClipPath == pSave->aClipPath ) )
+ {
+ aClipPath = pSave->aClipPath;
+ aClipPath.bNeedsUpdate = sal_True;
+ }
+ if ( meLatestRasterOp != meRasterOp )
+ mpGDIMetaFile->AddAction( new MetaRasterOpAction( meRasterOp ) );
+ vSaveStack.pop_back();
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/wmf/svt_winwmf.cxx b/binfilter/bf_svtools/source/filter.vcl/wmf/svt_winwmf.cxx
new file mode 100644
index 000000000000..79a39495574f
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/wmf/svt_winwmf.cxx
@@ -0,0 +1,1317 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 "winmtf.hxx"
+#include <rtl/crc.h>
+#include <rtl/tencinfo.h>
+#include <osl/endian.h>
+
+namespace binfilter
+{
+
+
+//====================== MS-Windows-defines ===============================
+
+#define W_META_SETBKCOLOR 0x0201
+#define W_META_SETBKMODE 0x0102
+#define W_META_SETMAPMODE 0x0103
+#define W_META_SETROP2 0x0104
+#define W_META_SETRELABS 0x0105
+#define W_META_SETPOLYFILLMODE 0x0106
+#define W_META_SETSTRETCHBLTMODE 0x0107
+#define W_META_SETTEXTCHAREXTRA 0x0108
+#define W_META_SETTEXTCOLOR 0x0209
+#define W_META_SETTEXTJUSTIFICATION 0x020A
+#define W_META_SETWINDOWORG 0x020B
+#define W_META_SETWINDOWEXT 0x020C
+#define W_META_SETVIEWPORTORG 0x020D
+#define W_META_SETVIEWPORTEXT 0x020E
+#define W_META_OFFSETWINDOWORG 0x020F
+#define W_META_SCALEWINDOWEXT 0x0410
+#define W_META_OFFSETVIEWPORTORG 0x0211
+#define W_META_SCALEVIEWPORTEXT 0x0412
+#define W_META_LINETO 0x0213
+#define W_META_MOVETO 0x0214
+#define W_META_EXCLUDECLIPRECT 0x0415
+#define W_META_INTERSECTCLIPRECT 0x0416
+#define W_META_ARC 0x0817
+#define W_META_ELLIPSE 0x0418
+#define W_META_FLOODFILL 0x0419
+#define W_META_PIE 0x081A
+#define W_META_RECTANGLE 0x041B
+#define W_META_ROUNDRECT 0x061C
+#define W_META_PATBLT 0x061D
+#define W_META_SAVEDC 0x001E
+#define W_META_SETPIXEL 0x041F
+#define W_META_OFFSETCLIPRGN 0x0220
+#define W_META_TEXTOUT 0x0521
+#define W_META_BITBLT 0x0922
+#define W_META_STRETCHBLT 0x0B23
+#define W_META_POLYGON 0x0324
+#define W_META_POLYLINE 0x0325
+#define W_META_ESCAPE 0x0626
+#define W_META_RESTOREDC 0x0127
+#define W_META_FILLREGION 0x0228
+#define W_META_FRAMEREGION 0x0429
+#define W_META_INVERTREGION 0x012A
+#define W_META_PAINTREGION 0x012B
+#define W_META_SELECTCLIPREGION 0x012C
+#define W_META_SELECTOBJECT 0x012D
+#define W_META_SETTEXTALIGN 0x012E
+#define W_META_DRAWTEXT 0x062F
+#define W_META_CHORD 0x0830
+#define W_META_SETMAPPERFLAGS 0x0231
+#define W_META_EXTTEXTOUT 0x0a32
+#define W_META_SETDIBTODEV 0x0d33
+#define W_META_SELECTPALETTE 0x0234
+#define W_META_REALIZEPALETTE 0x0035
+#define W_META_ANIMATEPALETTE 0x0436
+#define W_META_SETPALENTRIES 0x0037
+#define W_META_POLYPOLYGON 0x0538
+#define W_META_RESIZEPALETTE 0x0139
+#define W_META_DIBBITBLT 0x0940
+#define W_META_DIBSTRETCHBLT 0x0b41
+#define W_META_DIBCREATEPATTERNBRUSH 0x0142
+#define W_META_STRETCHDIB 0x0f43
+#define W_META_EXTFLOODFILL 0x0548
+#define W_META_RESETDC 0x014C
+#define W_META_STARTDOC 0x014D
+#define W_META_STARTPAGE 0x004F
+#define W_META_ENDPAGE 0x0050
+#define W_META_ABORTDOC 0x0052
+#define W_META_ENDDOC 0x005E
+#define W_META_DELETEOBJECT 0x01f0
+#define W_META_CREATEPALETTE 0x00f7
+#define W_META_CREATEBRUSH 0x00F8
+#define W_META_CREATEPATTERNBRUSH 0x01F9
+#define W_META_CREATEPENINDIRECT 0x02FA
+#define W_META_CREATEFONTINDIRECT 0x02FB
+#define W_META_CREATEBRUSHINDIRECT 0x02FC
+#define W_META_CREATEBITMAPINDIRECT 0x02FD
+#define W_META_CREATEBITMAP 0x06FE
+#define W_META_CREATEREGION 0x06FF
+
+//=================== Methoden von WMFReader ==============================
+
+inline Point WMFReader::ReadPoint()
+{
+ short nX, nY;
+ *pWMF >> nX >> nY;
+ return Point( nX, nY );
+}
+
+// ------------------------------------------------------------------------
+
+inline Point WMFReader::ReadYX()
+{
+ short nX, nY;
+ *pWMF >> nY >> nX;
+ return Point( nX, nY );
+}
+
+// ------------------------------------------------------------------------
+
+Rectangle WMFReader::ReadRectangle()
+{
+ Point aBR, aTL;
+ aBR = ReadYX();
+ aTL = ReadYX();
+ aBR.X()--;
+ aBR.Y()--;
+ return Rectangle( aTL, aBR );
+}
+
+// ------------------------------------------------------------------------
+
+Size WMFReader::ReadYXExt()
+{
+ short nW, nH;
+ *pWMF >> nH >> nW;
+ return Size( nW, nH );
+}
+
+// ------------------------------------------------------------------------
+
+void WMFReader::ReadRecordParams( USHORT nFunc )
+{
+ switch( nFunc )
+ {
+ case W_META_SETBKCOLOR:
+ {
+ pOut->SetBkColor( ReadColor() );
+ }
+ break;
+
+ case W_META_SETBKMODE:
+ {
+ USHORT nDat;
+ *pWMF >> nDat;
+ pOut->SetBkMode( nDat );
+ }
+ break;
+
+ // !!!
+ case W_META_SETMAPMODE:
+ {
+ sal_Int16 nMapMode;
+ *pWMF >> nMapMode;
+ pOut->SetMapMode( nMapMode );
+ }
+ break;
+
+ case W_META_SETROP2:
+ {
+ UINT16 nROP2;
+ *pWMF >> nROP2;
+ pOut->SetRasterOp( nROP2 );
+ }
+ break;
+
+ case W_META_SETTEXTCOLOR:
+ {
+ pOut->SetTextColor( ReadColor() );
+ }
+ break;
+
+ case W_META_SETWINDOWORG:
+ {
+ pOut->SetWinOrg( ReadYX() );
+ }
+ break;
+
+ case W_META_SETWINDOWEXT:
+ {
+ short nWidth, nHeight;
+ *pWMF >> nHeight >> nWidth;
+ pOut->SetWinExt( Size( nWidth, nHeight ) );
+ }
+ break;
+
+ case W_META_OFFSETWINDOWORG:
+ {
+ short nXAdd, nYAdd;
+ *pWMF >> nYAdd >> nXAdd;
+ pOut->SetWinOrgOffset( nXAdd, nYAdd );
+ }
+ break;
+
+ case W_META_SCALEWINDOWEXT:
+ {
+ short nXNum, nXDenom, nYNum, nYDenom;
+ *pWMF >> nYDenom >> nYNum >> nXDenom >> nXNum;
+ pOut->ScaleWinExt( (double)nXNum / nXDenom, (double)nYNum / nYDenom );
+ }
+ break;
+
+ case W_META_SETVIEWPORTORG:
+ case W_META_SETVIEWPORTEXT:
+ break;
+
+ case W_META_OFFSETVIEWPORTORG:
+ {
+ short nXAdd, nYAdd;
+ *pWMF >> nYAdd >> nXAdd;
+ pOut->SetDevOrgOffset( nXAdd, nYAdd );
+ }
+ break;
+
+ case W_META_SCALEVIEWPORTEXT:
+ {
+ short nXNum, nXDenom, nYNum, nYDenom;
+ *pWMF >> nYDenom >> nYNum >> nXDenom >> nXNum;
+ pOut->ScaleDevExt( (double)nXNum / nXDenom, (double)nYNum / nYDenom );
+ }
+ break;
+
+ case W_META_LINETO:
+ {
+ pOut->LineTo( ReadYX() );
+ }
+ break;
+
+ case W_META_MOVETO:
+ {
+ pOut->MoveTo( ReadYX() );
+ }
+ break;
+
+ case W_META_INTERSECTCLIPRECT:
+ {
+ pOut->IntersectClipRect( ReadRectangle() );
+ }
+ break;
+
+ case W_META_RECTANGLE:
+ {
+ pOut->DrawRect( ReadRectangle() );
+ }
+ break;
+
+ case W_META_ROUNDRECT:
+ {
+ Size aSize( ReadYXExt() );
+ pOut->DrawRoundRect( ReadRectangle(), aSize );
+ }
+ break;
+
+ case W_META_ELLIPSE:
+ {
+ pOut->DrawEllipse( ReadRectangle() );
+ }
+ break;
+
+ case W_META_ARC:
+ {
+ Point aEnd( ReadYX() );
+ Point aStart( ReadYX() );
+ pOut->DrawArc( ReadRectangle(), aStart, aEnd );
+ }
+ break;
+
+ case W_META_PIE:
+ {
+ Point aEnd( ReadYX() );
+ Point aStart( ReadYX() );
+ Rectangle aRect( ReadRectangle() );
+
+ // #i73608# OutputDevice deviates from WMF
+ // semantics. start==end means full ellipse here.
+ if( aStart == aEnd )
+ pOut->DrawEllipse( aRect );
+ else
+ pOut->DrawPie( aRect, aStart, aEnd );
+ }
+ break;
+
+ case W_META_CHORD:
+ {
+ Point aEnd( ReadYX() );
+ Point aStart( ReadYX() );
+ pOut->DrawChord( ReadRectangle(), aStart, aEnd );
+ }
+ break;
+
+ case W_META_POLYGON:
+ {
+ USHORT i,nPoints;
+ *pWMF >> nPoints;
+ Polygon aPoly( nPoints );
+ for( i = 0; i < nPoints; i++ )
+ aPoly[ i ] = ReadPoint();
+ pOut->DrawPolygon( aPoly );
+ }
+ break;
+
+ case W_META_POLYPOLYGON:
+ {
+ USHORT i, nPoly, nPoints;
+ USHORT* pnPoints;
+ Point* pPtAry;
+ // Anzahl der Polygone:
+ *pWMF >> nPoly;
+ // Anzahl der Punkte eines jeden Polygons holen, Gesammtzahl der Punkte ermitteln:
+ pnPoints = new USHORT[ nPoly ];
+ nPoints = 0;
+ for( i = 0; i < nPoly; i++ )
+ {
+ *pWMF >> pnPoints[i];
+ nPoints = nPoints + pnPoints[i];
+ }
+ // Polygonpunkte holen:
+ pPtAry = (Point*) new char[ nPoints * sizeof(Point) ];
+ for ( i = 0; i < nPoints; i++ )
+ pPtAry[ i ] = ReadPoint();
+ // PolyPolygon Actions erzeugen
+ PolyPolygon aPolyPoly( nPoly, pnPoints, pPtAry );
+ pOut->DrawPolyPolygon( aPolyPoly );
+ delete[] (char*) pPtAry;
+ delete[] pnPoints;
+ }
+ break;
+
+ case W_META_POLYLINE:
+ {
+ USHORT i,nPoints;
+ *pWMF >> nPoints;
+ Polygon aPoly( nPoints );
+ for( i = 0; i < nPoints; i++ )
+ aPoly[ i ] = ReadPoint();
+ pOut->DrawPolyLine( aPoly );
+ }
+ break;
+
+ case W_META_SAVEDC:
+ {
+ pOut->Push();
+ }
+ break;
+
+ case W_META_RESTOREDC:
+ {
+ pOut->Pop();
+ }
+ break;
+
+ case W_META_SETPIXEL:
+ {
+ const Color aColor = ReadColor();
+ pOut->DrawPixel( ReadYX(), aColor );
+ }
+ break;
+
+ case W_META_OFFSETCLIPRGN:
+ {
+ pOut->MoveClipRegion( ReadYXExt() );
+ }
+ break;
+
+ case W_META_TEXTOUT:
+ {
+ USHORT nLength;
+ *pWMF >> nLength;
+ if ( nLength )
+ {
+ char* pChar = new char[ ( nLength + 1 ) &~ 1 ];
+ pWMF->Read( pChar, ( nLength + 1 ) &~ 1 );
+ String aText( pChar, nLength, pOut->GetCharSet() );
+ delete[] pChar;
+ Point aPosition( ReadYX() );
+ pOut->DrawText( aPosition, aText );
+ }
+ }
+ break;
+
+ case W_META_EXTTEXTOUT:
+ {
+ sal_Int16 nDx, nDxTmp;
+ sal_uInt16 i, nLen, nOptions;
+ sal_Int32 nRecordPos, nRecordSize, nOriginalTextLen, nNewTextLen;
+ Point aPosition;
+ Rectangle aRect;
+ sal_Int32* pDXAry = NULL;
+
+ pWMF->SeekRel(-6);
+ nRecordPos = pWMF->Tell();
+ *pWMF >> nRecordSize;
+ pWMF->SeekRel(2);
+ aPosition = ReadYX();
+ *pWMF >> nLen >> nOptions;
+
+ sal_Int32 nTextLayoutMode = TEXT_LAYOUT_DEFAULT;
+ if ( nOptions & ETO_RTLREADING )
+ nTextLayoutMode = TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_TEXTORIGIN_LEFT;
+ pOut->SetTextLayoutMode( nTextLayoutMode );
+ DBG_ASSERT( ( nOptions & ( ETO_PDY | ETO_GLYPH_INDEX ) ) == 0, "SJ: ETO_PDY || ETO_GLYPH_INDEX in WMF" );
+
+ // Nur wenn der Text auch Zeichen enthaelt, macht die Ausgabe Sinn
+ if( nLen )
+ {
+ nOriginalTextLen = nLen;
+ if( nOptions & ETO_CLIPPED )
+ {
+ const Point aPt1( ReadPoint() );
+ const Point aPt2( ReadPoint() );
+ aRect = Rectangle( aPt1, aPt2 );
+ }
+ char* pChar = new char[ ( nOriginalTextLen + 1 ) &~ 1 ];
+ pWMF->Read( pChar, ( nOriginalTextLen + 1 ) &~ 1 );
+ String aText( pChar, (sal_uInt16)nOriginalTextLen, pOut->GetCharSet() );// after this conversion the text may contain
+ nNewTextLen = aText.Len(); // less character (japanese version), so the
+ delete[] pChar; // dxAry will not fit
+
+ if ( nNewTextLen )
+ {
+ sal_uInt32 nMaxStreamPos = nRecordPos + ( nRecordSize << 1 );
+ sal_Int32 nDxArySize = nMaxStreamPos - pWMF->Tell();
+ sal_Int32 nDxAryEntries = nDxArySize >> 1;
+ sal_Bool bUseDXAry = FALSE;
+
+ if ( ( ( nDxAryEntries % nOriginalTextLen ) == 0 ) && ( nNewTextLen <= nOriginalTextLen ) )
+ {
+ pDXAry = new sal_Int32[ nNewTextLen ];
+ for ( i = 0; i < nNewTextLen; i++ )
+ {
+ if ( pWMF->Tell() >= nMaxStreamPos )
+ break;
+ *pWMF >> nDx;
+ if ( nNewTextLen != nOriginalTextLen )
+ {
+ ByteString aTmp( aText.GetChar( i ), pOut->GetCharSet() );
+ if ( aTmp.Len() > 1 )
+ {
+ sal_Int32 nDxCount = aTmp.Len() - 1;
+ if ( ( ( nDxCount * 2 ) + pWMF->Tell() ) > nMaxStreamPos )
+ break;
+ while ( nDxCount-- )
+ {
+ *pWMF >> nDxTmp;
+ nDx = nDx + nDxTmp;
+ }
+ }
+ }
+ pDXAry[ i ] = nDx;
+ }
+ if ( i == nNewTextLen )
+ bUseDXAry = TRUE;
+ }
+ if ( pDXAry && bUseDXAry )
+ pOut->DrawText( aPosition, aText, pDXAry );
+ else
+ pOut->DrawText( aPosition, aText );
+ }
+ }
+ delete[] pDXAry;
+
+ }
+ break;
+
+ case W_META_SELECTOBJECT:
+ {
+ INT16 nObjIndex;
+ *pWMF >> nObjIndex;
+ pOut->SelectObject( nObjIndex );
+ }
+ break;
+
+ case W_META_SETTEXTALIGN:
+ {
+ UINT16 nAlign;
+ *pWMF >> nAlign;
+ pOut->SetTextAlign( nAlign );
+ }
+ break;
+
+ case W_META_BITBLT:
+ {
+ // 0-3 : nWinROP #93454#
+ // 4-5 : y offset of source bitmap
+ // 6-7 : x offset of source bitmap
+ // 8-9 : used height of source bitmap
+ // 10-11 : used width of source bitmap
+ // 12-13 : destination position y (in pixel)
+ // 14-15 : destination position x (in pixel)
+ // 16-17 : dont know
+ // 18-19 : Width Bitmap in Pixel
+ // 20-21 : Height Bitmap in Pixel
+ // 22-23 : bytes per scanline
+ // 24 : planes
+ // 25 : bitcount
+
+ sal_Int32 nWinROP;
+ sal_uInt16 nSx, nSy, nSxe, nSye, nDontKnow, nWidth, nHeight, nBytesPerScan;
+ sal_uInt8 nPlanes, nBitCount;
+
+ *pWMF >> nWinROP
+ >> nSy >> nSx >> nSye >> nSxe;
+ Point aPoint( ReadYX() );
+ *pWMF >> nDontKnow >> nWidth >> nHeight >> nBytesPerScan >> nPlanes >> nBitCount;
+
+ if ( nWidth && nHeight && ( nPlanes == 1 ) && ( nBitCount == 1 ) )
+ {
+ Bitmap aBmp( Size( nWidth, nHeight ), nBitCount );
+ BitmapWriteAccess* pAcc;
+ pAcc = aBmp.AcquireWriteAccess();
+ if ( pAcc )
+ {
+ sal_uInt16 y, x, scan;
+ sal_Int8 i, nEightPixels;
+ for ( y = 0; y < nHeight; y++ )
+ {
+ x = 0;
+ for ( scan = 0; scan < nBytesPerScan; scan++ )
+ {
+ *pWMF >> nEightPixels;
+ for ( i = 7; i >= 0; i-- )
+ {
+ if ( x < nWidth )
+ {
+ pAcc->SetPixel( y, x, (nEightPixels>>i)&1 );
+ }
+ x++;
+ }
+ }
+ }
+ aBmp.ReleaseAccess( pAcc );
+ if ( nSye && nSxe &&
+ ( ( nSx + nSxe ) <= aBmp.GetSizePixel().Width() ) &&
+ ( ( nSy + nSye <= aBmp.GetSizePixel().Height() ) ) )
+ {
+ Rectangle aCropRect( Point( nSx, nSy ), Size( nSxe, nSye ) );
+ aBmp.Crop( aCropRect );
+ }
+ Rectangle aDestRect( aPoint, Size( nSxe, nSye ) );
+ aBmpSaveList.Insert( new BSaveStruct( aBmp, aDestRect, nWinROP ), LIST_APPEND );
+ }
+ }
+ }
+ break;
+
+ case W_META_STRETCHBLT:
+ case W_META_DIBBITBLT:
+ case W_META_DIBSTRETCHBLT:
+ case W_META_STRETCHDIB:
+ {
+ sal_Int32 nWinROP;
+ sal_uInt16 nSx, nSy, nSxe, nSye, nUsage;
+ Bitmap aBmp;
+
+ *pWMF >> nWinROP;
+
+ if( nFunc == W_META_STRETCHDIB )
+ *pWMF >> nUsage;
+
+ // nSye and nSxe is the number of pixels that has to been used
+ if( nFunc == W_META_STRETCHDIB || nFunc == W_META_STRETCHBLT || nFunc == W_META_DIBSTRETCHBLT )
+ *pWMF >> nSye >> nSxe;
+ else
+ nSye = nSxe = 0; // set this to zero as indicator not to scale the bitmap later
+
+ // nSy and nx is the offset of the first pixel
+ *pWMF >> nSy >> nSx;
+
+ if( nFunc == W_META_STRETCHDIB || nFunc == W_META_DIBBITBLT || nFunc == W_META_DIBSTRETCHBLT )
+ {
+ if ( nWinROP == PATCOPY )
+ *pWMF >> nUsage; // i don't know anything of this parameter, so its called nUsage
+ // pOut->DrawRect( Rectangle( ReadYX(), aDestSize ), FALSE );
+
+ Size aDestSize( ReadYXExt() );
+ if ( aDestSize.Width() && aDestSize.Height() ) // #92623# do not try to read buggy bitmaps
+ {
+ Rectangle aDestRect( ReadYX(), aDestSize );
+ if ( nWinROP != PATCOPY )
+ aBmp.Read( *pWMF, FALSE );
+
+ // test if it is sensible to crop
+ if ( nSye && nSxe &&
+ ( ( nSx + nSxe ) <= aBmp.GetSizePixel().Width() ) &&
+ ( ( nSy + nSye <= aBmp.GetSizePixel().Height() ) ) )
+ {
+ Rectangle aCropRect( Point( nSx, nSy ), Size( nSxe, nSye ) );
+ aBmp.Crop( aCropRect );
+ }
+ aBmpSaveList.Insert( new BSaveStruct( aBmp, aDestRect, nWinROP ), LIST_APPEND );
+ }
+ }
+ }
+ break;
+
+ case W_META_DIBCREATEPATTERNBRUSH:
+ {
+ Bitmap aBmp;
+ BitmapReadAccess* pBmp;
+ UINT32 nRed = 0, nGreen = 0, nBlue = 0, nCount = 1;
+ UINT16 nFunction;
+
+ *pWMF >> nFunction >> nFunction;
+
+ aBmp.Read( *pWMF, FALSE );
+ pBmp = aBmp.AcquireReadAccess();
+ if ( pBmp )
+ {
+ for ( INT32 y = 0; y < pBmp->Height(); y++ )
+ {
+ for ( INT32 x = 0; x < pBmp->Width(); x++ )
+ {
+ const BitmapColor aColor( pBmp->GetColor( y, x ) );
+
+ nRed += aColor.GetRed();
+ nGreen += aColor.GetGreen();
+ nBlue += aColor.GetBlue();
+ }
+ }
+ nCount = pBmp->Height() * pBmp->Width();
+ if ( !nCount )
+ nCount++;
+ aBmp.ReleaseAccess( pBmp );
+ }
+ Color aColor( (BYTE)( nRed / nCount ), (BYTE)( nGreen / nCount ), (BYTE)( nBlue / nCount ) );
+ pOut->CreateObject( GDI_BRUSH, new WinMtfFillStyle( aColor, FALSE ) );
+ }
+ break;
+
+ case W_META_DELETEOBJECT:
+ {
+ INT16 nIndex;
+ *pWMF >> nIndex;
+ pOut->DeleteObject( nIndex );
+ }
+ break;
+
+ case W_META_CREATEPALETTE:
+ {
+ pOut->CreateObject( GDI_DUMMY );
+ }
+ break;
+
+ case W_META_CREATEBRUSH:
+ {
+ pOut->CreateObject( GDI_BRUSH, new WinMtfFillStyle( Color( COL_WHITE ), FALSE ) );
+ }
+ break;
+
+ case W_META_CREATEPATTERNBRUSH:
+ {
+ pOut->CreateObject( GDI_BRUSH, new WinMtfFillStyle( Color( COL_WHITE ), FALSE ) );
+ }
+ break;
+
+ case W_META_CREATEPENINDIRECT:
+ {
+ LineInfo aLineInfo;
+ USHORT nStyle, nWidth, nHeight;
+
+ *pWMF >> nStyle >> nWidth >> nHeight;
+
+ if ( nWidth )
+ aLineInfo.SetWidth( nWidth );
+
+ BOOL bTransparent = FALSE;
+ UINT16 nDashCount = 0;
+ UINT16 nDotCount = 0;
+ switch( nStyle )
+ {
+ case PS_DASHDOTDOT :
+ nDotCount++;
+ case PS_DASHDOT :
+ nDashCount++;
+ case PS_DOT :
+ nDotCount++;
+ break;
+ case PS_DASH :
+ nDashCount++;
+ break;
+ case PS_NULL :
+ bTransparent = TRUE;
+ aLineInfo.SetStyle( LINE_NONE );
+ break;
+ default :
+ case PS_INSIDEFRAME :
+ case PS_SOLID :
+ aLineInfo.SetStyle( LINE_SOLID );
+ }
+ if ( nDashCount | nDotCount )
+ {
+ aLineInfo.SetStyle( LINE_DASH );
+ aLineInfo.SetDashCount( nDashCount );
+ aLineInfo.SetDotCount( nDotCount );
+ }
+ pOut->CreateObject( GDI_PEN, new WinMtfLineStyle( ReadColor(), aLineInfo, bTransparent ) );
+ }
+ break;
+
+ case W_META_CREATEBRUSHINDIRECT:
+ {
+ USHORT nStyle;
+ *pWMF >> nStyle;
+ pOut->CreateObject( GDI_BRUSH, new WinMtfFillStyle( ReadColor(), ( nStyle == BS_HOLLOW ) ? TRUE : FALSE ) );
+ }
+ break;
+
+ case W_META_CREATEFONTINDIRECT:
+ {
+ Size aFontSize;
+ char lfFaceName[ LF_FACESIZE ];
+ INT16 lfEscapement, lfOrientation, lfWeight; // ( ehemals USHORT )
+
+ LOGFONTW aLogFont;
+ aFontSize = ReadYXExt();
+ *pWMF >> lfEscapement >> lfOrientation >> lfWeight
+ >> aLogFont.lfItalic >> aLogFont.lfUnderline >> aLogFont.lfStrikeOut >> aLogFont.lfCharSet >> aLogFont.lfOutPrecision
+ >> aLogFont.lfClipPrecision >> aLogFont.lfQuality >> aLogFont.lfPitchAndFamily;
+ pWMF->Read( lfFaceName, LF_FACESIZE );
+ aLogFont.lfWidth = aFontSize.Width();
+ aLogFont.lfHeight = aFontSize.Height();
+ aLogFont.lfEscapement = lfEscapement;
+ aLogFont.lfOrientation = lfOrientation;
+ aLogFont.lfWeight = lfWeight;
+
+ CharSet eCharSet;
+ if ( ( aLogFont.lfCharSet == OEM_CHARSET ) || ( aLogFont.lfCharSet == DEFAULT_CHARSET ) )
+ eCharSet = gsl_getSystemTextEncoding();
+ else
+ eCharSet = rtl_getTextEncodingFromWindowsCharset( aLogFont.lfCharSet );
+ if ( eCharSet == RTL_TEXTENCODING_DONTKNOW )
+ eCharSet = gsl_getSystemTextEncoding();
+ if ( eCharSet == RTL_TEXTENCODING_SYMBOL )
+ eCharSet = RTL_TEXTENCODING_MS_1252;
+ aLogFont.alfFaceName = UniString( lfFaceName, eCharSet );
+
+ pOut->CreateObject( GDI_FONT, new WinMtfFontStyle( aLogFont ) );
+ }
+ break;
+
+ case W_META_CREATEBITMAPINDIRECT:
+ {
+ pOut->CreateObject( GDI_DUMMY );
+ }
+ break;
+
+ case W_META_CREATEBITMAP:
+ {
+ pOut->CreateObject( GDI_DUMMY );
+ }
+ break;
+
+ case W_META_CREATEREGION:
+ {
+ pOut->CreateObject( GDI_DUMMY );
+ }
+ break;
+
+ case W_META_EXCLUDECLIPRECT :
+ {
+ pOut->ExcludeClipRect( ReadRectangle() );
+ }
+ break;
+
+ case W_META_PATBLT:
+ {
+ UINT32 nROP, nOldROP;
+ *pWMF >> nROP;
+ Size aSize = ReadYXExt();
+ nOldROP = pOut->SetRasterOp( nROP );
+ pOut->DrawRect( Rectangle( ReadYX(), aSize ), FALSE );
+ pOut->SetRasterOp( nOldROP );
+ }
+ break;
+
+ case W_META_SELECTCLIPREGION:
+ {
+ sal_Int16 nObjIndex;
+ *pWMF >> nObjIndex;
+ if ( !nObjIndex )
+ {
+ PolyPolygon aEmptyPolyPoly;
+ pOut->SetClipPath( aEmptyPolyPoly, RGN_COPY, sal_True );
+ }
+ }
+ break;
+
+ case W_META_ESCAPE :
+ {
+ if ( nRecSize >= 12 ) // minimal escape lenght
+ {
+ sal_uInt16 nMode, nLen, OO;
+ sal_uInt32 Magic, nCheck,nEsc;
+ *pWMF >> nMode
+ >> nLen
+ >> OO
+ >> Magic
+ >> nCheck
+ >> nEsc;
+ if ( ( nMode == W_MFCOMMENT ) && ( nLen >= 14 ) && ( OO == 0x4f4f ) && ( Magic == 0xa2c2a ) )
+ {
+ sal_uInt32 nEscLen = nLen - 14;
+ if ( nEscLen <= ( nRecSize * 2 ) )
+ {
+#ifdef OSL_BIGENDIAN
+ sal_uInt32 nTmp = SWAPLONG( nEsc );
+ sal_uInt32 nCheckSum = rtl_crc32( 0, &nTmp, 4 );
+#else
+ sal_uInt32 nCheckSum = rtl_crc32( 0, &nEsc, 4 );
+#endif
+ sal_Int8* pData = NULL;
+ if ( nEscLen )
+ {
+ pData = new sal_Int8[ nEscLen ];
+ pWMF->Read( pData, nEscLen );
+ nCheckSum = rtl_crc32( nCheckSum, pData, nEscLen );
+ }
+ if ( nCheck == nCheckSum )
+ {
+ switch( nEsc )
+ {
+ case PRIVATE_ESCAPE_UNICODE :
+ { // we will use text instead of polygons only if we have the correct font
+ if ( aVDev.IsFontAvailable( pOut->GetFont().GetName() ) )
+ {
+ Point aPt;
+ String aString;
+ sal_uInt32 i, nStringLen, nDXCount;
+ sal_Int32* pDXAry = NULL;
+ SvMemoryStream aMemoryStream( nEscLen );
+ aMemoryStream.Write( pData, nEscLen );
+ aMemoryStream.Seek( STREAM_SEEK_TO_BEGIN );
+ aMemoryStream >> aPt.X()
+ >> aPt.Y()
+ >> nStringLen;
+
+ if (nStringLen < STRING_MAXLEN)
+ {
+ sal_Unicode* pBuf = aString.AllocBuffer( (xub_StrLen)nStringLen );
+ for ( i = 0; i < nStringLen; i++ )
+ aMemoryStream >> pBuf[ i ];
+ aMemoryStream >> nDXCount;
+ if ( nDXCount )
+ pDXAry = new sal_Int32[ nDXCount ];
+ for ( i = 0; i < nDXCount; i++ )
+ aMemoryStream >> pDXAry[ i ];
+ aMemoryStream >> nSkipActions;
+ pOut->DrawText( aPt, aString, pDXAry );
+ delete[] pDXAry;
+ }
+ }
+ }
+ break;
+ }
+ }
+ delete[] pData;
+ }
+ }
+ }
+ }
+ break;
+
+ case W_META_SETRELABS:
+ case W_META_SETPOLYFILLMODE:
+ case W_META_SETSTRETCHBLTMODE:
+ case W_META_SETTEXTCHAREXTRA:
+ case W_META_SETTEXTJUSTIFICATION:
+ case W_META_FLOODFILL :
+ case W_META_FILLREGION:
+ case W_META_FRAMEREGION:
+ case W_META_INVERTREGION:
+ case W_META_PAINTREGION:
+ case W_META_DRAWTEXT:
+ case W_META_SETMAPPERFLAGS:
+ case W_META_SETDIBTODEV:
+ case W_META_SELECTPALETTE:
+ case W_META_REALIZEPALETTE:
+ case W_META_ANIMATEPALETTE:
+ case W_META_SETPALENTRIES:
+ case W_META_RESIZEPALETTE:
+ case W_META_EXTFLOODFILL:
+ case W_META_RESETDC:
+ case W_META_STARTDOC:
+ case W_META_STARTPAGE:
+ case W_META_ENDPAGE:
+ case W_META_ABORTDOC:
+ case W_META_ENDDOC:
+ break;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+BOOL WMFReader::ReadHeader()
+{
+ Rectangle aPlaceableBound;
+ sal_uInt32 nl, nStrmPos = pWMF->Tell();
+
+ // Einlesen des METAFILEHEADER, falls vorhanden
+ *pWMF >> nl;
+
+ Size aWMFSize;
+ if ( nl == 0x9ac6cdd7L )
+ {
+ INT16 nVal;
+
+ // hmf (Unused) ueberlesen wir
+ pWMF->SeekRel(2);
+
+ // BoundRect
+ *pWMF >> nVal; aPlaceableBound.Left() = nVal;
+ *pWMF >> nVal; aPlaceableBound.Top() = nVal;
+ *pWMF >> nVal; aPlaceableBound.Right() = nVal;
+ *pWMF >> nVal; aPlaceableBound.Bottom() = nVal;
+
+ // inch
+ *pWMF >> nUnitsPerInch;
+
+ // reserved
+ pWMF->SeekRel( 4 );
+
+ // checksum pruefen wir lieber nicht
+ pWMF->SeekRel( 2 );
+ }
+ else
+ {
+ nUnitsPerInch = 96;
+ pWMF->Seek( nStrmPos + 18 ); // set the streampos to the start of the the metaactions
+ GetPlaceableBound( aPlaceableBound, pWMF );
+ pWMF->Seek( nStrmPos );
+ }
+
+ pOut->SetWinOrg( aPlaceableBound.TopLeft() );
+ aWMFSize = Size( labs( aPlaceableBound.GetWidth() ), labs( aPlaceableBound.GetHeight() ) );
+ pOut->SetWinExt( aWMFSize );
+
+ Size aDevExt( 10000, 10000 );
+ if( ( labs( aWMFSize.Width() ) > 1 ) && ( labs( aWMFSize.Height() ) > 1 ) )
+ {
+ const Fraction aFrac( 1, nUnitsPerInch );
+ MapMode aWMFMap( MAP_INCH, Point(), aFrac, aFrac );
+ Size aSize100( OutputDevice::LogicToLogic( aWMFSize, aWMFMap, MAP_100TH_MM ) );
+ aDevExt = Size( labs( aSize100.Width() ), labs( aSize100.Height() ) );
+ }
+ pOut->SetDevExt( aDevExt );
+
+ // Einlesen des METAHEADER
+ *pWMF >> nl; // Typ und Headergroesse
+
+ if( nl != 0x00090001 )
+ {
+ pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR );
+ return FALSE;
+ }
+
+ pWMF->SeekRel( 2 ); // Version (von Windows)
+ pWMF->SeekRel( 4 ); // Size (der Datei in Words)
+ pWMF->SeekRel( 2 ); // NoObjects (Maximale Anzahl der gleichzeitigen Objekte)
+ pWMF->SeekRel( 4 ); // MaxRecord (Groesse des groessten Records in Words)
+ pWMF->SeekRel( 2 ); // NoParameters (Unused
+
+ return TRUE;
+}
+
+void WMFReader::ReadWMF()
+{
+ USHORT nFunction;
+ ULONG nPos, nPercent, nLastPercent;
+
+ nSkipActions = 0;
+ nCurrentAction = 0;
+ nUnicodeEscapeAction = 0;
+
+ pOut->SetMapMode( MM_ANISOTROPIC );
+ pOut->SetWinOrg( Point() );
+ pOut->SetWinExt( Size( 1, 1 ) );
+ pOut->SetDevExt( Size( 10000, 10000 ) );
+
+ nEndPos=pWMF->Seek( STREAM_SEEK_TO_END );
+ pWMF->Seek( nStartPos );
+ Callback( (USHORT) ( nLastPercent = 0 ) );
+
+ if ( ReadHeader() )
+ {
+
+ nPos = pWMF->Tell();
+
+ if( nEndPos - nStartPos )
+ {
+ while( TRUE )
+ {
+ nCurrentAction++;
+ nPercent = ( nPos - nStartPos ) * 100 / ( nEndPos - nStartPos );
+
+ if( nLastPercent + 4 <= nPercent )
+ {
+ Callback( (USHORT) nPercent );
+ nLastPercent = nPercent;
+ }
+ *pWMF >> nRecSize >> nFunction;
+
+ if( pWMF->GetError() || ( nRecSize < 3 ) || ( nRecSize==3 && nFunction==0 ) || pWMF->IsEof() )
+ {
+
+ if( pWMF->IsEof() )
+ pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR );
+
+ break;
+ }
+ if( aBmpSaveList.Count() &&
+ ( nFunction != W_META_STRETCHDIB ) &&
+ ( nFunction != W_META_DIBBITBLT ) &&
+ ( nFunction != W_META_DIBSTRETCHBLT ) )
+ {
+ pOut->ResolveBitmapActions( aBmpSaveList );
+ }
+ if ( !nSkipActions )
+ ReadRecordParams( nFunction );
+ else
+ nSkipActions--;
+ nPos += nRecSize * 2;
+ if ( nPos <= nEndPos )
+ pWMF->Seek( nPos );
+ else
+ pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR );
+
+ }
+ }
+ else
+ pWMF->SetError( SVSTREAM_GENERALERROR );
+
+ if( !pWMF->GetError() && aBmpSaveList.Count() )
+ pOut->ResolveBitmapActions( aBmpSaveList );
+ }
+ if ( pWMF->GetError() )
+ pWMF->Seek( nStartPos );
+}
+
+// ------------------------------------------------------------------------
+
+static void GetWinExtMax( const Point& rSource, Rectangle& rPlaceableBound, const sal_Int16 nMapMode )
+{
+ Point aSource( rSource );
+ if ( nMapMode == MM_HIMETRIC )
+ aSource.Y() = -rSource.Y();
+ if ( aSource.X() < rPlaceableBound.Left() )
+ rPlaceableBound.Left() = aSource.X();
+ if ( aSource.X() > rPlaceableBound.Right() )
+ rPlaceableBound.Right() = aSource.X();
+ if ( aSource.Y() < rPlaceableBound.Top() )
+ rPlaceableBound.Top() = aSource.Y();
+ if ( aSource.Y() > rPlaceableBound.Bottom() )
+ rPlaceableBound.Bottom() = aSource.Y();
+}
+
+static void GetWinExtMax( const Rectangle& rSource, Rectangle& rPlaceableBound, const sal_Int16 nMapMode )
+{
+ GetWinExtMax( rSource.TopLeft(), rPlaceableBound, nMapMode );
+ GetWinExtMax( rSource.BottomRight(), rPlaceableBound, nMapMode );
+}
+
+sal_Bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm )
+{
+ sal_Bool bRet = sal_True;
+
+ rPlaceableBound.Left() = (sal_Int32)0x7fffffff;
+ rPlaceableBound.Top() = (sal_Int32)0x7fffffff;
+ rPlaceableBound.Right() = (sal_Int32)0x80000000;
+ rPlaceableBound.Bottom() = (sal_Int32)0x80000000;
+
+ sal_Int16 nMapMode = MM_ANISOTROPIC;
+
+ sal_uInt16 nFunction;
+ sal_uInt32 nRSize;
+ sal_uInt32 nPos = pStm->Tell();
+ sal_uInt32 nEnd = pStm->Seek( STREAM_SEEK_TO_END );
+
+ pStm->Seek( nPos );
+
+ if( nEnd - nPos )
+ {
+ while( bRet )
+ {
+ *pStm >> nRSize >> nFunction;
+
+ if( pStm->GetError() || ( nRSize < 3 ) || ( nRSize==3 && nFunction==0 ) || pStm->IsEof() )
+ {
+ if( pStm->IsEof() )
+ {
+ pStm->SetError( SVSTREAM_FILEFORMAT_ERROR );
+ bRet = sal_False;
+ }
+ break;
+ }
+ switch( nFunction )
+ {
+ case W_META_SETWINDOWORG:
+ {
+ Point aWinOrg;
+ aWinOrg = ReadYX();
+ rPlaceableBound.SetPos( aWinOrg );
+ }
+ break;
+
+ case W_META_SETWINDOWEXT:
+ {
+ Point aPos0( 0, 0 );
+ sal_Int16 nWidth, nHeight;
+ *pStm >> nHeight >> nWidth;
+ rPlaceableBound.SetSize( Size( nWidth, nHeight ) );
+ }
+ break;
+
+ case W_META_SETMAPMODE :
+ *pStm >> nMapMode;
+ break;
+
+ case W_META_MOVETO:
+ case W_META_LINETO:
+ GetWinExtMax( ReadYX(), rPlaceableBound, nMapMode );
+ break;
+
+ case W_META_RECTANGLE:
+ case W_META_INTERSECTCLIPRECT:
+ case W_META_EXCLUDECLIPRECT :
+ case W_META_ELLIPSE:
+ GetWinExtMax( ReadRectangle(), rPlaceableBound, nMapMode );
+ break;
+
+ case W_META_ROUNDRECT:
+ {
+ Size aSize( ReadYXExt() );
+ GetWinExtMax( ReadRectangle(), rPlaceableBound, nMapMode );
+ }
+ break;
+
+ case W_META_ARC:
+ case W_META_PIE:
+ case W_META_CHORD:
+ {
+ Point aEnd( ReadYX() );
+ Point aStart( ReadYX() );
+ GetWinExtMax( ReadRectangle(), rPlaceableBound, nMapMode );
+ }
+ break;
+
+ case W_META_POLYGON:
+ {
+ USHORT i,nPoints;
+ *pStm >> nPoints;
+ for( i = 0; i < nPoints; i++ )
+ GetWinExtMax( ReadPoint(), rPlaceableBound, nMapMode );
+ }
+ break;
+
+ case W_META_POLYPOLYGON:
+ {
+ USHORT i, nPoly, nPoints = 0;
+ *pStm >> nPoly;
+ for( i = 0; i < nPoly; i++ )
+ {
+ sal_uInt16 nP;
+ *pStm >> nP;
+ nPoints = nPoints + nP;
+ }
+ for ( i = 0; i < nPoints; i++ )
+ GetWinExtMax( ReadPoint(), rPlaceableBound, nMapMode );
+ }
+ break;
+
+ case W_META_POLYLINE:
+ {
+ USHORT i,nPoints;
+ *pStm >> nPoints;
+ for( i = 0; i < nPoints; i++ )
+ GetWinExtMax( ReadPoint(), rPlaceableBound, nMapMode );
+ }
+ break;
+
+ case W_META_SETPIXEL:
+ {
+ const Color aColor = ReadColor();
+ GetWinExtMax( ReadYX(), rPlaceableBound, nMapMode );
+ }
+ break;
+
+ case W_META_TEXTOUT:
+ {
+ USHORT nLength;
+ *pStm >> nLength;
+ // todo: we also have to take care of the text width
+ if ( nLength )
+ {
+ pStm->SeekRel( ( nLength + 1 ) &~ 1 );
+ GetWinExtMax( ReadYX(), rPlaceableBound, nMapMode );
+ }
+ }
+ break;
+
+ case W_META_EXTTEXTOUT:
+ {
+ sal_uInt16 nLen, nOptions;
+ sal_Int32 nRecordPos, nRecordSize;
+ Point aPosition;
+ Rectangle aRect;
+
+ pStm->SeekRel(-6);
+ nRecordPos = pStm->Tell();
+ *pStm >> nRecordSize;
+ pStm->SeekRel(2);
+ aPosition = ReadYX();
+ *pStm >> nLen >> nOptions;
+ // todo: we also have to take care of the text width
+ if( nLen )
+ GetWinExtMax( aPosition, rPlaceableBound, nMapMode );
+ }
+ break;
+ case W_META_BITBLT:
+ case W_META_STRETCHBLT:
+ case W_META_DIBBITBLT:
+ case W_META_DIBSTRETCHBLT:
+ case W_META_STRETCHDIB:
+ {
+ sal_Int32 nWinROP;
+ sal_uInt16 nSx, nSy, nSxe, nSye, nUsage;
+ *pStm >> nWinROP;
+
+ if( nFunction == W_META_STRETCHDIB )
+ *pStm >> nUsage;
+
+ // nSye and nSxe is the number of pixels that has to been used
+ if( nFunction == W_META_STRETCHDIB || nFunction == W_META_STRETCHBLT || nFunction == W_META_DIBSTRETCHBLT )
+ *pStm >> nSye >> nSxe;
+ else
+ nSye = nSxe = 0; // set this to zero as indicator not to scale the bitmap later
+
+ // nSy and nx is the offset of the first pixel
+ *pStm >> nSy >> nSx;
+
+ if( nFunction == W_META_STRETCHDIB || nFunction == W_META_DIBBITBLT || nFunction == W_META_DIBSTRETCHBLT )
+ {
+ if ( nWinROP == PATCOPY )
+ *pStm >> nUsage; // i don't know anything of this parameter, so its called nUsage
+ // pOut->DrawRect( Rectangle( ReadYX(), aDestSize ), FALSE );
+
+ Size aDestSize( ReadYXExt() );
+ if ( aDestSize.Width() && aDestSize.Height() ) // #92623# do not try to read buggy bitmaps
+ {
+ Rectangle aDestRect( ReadYX(), aDestSize );
+ GetWinExtMax( aDestRect, rPlaceableBound, nMapMode );
+ }
+ }
+ }
+ break;
+
+ case W_META_PATBLT:
+ {
+ UINT32 nROP;
+ *pStm >> nROP;
+ Size aSize = ReadYXExt();
+ GetWinExtMax( Rectangle( ReadYX(), aSize ), rPlaceableBound, nMapMode );
+ }
+ break;
+ }
+ nPos += nRSize * 2;
+ if ( nPos <= nEnd )
+ pStm->Seek( nPos );
+ else
+ {
+ pStm->SetError( SVSTREAM_FILEFORMAT_ERROR );
+ bRet = sal_False;
+ }
+
+ }
+ }
+ else
+ {
+ pStm->SetError( SVSTREAM_GENERALERROR );
+ bRet = sal_False;
+ }
+ return bRet;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/wmf/svt_wmf.cxx b/binfilter/bf_svtools/source/filter.vcl/wmf/svt_wmf.cxx
new file mode 100644
index 000000000000..ea6f69e7c881
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/wmf/svt_wmf.cxx
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 "winmtf.hxx"
+#include "emfwr.hxx"
+#include "wmfwr.hxx"
+#include <bf_svtools/wmf.hxx>
+
+namespace binfilter
+{
+
+// -----------------------------------------------------------------------------
+
+BOOL ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem )
+{
+ UINT32 nMetaType;
+ UINT32 nOrgPos = rStreamWMF.Tell();
+ UINT16 nOrigNumberFormat = rStreamWMF.GetNumberFormatInt();
+ rStreamWMF.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ rStreamWMF.Seek( 0x28 );
+ rStreamWMF >> nMetaType;
+ rStreamWMF.Seek( nOrgPos );
+ if ( nMetaType == 0x464d4520 )
+ {
+ if ( EnhWMFReader( rStreamWMF, rGDIMetaFile, pConfigItem ).ReadEnhWMF() == FALSE )
+ rStreamWMF.SetError( SVSTREAM_FILEFORMAT_ERROR );
+ }
+ else
+ {
+ WMFReader( rStreamWMF, rGDIMetaFile, pConfigItem ).ReadWMF();
+ }
+ rStreamWMF.SetNumberFormatInt( nOrigNumberFormat );
+ return !rStreamWMF.GetError();
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL ReadWindowMetafile( SvStream& rStream, GDIMetaFile& rMTF, FilterConfigItem* pFilterConfigItem )
+{
+ UINT32 nMetaType;
+ UINT32 nOrgPos = rStream.Tell();
+ UINT16 nOrigNumberFormat = rStream.GetNumberFormatInt();
+ rStream.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ rStream.Seek( 0x28 );
+ rStream >> nMetaType;
+ rStream.Seek( nOrgPos );
+ if ( nMetaType == 0x464d4520 )
+ {
+ if ( EnhWMFReader( rStream, rMTF, NULL ).ReadEnhWMF() == FALSE )
+ rStream.SetError( SVSTREAM_FILEFORMAT_ERROR );
+ }
+ else
+ {
+ WMFReader( rStream, rMTF, pFilterConfigItem ).ReadWMF();
+ }
+ rStream.SetNumberFormatInt( nOrigNumberFormat );
+ return !rStream.GetError();
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL ConvertGDIMetaFileToWMF( const GDIMetaFile & rMTF, SvStream & rTargetStream,
+ FilterConfigItem* pConfigItem, BOOL bPlaceable)
+{
+ WMFWriter aWMFWriter;
+ return aWMFWriter.WriteWMF( rMTF, rTargetStream, pConfigItem, bPlaceable );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL ConvertGDIMetaFileToEMF( const GDIMetaFile & rMTF, SvStream & rTargetStream,
+ FilterConfigItem* pConfigItem )
+{
+ EMFWriter aEMFWriter;
+ return aEMFWriter.WriteEMF( rMTF, rTargetStream, pConfigItem );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL WriteWindowMetafileBits( SvStream& rStream, const GDIMetaFile& rMTF )
+{
+ return WMFWriter().WriteWMF( rMTF, rStream, NULL, FALSE );
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/wmf/svt_wmfwr.cxx b/binfilter/bf_svtools/source/filter.vcl/wmf/svt_wmfwr.cxx
new file mode 100644
index 000000000000..f4c03916922d
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/wmf/svt_wmfwr.cxx
@@ -0,0 +1,1878 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <vcl/salbtype.hxx>
+#include "wmfwr.hxx"
+#include <unotools/fontcvt.hxx>
+#include <rtl/crc.h>
+#include <rtl/tencinfo.h>
+#include <tools/tenccvt.hxx>
+#include <osl/endian.h>
+
+#include <vcl/metric.hxx>
+
+namespace binfilter
+{
+
+//====================== MS-Windows-defines ===============================
+
+#define W_META_SETBKCOLOR 0x0201
+#define W_META_SETBKMODE 0x0102
+#define W_META_SETMAPMODE 0x0103
+#define W_META_SETROP2 0x0104
+#define W_META_SETRELABS 0x0105
+#define W_META_SETPOLYFILLMODE 0x0106
+#define W_META_SETSTRETCHBLTMODE 0x0107
+#define W_META_SETTEXTCHAREXTRA 0x0108
+#define W_META_SETTEXTCOLOR 0x0209
+#define W_META_SETTEXTJUSTIFICATION 0x020A
+#define W_META_SETWINDOWORG 0x020B
+#define W_META_SETWINDOWEXT 0x020C
+#define W_META_SETVIEWPORTORG 0x020D
+#define W_META_SETVIEWPORTEXT 0x020E
+#define W_META_OFFSETWINDOWORG 0x020F
+#define W_META_SCALEWINDOWEXT 0x0410
+#define W_META_OFFSETVIEWPORTORG 0x0211
+#define W_META_SCALEVIEWPORTEXT 0x0412
+#define W_META_LINETO 0x0213
+#define W_META_MOVETO 0x0214
+#define W_META_EXCLUDECLIPRECT 0x0415
+#define W_META_INTERSECTCLIPRECT 0x0416
+#define W_META_ARC 0x0817
+#define W_META_ELLIPSE 0x0418
+#define W_META_FLOODFILL 0x0419
+#define W_META_PIE 0x081A
+#define W_META_RECTANGLE 0x041B
+#define W_META_ROUNDRECT 0x061C
+#define W_META_PATBLT 0x061D
+#define W_META_SAVEDC 0x001E
+#define W_META_SETPIXEL 0x041F
+#define W_META_OFFSETCLIPRGN 0x0220
+#define W_META_TEXTOUT 0x0521
+#define W_META_BITBLT 0x0922
+#define W_META_STRETCHBLT 0x0B23
+#define W_META_POLYGON 0x0324
+#define W_META_POLYLINE 0x0325
+#define W_META_ESCAPE 0x0626
+#define W_META_RESTOREDC 0x0127
+#define W_META_FILLREGION 0x0228
+#define W_META_FRAMEREGION 0x0429
+#define W_META_INVERTREGION 0x012A
+#define W_META_PAINTREGION 0x012B
+#define W_META_SELECTCLIPREGION 0x012C
+#define W_META_SELECTOBJECT 0x012D
+#define W_META_SETTEXTALIGN 0x012E
+#define W_META_DRAWTEXT 0x062F
+#define W_META_CHORD 0x0830
+#define W_META_SETMAPPERFLAGS 0x0231
+#define W_META_EXTTEXTOUT 0x0a32
+#define W_META_SETDIBTODEV 0x0d33
+#define W_META_SELECTPALETTE 0x0234
+#define W_META_REALIZEPALETTE 0x0035
+#define W_META_ANIMATEPALETTE 0x0436
+#define W_META_SETPALENTRIES 0x0037
+#define W_META_POLYPOLYGON 0x0538
+#define W_META_RESIZEPALETTE 0x0139
+#define W_META_DIBBITBLT 0x0940
+#define W_META_DIBSTRETCHBLT 0x0b41
+#define W_META_DIBCREATEPATTERNBRUSH 0x0142
+#define W_META_STRETCHDIB 0x0f43
+#define W_META_EXTFLOODFILL 0x0548
+#define W_META_RESETDC 0x014C
+#define W_META_STARTDOC 0x014D
+#define W_META_STARTPAGE 0x004F
+#define W_META_ENDPAGE 0x0050
+#define W_META_ABORTDOC 0x0052
+#define W_META_ENDDOC 0x005E
+#define W_META_DELETEOBJECT 0x01f0
+#define W_META_CREATEPALETTE 0x00f7
+#define W_META_CREATEBRUSH 0x00F8
+#define W_META_CREATEPATTERNBRUSH 0x01F9
+#define W_META_CREATEPENINDIRECT 0x02FA
+#define W_META_CREATEFONTINDIRECT 0x02FB
+#define W_META_CREATEBRUSHINDIRECT 0x02FC
+#define W_META_CREATEBITMAPINDIRECT 0x02FD
+#define W_META_CREATEBITMAP 0x06FE
+#define W_META_CREATEREGION 0x06FF
+
+#define W_TRANSPARENT 1
+#define W_OPAQUE 2
+
+#define W_R2_BLACK 1
+#define W_R2_NOTMERGEPEN 2
+#define W_R2_MASKNOTPEN 3
+#define W_R2_NOTCOPYPEN 4
+#define W_R2_MASKPENNOT 5
+#define W_R2_NOT 6
+#define W_R2_XORPEN 7
+#define W_R2_NOTMASKPEN 8
+#define W_R2_MASKPEN 9
+#define W_R2_NOTXORPEN 10
+#define W_R2_NOP 11
+#define W_R2_MERGENOTPEN 12
+#define W_R2_COPYPEN 13
+#define W_R2_MERGEPENNOT 14
+#define W_R2_MERGEPEN 15
+#define W_R2_WHITE 16
+
+#define W_TA_NOUPDATECP 0x0000
+#define W_TA_UPDATECP 0x0001
+#define W_TA_LEFT 0x0000
+#define W_TA_RIGHT 0x0002
+#define W_TA_CENTER 0x0006
+#define W_TA_TOP 0x0000
+#define W_TA_BOTTOM 0x0008
+#define W_TA_BASELINE 0x0018
+
+#define W_SRCCOPY 0x00CC0020L
+#define W_SRCPAINT 0x00EE0086L
+#define W_SRCAND 0x008800C6L
+#define W_SRCINVERT 0x00660046L
+#define W_SRCERASE 0x00440328L
+#define W_NOTSRCCOPY 0x00330008L
+#define W_NOTSRCERASE 0x001100A6L
+#define W_MERGECOPY 0x00C000CAL
+#define W_MERGEPAINT 0x00BB0226L
+#define W_PATCOPY 0x00F00021L
+#define W_PATPAINT 0x00FB0A09L
+#define W_PATINVERT 0x005A0049L
+#define W_DSTINVERT 0x00550009L
+#define W_BLACKNESS 0x00000042L
+#define W_WHITENESS 0x00FF0062L
+
+#define W_PS_SOLID 0
+#define W_PS_DASH 1
+#define W_PS_DOT 2
+#define W_PS_DASHDOT 3
+#define W_PS_DASHDOTDOT 4
+#define W_PS_NULL 5
+#define W_PS_INSIDEFRAME 6
+
+#define W_LF_FACESIZE 32
+
+#define W_ANSI_CHARSET 0
+#define W_DEFAULT_CHARSET 1
+#define W_SYMBOL_CHARSET 2
+#define W_SHIFTJIS_CHARSET 128
+#define W_HANGEUL_CHARSET 129
+#define W_GB2312_CHARSET 134
+#define W_CHINESEBIG5_CHARSET 136
+#define W_OEM_CHARSET 255
+/*WINVER >= 0x0400*/
+#define W_JOHAB_CHARSET 130
+#define W_HEBREW_CHARSET 177
+#define W_ARABIC_CHARSET 178
+#define W_GREEK_CHARSET 161
+#define W_TURKISH_CHARSET 162
+#define W_VIETNAMESE_CHARSET 163
+#define W_THAI_CHARSET 222
+#define W_EASTEUROPE_CHARSET 238
+#define W_RUSSIAN_CHARSET 204
+#define W_MAC_CHARSET 77
+#define W_BALTIC_CHARSET 186
+
+#define W_DEFAULT_PITCH 0x00
+#define W_FIXED_PITCH 0x01
+#define W_VARIABLE_PITCH 0x02
+
+#define W_FF_DONTCARE 0x00
+#define W_FF_ROMAN 0x10
+#define W_FF_SWISS 0x20
+#define W_FF_MODERN 0x30
+#define W_FF_SCRIPT 0x40
+#define W_FF_DECORATIVE 0x50
+
+#define W_FW_DONTCARE 0
+#define W_FW_THIN 100
+#define W_FW_EXTRALIGHT 200
+#define W_FW_LIGHT 300
+#define W_FW_NORMAL 400
+#define W_FW_MEDIUM 500
+#define W_FW_SEMIBOLD 600
+#define W_FW_BOLD 700
+#define W_FW_EXTRABOLD 800
+#define W_FW_HEAVY 900
+#define W_FW_ULTRALIGHT 200
+#define W_FW_REGULAR 400
+#define W_FW_DEMIBOLD 600
+#define W_FW_ULTRABOLD 800
+#define W_FW_BLACK 900
+
+#define W_BS_SOLID 0
+#define W_BS_HOLLOW 1
+#define W_BS_HATCHED 2
+#define W_BS_PATTERN 3
+#define W_BS_INDEXED 4
+#define W_BS_DIBPATTERN 5
+
+#define W_HS_HORIZONTAL 0
+#define W_HS_VERTICAL 1
+#define W_HS_FDIAGONAL 2
+#define W_HS_BDIAGONAL 3
+#define W_HS_CROSS 4
+#define W_HS_DIAGCROSS 5
+
+#define W_MFCOMMENT 15
+
+#define PRIVATE_ESCAPE_UNICODE 2
+
+//========================== Methoden von WMFWriter ==========================
+
+void WMFWriter::MayCallback()
+{
+ if ( xStatusIndicator.is() )
+ {
+ ULONG nPercent;
+
+ // Wir gehen mal einfach so davon aus, dass 16386 Actions einer Bitmap entsprechen
+ // (in der Regel wird ein Metafile entweder nur Actions oder einige Bitmaps und fast
+ // keine Actions enthalten. Dann ist das Verhaeltnis ziemlich unwichtig)
+
+ nPercent=((nWrittenBitmaps<<14)+(nActBitmapPercent<<14)/100+nWrittenActions)
+ *100
+ /((nNumberOfBitmaps<<14)+nNumberOfActions);
+
+ if ( nPercent >= nLastPercent + 3 )
+ {
+ nLastPercent = nPercent;
+ if( nPercent <= 100 )
+ xStatusIndicator->setValue( nPercent );
+ }
+ }
+}
+
+void WMFWriter::CountActionsAndBitmaps( const GDIMetaFile & rMTF )
+{
+ ULONG nAction, nActionCount;
+
+ nActionCount = rMTF.GetActionCount();
+
+ for ( nAction=0; nAction<nActionCount; nAction++ )
+ {
+ MetaAction* pMA = rMTF.GetAction( nAction );
+
+ switch( pMA->GetType() )
+ {
+ case META_BMP_ACTION:
+ case META_BMPSCALE_ACTION:
+ case META_BMPSCALEPART_ACTION:
+ case META_BMPEX_ACTION:
+ case META_BMPEXSCALE_ACTION:
+ case META_BMPEXSCALEPART_ACTION:
+ nNumberOfBitmaps++;
+ break;
+ }
+ nNumberOfActions++;
+ }
+}
+
+
+void WMFWriter::WritePointXY(const Point & rPoint)
+{
+ Point aPt( pVirDev->LogicToLogic(rPoint,aSrcMapMode,aTargetMapMode) );
+ *pWMF << ((short)aPt.X()) << ((short)aPt.Y());
+}
+
+
+void WMFWriter::WritePointYX(const Point & rPoint)
+{
+ Point aPt( pVirDev->LogicToLogic(rPoint,aSrcMapMode,aTargetMapMode) );
+ *pWMF << ((short)aPt.Y()) << ((short)aPt.X());
+}
+
+
+sal_Int32 WMFWriter::ScaleWidth( sal_Int32 nDX )
+{
+ Size aSz( pVirDev->LogicToLogic(Size(nDX,0),aSrcMapMode,aTargetMapMode) );
+ return aSz.Width();
+}
+
+
+void WMFWriter::WriteSize(const Size & rSize)
+{
+ Size aSz( pVirDev->LogicToLogic(rSize,aSrcMapMode,aTargetMapMode) );
+ *pWMF << ((short)aSz.Width()) << ((short)aSz.Height());
+}
+
+
+void WMFWriter::WriteHeightWidth(const Size & rSize)
+{
+ Size aSz( pVirDev->LogicToLogic(rSize,aSrcMapMode,aTargetMapMode) );
+ *pWMF << ((short)aSz.Height()) << ((short)aSz.Width());
+}
+
+
+void WMFWriter::WriteRectangle(const Rectangle & rRect)
+{
+ WritePointYX(Point(rRect.Right()+1,rRect.Bottom()+1));
+ WritePointYX(rRect.TopLeft());
+}
+
+
+void WMFWriter::WriteColor(const Color & rColor)
+{
+ *pWMF << (BYTE) rColor.GetRed() << (BYTE) rColor.GetGreen() << (BYTE) rColor.GetBlue() << (BYTE) 0;
+}
+
+
+void WMFWriter::WriteRecordHeader(sal_uInt32 nSizeWords, sal_uInt16 nType)
+{
+ nActRecordPos=pWMF->Tell();
+ if (nSizeWords>nMaxRecordSize) nMaxRecordSize=nSizeWords;
+ *pWMF << nSizeWords << nType;
+}
+
+
+void WMFWriter::UpdateRecordHeader()
+{
+ ULONG nPos;
+ sal_uInt32 nSize;
+
+ nPos=pWMF->Tell(); nSize=nPos-nActRecordPos;
+ if ((nSize & 1)!=0) {
+ *pWMF << (BYTE)0;
+ nPos++; nSize++;
+ }
+ nSize/=2;
+ if (nSize>nMaxRecordSize) nMaxRecordSize=nSize;
+ pWMF->Seek(nActRecordPos);
+ *pWMF << nSize;
+ pWMF->Seek(nPos);
+}
+
+
+void WMFWriter::WMFRecord_Arc(const Rectangle & rRect, const Point & rStartPt, const Point & rEndPt)
+{
+ WriteRecordHeader(0x0000000b,W_META_ARC);
+ WritePointYX(rEndPt);
+ WritePointYX(rStartPt);
+ WriteRectangle(rRect);
+}
+
+void WMFWriter::WMFRecord_Chord(const Rectangle & rRect, const Point & rStartPt, const Point & rEndPt)
+{
+ WriteRecordHeader(0x0000000b,W_META_CHORD);
+ WritePointYX(rEndPt);
+ WritePointYX(rStartPt);
+ WriteRectangle(rRect);
+}
+
+
+void WMFWriter::WMFRecord_CreateBrushIndirect(const Color& rColor)
+{
+ WriteRecordHeader(0x00000007,W_META_CREATEBRUSHINDIRECT);
+
+ if( rColor==Color(COL_TRANSPARENT) )
+ *pWMF << (UINT16) W_BS_HOLLOW;
+ else
+ *pWMF << (UINT16) W_BS_SOLID;
+
+ WriteColor( rColor );
+ *pWMF << (UINT16) 0;
+}
+
+
+void WMFWriter::WMFRecord_CreateFontIndirect(const Font & rFont)
+{
+ USHORT nWeight,i;
+ BYTE nPitchFamily;
+
+ WriteRecordHeader(0x00000000,W_META_CREATEFONTINDIRECT);
+
+ if ( !rFont.GetSize().Width() )
+ {
+ VirtualDevice aDev;
+ FontMetric aMetric( aDev.GetFontMetric( rFont ) );
+ WriteHeightWidth(Size(aMetric.GetWidth(),-rFont.GetSize().Height()));
+ }
+ else
+ WriteHeightWidth(Size(rFont.GetSize().Width(),-rFont.GetSize().Height()));
+
+ *pWMF << (short)rFont.GetOrientation() << (short)rFont.GetOrientation();
+
+ switch (rFont.GetWeight()) {
+ case WEIGHT_THIN: nWeight=W_FW_THIN; break;
+ case WEIGHT_ULTRALIGHT: nWeight=W_FW_ULTRALIGHT; break;
+ case WEIGHT_LIGHT: nWeight=W_FW_LIGHT; break;
+ case WEIGHT_SEMILIGHT: nWeight=W_FW_LIGHT; break;
+ case WEIGHT_NORMAL: nWeight=W_FW_NORMAL; break;
+ case WEIGHT_MEDIUM: nWeight=W_FW_MEDIUM; break;
+ case WEIGHT_SEMIBOLD: nWeight=W_FW_SEMIBOLD; break;
+ case WEIGHT_BOLD: nWeight=W_FW_BOLD; break;
+ case WEIGHT_ULTRABOLD: nWeight=W_FW_ULTRABOLD; break;
+ case WEIGHT_BLACK: nWeight=W_FW_BLACK; break;
+ default: nWeight=W_FW_DONTCARE;
+ }
+ *pWMF << nWeight;
+
+ if (rFont.GetItalic()==ITALIC_NONE) *pWMF << (BYTE)0; else *pWMF << (BYTE)1;
+ if (rFont.GetUnderline()==UNDERLINE_NONE) *pWMF << (BYTE)0; else *pWMF << (BYTE)1;
+ if (rFont.GetStrikeout()==STRIKEOUT_NONE) *pWMF << (BYTE)0; else *pWMF << (BYTE)1;
+
+ CharSet eFontNameEncoding = rFont.GetCharSet();
+ sal_uInt8 nCharSet = rtl_getBestWindowsCharsetFromTextEncoding( eFontNameEncoding );
+ if ( eFontNameEncoding == RTL_TEXTENCODING_SYMBOL )
+ eFontNameEncoding = RTL_TEXTENCODING_MS_1252;
+ if ( nCharSet == 1 )
+ nCharSet = W_ANSI_CHARSET;
+ *pWMF << nCharSet;
+
+ *pWMF << (BYTE)0 << (BYTE)0 << (BYTE)0;
+
+ switch (rFont.GetPitch()) {
+ case PITCH_FIXED: nPitchFamily=W_FIXED_PITCH; break;
+ case PITCH_VARIABLE: nPitchFamily=W_VARIABLE_PITCH; break;
+ default: nPitchFamily=W_DEFAULT_PITCH;
+ }
+ switch (rFont.GetFamily()) {
+ case FAMILY_DECORATIVE: nPitchFamily|=W_FF_DECORATIVE; break;
+ case FAMILY_MODERN: nPitchFamily|=W_FF_MODERN; break;
+ case FAMILY_ROMAN: nPitchFamily|=W_FF_ROMAN; break;
+ case FAMILY_SCRIPT: nPitchFamily|=W_FF_SCRIPT; break;
+ case FAMILY_SWISS: nPitchFamily|=W_FF_SWISS; break;
+ default: nPitchFamily|=W_FF_DONTCARE;
+ }
+ *pWMF << nPitchFamily;
+
+ ByteString aFontName( rFont.GetName(), eFontNameEncoding );
+ for ( i = 0; i < W_LF_FACESIZE; i++ )
+ {
+ sal_Char nChar = ( i < aFontName.Len() ) ? aFontName.GetChar( i ) : 0;
+ *pWMF << nChar;
+ }
+ UpdateRecordHeader();
+}
+
+void WMFWriter::WMFRecord_CreatePenIndirect(const Color& rColor, const LineInfo& rLineInfo )
+{
+ WriteRecordHeader(0x00000008,W_META_CREATEPENINDIRECT);
+ USHORT nStyle = rColor == Color( COL_TRANSPARENT ) ? W_PS_NULL : W_PS_SOLID;
+ switch( rLineInfo.GetStyle() )
+ {
+ case LINE_DASH :
+ {
+ if ( rLineInfo.GetDotCount() )
+ {
+ if ( !rLineInfo.GetDashCount() )
+ nStyle = W_PS_DOT;
+ else
+ {
+ if ( !rLineInfo.GetDotCount() == 1 )
+ nStyle = W_PS_DASHDOT;
+ else
+ nStyle = W_PS_DASHDOTDOT;
+ }
+ }
+ else
+ nStyle = W_PS_DASH;
+ }
+ break;
+ case LINE_NONE :
+ nStyle = W_PS_NULL;
+ break;
+ default:
+ break;
+ }
+ *pWMF << nStyle;
+
+ WriteSize( Size( rLineInfo.GetWidth(), 0 ) );
+ WriteColor( rColor );
+}
+
+void WMFWriter::WMFRecord_DeleteObject(USHORT nObjectHandle)
+{
+ WriteRecordHeader(0x00000004,W_META_DELETEOBJECT);
+ *pWMF << nObjectHandle;
+}
+
+
+void WMFWriter::WMFRecord_Ellipse(const Rectangle & rRect)
+{
+ WriteRecordHeader(0x00000007,W_META_ELLIPSE);
+ WriteRectangle(rRect);
+}
+
+bool IsStarSymbol(const String &rStr)
+{
+ return rStr.EqualsIgnoreCaseAscii("starsymbol") ||
+ rStr.EqualsIgnoreCaseAscii("opensymbol");
+}
+
+void WMFWriter::WMFRecord_Escape( sal_uInt32 nEsc, sal_uInt32 nLen, const sal_Int8* pData )
+{
+#ifdef OSL_BIGENDIAN
+ sal_uInt32 nTmp = SWAPLONG( nEsc );
+ sal_uInt32 nCheckSum = rtl_crc32( 0, &nTmp, 4 );
+#else
+ sal_uInt32 nCheckSum = rtl_crc32( 0, &nEsc, 4 );
+#endif
+ if ( nLen )
+ nCheckSum = rtl_crc32( nCheckSum, pData, nLen );
+
+ WriteRecordHeader( 3 + 9 + ( ( nLen + 1 ) >> 1 ), W_META_ESCAPE );
+ *pWMF << (sal_uInt16)W_MFCOMMENT
+ << (sal_uInt16)( nLen + 14 ) // we will always have a fourteen byte escape header:
+ << (sal_uInt16)0x4f4f // OO
+ << (sal_uInt32)0xa2c2a // evil magic number
+ << (sal_uInt32)nCheckSum // crc32 checksum about nEsc & pData
+ << (sal_uInt32)nEsc; // escape number
+ pWMF->Write( pData, nLen );
+ if ( nLen & 1 )
+ *pWMF << (sal_uInt8)0; // pad byte
+}
+
+/* if return value is true, then a complete unicode string and also a polygon replacement has been written,
+ so there is no more action necessary
+*/
+sal_Bool WMFWriter::WMFRecord_Escape_Unicode( const Point& rPoint, const String& rUniStr, const sal_Int32* pDXAry )
+{
+ sal_Bool bEscapeUsed = sal_False;
+
+ sal_uInt32 i, nStringLen = rUniStr.Len();
+ if ( nStringLen )
+ {
+ // first we will check if a comment is necessary
+ if ( aSrcFont.GetCharSet() != RTL_TEXTENCODING_SYMBOL ) // symbol is always byte character, so there is no unicode loss
+ {
+ const sal_Unicode* pBuf = rUniStr.GetBuffer();
+
+ ByteString aByteStr( rUniStr, aSrcFont.GetCharSet() );
+ String aUniStr2( aByteStr, aSrcFont.GetCharSet() );
+ const sal_Unicode* pConversion = aUniStr2.GetBuffer(); // this is the unicode array after bytestring <-> unistring conversion
+ for ( i = 0; i < nStringLen; i++ )
+ {
+ if ( *pBuf++ != *pConversion++ )
+ break;
+ }
+ if ( ( i != nStringLen ) || IsStarSymbol( aSrcFont.GetName() ) ) // after conversion the characters are not original, so we
+ { // will store the unicode string and a polypoly replacement
+ Color aOldFillColor( aSrcFillColor );
+ Color aOldLineColor( aSrcLineColor );
+ aSrcLineInfo = LineInfo();
+ aSrcFillColor = aSrcTextColor;
+ aSrcLineColor = Color( COL_TRANSPARENT );
+ SetLineAndFillAttr();
+ pVirDev->SetFont( aSrcFont );
+ std::vector<PolyPolygon> aPolyPolyVec;
+ if ( pVirDev->GetTextOutlines( aPolyPolyVec, rUniStr ) )
+ {
+ sal_uInt32 nDXCount = pDXAry ? nStringLen : 0;
+ sal_uInt32 nSkipActions = aPolyPolyVec.size();
+ sal_Int32 nStrmLen = 8 +
+ + sizeof( nStringLen ) + ( nStringLen * 2 )
+ + sizeof( nDXCount ) + ( nDXCount * 4 )
+ + sizeof( nSkipActions );
+
+ SvMemoryStream aMemoryStream( nStrmLen );
+ Point aPt( pVirDev->LogicToLogic( rPoint, aSrcMapMode, aTargetMapMode ) );
+ aMemoryStream << aPt.X()
+ << aPt.Y()
+ << nStringLen;
+ for ( i = 0; i < nStringLen; i++ )
+ aMemoryStream << rUniStr.GetChar( (sal_uInt16)i );
+ aMemoryStream << nDXCount;
+ for ( i = 0; i < nDXCount; i++ )
+ aMemoryStream << pDXAry[ i ];
+ aMemoryStream << nSkipActions;
+ WMFRecord_Escape( PRIVATE_ESCAPE_UNICODE, nStrmLen, (const sal_Int8*)aMemoryStream.GetData() );
+
+ std::vector<PolyPolygon>::iterator aIter( aPolyPolyVec.begin() );
+ while ( aIter != aPolyPolyVec.end() )
+ {
+ PolyPolygon aPolyPoly( *aIter++ );
+ aPolyPoly.Move( rPoint.X(), rPoint.Y() );
+ WMFRecord_PolyPolygon( aPolyPoly );
+ }
+ aSrcFillColor = aOldFillColor;
+ aSrcLineColor = aOldLineColor;
+ bEscapeUsed = sal_True;
+ }
+ }
+ }
+ }
+ return bEscapeUsed;
+}
+
+void WMFWriter::WMFRecord_ExtTextOut( const Point & rPoint,
+ const String & rString, const sal_Int32 * pDXAry )
+{
+ sal_uInt16 nOriginalTextLen = rString.Len();
+
+ if ( (nOriginalTextLen <= 1) || (pDXAry == NULL) )
+ {
+ WMFRecord_TextOut(rPoint, rString);
+ return;
+ }
+ rtl_TextEncoding eChrSet = aSrcFont.GetCharSet();
+ ByteString aByteString(rString, eChrSet);
+ TrueExtTextOut(rPoint,rString,aByteString,pDXAry);
+}
+
+void WMFWriter::TrueExtTextOut( const Point & rPoint, const String & rString,
+ const ByteString & rByteString, const sal_Int32 * pDXAry )
+{
+ WriteRecordHeader( 0, W_META_EXTTEXTOUT );
+ WritePointYX( rPoint );
+ sal_uInt16 nNewTextLen = rByteString.Len();
+ *pWMF << nNewTextLen << (sal_uInt16)0;
+
+ sal_uInt16 i;
+ for ( i = 0; i < nNewTextLen; i++ )
+ *pWMF << (sal_uInt8)rByteString.GetChar( i );
+ if ( nNewTextLen & 1 )
+ *pWMF << (sal_uInt8)0;
+
+ sal_uInt16 nOriginalTextLen = rString.Len();
+ sal_Int16* pConvertedDXAry = new sal_Int16[ nOriginalTextLen ];
+ sal_Int32 j = 0;
+ pConvertedDXAry[ j++ ] = (sal_Int16)ScaleWidth( pDXAry[ 0 ] );
+ for ( i = 1; i < ( nOriginalTextLen - 1 ); i++ )
+ pConvertedDXAry[ j++ ] = (sal_Int16)ScaleWidth( pDXAry[ i ] - pDXAry[ i - 1 ] );
+ pConvertedDXAry[ j ] = (sal_Int16)ScaleWidth( pDXAry[ nOriginalTextLen - 2 ] / ( nOriginalTextLen - 1 ) );
+
+ for ( i = 0; i < nOriginalTextLen; i++ )
+ {
+ sal_Int16 nDx = pConvertedDXAry[ i ];
+ *pWMF << nDx;
+ if ( nOriginalTextLen < nNewTextLen )
+ {
+ ByteString aTemp( rString.GetChar( i ), aSrcFont.GetCharSet());
+ j = aTemp.Len();
+ while ( --j > 0 )
+ *pWMF << (sal_uInt16)0;
+ }
+ }
+ delete[] pConvertedDXAry;
+ UpdateRecordHeader();
+}
+
+void WMFWriter::WMFRecord_LineTo(const Point & rPoint)
+{
+ WriteRecordHeader(0x00000005,W_META_LINETO);
+ WritePointYX(rPoint);
+}
+
+
+void WMFWriter::WMFRecord_MoveTo(const Point & rPoint)
+{
+ WriteRecordHeader(0x00000005,W_META_MOVETO);
+ WritePointYX(rPoint);
+}
+
+
+void WMFWriter::WMFRecord_Pie(const Rectangle & rRect, const Point & rStartPt, const Point & rEndPt)
+{
+ WriteRecordHeader(0x0000000b,W_META_PIE);
+ WritePointYX(rEndPt);
+ WritePointYX(rStartPt);
+ WriteRectangle(rRect);
+}
+
+
+void WMFWriter::WMFRecord_Polygon(const Polygon & rPoly)
+{
+ USHORT nSize,i;
+
+ Polygon aSimplePoly;
+ if ( rPoly.HasFlags() )
+ rPoly.AdaptiveSubdivide( aSimplePoly );
+ else
+ aSimplePoly = rPoly;
+ nSize = aSimplePoly.GetSize();
+ WriteRecordHeader(((ULONG)nSize)*2+4,W_META_POLYGON);
+ *pWMF << nSize;
+ for (i=0; i<nSize; i++) WritePointXY(aSimplePoly.GetPoint(i));
+}
+
+
+void WMFWriter::WMFRecord_PolyLine(const Polygon & rPoly)
+{
+ USHORT nSize,i;
+ Polygon aSimplePoly;
+ if ( rPoly.HasFlags() )
+ rPoly.AdaptiveSubdivide( aSimplePoly );
+ else
+ aSimplePoly = rPoly;
+ nSize=aSimplePoly.GetSize();
+ WriteRecordHeader(((ULONG)nSize)*2+4,W_META_POLYLINE);
+ *pWMF << nSize;
+ for (i=0; i<nSize; i++) WritePointXY(aSimplePoly.GetPoint(i));
+}
+
+
+void WMFWriter::WMFRecord_PolyPolygon(const PolyPolygon & rPolyPoly)
+{
+ const Polygon * pPoly;
+ USHORT nCount,nSize,i,j;
+
+ nCount=rPolyPoly.Count();
+ PolyPolygon aSimplePolyPoly( rPolyPoly );
+ for ( i = 0; i < nCount; i++ )
+ {
+ if ( aSimplePolyPoly[ i ].HasFlags() )
+ {
+ Polygon aSimplePoly;
+ aSimplePolyPoly[ i ].AdaptiveSubdivide( aSimplePoly );
+ aSimplePolyPoly[ i ] = aSimplePoly;
+ }
+ }
+ WriteRecordHeader(0,W_META_POLYPOLYGON);
+ *pWMF << nCount;
+ for (i=0; i<nCount; i++) *pWMF << ((USHORT)(aSimplePolyPoly.GetObject(i).GetSize()));
+ for (i=0; i<nCount; i++) {
+ pPoly=&(aSimplePolyPoly.GetObject(i));
+ nSize=pPoly->GetSize();
+ for (j=0; j<nSize; j++) WritePointXY(pPoly->GetPoint(j));
+ }
+ UpdateRecordHeader();
+}
+
+
+void WMFWriter::WMFRecord_Rectangle(const Rectangle & rRect)
+{
+ WriteRecordHeader( 0x00000007,W_META_RECTANGLE );
+ WriteRectangle( rRect );
+}
+
+
+void WMFWriter::WMFRecord_RestoreDC()
+{
+ WriteRecordHeader(0x00000004,W_META_RESTOREDC);
+ *pWMF << (short)-1;
+}
+
+
+void WMFWriter::WMFRecord_RoundRect(const Rectangle & rRect, long nHorzRound, long nVertRound)
+{
+ WriteRecordHeader(0x00000009,W_META_ROUNDRECT);
+ WriteHeightWidth(Size(nHorzRound,nVertRound));
+ WriteRectangle(rRect);
+}
+
+
+void WMFWriter::WMFRecord_SaveDC()
+{
+ WriteRecordHeader(0x00000003,W_META_SAVEDC);
+}
+
+
+void WMFWriter::WMFRecord_SelectObject(USHORT nObjectHandle)
+{
+ WriteRecordHeader(0x00000004,W_META_SELECTOBJECT);
+ *pWMF << nObjectHandle;
+}
+
+
+void WMFWriter::WMFRecord_SetBkMode(BOOL bTransparent)
+{
+ WriteRecordHeader(0x00000004,W_META_SETBKMODE);
+ if (bTransparent==TRUE) *pWMF << (USHORT)W_TRANSPARENT;
+ else *pWMF << (USHORT)W_OPAQUE;
+}
+
+void WMFWriter::WMFRecord_SetStretchBltMode()
+{
+ WriteRecordHeader( 0x00000004, W_META_SETSTRETCHBLTMODE );
+ *pWMF << (USHORT) 3; // STRETCH_DELETESCANS
+}
+
+void WMFWriter::WMFRecord_SetPixel(const Point & rPoint, const Color & rColor)
+{
+ WriteRecordHeader(0x00000007,W_META_SETPIXEL);
+ WriteColor(rColor);
+ WritePointYX(rPoint);
+}
+
+
+void WMFWriter::WMFRecord_SetROP2(RasterOp eROP)
+{
+ USHORT nROP2;
+
+ switch (eROP) {
+ case ROP_INVERT: nROP2=W_R2_NOT; break;
+ case ROP_XOR: nROP2=W_R2_XORPEN; break;
+ default: nROP2=W_R2_COPYPEN;
+ }
+ WriteRecordHeader(0x00000004,W_META_SETROP2);
+ *pWMF << nROP2;
+}
+
+
+void WMFWriter::WMFRecord_SetTextAlign(FontAlign eFontAlign)
+{
+ USHORT nAlign;
+
+ switch (eFontAlign) {
+ case ALIGN_TOP: nAlign=W_TA_TOP; break;
+ case ALIGN_BOTTOM: nAlign=W_TA_BOTTOM; break;
+ default: nAlign=W_TA_BASELINE;
+ }
+ nAlign|=W_TA_LEFT;
+ nAlign|=W_TA_NOUPDATECP;
+
+ WriteRecordHeader(0x00000004,W_META_SETTEXTALIGN);
+ *pWMF << nAlign;
+}
+
+
+void WMFWriter::WMFRecord_SetTextColor(const Color & rColor)
+{
+ WriteRecordHeader(0x00000005,W_META_SETTEXTCOLOR);
+ WriteColor(rColor);
+}
+
+
+void WMFWriter::WMFRecord_SetWindowExt(const Size & rSize)
+{
+ WriteRecordHeader(0x00000005,W_META_SETWINDOWEXT);
+ WriteHeightWidth(rSize);
+}
+
+
+void WMFWriter::WMFRecord_SetWindowOrg(const Point & rPoint)
+{
+ WriteRecordHeader(0x00000005,W_META_SETWINDOWORG);
+ WritePointYX(rPoint);
+}
+
+
+void WMFWriter::WMFRecord_StretchDIB( const Point & rPoint, const Size & rSize,
+ const Bitmap & rBitmap, sal_uInt32 nROP )
+{
+ ULONG nPosAnf,nPosEnd;
+
+ nActBitmapPercent=50;
+ MayCallback();
+
+ WriteRecordHeader(0x00000000,W_META_STRETCHDIB);
+
+ // Die Reihenfolge im Metafile soll jetzt sein:
+ // einige Parameter (laenge 22), dann die Bitmap ohne FILEHEADER.
+ // Da aber *pWMF << rBitmap einen FILEHEADER der Laenge 14
+ // erzeugt, schreiben wir zuerst die Bitmap an die richtige Position
+ // Und ueberschreiben hinterher den FILEHEADER mit den Parametern.
+ nPosAnf=pWMF->Tell(); // Position merken, wo Parameter hin sollen
+ *pWMF << (long)0 << (long)0; // 8 bytes auffuellen (diese 8 bytes +
+ // 14 bytes ueberfluessigen FILEHEADER
+ // = 22 bytes Parameter)
+ *pWMF << rBitmap; // Bitmap schreiben
+
+ // Parameter schreiben:
+ nPosEnd=pWMF->Tell();
+ pWMF->Seek(nPosAnf);
+
+ // Raster-Op bestimmen, falls nichts uebergeben wurde
+ if( !nROP )
+ {
+ switch( eSrcRasterOp )
+ {
+ case ROP_INVERT: nROP = W_DSTINVERT; break;
+ case ROP_XOR: nROP = W_SRCINVERT; break;
+ default: nROP = W_SRCCOPY;
+ }
+ }
+
+ *pWMF << nROP <<
+ (short) 0 <<
+ (short) rBitmap.GetSizePixel().Height() <<
+ (short) rBitmap.GetSizePixel().Width() <<
+ (short) 0 <<
+ (short) 0;
+
+ WriteHeightWidth(rSize);
+ WritePointYX(rPoint);
+ pWMF->Seek(nPosEnd);
+
+ UpdateRecordHeader();
+
+ nWrittenBitmaps++;
+ nActBitmapPercent=0;
+}
+
+
+void WMFWriter::WMFRecord_TextOut(const Point & rPoint, const String & rStr)
+{
+ rtl_TextEncoding eChrSet = aSrcFont.GetCharSet();
+ ByteString aString( rStr, eChrSet );
+ TrueTextOut(rPoint, aString);
+}
+
+void WMFWriter::TrueTextOut(const Point & rPoint, const ByteString& rString)
+{
+ USHORT nLen,i;
+
+ WriteRecordHeader(0,W_META_TEXTOUT);
+ nLen=rString.Len();
+ *pWMF << nLen;
+ for ( i = 0; i < nLen; i++ )
+ *pWMF << (BYTE)rString.GetChar( i );
+ if ((nLen&1)!=0) *pWMF << (BYTE)0;
+ WritePointYX(rPoint);
+ UpdateRecordHeader();
+}
+
+void WMFWriter::WMFRecord_EndOfFile()
+{
+ WriteRecordHeader(0x00000003,0x0000);
+}
+
+
+void WMFWriter::WMFRecord_IntersectClipRect( const Rectangle& rRect )
+{
+ WriteRecordHeader( 0x00000007, W_META_INTERSECTCLIPRECT );
+ WriteRectangle(rRect);
+}
+
+
+USHORT WMFWriter::AllocHandle()
+{
+ USHORT i;
+
+ for (i=0; i<MAXOBJECTHANDLES; i++) {
+ if (bHandleAllocated[i]==FALSE) {
+ bHandleAllocated[i]=TRUE;
+ return i;
+ }
+ }
+ bStatus=FALSE;
+ return 0xffff;
+}
+
+
+void WMFWriter::FreeHandle(USHORT nObjectHandle)
+{
+ if (nObjectHandle<MAXOBJECTHANDLES) bHandleAllocated[nObjectHandle]=FALSE;
+}
+
+
+void WMFWriter::CreateSelectDeletePen( const Color& rColor, const LineInfo& rLineInfo )
+{
+ USHORT nOldHandle;
+
+ nOldHandle=nDstPenHandle;
+ nDstPenHandle=AllocHandle();
+ WMFRecord_CreatePenIndirect( rColor, rLineInfo );
+ WMFRecord_SelectObject(nDstPenHandle);
+ if (nOldHandle<MAXOBJECTHANDLES) {
+ WMFRecord_DeleteObject(nOldHandle);
+ FreeHandle(nOldHandle);
+ }
+}
+
+
+void WMFWriter::CreateSelectDeleteFont(const Font & rFont)
+{
+ USHORT nOldHandle;
+
+ nOldHandle=nDstFontHandle;
+ nDstFontHandle=AllocHandle();
+ WMFRecord_CreateFontIndirect(rFont);
+ WMFRecord_SelectObject(nDstFontHandle);
+ if (nOldHandle<MAXOBJECTHANDLES) {
+ WMFRecord_DeleteObject(nOldHandle);
+ FreeHandle(nOldHandle);
+ }
+}
+
+
+void WMFWriter::CreateSelectDeleteBrush(const Color& rColor)
+{
+ USHORT nOldHandle;
+
+ nOldHandle=nDstBrushHandle;
+ nDstBrushHandle=AllocHandle();
+ WMFRecord_CreateBrushIndirect(rColor);
+ WMFRecord_SelectObject(nDstBrushHandle);
+ if (nOldHandle<MAXOBJECTHANDLES) {
+ WMFRecord_DeleteObject(nOldHandle);
+ FreeHandle(nOldHandle);
+ }
+}
+
+
+void WMFWriter::SetLineAndFillAttr()
+{
+ if ( eDstROP2 != eSrcRasterOp )
+ {
+ eDstROP2=eSrcRasterOp;
+ WMFRecord_SetROP2(eDstROP2);
+ }
+ if ( ( aDstLineColor != aSrcLineColor ) || ( aDstLineInfo != aSrcLineInfo ) )
+ {
+ aDstLineColor = aSrcLineColor;
+ aDstLineInfo = aSrcLineInfo;
+ CreateSelectDeletePen( aDstLineColor, aDstLineInfo );
+ }
+ if ( aDstFillColor != aSrcFillColor )
+ {
+ aDstFillColor = aSrcFillColor;
+ CreateSelectDeleteBrush( aDstFillColor );
+ }
+ if ( bDstIsClipping != bSrcIsClipping ||
+ (bSrcIsClipping==TRUE && aDstClipRegion!=aSrcClipRegion)) {
+ bDstIsClipping=bSrcIsClipping;
+ aDstClipRegion=aSrcClipRegion;
+ }
+}
+
+void WMFWriter::SetAllAttr()
+{
+ SetLineAndFillAttr();
+ if ( aDstTextColor != aSrcTextColor )
+ {
+ aDstTextColor = aSrcTextColor;
+ WMFRecord_SetTextColor(aDstTextColor);
+ }
+ if ( eDstTextAlign != eSrcTextAlign )
+ {
+ eDstTextAlign = eSrcTextAlign;
+ WMFRecord_SetTextAlign( eDstTextAlign );
+ }
+ if ( aDstFont != aSrcFont )
+ {
+ pVirDev->SetFont(aSrcFont);
+ if ( aDstFont.GetName() != aSrcFont.GetName() )
+ {
+ FontCharMap aFontCharMap;
+ if ( pVirDev->GetFontCharMap( aFontCharMap ) )
+ {
+ if ( ( aFontCharMap.GetFirstChar() & 0xff00 ) == 0xf000 )
+ aSrcFont.SetCharSet( RTL_TEXTENCODING_SYMBOL );
+ else if ( aSrcFont.GetCharSet() == RTL_TEXTENCODING_SYMBOL )
+ aSrcFont.SetCharSet( RTL_TEXTENCODING_MS_1252 );
+ }
+ }
+ aDstFont = aSrcFont;
+ CreateSelectDeleteFont(aDstFont);
+ }
+}
+
+
+void WMFWriter::WriteRecords( const GDIMetaFile & rMTF )
+{
+ ULONG nA, nACount;
+ MetaAction* pMA;
+
+ if( bStatus )
+ {
+ nACount = rMTF.GetActionCount();
+
+ WMFRecord_SetStretchBltMode();
+
+ for( nA=0; nA<nACount; nA++ )
+ {
+ pMA = rMTF.GetAction( nA );
+
+ switch( pMA->GetType() )
+ {
+ case META_PIXEL_ACTION:
+ {
+ const MetaPixelAction* pA = (const MetaPixelAction *) pMA;
+ aSrcLineInfo = LineInfo();
+ SetLineAndFillAttr();
+ WMFRecord_SetPixel( pA->GetPoint(), pA->GetColor() );
+ }
+ break;
+
+ case META_POINT_ACTION:
+ {
+ const MetaPointAction* pA = (const MetaPointAction*) pMA;
+ const Point& rPt = pA->GetPoint();
+ aSrcLineInfo = LineInfo();
+ SetLineAndFillAttr();
+ WMFRecord_MoveTo( rPt);
+ WMFRecord_LineTo( rPt );
+ }
+ break;
+
+ case META_LINE_ACTION:
+ {
+ const MetaLineAction* pA = (const MetaLineAction *) pMA;
+ aSrcLineInfo = pA->GetLineInfo();
+ SetLineAndFillAttr();
+ WMFRecord_MoveTo( pA->GetStartPoint() );
+ WMFRecord_LineTo( pA->GetEndPoint() );
+ }
+ break;
+
+ case META_RECT_ACTION:
+ {
+ const MetaRectAction* pA = (const MetaRectAction*) pMA;
+ aSrcLineInfo = LineInfo();
+ SetLineAndFillAttr();
+ WMFRecord_Rectangle( pA->GetRect() );
+ }
+ break;
+
+ case META_ROUNDRECT_ACTION:
+ {
+ const MetaRoundRectAction* pA = (const MetaRoundRectAction*) pMA;
+ aSrcLineInfo = LineInfo();
+ SetLineAndFillAttr();
+ WMFRecord_RoundRect( pA->GetRect(), pA->GetHorzRound(), pA->GetVertRound() );
+ }
+ break;
+
+ case META_ELLIPSE_ACTION:
+ {
+ const MetaEllipseAction* pA = (const MetaEllipseAction*) pMA;
+ aSrcLineInfo = LineInfo();
+ SetLineAndFillAttr();
+ WMFRecord_Ellipse( pA->GetRect() );
+ }
+ break;
+
+ case META_ARC_ACTION:
+ {
+ const MetaArcAction* pA = (const MetaArcAction*) pMA;
+ aSrcLineInfo = LineInfo();
+ SetLineAndFillAttr();
+ WMFRecord_Arc( pA->GetRect(),pA->GetStartPoint(),pA->GetEndPoint() );
+ }
+ break;
+
+ case META_PIE_ACTION:
+ {
+ const MetaPieAction* pA = (const MetaPieAction*) pMA;
+ aSrcLineInfo = LineInfo();
+ SetLineAndFillAttr();
+ WMFRecord_Pie( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() );
+ }
+ break;
+
+
+ case META_CHORD_ACTION:
+ {
+ const MetaChordAction* pA = (const MetaChordAction*) pMA;
+ aSrcLineInfo = LineInfo();
+ SetLineAndFillAttr();
+ WMFRecord_Chord( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() );
+ }
+ break;
+
+ case META_POLYLINE_ACTION:
+ {
+ const MetaPolyLineAction* pA = (const MetaPolyLineAction*) pMA;
+ aSrcLineInfo = pA->GetLineInfo();
+ SetLineAndFillAttr();
+ WMFRecord_PolyLine( pA->GetPolygon() );
+ }
+ break;
+
+ case META_POLYGON_ACTION:
+ {
+ const MetaPolygonAction* pA = (const MetaPolygonAction*) pMA;
+ aSrcLineInfo = LineInfo();
+ SetLineAndFillAttr();
+ WMFRecord_Polygon( pA->GetPolygon() );
+ }
+ break;
+
+ case META_POLYPOLYGON_ACTION:
+ {
+ const MetaPolyPolygonAction* pA = (const MetaPolyPolygonAction*) pMA;
+ aSrcLineInfo = LineInfo();
+ SetLineAndFillAttr();
+ WMFRecord_PolyPolygon( pA->GetPolyPolygon() );
+ }
+ break;
+
+ case META_TEXTRECT_ACTION:
+ {
+ const MetaTextRectAction * pA = (const MetaTextRectAction*)pMA;
+ String aTemp( pA->GetText() );
+ aSrcLineInfo = LineInfo();
+ SetAllAttr();
+
+ Point aPos( pA->GetRect().TopLeft() );
+ if ( !WMFRecord_Escape_Unicode( aPos, aTemp, NULL ) )
+ WMFRecord_TextOut( aPos, aTemp );
+ }
+ break;
+
+ case META_TEXT_ACTION:
+ {
+ const MetaTextAction * pA = (const MetaTextAction*) pMA;
+ String aTemp( pA->GetText(), pA->GetIndex(), pA->GetLen() );
+ aSrcLineInfo = LineInfo();
+ SetAllAttr();
+ if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, NULL ) )
+ WMFRecord_TextOut( pA->GetPoint(), aTemp );
+ }
+ break;
+
+ case META_TEXTARRAY_ACTION:
+ {
+ const MetaTextArrayAction* pA = (const MetaTextArrayAction*) pMA;
+
+ String aTemp( pA->GetText(), pA->GetIndex(), pA->GetLen() );
+ aSrcLineInfo = LineInfo();
+ SetAllAttr();
+ if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, pA->GetDXArray() ) )
+ WMFRecord_ExtTextOut( pA->GetPoint(), aTemp, pA->GetDXArray() );
+ }
+ break;
+
+ case META_STRETCHTEXT_ACTION:
+ {
+ const MetaStretchTextAction* pA = (const MetaStretchTextAction *) pMA;
+ String aTemp( pA->GetText(), pA->GetIndex(), pA->GetLen() );
+
+ sal_uInt16 nLen,i;
+ sal_Int32 nNormSize;
+
+ pVirDev->SetFont( aSrcFont );
+ nLen = aTemp.Len();
+ sal_Int32* pDXAry = nLen ? new sal_Int32[ nLen ] : NULL;
+ nNormSize = pVirDev->GetTextArray( aTemp, pDXAry );
+ for ( i = 0; i < ( nLen - 1 ); i++ )
+ pDXAry[ i ] = pDXAry[ i ] * (sal_Int32)pA->GetWidth() / nNormSize;
+ if ( ( nLen <= 1 ) || ( (sal_Int32)pA->GetWidth() == nNormSize ) )
+ delete[] pDXAry, pDXAry = NULL;
+ aSrcLineInfo = LineInfo();
+ SetAllAttr();
+ if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, pDXAry ) )
+ WMFRecord_ExtTextOut( pA->GetPoint(), aTemp, pDXAry );
+ delete[] pDXAry;
+ }
+ break;
+
+ case META_BMP_ACTION:
+ {
+ const MetaBmpAction* pA = (const MetaBmpAction *) pMA;
+ WMFRecord_StretchDIB( pA->GetPoint(), pA->GetBitmap().GetSizePixel(), pA->GetBitmap() );
+ }
+ break;
+
+ case META_BMPSCALE_ACTION:
+ {
+ const MetaBmpScaleAction* pA = (const MetaBmpScaleAction*) pMA;
+ WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), pA->GetBitmap() );
+ }
+ break;
+
+ case META_BMPSCALEPART_ACTION:
+ {
+ const MetaBmpScalePartAction* pA = (const MetaBmpScalePartAction*) pMA;
+ Bitmap aTmp( pA->GetBitmap() );
+
+ if( aTmp.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ) )
+ WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aTmp );
+ }
+ break;
+
+ case META_BMPEX_ACTION:
+ {
+ const MetaBmpExAction* pA = (const MetaBmpExAction *) pMA;
+ Bitmap aBmp( pA->GetBitmapEx().GetBitmap() );
+ Bitmap aMsk( pA->GetBitmapEx().GetMask() );
+
+ if( !!aMsk )
+ {
+ aBmp.Replace( aMsk, COL_WHITE );
+ aMsk.Invert();
+ WMFRecord_StretchDIB( pA->GetPoint(), aMsk.GetSizePixel(), aBmp, W_SRCPAINT );
+ WMFRecord_StretchDIB( pA->GetPoint(), aBmp.GetSizePixel(), aBmp, W_SRCAND );
+ }
+ else
+ WMFRecord_StretchDIB( pA->GetPoint(), aBmp.GetSizePixel(), aBmp );
+ }
+ break;
+
+ case META_BMPEXSCALE_ACTION:
+ {
+ const MetaBmpExScaleAction* pA = (const MetaBmpExScaleAction*) pMA;
+ Bitmap aBmp( pA->GetBitmapEx().GetBitmap() );
+ Bitmap aMsk( pA->GetBitmapEx().GetMask() );
+
+ if( !!aMsk )
+ {
+ aBmp.Replace( aMsk, COL_WHITE );
+ aMsk.Invert();
+ WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aMsk, W_SRCPAINT );
+ WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aBmp, W_SRCAND );
+ }
+ else
+ WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aBmp );
+ }
+ break;
+
+ case META_BMPEXSCALEPART_ACTION:
+ {
+ const MetaBmpExScalePartAction* pA = (const MetaBmpExScalePartAction*) pMA;
+ BitmapEx aBmpEx( pA->GetBitmapEx() );
+ aBmpEx.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) );
+ Bitmap aBmp( aBmpEx.GetBitmap() );
+ Bitmap aMsk( aBmpEx.GetMask() );
+
+ if( !!aMsk )
+ {
+ aBmp.Replace( aMsk, COL_WHITE );
+ aMsk.Invert();
+ WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aMsk, W_SRCPAINT );
+ WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aBmp, W_SRCAND );
+ }
+ else
+ WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aBmp );
+ }
+ break;
+
+ case META_GRADIENT_ACTION:
+ {
+ const MetaGradientAction* pA = (const MetaGradientAction*) pMA;
+ GDIMetaFile aTmpMtf;
+
+ pVirDev->AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf );
+ WriteRecords( aTmpMtf );
+ }
+ break;
+
+ case META_HATCH_ACTION:
+ {
+ const MetaHatchAction* pA = (const MetaHatchAction*) pMA;
+ GDIMetaFile aTmpMtf;
+
+ pVirDev->AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf );
+ WriteRecords( aTmpMtf );
+ }
+ break;
+
+ case META_WALLPAPER_ACTION:
+ {
+ const MetaWallpaperAction* pA = (const MetaWallpaperAction*) pMA;
+ const Color& rColor = pA->GetWallpaper().GetColor();
+ const Color aOldLineColor( aSrcLineColor );
+ const Color aOldFillColor( aSrcFillColor );
+
+ aSrcLineColor = rColor;
+ aSrcFillColor = rColor;
+ aSrcLineInfo = LineInfo();
+ SetLineAndFillAttr();
+ WMFRecord_Rectangle( pA->GetRect() );
+ aSrcLineColor = aOldLineColor;
+ aSrcFillColor = aOldFillColor;
+ }
+ break;
+
+ case META_ISECTRECTCLIPREGION_ACTION:
+ {
+ const MetaISectRectClipRegionAction* pA = (const MetaISectRectClipRegionAction*) pMA;
+ WMFRecord_IntersectClipRect( pA->GetRect() );
+ }
+ break;
+
+ case META_LINECOLOR_ACTION:
+ {
+ const MetaLineColorAction* pA = (const MetaLineColorAction*) pMA;
+
+ if( pA->IsSetting() )
+ aSrcLineColor = pA->GetColor();
+ else
+ aSrcLineColor = Color( COL_TRANSPARENT );
+ }
+ break;
+
+ case META_FILLCOLOR_ACTION:
+ {
+ const MetaFillColorAction* pA = (const MetaFillColorAction*) pMA;
+
+ if( pA->IsSetting() )
+ aSrcFillColor = pA->GetColor();
+ else
+ aSrcFillColor = Color( COL_TRANSPARENT );
+ }
+ break;
+
+ case META_TEXTCOLOR_ACTION:
+ {
+ const MetaTextColorAction* pA = (const MetaTextColorAction*) pMA;
+ aSrcTextColor = pA->GetColor();
+ }
+ break;
+
+ case META_TEXTFILLCOLOR_ACTION:
+ {
+ const MetaTextFillColorAction* pA = (const MetaTextFillColorAction*) pMA;
+ if( pA->IsSetting() )
+ aSrcFont.SetFillColor( pA->GetColor() );
+ else
+ aSrcFont.SetFillColor( Color( COL_TRANSPARENT ) );
+ }
+ break;
+
+ case META_TEXTALIGN_ACTION:
+ {
+ const MetaTextAlignAction* pA = (const MetaTextAlignAction*) pMA;
+ eSrcTextAlign = pA->GetTextAlign();
+ }
+ break;
+
+ case META_MAPMODE_ACTION:
+ {
+ const MetaMapModeAction* pA = (const MetaMapModeAction*) pMA;
+
+ if (aSrcMapMode!=pA->GetMapMode())
+ {
+ if( pA->GetMapMode().GetMapUnit() == MAP_RELATIVE )
+ {
+ MapMode aMM = pA->GetMapMode();
+ Fraction aScaleX = aMM.GetScaleX();
+ Fraction aScaleY = aMM.GetScaleY();
+
+ Point aOrigin = aSrcMapMode.GetOrigin();
+ BigInt aX( aOrigin.X() );
+ aX *= BigInt( aScaleX.GetDenominator() );
+ if( aOrigin.X() >= 0 )
+ if( aScaleX.GetNumerator() >= 0 )
+ aX += BigInt( aScaleX.GetNumerator()/2 );
+ else
+ aX -= BigInt( (aScaleX.GetNumerator()+1)/2 );
+ else
+ if( aScaleX.GetNumerator() >= 0 )
+ aX -= BigInt( (aScaleX.GetNumerator()-1)/2 );
+ else
+ aX += BigInt( aScaleX.GetNumerator()/2 );
+ aX /= BigInt( aScaleX.GetNumerator() );
+ aOrigin.X() = (long)aX + aMM.GetOrigin().X();
+ BigInt aY( aOrigin.Y() );
+ aY *= BigInt( aScaleY.GetDenominator() );
+ if( aOrigin.Y() >= 0 )
+ if( aScaleY.GetNumerator() >= 0 )
+ aY += BigInt( aScaleY.GetNumerator()/2 );
+ else
+ aY -= BigInt( (aScaleY.GetNumerator()+1)/2 );
+ else
+ if( aScaleY.GetNumerator() >= 0 )
+ aY -= BigInt( (aScaleY.GetNumerator()-1)/2 );
+ else
+ aY += BigInt( aScaleY.GetNumerator()/2 );
+ aY /= BigInt( aScaleY.GetNumerator() );
+ aOrigin.Y() = (long)aY + aMM.GetOrigin().Y();
+ aSrcMapMode.SetOrigin( aOrigin );
+
+ aScaleX *= aSrcMapMode.GetScaleX();
+ aScaleY *= aSrcMapMode.GetScaleY();
+ aSrcMapMode.SetScaleX( aScaleX );
+ aSrcMapMode.SetScaleY( aScaleY );
+ }
+ else
+ aSrcMapMode=pA->GetMapMode();
+ }
+ }
+ break;
+
+ case META_FONT_ACTION:
+ {
+ const MetaFontAction* pA = (const MetaFontAction*) pMA;
+ aSrcFont = pA->GetFont();
+
+ if ( aSrcFont.GetCharSet() == RTL_TEXTENCODING_DONTKNOW )
+ aSrcFont.SetCharSet( GetExtendedTextEncoding( gsl_getSystemTextEncoding() ) );
+ if ( aSrcFont.GetCharSet() == RTL_TEXTENCODING_UNICODE )
+ aSrcFont.SetCharSet( RTL_TEXTENCODING_MS_1252 );
+ eSrcTextAlign = aSrcFont.GetAlign();
+ aSrcTextColor = aSrcFont.GetColor();
+ aSrcFont.SetAlign( ALIGN_BASELINE );
+ aSrcFont.SetColor( COL_WHITE );
+ }
+ break;
+
+ case META_PUSH_ACTION:
+ {
+ const MetaPushAction* pA = (const MetaPushAction*)pMA;
+
+ WMFWriterAttrStackMember* pAt = new WMFWriterAttrStackMember;
+ pAt->nFlags = pA->GetFlags();
+ pAt->aClipRegion = aSrcClipRegion;
+ pAt->aLineColor=aSrcLineColor;
+ pAt->aFillColor=aSrcFillColor;
+ pAt->eRasterOp=eSrcRasterOp;
+ pAt->aFont=aSrcFont;
+ pAt->eTextAlign=eSrcTextAlign;
+ pAt->aTextColor=aSrcTextColor;
+ pAt->aMapMode=aSrcMapMode;
+ pAt->aLineInfo=aDstLineInfo;
+ pAt->pSucc=pAttrStack;
+ pAttrStack=pAt;
+
+ SetAllAttr(); // update ( now all source attributes are equal to the destination attributes )
+ WMFRecord_SaveDC();
+
+ }
+ break;
+
+ case META_POP_ACTION:
+ {
+ WMFWriterAttrStackMember * pAt=pAttrStack;
+
+ if( pAt )
+ {
+ aDstLineInfo = pAt->aLineInfo;
+ aDstLineColor = pAt->aLineColor;
+ if ( pAt->nFlags & PUSH_LINECOLOR )
+ aSrcLineColor = pAt->aLineColor;
+ aDstFillColor = pAt->aFillColor;
+ if ( pAt->nFlags & PUSH_FILLCOLOR )
+ aSrcFillColor = pAt->aFillColor;
+ eDstROP2 = pAt->eRasterOp;
+ if ( pAt->nFlags & PUSH_RASTEROP )
+ eSrcRasterOp = pAt->eRasterOp;
+ aDstFont = pAt->aFont;
+ if ( pAt->nFlags & PUSH_FONT )
+ aSrcFont = pAt->aFont;
+ eDstTextAlign = pAt->eTextAlign;
+ if ( pAt->nFlags & ( PUSH_FONT | PUSH_TEXTALIGN ) )
+ eSrcTextAlign = pAt->eTextAlign;
+ aDstTextColor = pAt->aTextColor;
+ if ( pAt->nFlags & ( PUSH_FONT | PUSH_TEXTCOLOR ) )
+ aSrcTextColor = pAt->aTextColor;
+ if ( pAt->nFlags & PUSH_MAPMODE )
+ aSrcMapMode = pAt->aMapMode;
+ aDstClipRegion = pAt->aClipRegion;
+ if ( pAt->nFlags & PUSH_CLIPREGION )
+ aSrcClipRegion = pAt->aClipRegion;
+
+ WMFRecord_RestoreDC();
+ pAttrStack = pAt->pSucc;
+ delete pAt;
+ }
+ }
+ break;
+
+ case META_EPS_ACTION :
+ {
+ const MetaEPSAction* pA = (const MetaEPSAction*)pMA;
+ const GDIMetaFile aGDIMetaFile( pA->GetSubstitute() );
+
+ INT32 nCount = aGDIMetaFile.GetActionCount();
+ for ( INT32 i = 0; i < nCount; i++ )
+ {
+ const MetaAction* pMetaAct = aGDIMetaFile.GetAction( i );
+ if ( pMetaAct->GetType() == META_BMPSCALE_ACTION )
+ {
+ const MetaBmpScaleAction* pBmpScaleAction = (const MetaBmpScaleAction*)pMetaAct;
+ WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), pBmpScaleAction->GetBitmap() );
+ break;
+ }
+ }
+ }
+ break;
+
+ case META_RASTEROP_ACTION:
+ {
+ const MetaRasterOpAction* pA = (const MetaRasterOpAction*) pMA;
+ eSrcRasterOp=pA->GetRasterOp();
+ }
+ break;
+
+ case META_TRANSPARENT_ACTION:
+ {
+ aSrcLineInfo = LineInfo();
+ SetLineAndFillAttr();
+ WMFRecord_PolyPolygon( ( (MetaTransparentAction*) pMA )->GetPolyPolygon() );
+ }
+ break;
+
+ case META_FLOATTRANSPARENT_ACTION:
+ {
+ const MetaFloatTransparentAction* pA = (const MetaFloatTransparentAction*) pMA;
+
+ GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() );
+ Point aSrcPt( aTmpMtf.GetPrefMapMode().GetOrigin() );
+ const Size aSrcSize( aTmpMtf.GetPrefSize() );
+ const Point aDestPt( pA->GetPoint() );
+ const Size aDestSize( pA->GetSize() );
+ const double fScaleX = aSrcSize.Width() ? (double) aDestSize.Width() / aSrcSize.Width() : 1.0;
+ const double fScaleY = aSrcSize.Height() ? (double) aDestSize.Height() / aSrcSize.Height() : 1.0;
+ long nMoveX, nMoveY;
+
+ aSrcLineInfo = LineInfo();
+ SetAllAttr();
+
+ if( fScaleX != 1.0 || fScaleY != 1.0 )
+ {
+ aTmpMtf.Scale( fScaleX, fScaleY );
+ aSrcPt.X() = FRound( aSrcPt.X() * fScaleX ), aSrcPt.Y() = FRound( aSrcPt.Y() * fScaleY );
+ }
+
+ nMoveX = aDestPt.X() - aSrcPt.X(), nMoveY = aDestPt.Y() - aSrcPt.Y();
+
+ if( nMoveX || nMoveY )
+ aTmpMtf.Move( nMoveX, nMoveY );
+
+ WriteRecords( aTmpMtf );
+ }
+ break;
+
+ // Unsupported Actions
+ case META_MASK_ACTION:
+ case META_MASKSCALE_ACTION:
+ case META_MASKSCALEPART_ACTION:
+ {
+ DBG_ERROR( "Unsupported action: MetaMask...Action!" );
+ }
+ break;
+
+ case META_CLIPREGION_ACTION:
+ break;
+
+ case META_ISECTREGIONCLIPREGION_ACTION:
+ {
+ DBG_ERROR( "Unsupported action: MetaISectRegionClipRegionAction!" );
+ }
+ break;
+
+ case META_MOVECLIPREGION_ACTION:
+ {
+ DBG_ERROR( "Unsupported action: MetaMoveClipRegionAction!" );
+ }
+ break;
+ }
+
+ nWrittenActions++;
+ MayCallback();
+
+ if (pWMF->GetError())
+ bStatus=FALSE;
+
+ if(bStatus==FALSE)
+ break;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void WMFWriter::WriteHeader( const GDIMetaFile &, BOOL bPlaceable )
+{
+ if( bPlaceable )
+ {
+ USHORT nCheckSum, nValue;
+ Size aSize( pVirDev->LogicToLogic(Size(1,1),MapMode(MAP_INCH), aTargetMapMode) );
+ USHORT nUnitsPerInch = (USHORT) ( ( aSize.Width() + aSize.Height() ) >> 1 );
+
+ nCheckSum=0;
+ nValue=0xcdd7; nCheckSum^=nValue; *pWMF << nValue;
+ nValue=0x9ac6; nCheckSum^=nValue; *pWMF << nValue;
+ nValue=0x0000; nCheckSum^=nValue; *pWMF << nValue;
+ nValue=0x0000; nCheckSum^=nValue; *pWMF << nValue;
+ nValue=0x0000; nCheckSum^=nValue; *pWMF << nValue;
+ nValue=(USHORT) aTargetSize.Width(); nCheckSum^=nValue; *pWMF << nValue;
+ nValue=(USHORT) aTargetSize.Height(); nCheckSum^=nValue; *pWMF << nValue;
+ nValue=nUnitsPerInch; nCheckSum^=nValue; *pWMF << nValue;
+ nValue=0x0000; nCheckSum^=nValue; *pWMF << nValue;
+ nValue=0x0000; nCheckSum^=nValue; *pWMF << nValue;
+ *pWMF << nCheckSum;
+ }
+
+ nMetafileHeaderPos=pWMF->Tell();
+ *pWMF << (sal_uInt16)0x0001 // Typ: Datei
+ << (sal_uInt16)0x0009 // Headerlaenge in Worten
+ << (sal_uInt16)0x0300 // Version als BCD-Zahl
+ << (sal_uInt32) 0x00000000 // Dateilaenge (ohne 1. Header), wird spaeter durch UpdateHeader() berichtigt
+ << (sal_uInt16)MAXOBJECTHANDLES // Maximalezahl der gleichzeitigen Objekte
+ << (sal_uInt32) 0x00000000 // Maximale Record-laenge, wird spaeter durch UpdateHeader() berichtigt
+ << (sal_uInt16)0x0000; // Reserved
+}
+
+// ------------------------------------------------------------------------
+
+void WMFWriter::UpdateHeader()
+{
+ ULONG nPos;
+ sal_uInt32 nFileSize;
+
+ nPos=pWMF->Tell(); // Endposition = Gesammtgroesse der Datei
+ nFileSize=nPos-nMetafileHeaderPos; // Groesse des 1. Headers abziehen
+ if ((nFileSize&1)!=0) { // ggf. auf ganze Worte aufrunden
+ *pWMF << (BYTE)0;
+ nPos++;
+ nFileSize++;
+ }
+ nFileSize>>=1; // In Anzahl Worte umrechnen
+ pWMF->Seek(nMetafileHeaderPos+6); // Zum Dateigroessen-Eintrag im zweiten Header
+ *pWMF << nFileSize; // Dateigroesse berichtigen
+ pWMF->SeekRel(2); // Zum Max-Record-Laenge-Eintrag im zweiten Header
+ *pWMF << nMaxRecordSize; // und berichtigen
+ pWMF->Seek(nPos);
+}
+
+// ------------------------------------------------------------------------
+
+BOOL WMFWriter::WriteWMF( const GDIMetaFile& rMTF, SvStream& rTargetStream,
+ FilterConfigItem* pFConfigItem, BOOL bPlaceable )
+{
+ WMFWriterAttrStackMember * pAt;
+
+ bStatus=TRUE;
+ pConvert = 0;
+ pVirDev = new VirtualDevice;
+
+ pFilterConfigItem = pFConfigItem;
+ if ( pFilterConfigItem )
+ {
+ xStatusIndicator = pFilterConfigItem->GetStatusIndicator();
+ if ( xStatusIndicator.is() )
+ {
+ rtl::OUString aMsg;
+ xStatusIndicator->start( aMsg, 100 );
+ }
+ }
+ nLastPercent=0;
+
+ pWMF=&rTargetStream;
+ pWMF->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
+
+ nMaxRecordSize=0;
+
+ aSrcMapMode=rMTF.GetPrefMapMode();
+
+ if( bPlaceable )
+ {
+ aTargetMapMode = aSrcMapMode;
+ aTargetSize = rMTF.GetPrefSize();
+ nTargetDivisor = CalcSaveTargetMapMode(aTargetMapMode, aTargetSize);
+ aTargetSize.Width() /= nTargetDivisor;
+ aTargetSize.Height() /= nTargetDivisor;
+ }
+ else
+ {
+ aTargetMapMode = MapMode( MAP_INCH );
+
+ const long nUnit = pVirDev->LogicToPixel( Size( 1, 1 ), aTargetMapMode ).Width();
+ const Fraction aFrac( 1, nUnit );
+
+ aTargetMapMode.SetScaleX( aFrac );
+ aTargetMapMode.SetScaleY( aFrac );
+ aTargetSize = pVirDev->LogicToLogic( rMTF.GetPrefSize(), aSrcMapMode, aTargetMapMode );
+ }
+
+ pVirDev->SetMapMode( aTargetMapMode );
+
+ pAttrStack=NULL;
+
+ for (USHORT i=0; i<MAXOBJECTHANDLES; i++)
+ bHandleAllocated[i]=FALSE;
+
+ nDstPenHandle=0xffff;
+ nDstFontHandle=0xffff;
+ nDstBrushHandle=0xffff;
+
+ nNumberOfActions=0;
+ nNumberOfBitmaps=0;
+ nWrittenActions=0;
+ nWrittenBitmaps=0;
+ nActBitmapPercent=0;
+
+ CountActionsAndBitmaps(rMTF);
+
+ WriteHeader(rMTF,bPlaceable);
+ WMFRecord_SetWindowOrg(Point(0,0));
+ WMFRecord_SetWindowExt(rMTF.GetPrefSize());
+ WMFRecord_SetBkMode( TRUE );
+
+ eDstROP2 = eSrcRasterOp = ROP_OVERPAINT;
+ WMFRecord_SetROP2(eDstROP2);
+
+ aDstLineInfo = LineInfo();
+ aDstLineColor = aSrcLineColor = Color( COL_BLACK );
+ CreateSelectDeletePen( aDstLineColor, aDstLineInfo );
+
+ aDstFillColor = aSrcFillColor = Color( COL_WHITE );
+ CreateSelectDeleteBrush( aDstFillColor );
+
+ aDstClipRegion = aSrcClipRegion = Region();
+ bDstIsClipping = bSrcIsClipping = FALSE;
+
+ Font aFont;
+ aFont.SetCharSet( GetExtendedTextEncoding( gsl_getSystemTextEncoding() ) );
+ aFont.SetColor( Color( COL_WHITE ) );
+ aFont.SetAlign( ALIGN_BASELINE );
+ aDstFont = aSrcFont = aFont;
+ CreateSelectDeleteFont(aDstFont);
+
+ eDstTextAlign = eSrcTextAlign = ALIGN_BASELINE;
+ WMFRecord_SetTextAlign( eDstTextAlign );
+
+ aDstTextColor = aSrcTextColor = Color( COL_WHITE );
+ WMFRecord_SetTextColor(aDstTextColor);
+
+ // Write records
+ WriteRecords(rMTF);
+
+ WMFRecord_EndOfFile();
+ UpdateHeader();
+
+ while(pAttrStack)
+ {
+ pAt=pAttrStack;
+ pAttrStack=pAt->pSucc;
+ delete pAt;
+ }
+
+ delete pVirDev;
+ delete pConvert;
+
+ if ( xStatusIndicator.is() )
+ xStatusIndicator->end();
+
+ return bStatus;
+}
+
+// ------------------------------------------------------------------------
+
+USHORT WMFWriter::CalcSaveTargetMapMode(MapMode& rMapMode,
+ const Size& rPrefSize)
+{
+ Fraction aDivFrac(2, 1);
+ USHORT nDivisor = 1;
+
+ Size aSize = pVirDev->LogicToLogic( rPrefSize, aSrcMapMode, rMapMode );
+
+ while( nDivisor <= 64 && (aSize.Width() > 32767 || aSize.Height() > 32767) )
+ {
+ Fraction aFrac = rMapMode.GetScaleX();
+
+ aFrac *= aDivFrac;
+ rMapMode.SetScaleX(aFrac);
+ aFrac = rMapMode.GetScaleY();
+ aFrac *= aDivFrac;
+ rMapMode.SetScaleY(aFrac);
+ nDivisor <<= 1;
+ aSize = pVirDev->LogicToLogic( rPrefSize, aSrcMapMode, rMapMode );
+ }
+
+ return nDivisor;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/wmf/winmtf.hxx b/binfilter/bf_svtools/source/filter.vcl/wmf/winmtf.hxx
new file mode 100644
index 000000000000..85f6d8fc4b9c
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/wmf/winmtf.hxx
@@ -0,0 +1,760 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 _WINMTF_HXX
+#define _WINMTF_HXX
+
+#ifdef DBG_UTIL
+#define WIN_MTF_ASSERT
+#endif
+
+#include <vector>
+#include <stdlib.h>
+#include <sot/object.hxx>
+#include <boost/shared_ptr.hpp>
+#include <tools/debug.hxx>
+#include <tools/stack.hxx>
+#include <tools/table.hxx>
+#include <tools/dynary.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/virdev.hxx>
+#include <tools/poly.hxx>
+#include <vcl/font.hxx>
+#include <vcl/bmpacc.hxx>
+#include <vcl/lineinfo.hxx>
+#include <bf_svtools/fltcall.hxx>
+
+namespace binfilter
+{
+
+
+#define ERROR 0
+#define NULLREGION 1
+#define SIMPLEREGION 2
+#define COMPLEXREGION 3
+
+#define RGN_AND 1
+#define RGN_OR 2
+#define RGN_XOR 3
+#define RGN_DIFF 4
+#define RGN_COPY 5
+
+#define TRANSPARENT 1
+#define OPAQUE 2
+#define BKMODE_LAST 2
+
+/* xform stuff */
+#define MWT_IDENTITY 1
+#define MWT_LEFTMULTIPLY 2
+#define MWT_RIGHTMULTIPLY 3
+
+#define ENHMETA_STOCK_OBJECT 0x80000000
+
+/* Stock Logical Objects */
+#define WHITE_BRUSH 0
+#define LTGRAY_BRUSH 1
+#define GRAY_BRUSH 2
+#define DKGRAY_BRUSH 3
+#define BLACK_BRUSH 4
+#define NULL_BRUSH 5
+#define HOLLOW_BRUSH NULL_BRUSH
+#define WHITE_PEN 6
+#define BLACK_PEN 7
+#define NULL_PEN 8
+#define OEM_FIXED_FONT 10
+#define ANSI_FIXED_FONT 11
+#define ANSI_VAR_FONT 12
+#define SYSTEM_FONT 13
+#define DEVICE_DEFAULT_FONT 14
+#define DEFAULT_PALETTE 15
+#define SYSTEM_FIXED_FONT 16
+
+
+#define R2_BLACK 1
+#define R2_NOTMERGEPEN 2
+#define R2_MASKNOTPEN 3
+#define R2_NOTCOPYPEN 4
+#define R2_MASKPENNOT 5
+#define R2_NOT 6
+#define R2_XORPEN 7
+#define R2_NOTMASKPEN 8
+#define R2_MASKPEN 9
+#define R2_NOTXORPEN 10
+#define R2_NOP 11
+#define R2_MERGENOTPEN 12
+#define R2_COPYPEN 13
+#define R2_MERGEPENNOT 14
+#define R2_MERGEPEN 15
+#define R2_WHITE 16
+
+/* Mapping Modes */
+#define MM_TEXT 1
+#define MM_LOMETRIC 2
+#define MM_HIMETRIC 3
+#define MM_LOENGLISH 4
+#define MM_HIENGLISH 5
+#define MM_TWIPS 6
+#define MM_ISOTROPIC 7
+#define MM_ANISOTROPIC 8
+
+
+/* Graphics Modes */
+#define GM_COMPATIBLE 1
+#define GM_ADVANCED 2
+#define GM_LAST 2
+
+/* StretchBlt() Modes */
+#define BLACKONWHITE 1
+#define WHITEONBLACK 2
+#define COLORONCOLOR 3
+#define HALFTONE 4
+#define MAXSTRETCHBLTMODE 4
+#define STRETCH_ANDSCANS BLACKONWHITE
+#define STRETCH_ORSCANS WHITEONBLACK
+#define STRETCH_DELETESCANS COLORONCOLOR
+#define STRETCH_HALFTONE HALFTONE
+
+#define LF_FACESIZE 32
+
+struct LOGFONTW
+{
+ INT32 lfHeight;
+ INT32 lfWidth;
+ INT32 lfEscapement;
+ INT32 lfOrientation;
+ INT32 lfWeight;
+ BYTE lfItalic;
+ BYTE lfUnderline;
+ BYTE lfStrikeOut;
+ BYTE lfCharSet;
+ BYTE lfOutPrecision;
+ BYTE lfClipPrecision;
+ BYTE lfQuality;
+ BYTE lfPitchAndFamily;
+ String alfFaceName;
+};
+
+#define TA_NOUPDATECP 0x0000
+#define TA_UPDATECP 0x0001
+#define TA_LEFT 0x0000
+#define TA_RIGHT 0x0002
+#define TA_CENTER 0x0006
+#define TA_RIGHT_CENTER (TA_RIGHT | TA_CENTER)
+#define TA_TOP 0x0000
+#define TA_BOTTOM 0x0008
+#define TA_BASELINE 0x0018
+
+#define SRCCOPY 0x00CC0020L
+#define SRCPAINT 0x00EE0086L
+#define SRCAND 0x008800C6L
+#define SRCINVERT 0x00660046L
+#define SRCERASE 0x00440328L
+#define NOTSRCCOPY 0x00330008L
+#define NOTSRCERASE 0x001100A6L
+#define MERGECOPY 0x00C000CAL
+#define MERGEPAINT 0x00BB0226L
+#define PATCOPY 0x00F00021L
+#define PATPAINT 0x00FB0A09L
+#define PATINVERT 0x005A0049L
+#define DSTINVERT 0x00550009L
+#define BLACKNESS 0x00000042L
+#define WHITENESS 0x00FF0062L
+
+#define PS_SOLID 0
+#define PS_DASH 1
+#define PS_DOT 2
+#define PS_DASHDOT 3
+#define PS_DASHDOTDOT 4
+#define PS_NULL 5
+#define PS_INSIDEFRAME 6
+#define PS_USERSTYLE 7
+#define PS_ALTERNATE 8
+#define PS_STYLE_MASK 15
+
+#define PS_ENDCAP_ROUND 0x000
+#define PS_ENDCAP_SQUARE 0x100
+#define PS_ENDCAP_FLAT 0x200
+#define PS_ENDCAP_MASK 0xF00
+
+#define PS_JOIN_ROUND 0x0000
+#define PS_JOIN_BEVEL 0x1000
+#define PS_JOIN_MITER 0x2000
+#define PS_JOIN_MASK 0xF000
+
+#define PS_COSMETIC 0x00000
+#define PS_GEOMETRIC 0x10000
+#define PS_TYPE_MASK 0xF0000
+
+#define ANSI_CHARSET 0
+#define DEFAULT_CHARSET 1
+#define SYMBOL_CHARSET 2
+#define SHIFTJIS_CHARSET 128
+#define HANGEUL_CHARSET 129
+#define GB2312_CHARSET 134
+#define CHINESEBIG5_CHARSET 136
+#define OEM_CHARSET 255
+/*WINVER >= 0x0400*/
+#define JOHAB_CHARSET 130
+#define HEBREW_CHARSET 177
+#define ARABIC_CHARSET 178
+#define GREEK_CHARSET 161
+#define TURKISH_CHARSET 162
+#define VIETNAMESE_CHARSET 163
+#define THAI_CHARSET 222
+#define EASTEUROPE_CHARSET 238
+#define RUSSIAN_CHARSET 204
+#define MAC_CHARSET 77
+#define BALTIC_CHARSET 186
+
+#define ETO_OPAQUE 0x0002
+#define ETO_CLIPPED 0x0004
+/*WINVER >= 0x0400*/
+#define ETO_GLYPH_INDEX 0x0010
+#define ETO_RTLREADING 0x0080
+#define ETO_NUMERICSLOCAL 0x0400
+#define ETO_NUMERICSLATIN 0x0800
+#define ETO_IGNORELANGUAGE 0x1000
+/*_WIN32_WINNT >= 0x0500*/
+#define ETO_PDY 0x2000
+
+
+#define DEFAULT_PITCH 0x00
+#define FIXED_PITCH 0x01
+#define VARIABLE_PITCH 0x02
+
+/* Font Families */
+#define FF_DONTCARE 0x00
+#define FF_ROMAN 0x10
+#define FF_SWISS 0x20
+#define FF_MODERN 0x30
+#define FF_SCRIPT 0x40
+#define FF_DECORATIVE 0x50
+
+#define FW_DONTCARE 0
+#define FW_THIN 100
+#define FW_EXTRALIGHT 200
+#define FW_LIGHT 300
+#define FW_NORMAL 400
+#define FW_MEDIUM 500
+#define FW_SEMIBOLD 600
+#define FW_BOLD 700
+#define FW_EXTRABOLD 800
+#define FW_HEAVY 900
+#define FW_ULTRALIGHT 200
+#define FW_REGULAR 400
+#define FW_DEMIBOLD 600
+#define FW_ULTRABOLD 800
+#define FW_BLACK 900
+
+#define BS_SOLID 0
+#define BS_NULL 1
+#define BS_HOLLOW 1
+#define BS_HATCHED 2
+#define BS_PATTERN 3
+#define BS_INDEXED 4
+#define BS_DIBPATTERN 5
+#define BS_DIBPATTERNPT 6
+#define BS_PATTERN8X8 7
+#define BS_DIBPATTERN8X8 8
+#define BS_MONOPATTERN 9
+
+#define W_HS_HORIZONTAL 0
+#define W_HS_VERTICAL 1
+#define W_HS_FDIAGONAL 2
+#define W_HS_BDIAGONAL 3
+#define W_HS_CROSS 4
+#define W_HS_DIAGCROSS 5
+
+#define RDH_RECTANGLES 1
+
+#define W_MFCOMMENT 15
+
+#define PRIVATE_ESCAPE_UNICODE 2
+
+//============================ WMFReader ==================================
+
+
+#ifdef WIN_MTF_ASSERT
+#define WIN_MTF_ASSERT_INIT 0x80000000
+#define WIN_MTF_ASSERT_ONCE 0x40000000
+#define WIN_MTF_ASSERT_MIFE 0x20000000
+
+void WinMtfAssertHandler( const sal_Char*, sal_uInt32 nFlags = WIN_MTF_ASSERT_MIFE );
+#endif
+
+enum WinMtfClipPathType{ EMPTY, RECTANGLE, COMPLEX };
+
+class WinMtfClipPath
+{
+ PolyPolygon aPolyPoly;
+ WinMtfClipPathType eType;
+
+ void ImpUpdateType();
+
+ public :
+
+ sal_Bool bNeedsUpdate;
+
+ WinMtfClipPath(): eType(EMPTY), bNeedsUpdate( sal_False ){};
+
+ void SetClipPath( const PolyPolygon& rPolyPolygon, sal_Int32 nClippingMode );
+ void IntersectClipRect( const Rectangle& rRect );
+ void ExcludeClipRect( const Rectangle& rRect );
+ void MoveClipRegion( const Size& rSize );
+
+ WinMtfClipPathType GetType() const { return eType; };
+ const PolyPolygon& GetClipPath() const { return aPolyPoly; };
+
+ sal_Bool operator==( const WinMtfClipPath& rPath )
+ {
+ return ( rPath.eType == eType ) &&
+ ( rPath.aPolyPoly == aPolyPoly );
+ };
+};
+
+class WinMtfPathObj : public PolyPolygon
+{
+ sal_Bool bClosed;
+
+ public :
+
+ WinMtfPathObj() { bClosed = sal_True; }
+ void Init() { Clear(); bClosed = sal_True; };
+ void ClosePath();
+
+ void AddPoint( const Point& rPoint );
+ void AddPolygon( const Polygon& rPoly );
+ void AddPolyLine( const Polygon& rPoly );
+ void AddPolyPolygon( const PolyPolygon& rPolyPolygon );
+};
+
+struct WinMtfFontStyle
+{
+ Font aFont;
+
+ WinMtfFontStyle( LOGFONTW& rLogFont );
+};
+
+// -----------------------------------------------------------------------------
+
+struct WinMtfFillStyle
+{
+ Color aFillColor;
+ BOOL bTransparent;
+
+ WinMtfFillStyle() :
+ aFillColor ( Color( COL_BLACK ) ),
+ bTransparent( FALSE )
+ {
+ };
+
+ WinMtfFillStyle( const Color& rColor, BOOL bTrans = FALSE ) :
+ aFillColor ( rColor ),
+ bTransparent( bTrans )
+ {
+ };
+
+ BOOL operator==( const WinMtfFillStyle& rStyle )
+ { return ( ( aFillColor == rStyle.aFillColor ) && ( bTransparent == rStyle.bTransparent ) ); };
+ BOOL operator==( WinMtfFillStyle* pStyle )
+ { return ( ( aFillColor == pStyle->aFillColor ) && ( bTransparent == pStyle->bTransparent ) ); };
+ void operator=( const WinMtfFillStyle& rStyle ) { aFillColor = rStyle.aFillColor; bTransparent = rStyle.bTransparent; };
+ void operator=( WinMtfFillStyle* pStyle ) { aFillColor = pStyle->aFillColor; bTransparent = pStyle->bTransparent; };
+};
+
+// -----------------------------------------------------------------------------
+
+struct WinMtfLineStyle
+{
+ Color aLineColor;
+ LineInfo aLineInfo;
+ BOOL bTransparent;
+
+ WinMtfLineStyle() :
+ aLineColor ( COL_BLACK ),
+ bTransparent( FALSE ) {};
+
+ WinMtfLineStyle( const Color& rColor, BOOL bTrans = FALSE ) :
+ aLineColor ( rColor ),
+ bTransparent( bTrans ) {};
+
+ WinMtfLineStyle( const Color& rColor, const LineInfo rStyle, BOOL bTrans = FALSE ) :
+ aLineColor ( rColor ),
+ aLineInfo ( rStyle ),
+ bTransparent( bTrans ) {};
+
+ BOOL operator==( const WinMtfLineStyle& rStyle ) { return ( ( aLineColor == rStyle.aLineColor ) && ( bTransparent == rStyle.bTransparent ) && ( aLineInfo == rStyle.aLineInfo ) ); };
+ BOOL operator==( WinMtfLineStyle* pStyle ) { return ( ( aLineColor == pStyle->aLineColor ) && ( bTransparent == pStyle->bTransparent ) && ( aLineInfo == pStyle->aLineInfo ) ); };
+ void operator=( const WinMtfLineStyle& rStyle )
+ {
+ aLineColor = rStyle.aLineColor;
+ bTransparent = rStyle.bTransparent;
+ aLineInfo = rStyle.aLineInfo;
+ };
+
+ void operator=( WinMtfLineStyle* pStyle )
+ {
+ aLineColor = pStyle->aLineColor;
+ bTransparent = pStyle->bTransparent;
+ aLineInfo = pStyle->aLineInfo;
+ };
+};
+
+// -----------------------------------------------------------------------------
+
+struct XForm
+{
+ float eM11;
+ float eM12;
+ float eM21;
+ float eM22;
+ float eDx;
+ float eDy;
+ XForm()
+ {
+ eM11 = eM22 = 1.0f;
+ eDx = eDy = eM12 = eM21 = 0.0f;
+ };
+
+ friend SvStream& operator>>( SvStream& rIn, XForm& rXForm );
+};
+
+// -----------------------------------------------------------------------------
+
+struct SaveStruct
+{
+ sal_uInt32 nBkMode, nMapMode, nGfxMode, nTextLayoutMode;
+ sal_Int32 nWinOrgX, nWinOrgY, nWinExtX, nWinExtY;
+ sal_Int32 nDevOrgX, nDevOrgY, nDevWidth, nDevHeight;
+
+ WinMtfLineStyle aLineStyle;
+ WinMtfFillStyle aFillStyle;
+
+ Font aFont;
+ Color aBkColor;
+ Color aTextColor;
+ sal_uInt32 nTextAlign;
+ RasterOp eRasterOp;
+
+ Point aActPos;
+ WinMtfPathObj aPathObj;
+ WinMtfClipPath aClipPath;
+ XForm aXForm;
+
+ sal_Bool bRecordPath;
+ sal_Bool bFillStyleSelected;
+};
+
+typedef ::boost::shared_ptr< SaveStruct > SaveStructPtr;
+
+// -----------------------------------------------------------------------------
+
+struct BSaveStruct
+{
+ Bitmap aBmp;
+ Rectangle aOutRect;
+ UINT32 nWinRop;
+
+ BSaveStruct( const Bitmap& rBmp, const Rectangle& rOutRect, UINT32 nRop ) :
+ aBmp( rBmp ), aOutRect( rOutRect ), nWinRop( nRop ){};
+};
+
+// -----------------------------------------------------------------------------
+
+enum GDIObjectType { GDI_DUMMY = 0, GDI_PEN = 1, GDI_BRUSH = 2, GDI_FONT = 3, GDI_PALETTE = 4, GDI_BITMAP = 5, GDI_REGION = 6 };
+
+struct GDIObj
+{
+ void* pStyle;
+ GDIObjectType eType;
+
+ GDIObj() :
+ pStyle ( NULL ),
+ eType ( GDI_DUMMY )
+ {
+ };
+
+ GDIObj( GDIObjectType eT, void* pS ) { pStyle = pS; eType = eT; };
+ void Set( GDIObjectType eT, void* pS ) { pStyle = pS; eType = eT; };
+ void Delete()
+ {
+ if ( pStyle )
+ {
+ switch ( eType )
+ {
+ case GDI_PEN :
+ delete (WinMtfLineStyle*)pStyle;
+ break;
+ case GDI_BRUSH :
+ delete (WinMtfFillStyle*)pStyle;
+ break;
+ case GDI_FONT :
+ delete (WinMtfFontStyle*)pStyle;
+ break;
+
+ default:
+ DBG_ERROR( "unsupported style deleted" );
+ break;
+ }
+ pStyle = NULL;
+ }
+ };
+
+ ~GDIObj()
+ {
+ Delete();
+ }
+};
+
+// -----------------------------------------------------------------------------
+
+class WinMtfOutput
+{
+
+ WinMtfPathObj aPathObj;
+ WinMtfClipPath aClipPath;
+
+ WinMtfLineStyle maLatestLineStyle;
+ WinMtfLineStyle maLineStyle;
+ WinMtfFillStyle maLatestFillStyle;
+ WinMtfFillStyle maFillStyle;
+ Font maLatestFont;
+ Font maFont;
+ sal_uInt32 mnLatestTextAlign;
+ sal_uInt32 mnTextAlign;
+ Color maLatestTextColor;
+ Color maTextColor;
+ Color maLatestBkColor;
+ Color maBkColor;
+ sal_uInt32 mnLatestTextLayoutMode;
+ sal_uInt32 mnTextLayoutMode;
+ sal_uInt32 mnLatestBkMode;
+ sal_uInt32 mnBkMode;
+ RasterOp meLatestRasterOp;
+ RasterOp meRasterOp;
+
+ std::vector< GDIObj* > vGDIObj;
+
+ Point maActPos;
+
+ sal_uInt32 mnRop;
+ sal_Bool mbNopMode;
+ sal_Bool mbFillStyleSelected;
+
+ std::vector< SaveStructPtr > vSaveStack;
+
+ sal_uInt32 mnGfxMode;
+ sal_uInt32 mnMapMode;
+ XForm maXForm;
+ sal_Int32 mnDevOrgX, mnDevOrgY;
+ sal_Int32 mnDevWidth, mnDevHeight;
+ sal_Int32 mnWinOrgX, mnWinOrgY; // aktuelles Window-Origin
+ sal_Int32 mnWinExtX, mnWinExtY; // aktuelles Window-Extent
+
+ sal_Int32 mnPixX, mnPixY; // Reference Device in pixel
+ sal_Int32 mnMillX, mnMillY; // Reference Device in Mill
+ Rectangle mrclFrame; // rectangle in logical units 1/100th mm
+ Rectangle mrclBounds;
+
+ GDIMetaFile* mpGDIMetaFile;
+
+ void UpdateLineStyle();
+ void UpdateFillStyle();
+
+ Point ImplMap( const Point& rPt );
+ Size ImplMap( const Size& rSz );
+ Rectangle ImplMap( const Rectangle& rRectangle );
+ void ImplMap( Font& rFont );
+ Polygon& ImplMap( Polygon& rPolygon );
+ PolyPolygon& ImplMap( PolyPolygon& rPolyPolygon );
+ void ImplResizeObjectArry( UINT32 nNewEntry );
+ void ImplSetNonPersistentLineColorTransparenz();
+ void ImplDrawClippedPolyPolygon( const PolyPolygon& rPolyPoly );
+ void ImplDrawBitmap( const Point& rPos, const Size& rSize, const BitmapEx rBitmap );
+
+ public:
+
+ void SetDevOrg( const Point& rPoint );
+ void SetDevOrgOffset( INT32 nXAdd, INT32 nYAdd );
+ void SetDevExt( const Size& rSize );
+ void ScaleDevExt( double fX, double fY );
+
+ void SetWinOrg( const Point& rPoint );
+ void SetWinOrgOffset( INT32 nX, INT32 nY );
+ void SetWinExt( const Size& rSize );
+ void ScaleWinExt( double fX, double fY );
+
+ void SetrclBounds( const Rectangle& rRect );
+ void SetrclFrame( const Rectangle& rRect );
+ void SetRefPix( const Size& rSize );
+ void SetRefMill( const Size& rSize );
+
+ sal_uInt32 GetMapMode() const { return mnMapMode; };
+ void SetMapMode( sal_uInt32 mnMapMode );
+ void SetWorldTransform( const XForm& rXForm );
+ void ModifyWorldTransform( const XForm& rXForm, UINT32 nMode );
+
+ void Push();
+ void Pop();
+
+ UINT32 SetRasterOp( UINT32 nRasterOp );
+ void StrokeAndFillPath( sal_Bool bStroke, sal_Bool bFill );
+
+ void SetGfxMode( sal_Int32 nGfxMode ){ mnGfxMode = nGfxMode; };
+ sal_Int32 GetGfxMode() const { return mnGfxMode; };
+ void SetBkMode( UINT32 nMode );
+ void SetBkColor( const Color& rColor );
+ void SetTextColor( const Color& rColor );
+ void SetTextAlign( UINT32 nAlign );
+ void CreateObject( GDIObjectType, void* pStyle = NULL );
+ void CreateObject( INT32 nIndex, GDIObjectType, void* pStyle = NULL );
+ void DeleteObject( INT32 nIndex );
+ void SelectObject( INT32 nIndex );
+ CharSet GetCharSet(){ return maFont.GetCharSet(); };
+ const Font& GetFont() const;
+ void SetTextLayoutMode( const sal_uInt32 nLayoutMode );
+
+ void ClearPath(){ aPathObj.Init(); };
+ void ClosePath(){ aPathObj.ClosePath(); };
+ const PolyPolygon& GetPathObj(){ return aPathObj; };
+
+ void MoveTo( const Point& rPoint, sal_Bool bRecordPath = sal_False );
+ void LineTo( const Point& rPoint, sal_Bool bRecordPath = sal_False );
+ void DrawPixel( const Point& rSource, const Color& rColor );
+ void DrawRect( const Rectangle& rRect, BOOL bEdge = TRUE );
+ void DrawRoundRect( const Rectangle& rRect, const Size& rSize );
+ void DrawEllipse( const Rectangle& rRect );
+ void DrawArc( const Rectangle& rRect, const Point& rStartAngle, const Point& rEndAngle, BOOL bDrawTo = FALSE );
+ void DrawPie( const Rectangle& rRect, const Point& rStartAngle, const Point& rEndAngle );
+ void DrawChord( const Rectangle& rRect, const Point& rStartAngle, const Point& rEndAngle );
+ void DrawPolygon( Polygon& rPolygon, sal_Bool bRecordPath = sal_False );
+ void DrawPolyPolygon( PolyPolygon& rPolyPolygon, sal_Bool bRecordPath = sal_False );
+ void DrawPolyLine( Polygon& rPolygon, sal_Bool bDrawTo = sal_False, sal_Bool bRecordPath = sal_False );
+ void DrawPolyBezier( Polygon& rPolygin, sal_Bool bDrawTo = sal_False, sal_Bool bRecordPath = sal_False );
+ void DrawText( Point& rPosition, String& rString, sal_Int32* pDXArry = NULL, sal_Bool bRecordPath = sal_False,
+ sal_Int32 nGraphicsMode = GM_COMPATIBLE );
+ void ResolveBitmapActions( List& rSaveList );
+
+ void IntersectClipRect( const Rectangle& rRect );
+ void ExcludeClipRect( const Rectangle& rRect );
+ void MoveClipRegion( const Size& rSize );
+ void SetClipPath( const PolyPolygon& rPolyPoly, sal_Int32 nClippingMode, sal_Bool bIsMapped );
+ void UpdateClipRegion();
+
+ WinMtfOutput( GDIMetaFile& rGDIMetaFile );
+ virtual ~WinMtfOutput();
+};
+
+// -----------------------------------------------------------------------------
+
+class WinMtf
+{
+ protected:
+
+ WinMtfOutput* pOut; //
+ SvStream* pWMF; // Die einzulesende WMF/EMF-Datei
+
+ UINT32 nStartPos, nEndPos;
+ List aBmpSaveList;
+
+ FilterConfigItem* pFilterConfigItem;
+
+ com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator > xStatusIndicator;
+
+ // Sorgt dafuer, das aSampledBrush der aktuelle Brush des GDIMetaFiles ist.
+
+ Color ReadColor();
+ void Callback( USHORT nPercent );
+
+ WinMtf( WinMtfOutput* pOut, SvStream& rStreamWMF, FilterConfigItem* pConfigItem = NULL );
+ ~WinMtf();
+
+ public:
+
+};
+
+//============================ EMFReader ==================================
+
+class EnhWMFReader : public WinMtf
+{
+ sal_Bool bRecordPath;
+ sal_Int32 nRecordCount;
+
+ BOOL ReadHeader();
+ Rectangle ReadRectangle( INT32, INT32, INT32, INT32 ); // Liesst und konvertiert ein Rechteck
+ void ImplExtTextOut( BOOL bWideCharakter );
+
+public:
+ EnhWMFReader( SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile, FilterConfigItem* pConfigItem = NULL )
+ : WinMtf( new WinMtfOutput( rGDIMetaFile ), rStreamWMF, pConfigItem ), bRecordPath( sal_False ) {};
+ ~EnhWMFReader();
+
+ BOOL ReadEnhWMF();
+};
+
+//============================ WMFReader ==================================
+
+class WMFReader : public WinMtf
+{
+private:
+
+ VirtualDevice aVDev; // just for the purpose of "IsFontAvailable"
+ UINT16 nUnitsPerInch;
+ sal_uInt32 nRecSize;
+
+ sal_uInt32 nSkipActions;
+ sal_uInt32 nCurrentAction;
+ sal_uInt32 nUnicodeEscapeAction;
+
+ // Liesst den Kopf der WMF-Datei
+ BOOL ReadHeader();
+
+ // Liesst die Parameter des Rocords mit der Funktionsnummer nFunction.
+ void ReadRecordParams( USHORT nFunction );
+
+ Point ReadPoint(); // Liesst und konvertiert einen Punkt (erst X dann Y)
+ Point ReadYX(); // Liesst und konvertiert einen Punkt (erst Y dann X)
+ Rectangle ReadRectangle(); // Liesst und konvertiert ein Rechteck
+ Size ReadYXExt();
+ sal_Bool GetPlaceableBound( Rectangle& rSize, SvStream* pStrm );
+
+public:
+
+ WMFReader( SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile, FilterConfigItem* pConfigItem = NULL )
+ : WinMtf( new WinMtfOutput( rGDIMetaFile ), rStreamWMF, pConfigItem ) {};
+
+ // Liesst aus dem Stream eine WMF-Datei und fuellt das GDIMetaFile
+ void ReadWMF();
+};
+
+}
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/wmf/wmfwr.hxx b/binfilter/bf_svtools/source/filter.vcl/wmf/wmfwr.hxx
new file mode 100644
index 000000000000..2b1f207f3c4e
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/wmf/wmfwr.hxx
@@ -0,0 +1,220 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 _WMFWR_HXX
+#define _WMFWR_HXX
+
+#include <tools/bigint.hxx>
+#include <tools/debug.hxx>
+#include <vcl/metaact.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/gdimtf.hxx>
+#include <vcl/virdev.hxx>
+#include <bf_svtools/fltcall.hxx>
+
+class StarSymbolToMSMultiFont;
+
+namespace binfilter
+{
+
+// -----------------------------------------------------------------------------
+
+#define MAXOBJECTHANDLES 16
+
+// -----------------------------------------------------------------------------
+
+struct WMFWriterAttrStackMember
+{
+ struct WMFWriterAttrStackMember * pSucc;
+ Color aLineColor;
+ Color aFillColor;
+ Color aTextColor;
+ LineInfo aLineInfo;
+ TextAlign eTextAlign;
+ RasterOp eRasterOp;
+ Font aFont;
+ MapMode aMapMode;
+ Region aClipRegion;
+ sal_uInt16 nFlags;
+};
+
+// -------------
+// - WMFWriter -
+// -------------
+
+class WMFWriter
+{
+private:
+
+ BOOL bStatus;
+
+ ULONG nLastPercent; // Mit welcher Zahl pCallback zuletzt aufgerufen wurde.
+ FilterConfigItem* pFilterConfigItem;
+
+ com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator > xStatusIndicator;
+
+ SvStream* pWMF;
+ VirtualDevice* pVirDev;
+ StarSymbolToMSMultiFont *pConvert;
+ MapMode aTargetMapMode;
+ Size aTargetSize;
+ USHORT nTargetDivisor;
+
+ ULONG nMetafileHeaderPos;
+ sal_uInt32 nMaxRecordSize; // in Worten
+ ULONG nActRecordPos;
+
+ // Aktuelle Attribute im Quell-Metafile:
+ Color aSrcLineColor;
+ Color aSrcFillColor;
+ Color aSrcTextColor;
+ LineInfo aSrcLineInfo;
+ RasterOp eSrcRasterOp;
+ FontAlign eSrcTextAlign;
+ Font aSrcFont;
+ MapMode aSrcMapMode;
+ BOOL bSrcIsClipping;
+ Region aSrcClipRegion;
+ WMFWriterAttrStackMember * pAttrStack;
+
+ // Aktuelle Attribute im Ziel-Metafile:
+ Color aDstLineColor;
+ Color aDstFillColor;
+ Color aDstTextColor;
+ LineInfo aDstLineInfo;
+ RasterOp eDstROP2;
+ FontAlign eDstTextAlign;
+ Font aDstFont;
+
+ BOOL bDstIsClipping; // ???: derzeit unberuecksichtigt
+ Region aDstClipRegion; // ???: derzeit unberuecksichtigt
+ BOOL bHandleAllocated[MAXOBJECTHANDLES]; // Welche Handles vergeben sind
+ USHORT nDstPenHandle,nDstFontHandle,nDstBrushHandle; // Welche Handles die jeweiligen
+ // Selected-Objects besitzen
+ // 0xffff = keines:
+
+ // Damit nicht bei jeder Operation alle Attribute verglichen werden muessen:
+
+ ULONG nNumberOfActions; // Anzahl der Actions im GDIMetafile
+ ULONG nNumberOfBitmaps; // Anzahl der Bitmaps
+ ULONG nWrittenActions; // Anzahl der bereits verarbeiteten Actions beim Schreiben der Orders
+ ULONG nWrittenBitmaps; // Anzahl der bereits geschriebenen Bitmaps
+ ULONG nActBitmapPercent; // Wieviel Prozent die naechste Bitmap schon geschrieben ist.
+
+ void MayCallback();
+ // Berechnet anhand der obigen 5 Parameter eine Prozentzahl
+ // und macht dann ggf. einen Callback. Setzt bStatus auf FALSE wenn User abbrechen
+ // moechte.
+
+ void CountActionsAndBitmaps(const GDIMetaFile & rMTF);
+ // Zaehlt die Bitmaps und Actions (nNumberOfActions und nNumberOfBitmaps muessen
+ // zu Anfang auf 0 gesetzt werden, weil diese Methode rekursiv ist)
+
+ void WritePointXY(const Point & rPoint);
+ void WritePointYX(const Point & rPoint);
+ sal_Int32 ScaleWidth( sal_Int32 nDX );
+ void WriteSize(const Size & rSize);
+ void WriteHeightWidth(const Size & rSize);
+ void WriteRectangle(const Rectangle & rRect);
+ void WriteColor(const Color & rColor);
+
+ void WriteRecordHeader(sal_uInt32 nSizeWords, sal_uInt16 nType);
+ // nSizeWords ist die Groesse des gesammten Records in Anzahl Worte.
+ // Wenn nSizeWords unbekannt ist, dann 0 einsetzen (siehe UpdateRecordHeader()).
+
+ void UpdateRecordHeader();
+ // berichtig die Groesse des Records nach dem Schreiben der Parameter, wenn
+ // nSizeWords bei Aufruf von WriteRecordHeader(..) unbekannt war.
+ // fuegt ggf. noch ein BYTE 0 ein damit Anzahl Bytes immer gerade.
+
+ void WMFRecord_Arc(const Rectangle & rRect, const Point & rStartPt, const Point & rEndPt);
+ void WMFRecord_Chord(const Rectangle & rRect, const Point & rStartPt, const Point & rEndPt);
+ void WMFRecord_CreateBrushIndirect(const Color& rColor);
+ void WMFRecord_CreateFontIndirect(const Font & rFont);
+ void WMFRecord_CreatePenIndirect(const Color& rColor, const LineInfo& rLineInfo );
+ void WMFRecord_DeleteObject(USHORT nObjectHandle);
+ void WMFRecord_Ellipse(const Rectangle & rRect);
+ void WMFRecord_Escape( sal_uInt32 nEsc, sal_uInt32 nLen, const sal_Int8* pData );
+ sal_Bool WMFRecord_Escape_Unicode( const Point& rPoint, const String& rStr, const sal_Int32 * pDXAry );
+ void WMFRecord_ExtTextOut(const Point & rPoint, const String & rString, const sal_Int32 * pDXAry);
+
+ void TrueExtTextOut(const Point & rPoint, const String & rString,
+ const ByteString & rByteString, const sal_Int32 * pDXAry);
+ void TrueTextOut(const Point & rPoint, const ByteString& rString);
+ void WMFRecord_LineTo(const Point & rPoint);
+ void WMFRecord_MoveTo(const Point & rPoint);
+ void WMFRecord_Pie(const Rectangle & rRect, const Point & rStartPt, const Point & rEndPt);
+ void WMFRecord_Polygon(const Polygon & rPoly);
+ void WMFRecord_PolyLine(const Polygon & rPoly);
+ void WMFRecord_PolyPolygon(const PolyPolygon & rPolyPoly);
+ void WMFRecord_Rectangle(const Rectangle & rRect);
+ void WMFRecord_RestoreDC();
+ void WMFRecord_RoundRect(const Rectangle & rRect, long nHorzRound, long nVertRound);
+ void WMFRecord_SaveDC();
+ void WMFRecord_SelectObject(USHORT nObjectHandle);
+ void WMFRecord_SetBkMode(BOOL bTransparent);
+ void WMFRecord_SetStretchBltMode();
+ void WMFRecord_SetPixel(const Point & rPoint, const Color & rColor);
+ void WMFRecord_SetROP2(RasterOp eROP);
+ void WMFRecord_SetTextAlign(FontAlign eFontAlign);
+ void WMFRecord_SetTextColor(const Color & rColor);
+ void WMFRecord_SetWindowExt(const Size & rSize);
+ void WMFRecord_SetWindowOrg(const Point & rPoint);
+ void WMFRecord_StretchDIB(const Point & rPoint, const Size & rSize, const Bitmap & rBitmap, sal_uInt32 nROP = 0UL );
+ void WMFRecord_TextOut(const Point & rPoint, const String & rString);
+ void WMFRecord_EndOfFile();
+ void WMFRecord_IntersectClipRect( const Rectangle& rRect);
+
+ USHORT AllocHandle();
+ void FreeHandle(USHORT nObjectHandle);
+ void CreateSelectDeletePen( const Color& rColor, const LineInfo& rLineInfo );
+ void CreateSelectDeleteFont(const Font & rFont);
+ void CreateSelectDeleteBrush(const Color& rColor);
+
+ void SetLineAndFillAttr();
+ void SetAllAttr();
+
+ void WriteRecords(const GDIMetaFile & rMTF);
+
+ void WriteHeader(const GDIMetaFile & rMTF, BOOL bPlaceable);
+ void UpdateHeader();
+
+ USHORT CalcSaveTargetMapMode(MapMode& rMapMode, const Size& rPrefSize);
+
+public:
+
+ WMFWriter() {}
+
+ BOOL WriteWMF(const GDIMetaFile & rMTF, SvStream & rTargetStream, FilterConfigItem* pFilterConfigItem, BOOL bPlaceable=TRUE);
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/inc/fsfactory.hxx b/binfilter/bf_svtools/source/inc/fsfactory.hxx
new file mode 100644
index 000000000000..a27b174bb87a
--- /dev/null
+++ b/binfilter/bf_svtools/source/inc/fsfactory.hxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 __FSFACTORY_HXX_
+#define __FSACTORY_HXX_
+
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <cppuhelper/implbase2.hxx>
+
+namespace binfilter
+{
+
+class FSStorage;
+
+class FSStorageFactory : public ::cppu::WeakImplHelper2< ::com::sun::star::lang::XSingleServiceFactory,
+ ::com::sun::star::lang::XServiceInfo >
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
+
+public:
+ FSStorageFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory )
+ : m_xFactory( xFactory )
+ {
+ OSL_ENSURE( xFactory.is(), "No service manager is provided!\n" );
+ }
+
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
+ impl_staticGetSupportedServiceNames();
+
+ static ::rtl::OUString SAL_CALL impl_staticGetImplementationName();
+
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ impl_staticCreateSelfInstance(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
+
+
+ // XSingleServiceFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException);
+
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/inc/poolio.hxx b/binfilter/bf_svtools/source/inc/poolio.hxx
new file mode 100644
index 000000000000..052865b77cfe
--- /dev/null
+++ b/binfilter/bf_svtools/source/inc/poolio.hxx
@@ -0,0 +1,207 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/brdcst.hxx>
+
+
+#ifndef DELETEZ
+#define DELETEZ(pPtr) { delete pPtr; pPtr = 0; }
+#endif
+
+namespace binfilter
+{
+
+struct SfxPoolVersion_Impl
+{
+ USHORT _nVer;
+ USHORT _nStart, _nEnd;
+ USHORT* _pMap;
+
+ SfxPoolVersion_Impl( USHORT nVer, USHORT nStart, USHORT nEnd,
+ USHORT *pMap )
+ : _nVer( nVer ),
+ _nStart( nStart ),
+ _nEnd( nEnd ),
+ _pMap( pMap )
+ {}
+ SfxPoolVersion_Impl( const SfxPoolVersion_Impl &rOrig )
+ : _nVer( rOrig._nVer ),
+ _nStart( rOrig._nStart ),
+ _nEnd( rOrig._nEnd ),
+ _pMap( rOrig._pMap )
+ {}
+};
+
+SV_DECL_PTRARR( SfxPoolItemArrayBase_Impl, SfxPoolItem*, 0, 5 )
+SV_DECL_PTRARR_DEL( SfxPoolVersionArr_Impl, SfxPoolVersion_Impl*, 0, 2 )
+
+struct SfxPoolItemArray_Impl: public SfxPoolItemArrayBase_Impl
+{
+ USHORT nFirstFree;
+
+ SfxPoolItemArray_Impl (USHORT nInitSize = 0)
+ : SfxPoolItemArrayBase_Impl( nInitSize ),
+ nFirstFree( 0 )
+ {}
+};
+
+class SfxStyleSheetIterator;
+
+struct SfxItemPool_Impl
+{
+ SfxBroadcaster aBC;
+ SfxPoolItemArray_Impl** ppPoolItems;
+ SfxPoolVersionArr_Impl aVersions;
+ USHORT nVersion;
+ USHORT nLoadingVersion;
+ USHORT nInitRefCount; // 1, beim Laden ggf. 2
+ USHORT nVerStart, nVerEnd; // WhichRange in Versions
+ USHORT nStoringStart, nStoringEnd; // zu speichernder Range
+ BYTE nMajorVer, nMinorVer; // Pool selbst
+ SfxMapUnit eDefMetric;
+ FASTBOOL bInSetItem;
+ FASTBOOL bStreaming; // in Load() bzw. Store()
+
+ SfxItemPool_Impl( USHORT nStart, USHORT nEnd )
+ : ppPoolItems (new SfxPoolItemArray_Impl*[ nEnd - nStart + 1])
+ {
+ memset( ppPoolItems, 0, sizeof( SfxPoolItemArray_Impl* ) * ( nEnd - nStart + 1) );
+ }
+
+ ~SfxItemPool_Impl()
+ {
+ delete[] ppPoolItems;
+ }
+
+ void DeleteItems()
+ {
+ delete[] ppPoolItems; ppPoolItems = 0;
+ }
+};
+
+// -----------------------------------------------------------------------
+
+// IBM-C-Set mag keine doppelten Defines
+#ifdef DBG
+# undef DBG
+#endif
+
+#if defined(DBG_UTIL) && defined(MSC)
+#define SFX_TRACE(s,p) \
+ { \
+ ByteString aPtr(RTL_CONSTASCII_STRINGPARAM("0x0000:0x0000")); \
+ _snprintf(const_cast< sal_Char *>(aPtr.GetBuffer()), aPtr.Len(), \
+ "%lp", p ); \
+ aPtr.Insert(s, 0); \
+ DbgTrace( aPtr.GetBuffer() ); \
+ }
+#define DBG(x) x
+#else
+#define SFX_TRACE(s,p)
+#define DBG(x)
+#endif
+
+#define CHECK_FILEFORMAT( rStream, nTag ) \
+ { USHORT nFileTag; \
+ rStream >> nFileTag; \
+ if ( nTag != nFileTag ) \
+ { \
+ DBG_ERROR( #nTag ); /*! s.u. */ \
+ /*! error-code setzen und auswerten! */ \
+ (rStream).SetError(SVSTREAM_FILEFORMAT_ERROR); \
+ pImp->bStreaming = FALSE; \
+ return rStream; \
+ } \
+ }
+
+#define CHECK_FILEFORMAT_RELEASE( rStream, nTag, pPointer ) \
+ { USHORT nFileTag; \
+ rStream >> nFileTag; \
+ if ( nTag != nFileTag ) \
+ { \
+ DBG_ERROR( #nTag ); /*! s.u. */ \
+ /*! error-code setzen und auswerten! */ \
+ (rStream).SetError(SVSTREAM_FILEFORMAT_ERROR); \
+ pImp->bStreaming = FALSE; \
+ delete pPointer; \
+ return rStream; \
+ } \
+ }
+
+#define CHECK_FILEFORMAT2( rStream, nTag1, nTag2 ) \
+ { USHORT nFileTag; \
+ rStream >> nFileTag; \
+ if ( nTag1 != nFileTag && nTag2 != nFileTag ) \
+ { \
+ DBG_ERROR( #nTag1 ); /*! s.u. */ \
+ /*! error-code setzen und auswerten! */ \
+ (rStream).SetError(SVSTREAM_FILEFORMAT_ERROR); \
+ pImp->bStreaming = FALSE; \
+ return rStream; \
+ } \
+ }
+
+#define SFX_ITEMPOOL_VER_MAJOR BYTE(2)
+#define SFX_ITEMPOOL_VER_MINOR BYTE(0)
+
+#define SFX_ITEMPOOL_TAG_STARTPOOL_4 USHORT(0x1111)
+#define SFX_ITEMPOOL_TAG_STARTPOOL_5 USHORT(0xBBBB)
+#define SFX_ITEMPOOL_TAG_ITEMPOOL USHORT(0xAAAA)
+#define SFX_ITEMPOOL_TAG_ITEMS USHORT(0x2222)
+#define SFX_ITEMPOOL_TAG_ITEM USHORT(0x7777)
+#define SFX_ITEMPOOL_TAG_SIZES USHORT(0x3333)
+#define SFX_ITEMPOOL_TAG_DEFAULTS USHORT(0x4444)
+#define SFX_ITEMPOOL_TAG_VERSIONMAP USHORT(0x5555)
+#define SFX_ITEMPOOL_TAG_HEADER USHORT(0x6666)
+#define SFX_ITEMPOOL_TAG_ENDPOOL USHORT(0xEEEE)
+#define SFX_ITEMPOOL_TAG_TRICK4OLD USHORT(0xFFFF)
+
+#define SFX_ITEMPOOL_REC BYTE(0x01)
+#define SFX_ITEMPOOL_REC_HEADER BYTE(0x10)
+#define SFX_ITEMPOOL_REC_VERSIONMAP USHORT(0x0020)
+#define SFX_ITEMPOOL_REC_WHICHIDS USHORT(0x0030)
+#define SFX_ITEMPOOL_REC_ITEMS USHORT(0x0040)
+#define SFX_ITEMPOOL_REC_DEFAULTS USHORT(0x0050)
+
+#define SFX_ITEMSET_REC BYTE(0x02)
+
+#define SFX_STYLES_REC BYTE(0x03)
+#define SFX_STYLES_REC_HEADER USHORT(0x0010)
+#define SFX_STYLES_REC_STYLES USHORT(0x0020)
+
+//========================================================================
+
+inline USHORT SfxItemPool::GetIndex_Impl(USHORT nWhich) const
+{
+ DBG_CHKTHIS(SfxItemPool, 0);
+ DBG_ASSERT(nWhich >= nStart && nWhich <= nEnd, "Which-Id nicht im Pool-Bereich");
+ return nWhich - nStart;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items/makefile.mk b/binfilter/bf_svtools/source/items/makefile.mk
new file mode 100644
index 000000000000..7f3a2e51b3b9
--- /dev/null
+++ b/binfilter/bf_svtools/source/items/makefile.mk
@@ -0,0 +1,58 @@
+#*************************************************************************
+#
+# DO NOT ALTER 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=binfilter
+TARGET=items
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=\
+ $(SLO)$/svt_aeitem.obj \
+ $(SLO)$/svt_eitem.obj \
+ $(SLO)$/svt_flagitem.obj \
+ $(SLO)$/svt_globalnameitem.obj \
+ $(SLO)$/svt_intitem.obj \
+ $(SLO)$/svt_macitem.obj \
+ $(SLO)$/svt_poolcach.obj \
+ $(SLO)$/svt_ptitem.obj \
+ $(SLO)$/svt_rectitem.obj \
+ $(SLO)$/svt_rngitem.obj \
+ $(SLO)$/svt_stritem.obj \
+ $(SLO)$/svt_style.obj \
+ $(SLO)$/svt_szitem.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/binfilter/bf_svtools/source/items/svt_aeitem.cxx b/binfilter/bf_svtools/source/items/svt_aeitem.cxx
new file mode 100644
index 000000000000..ffc45cd7b40f
--- /dev/null
+++ b/binfilter/bf_svtools/source/items/svt_aeitem.cxx
@@ -0,0 +1,249 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/string.hxx>
+
+#define _SVSTDARR_USHORTS
+#include <bf_svtools/svstdarr.hxx>
+#include <bf_svtools/svarray.hxx>
+#include <bf_svtools/aeitem.hxx>
+
+namespace binfilter
+{
+
+// STATIC DATA -----------------------------------------------------------
+
+DBG_NAME(SfxAllEnumItem)
+
+TYPEINIT1_AUTOFACTORY(SfxAllEnumItem, SfxEnumItem)
+
+// -----------------------------------------------------------------------
+
+struct SfxAllEnumValue_Impl
+{
+ USHORT nValue;
+ XubString aText;
+};
+
+SV_DECL_PTRARR_DEL(SfxAllEnumValueArr, SfxAllEnumValue_Impl*, 0, 8)
+SV_IMPL_PTRARR(SfxAllEnumValueArr, SfxAllEnumValue_Impl*)
+
+// -----------------------------------------------------------------------
+
+SfxAllEnumItem::SfxAllEnumItem() :
+ SfxEnumItem(),
+ pValues( 0 ),
+ pDisabledValues( 0 )
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxAllEnumItem::SfxAllEnumItem( USHORT which, SvStream &rStream ):
+ SfxEnumItem(which, rStream),
+ pValues( 0 ),
+ pDisabledValues( 0 )
+{
+ DBG_CTOR(SfxAllEnumItem, 0);
+ InsertValue( GetValue() );
+}
+
+// -----------------------------------------------------------------------
+
+
+SfxAllEnumItem::SfxAllEnumItem(USHORT which):
+ SfxEnumItem(which, 0),
+ pValues( 0 ),
+ pDisabledValues( 0 )
+{
+ DBG_CTOR(SfxAllEnumItem, 0);
+}
+
+
+// -----------------------------------------------------------------------
+
+SfxAllEnumItem::SfxAllEnumItem(const SfxAllEnumItem &rCopy):
+ SfxEnumItem(rCopy),
+ pValues(0),
+ pDisabledValues( 0 )
+{
+ DBG_CTOR(SfxAllEnumItem, 0);
+ if ( !rCopy.pValues )
+ return;
+
+ pValues = new SfxAllEnumValueArr;
+
+ for ( USHORT nPos = 0; nPos < rCopy.pValues->Count(); ++nPos )
+ {
+ SfxAllEnumValue_Impl *pVal = new SfxAllEnumValue_Impl;
+ pVal->nValue = rCopy.pValues->GetObject(nPos)->nValue;
+ pVal->aText = rCopy.pValues->GetObject(nPos)->aText;
+ const SfxAllEnumValue_Impl *pTemp = pVal;
+ pValues->Insert( pTemp, nPos );
+ }
+
+ if( rCopy.pDisabledValues )
+ {
+ pDisabledValues = new SvUShorts;
+ for ( USHORT nPos = 0; nPos < rCopy.pDisabledValues->Count(); ++nPos )
+ {
+ pDisabledValues->Insert( rCopy.pDisabledValues->GetObject(nPos),
+ nPos );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+SfxAllEnumItem::~SfxAllEnumItem()
+{
+ DBG_DTOR(SfxAllEnumItem, 0);
+ delete pValues;
+ delete pDisabledValues;
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SfxAllEnumItem::GetValueCount() const
+{
+ DBG_CHKTHIS(SfxAllEnumItem, 0);
+ return pValues ? pValues->Count() : 0;
+}
+
+// -----------------------------------------------------------------------
+
+XubString SfxAllEnumItem::GetValueTextByPos( USHORT nPos ) const
+{
+ DBG_CHKTHIS(SfxAllEnumItem, 0);
+ DBG_ASSERT( pValues && nPos < pValues->Count(), "enum overflow" );
+ return pValues->GetObject(nPos)->aText;
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SfxAllEnumItem::GetValueByPos( USHORT nPos ) const
+{
+ DBG_CHKTHIS(SfxAllEnumItem, 0);
+ DBG_ASSERT( pValues && nPos < pValues->Count(), "enum overflow" );
+ return pValues->GetObject(nPos)->nValue;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxAllEnumItem::Clone( SfxItemPool * ) const
+{
+ DBG_CHKTHIS(SfxAllEnumItem, 0);
+ return new SfxAllEnumItem(*this);
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxAllEnumItem::Create( SvStream & rStream, USHORT ) const
+{
+ DBG_CHKTHIS(SfxAllEnumItem, 0);
+ return new SfxAllEnumItem( Which(), rStream );
+}
+
+
+// -----------------------------------------------------------------------
+
+USHORT SfxAllEnumItem::_GetPosByValue( USHORT nVal ) const
+
+/* [Beschreibung]
+
+ Im Ggs. zu <SfxEnumItemInterface::GetPosByValue(USHORT)const> liefert
+ diese interne Methode bei nicht vorhandenen Values die Position,
+ an der der Wert liegen w"urde.
+*/
+
+{
+ DBG_CHKTHIS(SfxAllEnumItem, 0);
+
+ if ( !pValues )
+ return 0;
+
+ //!O: binaere Suche oder SortArray verwenden
+ USHORT nPos;
+ for ( nPos = 0; nPos < pValues->Count(); ++nPos )
+ if ( pValues->GetObject(nPos)->nValue >= nVal )
+ return nPos;
+ return nPos;
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SfxAllEnumItem::GetPosByValue( USHORT nValue ) const
+
+/* [Beschreibung]
+
+ Liefert im Gegensatz zu <SfxEnumItemInterface::GetPosByValue(USHORT)const>
+ immer nValue zur"uck, solange nicht mindestens ein Wert mit einer der
+ Methoden <SfxAllEnumItem::InsertValue()> eingef"ugt wurde.
+*/
+
+{
+ DBG_CHKTHIS(SfxAllEnumItem, 0);
+
+ if ( !pValues || !pValues->Count() )
+ return nValue;
+
+ return SfxEnumItem::GetPosByValue( nValue );
+}
+
+// -----------------------------------------------------------------------
+
+void SfxAllEnumItem::InsertValue( USHORT nValue )
+{
+ DBG_CHKTHIS(SfxAllEnumItem, 0);
+ SfxAllEnumValue_Impl *pVal = new SfxAllEnumValue_Impl;
+ pVal->nValue = nValue;
+ pVal->aText = XubString::CreateFromInt32( nValue );
+ const SfxAllEnumValue_Impl *pTemp = pVal;
+ if ( !pValues )
+ pValues = new SfxAllEnumValueArr;
+
+ pValues->Insert( pTemp, _GetPosByValue(nValue) ); //! doppelte?!
+}
+
+BOOL SfxAllEnumItem::IsEnabled( USHORT nValue ) const
+{
+ if ( pDisabledValues )
+ {
+ for ( USHORT i=0; i<pDisabledValues->Count(); i++ )
+ if ( (*pDisabledValues)[i] == nValue )
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items/svt_eitem.cxx b/binfilter/bf_svtools/source/items/svt_eitem.cxx
new file mode 100644
index 000000000000..3f3377a40187
--- /dev/null
+++ b/binfilter/bf_svtools/source/items/svt_eitem.cxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/eitem.hxx>
+
+namespace binfilter
+{
+
+//============================================================================
+//
+// class SfxEnumItem
+//
+//============================================================================
+
+TYPEINIT1(SfxEnumItem, CntEnumItem);
+
+//============================================================================
+//
+// class SfxBoolItem
+//
+//============================================================================
+
+TYPEINIT1_AUTOFACTORY(SfxBoolItem, CntBoolItem);
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items/svt_flagitem.cxx b/binfilter/bf_svtools/source/items/svt_flagitem.cxx
new file mode 100644
index 000000000000..23fbab33427f
--- /dev/null
+++ b/binfilter/bf_svtools/source/items/svt_flagitem.cxx
@@ -0,0 +1,149 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/flagitem.hxx>
+
+#include <bf_svtools/poolitem.hxx>
+
+#include <tools/stream.hxx>
+
+namespace binfilter
+{
+
+// STATIC DATA -----------------------------------------------------------
+
+DBG_NAME(SfxFlagItem)
+
+USHORT nSfxFlagVal[16] =
+{
+ 0x0001, 0x0002, 0x0004, 0x0008,
+ 0x0010, 0x0020, 0x0040, 0x0080,
+ 0x0100, 0x0200, 0x0400, 0x0800,
+ 0x1000, 0x2000, 0x4000, 0x8000
+};
+
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1(SfxFlagItem, SfxPoolItem);
+
+// -----------------------------------------------------------------------
+
+SfxFlagItem::SfxFlagItem( USHORT nW, USHORT nV ) :
+ SfxPoolItem( nW ),
+ nVal(nV)
+{
+ DBG_CTOR(SfxFlagItem, 0);
+}
+
+// -----------------------------------------------------------------------
+
+SfxFlagItem::SfxFlagItem( const SfxFlagItem& rItem ) :
+ SfxPoolItem( rItem ),
+ nVal( rItem.nVal )
+{
+ DBG_CTOR(SfxFlagItem, 0);
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SfxFlagItem::Store(SvStream &rStream, USHORT) const
+{
+ DBG_CHKTHIS(SfxFlagItem, 0);
+ rStream << nVal;
+ return rStream;
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemPresentation SfxFlagItem::GetPresentation
+(
+ SfxItemPresentation /*ePresentation*/,
+ SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/,
+ XubString& rText,
+ const ::IntlWrapper *
+) const
+{
+ DBG_CHKTHIS(SfxFlagItem, 0);
+ rText.Erase();
+ for ( BYTE nFlag = 0; nFlag < GetFlagCount(); ++nFlag )
+ rText += XubString::CreateFromInt32( GetFlag(nFlag) );
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+// -----------------------------------------------------------------------
+
+XubString SfxFlagItem::GetFlagText( BYTE ) const
+{
+ DBG_CHKTHIS(SfxFlagItem, 0);
+ DBG_WARNING( "calling GetValueText(USHORT) on SfxFlagItem -- overload!" );
+ return XubString();
+}
+
+// -----------------------------------------------------------------------
+
+BYTE SfxFlagItem::GetFlagCount() const
+{
+ DBG_CHKTHIS(SfxFlagItem, 0);
+ DBG_WARNING( "calling GetValueText(USHORT) on SfxFlagItem -- overload!" );
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxFlagItem::Create(SvStream &, USHORT) const
+{
+ DBG_CHKTHIS(SfxFlagItem, 0);
+ DBG_WARNING( "calling Create() on SfxFlagItem -- overload!" );
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+int SfxFlagItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_CHKTHIS(SfxFlagItem, 0);
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+ return (((SfxFlagItem&)rItem).nVal == nVal);
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxFlagItem::Clone(SfxItemPool *) const
+{
+ DBG_CHKTHIS(SfxFlagItem, 0);
+ return new SfxFlagItem( *this );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items/svt_globalnameitem.cxx b/binfilter/bf_svtools/source/items/svt_globalnameitem.cxx
new file mode 100644
index 000000000000..7a486da2276a
--- /dev/null
+++ b/binfilter/bf_svtools/source/items/svt_globalnameitem.cxx
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/script/XTypeConverter.hpp>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include <comphelper/processfactory.hxx>
+
+#include <bf_svtools/globalnameitem.hxx>
+
+// STATIC DATA -----------------------------------------------------------
+
+namespace binfilter
+{
+
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1_AUTOFACTORY(SfxGlobalNameItem, SfxPoolItem);
+
+// -----------------------------------------------------------------------
+
+SfxGlobalNameItem::SfxGlobalNameItem()
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxGlobalNameItem::~SfxGlobalNameItem()
+{
+}
+
+// -----------------------------------------------------------------------
+
+int SfxGlobalNameItem::operator==( const SfxPoolItem& rItem ) const
+{
+ return ((SfxGlobalNameItem&)rItem).m_aName == m_aName;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxGlobalNameItem::Clone(SfxItemPool *) const
+{
+ return new SfxGlobalNameItem( *this );
+}
+
+//----------------------------------------------------------------------------
+// virtual
+bool SfxGlobalNameItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE )
+{
+ com::sun::star::uno::Reference < com::sun::star::script::XTypeConverter > xConverter
+ ( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.script.Converter")),
+ com::sun::star::uno::UNO_QUERY );
+ com::sun::star::uno::Sequence< sal_Int8 > aSeq;
+ com::sun::star::uno::Any aNew;
+
+ try { aNew = xConverter->convertTo( rVal, ::getCppuType((const com::sun::star::uno::Sequence < sal_Int8 >*)0) ); }
+ catch (com::sun::star::uno::Exception&) {}
+ aNew >>= aSeq;
+ if ( aSeq.getLength() == 16 )
+ {
+ m_aName.MakeFromMemory( (void*) aSeq.getConstArray() );
+ return true;
+ }
+
+ DBG_ERROR( "SfxGlobalNameItem::PutValue - Wrong type!" );
+ return false;
+}
+
+//----------------------------------------------------------------------------
+// virtual
+bool SfxGlobalNameItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE ) const
+{
+ ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( 16 );
+ void* pData = ( void* ) &m_aName.GetCLSID();
+ memcpy( aSeq.getArray(), pData, 16 );
+ rVal <<= aSeq;
+ return true;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items/svt_intitem.cxx b/binfilter/bf_svtools/source/items/svt_intitem.cxx
new file mode 100644
index 000000000000..80a0018128f3
--- /dev/null
+++ b/binfilter/bf_svtools/source/items/svt_intitem.cxx
@@ -0,0 +1,308 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/intitem.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <tools/bigint.hxx>
+#include <tools/stream.hxx>
+
+#include <bf_svtools/metitem.hxx>
+
+namespace binfilter
+{
+
+CntByteItem::~CntByteItem()
+{
+ DBG_DTOR(CntByteItem, 0);
+}
+
+CntUInt16Item::~CntUInt16Item()
+{
+ DBG_DTOR(CntUInt16Item, 0);
+}
+
+CntInt32Item::~CntInt32Item()
+{
+ DBG_DTOR(CntInt32Item, 0);
+}
+
+CntUInt32Item::~CntUInt32Item() { DBG_DTOR(CntUInt32Item, 0); }
+
+SfxPoolItem * SfxByteItem::Clone(SfxItemPool *) const
+{ return new SfxByteItem(*this); }
+
+SfxInt16Item::~SfxInt16Item() { DBG_DTOR(SfxInt16Item, 0); }
+
+SfxPoolItem * SfxUInt16Item::Create(SvStream & rStream, USHORT) const
+{ return new SfxUInt16Item(Which(), rStream); }
+
+SfxPoolItem * SfxUInt16Item::Clone(SfxItemPool *) const
+{ return new SfxUInt16Item(*this); }
+
+SfxPoolItem * SfxInt32Item::Create(SvStream & rStream, USHORT) const
+{ return new SfxInt32Item(Which(), rStream); }
+
+SfxPoolItem * SfxInt32Item::Clone(SfxItemPool * ) const
+{ return new SfxInt32Item(*this); }
+
+SfxPoolItem * SfxUInt32Item::Create(SvStream & rStream, USHORT) const
+{ return new SfxUInt32Item(Which(), rStream); }
+
+SfxPoolItem * SfxUInt32Item::Clone(SfxItemPool * ) const
+{ return new SfxUInt32Item(*this); }
+
+//============================================================================
+//
+// class SfxByteItem
+//
+//============================================================================
+
+TYPEINIT1_AUTOFACTORY(SfxByteItem, CntByteItem);
+
+//============================================================================
+// virtual
+SfxPoolItem * SfxByteItem::Create(SvStream & rStream, USHORT) const
+{
+ short nValue = 0;
+ rStream >> nValue;
+ return new SfxByteItem(Which(), BYTE(nValue));
+}
+
+//============================================================================
+//
+// class SfxInt16Item
+//
+//============================================================================
+
+DBG_NAME(SfxInt16Item);
+
+//============================================================================
+TYPEINIT1_AUTOFACTORY(SfxInt16Item, SfxPoolItem);
+
+//============================================================================
+SfxInt16Item::SfxInt16Item(USHORT which, SvStream & rStream):
+ SfxPoolItem(which)
+{
+ DBG_CTOR(SfxInt16Item, 0);
+ short nTheValue = 0;
+ rStream >> nTheValue;
+ m_nValue = nTheValue;
+}
+
+//============================================================================
+// virtual
+int SfxInt16Item::operator ==(const SfxPoolItem & rItem) const
+{
+ DBG_CHKTHIS(SfxInt16Item, 0);
+ DBG_ASSERT(SfxPoolItem::operator ==(rItem), "unequal type");
+ return m_nValue == SAL_STATIC_CAST(const SfxInt16Item *, &rItem)->
+ m_nValue;
+}
+
+//============================================================================
+// virtual
+int SfxInt16Item::Compare(const SfxPoolItem & rWith) const
+{
+ DBG_CHKTHIS(SfxInt16Item, 0);
+ DBG_ASSERT(SfxPoolItem::operator ==(rWith), "unequal type");
+ return SAL_STATIC_CAST(const SfxInt16Item *, &rWith)->m_nValue
+ < m_nValue ?
+ -1 :
+ SAL_STATIC_CAST(const SfxInt16Item *, &rWith)->m_nValue
+ == m_nValue ?
+ 0 : 1;
+}
+
+//============================================================================
+// virtual
+SfxItemPresentation SfxInt16Item::GetPresentation(SfxItemPresentation,
+ SfxMapUnit, SfxMapUnit,
+ XubString & rText,
+ const ::IntlWrapper *) const
+{
+ DBG_CHKTHIS(SfxInt16Item, 0);
+ rText = UniString::CreateFromInt32(m_nValue);
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+
+//============================================================================
+// virtual
+bool SfxInt16Item::QueryValue(::com::sun::star::uno::Any& rVal, BYTE) const
+{
+ sal_Int16 nValue = m_nValue;
+ rVal <<= nValue;
+ return true;
+}
+
+//============================================================================
+// virtual
+bool SfxInt16Item::PutValue(const com::sun::star::uno::Any& rVal, BYTE )
+{
+ sal_Int16 nValue = sal_Int16();
+ if (rVal >>= nValue)
+ {
+ m_nValue = nValue;
+ return true;
+ }
+
+ DBG_ERROR( "SfxInt16Item::PutValue - Wrong type!" );
+ return false;
+}
+
+//============================================================================
+// virtual
+SfxPoolItem * SfxInt16Item::Create(SvStream & rStream, USHORT) const
+{
+ DBG_CHKTHIS(SfxInt16Item, 0);
+ return new SfxInt16Item(Which(), rStream);
+}
+
+//============================================================================
+// virtual
+SvStream & SfxInt16Item::Store(SvStream & rStream, USHORT) const
+{
+ DBG_CHKTHIS(SfxInt16Item, 0);
+ rStream << short(m_nValue);
+ return rStream;
+}
+
+//============================================================================
+SfxPoolItem * SfxInt16Item::Clone(SfxItemPool *) const
+{
+ DBG_CHKTHIS(SfxInt16Item, 0);
+ return new SfxInt16Item(*this);
+}
+
+//============================================================================
+INT16 SfxInt16Item::GetMin() const
+{
+ DBG_CHKTHIS(SfxInt16Item, 0);
+ return -32768;
+}
+
+//============================================================================
+INT16 SfxInt16Item::GetMax() const
+{
+ DBG_CHKTHIS(SfxInt16Item, 0);
+ return 32767;
+}
+
+//============================================================================
+SfxFieldUnit SfxInt16Item::GetUnit() const
+{
+ DBG_CHKTHIS(SfxInt16Item, 0);
+ return SFX_FUNIT_NONE;
+}
+
+//============================================================================
+//
+// class SfxUInt16Item
+//
+//============================================================================
+
+TYPEINIT1_AUTOFACTORY(SfxUInt16Item, CntUInt16Item);
+
+
+//============================================================================
+//
+// class SfxInt32Item
+//
+//============================================================================
+
+TYPEINIT1_AUTOFACTORY(SfxInt32Item, CntInt32Item);
+
+
+//============================================================================
+//
+// class SfxUInt32Item
+//
+//============================================================================
+
+TYPEINIT1_AUTOFACTORY(SfxUInt32Item, CntUInt32Item);
+
+
+//============================================================================
+//
+// class SfxMetricItem
+//
+//============================================================================
+
+DBG_NAME(SfxMetricItem);
+
+//============================================================================
+TYPEINIT1_AUTOFACTORY(SfxMetricItem, SfxInt32Item);
+
+//============================================================================
+SfxMetricItem::SfxMetricItem(USHORT which, UINT32 nValue):
+ SfxInt32Item(which, nValue)
+{
+ DBG_CTOR(SfxMetricItem, 0);
+}
+
+//============================================================================
+SfxMetricItem::SfxMetricItem(USHORT which, SvStream & rStream):
+ SfxInt32Item(which, rStream)
+{
+ DBG_CTOR(SfxMetricItem, 0);
+}
+
+//============================================================================
+SfxMetricItem::SfxMetricItem(const SfxMetricItem & rItem):
+ SfxInt32Item(rItem)
+{
+ DBG_CTOR(SfxMetricItem, 0);
+}
+
+//============================================================================
+// virtual
+int SfxMetricItem::ScaleMetrics(long nMult, long nDiv)
+{
+ BigInt aTheValue(GetValue());
+ aTheValue *= nMult;
+ aTheValue += nDiv / 2;
+ aTheValue /= nDiv;
+ SetValue(aTheValue);
+ return 1;
+}
+
+//============================================================================
+// virtual
+int SfxMetricItem::HasMetrics() const
+{
+ return 1;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items/svt_macitem.cxx b/binfilter/bf_svtools/source/items/svt_macitem.cxx
new file mode 100644
index 000000000000..92d90e78ab55
--- /dev/null
+++ b/binfilter/bf_svtools/source/items/svt_macitem.cxx
@@ -0,0 +1,275 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/stream.hxx>
+#include <tools/table.hxx>
+
+#include <bf_svtools/macitem.hxx>
+
+namespace binfilter
+{
+
+// STATIC DATA -----------------------------------------------------------
+
+DBG_NAME(SvxMacroItem)
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1_FACTORY(SvxMacroItem, SfxPoolItem, new SvxMacroItem(0));
+
+// -----------------------------------------------------------------------
+
+
+SjJSbxObjectBase::~SjJSbxObjectBase()
+{
+}
+
+SjJSbxObjectBase* SjJSbxObjectBase::Clone( void )
+{
+ return NULL;
+}
+
+SvxMacro::SvxMacro( const String &rMacName, const String &rLanguage)
+ : aMacName( rMacName ), aLibName( rLanguage),
+ pFunctionObject(NULL), eType( EXTENDED_STYPE)
+{
+ if (rLanguage.EqualsAscii(SVX_MACRO_LANGUAGE_STARBASIC))
+ eType=STARBASIC;
+ else if (rLanguage.EqualsAscii(SVX_MACRO_LANGUAGE_JAVASCRIPT))
+ eType=JAVASCRIPT;
+}
+
+
+SvxMacro::~SvxMacro()
+{
+ delete pFunctionObject;
+}
+
+SvxMacro& SvxMacro::operator=( const SvxMacro& rBase )
+{
+ if( this != &rBase )
+ {
+ aMacName = rBase.aMacName;
+ aLibName = rBase.aLibName;
+ delete pFunctionObject;
+ pFunctionObject = rBase.pFunctionObject ? rBase.pFunctionObject->Clone() : NULL;
+ eType = rBase.eType;
+ }
+ return *this;
+}
+
+
+SvxMacroTableDtor& SvxMacroTableDtor::operator=( const SvxMacroTableDtor& rTbl )
+{
+ DelDtor();
+ SvxMacro* pTmp = ((SvxMacroTableDtor&)rTbl).First();
+ while( pTmp )
+ {
+ SvxMacro *pNew = new SvxMacro( *pTmp );
+ Insert( rTbl.GetCurKey(), pNew );
+ pTmp = ((SvxMacroTableDtor&)rTbl).Next();
+ }
+ return *this;
+}
+
+
+SvStream& SvxMacroTableDtor::Read( SvStream& rStrm, USHORT nVersion )
+{
+ if( SVX_MACROTBL_VERSION40 <= nVersion )
+ rStrm >> nVersion;
+ short nMacro;
+ rStrm >> nMacro;
+
+ for( short i = 0; i < nMacro; ++i )
+ {
+ USHORT nCurKey, eType = STARBASIC;
+ String aLibName, aMacName;
+ rStrm >> nCurKey;
+ SfxPoolItem::readByteString(rStrm, aLibName);
+ SfxPoolItem::readByteString(rStrm, aMacName);
+
+ if( SVX_MACROTBL_VERSION40 <= nVersion )
+ rStrm >> eType;
+
+ SvxMacro* pNew = new SvxMacro( aMacName, aLibName, (ScriptType)eType );
+
+ SvxMacro *pOld = Get( nCurKey );
+ if( pOld )
+ {
+ delete pOld;
+ Replace( nCurKey, pNew );
+ }
+ else
+ Insert( nCurKey, pNew );
+ }
+ return rStrm;
+}
+
+
+SvStream& SvxMacroTableDtor::Write( SvStream& rStream ) const
+{
+ USHORT nVersion = SOFFICE_FILEFORMAT_31 == rStream.GetVersion()
+ ? SVX_MACROTBL_VERSION31
+ : SVX_MACROTBL_AKTVERSION;
+
+ if( SVX_MACROTBL_VERSION40 <= nVersion )
+ rStream << nVersion;
+
+ rStream << (USHORT)Count();
+
+ SvxMacro* pMac = ((SvxMacroTableDtor*)this)->First();
+ while( pMac && rStream.GetError() == SVSTREAM_OK )
+ {
+ rStream << (short)GetCurKey();
+ SfxPoolItem::writeByteString(rStream, pMac->GetLibName());
+ SfxPoolItem::writeByteString(rStream, pMac->GetMacName());
+
+ if( SVX_MACROTBL_VERSION40 <= nVersion )
+ rStream << (USHORT)pMac->GetScriptType();
+ pMac = ((SvxMacroTableDtor*)this)->Next();
+ }
+ return rStream;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxMacroTableDtor::DelDtor()
+{
+ SvxMacro* pTmp = First();
+ while( pTmp )
+ {
+ delete pTmp;
+ pTmp = Next();
+ }
+ Clear();
+}
+
+// -----------------------------------------------------------------------
+
+int SvxMacroItem::operator==( const SfxPoolItem& rAttr ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
+
+ const SvxMacroTableDtor& rOwn = aMacroTable;
+ const SvxMacroTableDtor& rOther = ( (SvxMacroItem&) rAttr ).aMacroTable;
+
+ // Anzahl unterschiedlich => auf jeden Fall ungleich
+ if ( rOwn.Count() != rOther.Count() )
+ return FALSE;
+
+ // einzeln verleichen; wegen Performance ist die Reihenfolge wichtig
+ for ( USHORT nNo = 0; nNo < rOwn.Count(); ++nNo )
+ {
+ const SvxMacro *pOwnMac = rOwn.GetObject(nNo);
+ const SvxMacro *pOtherMac = rOther.GetObject(nNo);
+ if ( rOwn.GetKey(pOwnMac) != rOther.GetKey(pOtherMac) ||
+ pOwnMac->GetLibName() != pOtherMac->GetLibName() ||
+ pOwnMac->GetMacName() != pOtherMac->GetMacName() )
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxMacroItem::Clone( SfxItemPool* ) const
+{
+ return new SvxMacroItem( *this );
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxMacroItem::GetPresentation
+(
+ SfxItemPresentation /*ePres*/,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText,
+ const ::IntlWrapper *
+) const
+{
+/*!!!
+ SvxMacroTableDtor& rTbl = (SvxMacroTableDtor&)GetMacroTable();
+ SvxMacro* pMac = rTbl.First();
+
+ while ( pMac )
+ {
+ rText += pMac->GetLibName();
+ rText += cpDelim;
+ rText += pMac->GetMacName();
+ pMac = rTbl.Next();
+ if ( pMac )
+ rText += cpDelim;
+ }
+*/
+ rText.Erase();
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SvxMacroItem::Store( SvStream& rStrm , USHORT ) const
+{
+ return aMacroTable.Write( rStrm );
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxMacroItem::Create( SvStream& rStrm, USHORT nVersion ) const
+{
+ SvxMacroItem* pAttr = new SvxMacroItem( Which() );
+ pAttr->aMacroTable.Read( rStrm, nVersion );
+ return pAttr;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxMacroItem::SetMacro( USHORT nEvent, const SvxMacro& rMacro )
+{
+ SvxMacro *pMacro;
+ if ( 0 != (pMacro=aMacroTable.Get(nEvent)) )
+ {
+ delete pMacro;
+ aMacroTable.Replace(nEvent, new SvxMacro( rMacro ) );
+ }
+ else
+ aMacroTable.Insert(nEvent, new SvxMacro( rMacro ) );
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SvxMacroItem::GetVersion( USHORT nFileFormatVersion ) const
+{
+ return SOFFICE_FILEFORMAT_31 == nFileFormatVersion
+ ? 0 : aMacroTable.GetVersion();
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items/svt_poolcach.cxx b/binfilter/bf_svtools/source/items/svt_poolcach.cxx
new file mode 100644
index 000000000000..f2c34e15df72
--- /dev/null
+++ b/binfilter/bf_svtools/source/items/svt_poolcach.cxx
@@ -0,0 +1,145 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <limits.h>
+
+#include <bf_svtools/itempool.hxx>
+#include <bf_svtools/itemset.hxx>
+#include "poolcach.hxx"
+
+namespace binfilter
+{
+
+// STATIC DATA -----------------------------------------------------------
+
+DBG_NAME(SfxItemPoolCache)
+
+
+//------------------------------------------------------------------------
+
+struct SfxItemModifyImpl
+{
+ const SfxSetItem *pOrigItem;
+ SfxSetItem *pPoolItem;
+};
+
+SV_DECL_VARARR( SfxItemModifyArr_Impl, SfxItemModifyImpl, 8, 8 )
+SV_IMPL_VARARR( SfxItemModifyArr_Impl, SfxItemModifyImpl);
+
+//------------------------------------------------------------------------
+
+SfxItemPoolCache::SfxItemPoolCache( SfxItemPool *pItemPool,
+ const SfxItemSet *pPutSet ):
+ pPool(pItemPool),
+ pCache(new SfxItemModifyArr_Impl),
+ pSetToPut( pPutSet ),
+ pItemToPut( 0 )
+{
+ DBG_CTOR(SfxItemPoolCache, 0);
+ DBG_ASSERT(pItemPool, "kein Pool angegeben");
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPoolCache::~SfxItemPoolCache()
+{
+ DBG_DTOR(SfxItemPoolCache, 0);
+ for ( USHORT nPos = 0; nPos < pCache->Count(); ++nPos ) {
+ pPool->Remove( *(*pCache)[nPos].pPoolItem );
+ pPool->Remove( *(*pCache)[nPos].pOrigItem );
+ }
+ delete pCache; pCache = 0;
+
+ if ( pItemToPut )
+ pPool->Remove( *pItemToPut );
+}
+
+//------------------------------------------------------------------------
+
+const SfxSetItem& SfxItemPoolCache::ApplyTo( const SfxSetItem &rOrigItem, BOOL bNew )
+{
+ DBG_CHKTHIS(SfxItemPoolCache, 0);
+ DBG_ASSERT( pPool == rOrigItem.GetItemSet().GetPool(), "invalid Pool" );
+ DBG_ASSERT( IsDefaultItem( &rOrigItem ) || IsPooledItem( &rOrigItem ),
+ "original not in pool" );
+
+ // Suchen, ob diese Transformations schon einmal vorkam
+ for ( USHORT nPos = 0; nPos < pCache->Count(); ++nPos )
+ {
+ SfxItemModifyImpl &rMapEntry = (*pCache)[nPos];
+ if ( rMapEntry.pOrigItem == &rOrigItem )
+ {
+ // aendert sich ueberhaupt etwas?
+ if ( rMapEntry.pPoolItem != &rOrigItem )
+ {
+ rMapEntry.pPoolItem->AddRef(2); // einen davon fuer den Cache
+ if ( bNew )
+ pPool->Put( rOrigItem ); //! AddRef??
+ }
+ return *rMapEntry.pPoolItem;
+ }
+ }
+
+ // die neue Attributierung in einem neuen Set eintragen
+ SfxSetItem *pNewItem = (SfxSetItem *)rOrigItem.Clone();
+ if ( pItemToPut )
+ {
+ pNewItem->GetItemSet().PutDirect( *pItemToPut );
+ DBG_ASSERT( &pNewItem->GetItemSet().Get( pItemToPut->Which() ) == pItemToPut,
+ "wrong item in temporary set" );
+ }
+ else
+ pNewItem->GetItemSet().Put( *pSetToPut );
+ const SfxSetItem* pNewPoolItem = (const SfxSetItem*) &pPool->Put( *pNewItem );
+ DBG_ASSERT( pNewPoolItem != pNewItem, "Pool: rein == raus?" );
+ delete pNewItem;
+
+ // Refernzzaehler anpassen, je einen davon fuer den Cache
+ pNewPoolItem->AddRef( pNewPoolItem != &rOrigItem ? 2 : 1 );
+ if ( bNew )
+ pPool->Put( rOrigItem ); //! AddRef??
+
+ // die Transformation im Cache eintragen
+ SfxItemModifyImpl aModify;
+ aModify.pOrigItem = &rOrigItem;
+ aModify.pPoolItem = (SfxSetItem*) pNewPoolItem;
+ pCache->Insert( aModify, pCache->Count() );
+
+ DBG_ASSERT( !pItemToPut ||
+ &pNewPoolItem->GetItemSet().Get( pItemToPut->Which() ) == pItemToPut,
+ "wrong item in resulting set" );
+
+ return *pNewPoolItem;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items/svt_ptitem.cxx b/binfilter/bf_svtools/source/items/svt_ptitem.cxx
new file mode 100644
index 000000000000..a0e206b5d94a
--- /dev/null
+++ b/binfilter/bf_svtools/source/items/svt_ptitem.cxx
@@ -0,0 +1,205 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/ptitem.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/awt/Point.hpp>
+
+#include <tools/stream.hxx>
+
+#include <bf_svtools/poolitem.hxx>
+#include "memberid.hrc"
+
+using namespace ::com::sun::star;
+
+namespace binfilter
+{
+
+// STATIC DATA -----------------------------------------------------------
+
+DBG_NAME(SfxPointItem)
+
+#define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
+#define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1_AUTOFACTORY(SfxPointItem, SfxPoolItem);
+
+// -----------------------------------------------------------------------
+
+SfxPointItem::SfxPointItem()
+{
+ DBG_CTOR(SfxPointItem, 0);
+}
+
+// -----------------------------------------------------------------------
+
+SfxPointItem::SfxPointItem( USHORT nW, const Point& rVal ) :
+ SfxPoolItem( nW ),
+ aVal( rVal )
+{
+ DBG_CTOR(SfxPointItem, 0);
+}
+
+// -----------------------------------------------------------------------
+
+SfxPointItem::SfxPointItem( const SfxPointItem& rItem ) :
+ SfxPoolItem( rItem ),
+ aVal( rItem.aVal )
+{
+ DBG_CTOR(SfxPointItem, 0);
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemPresentation SfxPointItem::GetPresentation
+(
+ SfxItemPresentation /*ePresentation*/,
+ SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/,
+ XubString& rText,
+ const ::IntlWrapper *
+) const
+{
+ DBG_CHKTHIS(SfxPointItem, 0);
+ rText = UniString::CreateFromInt32(aVal.X());
+ rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ rText += UniString::CreateFromInt32(aVal.Y());
+ rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+// -----------------------------------------------------------------------
+
+int SfxPointItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_CHKTHIS(SfxPointItem, 0);
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+ return ((SfxPointItem&)rItem).aVal == aVal;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxPointItem::Clone(SfxItemPool *) const
+{
+ DBG_CHKTHIS(SfxPointItem, 0);
+ return new SfxPointItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxPointItem::Create(SvStream &rStream, USHORT ) const
+{
+ DBG_CHKTHIS(SfxPointItem, 0);
+ Point aStr;
+ rStream >> aStr;
+ return new SfxPointItem(Which(), aStr);
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SfxPointItem::Store(SvStream &rStream, USHORT ) const
+{
+ DBG_CHKTHIS(SfxPointItem, 0);
+ rStream << aVal;
+ return rStream;
+}
+
+// -----------------------------------------------------------------------
+
+bool SfxPointItem::QueryValue( uno::Any& rVal,
+ BYTE nMemberId ) const
+{
+ sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ awt::Point aTmp(aVal.X(), aVal.Y());
+ if( bConvert )
+ {
+ aTmp.X = TWIP_TO_MM100(aTmp.X);
+ aTmp.Y = TWIP_TO_MM100(aTmp.Y);
+ }
+ nMemberId &= ~CONVERT_TWIPS;
+ switch ( nMemberId )
+ {
+ case 0: rVal <<= aTmp; break;
+ case MID_X: rVal <<= aTmp.X; break;
+ case MID_Y: rVal <<= aTmp.Y; break;
+ default: DBG_ERROR("Wrong MemberId!"); return false;
+ }
+
+ return true;
+}
+
+// -----------------------------------------------------------------------
+
+bool SfxPointItem::PutValue( const uno::Any& rVal,
+ BYTE nMemberId )
+{
+ sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+ bool bRet = false;
+ awt::Point aValue;
+ sal_Int32 nVal = 0;
+ if ( !nMemberId )
+ {
+ bRet = ( rVal >>= aValue );
+ if( bConvert )
+ {
+ aValue.X = MM100_TO_TWIP(aValue.X);
+ aValue.Y = MM100_TO_TWIP(aValue.Y);
+ }
+ }
+ else
+ {
+ bRet = ( rVal >>= nVal );
+ if( bConvert )
+ nVal = MM100_TO_TWIP( nVal );
+ }
+
+ if ( bRet )
+ {
+ switch ( nMemberId )
+ {
+ case 0: aVal.setX( aValue.X ); aVal.setY( aValue.Y ); break;
+ case MID_X: aVal.setX( nVal ); break;
+ case MID_Y: aVal.setY( nVal ); break;
+ default: DBG_ERROR("Wrong MemberId!"); return false;
+ }
+ }
+
+ return bRet;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items/svt_rectitem.cxx b/binfilter/bf_svtools/source/items/svt_rectitem.cxx
new file mode 100644
index 000000000000..6660b615a848
--- /dev/null
+++ b/binfilter/bf_svtools/source/items/svt_rectitem.cxx
@@ -0,0 +1,201 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/rectitem.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/awt/Rectangle.hpp>
+
+#include <tools/stream.hxx>
+
+#include <bf_svtools/poolitem.hxx>
+#include "memberid.hrc"
+
+namespace binfilter
+{
+
+// STATIC DATA -----------------------------------------------------------
+
+DBG_NAME(SfxRectangleItem)
+
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1_AUTOFACTORY(SfxRectangleItem, SfxPoolItem);
+
+// -----------------------------------------------------------------------
+
+SfxRectangleItem::SfxRectangleItem()
+{
+ DBG_CTOR(SfxRectangleItem, 0);
+}
+
+// -----------------------------------------------------------------------
+
+SfxRectangleItem::SfxRectangleItem( USHORT nW, const Rectangle& rVal ) :
+ SfxPoolItem( nW ),
+ aVal( rVal )
+{
+ DBG_CTOR(SfxRectangleItem, 0);
+}
+
+// -----------------------------------------------------------------------
+
+SfxRectangleItem::SfxRectangleItem( const SfxRectangleItem& rItem ) :
+ SfxPoolItem( rItem ),
+ aVal( rItem.aVal )
+{
+ DBG_CTOR(SfxRectangleItem, 0);
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemPresentation SfxRectangleItem::GetPresentation
+(
+ SfxItemPresentation /*ePresentation*/,
+ SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/,
+ XubString& rText,
+ const ::IntlWrapper *
+) const
+{
+ DBG_CHKTHIS(SfxRectangleItem, 0);
+ rText = UniString::CreateFromInt32(aVal.Top());
+ rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ rText += UniString::CreateFromInt32(aVal.Left());
+ rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ rText += UniString::CreateFromInt32(aVal.Bottom());
+ rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ rText += UniString::CreateFromInt32(aVal.Right());
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+// -----------------------------------------------------------------------
+
+int SfxRectangleItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_CHKTHIS(SfxRectangleItem, 0);
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+ return ((SfxRectangleItem&)rItem).aVal == aVal;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxRectangleItem::Clone(SfxItemPool *) const
+{
+ DBG_CHKTHIS(SfxRectangleItem, 0);
+ return new SfxRectangleItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxRectangleItem::Create(SvStream &rStream, USHORT ) const
+{
+ DBG_CHKTHIS(SfxRectangleItem, 0);
+ Rectangle aStr;
+ rStream >> aStr;
+ return new SfxRectangleItem(Which(), aStr);
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SfxRectangleItem::Store(SvStream &rStream, USHORT ) const
+{
+ DBG_CHKTHIS(SfxRectangleItem, 0);
+ rStream << aVal;
+ return rStream;
+}
+
+
+// -----------------------------------------------------------------------
+bool SfxRectangleItem::QueryValue( ::com::sun::star::uno::Any& rVal,
+ BYTE nMemberId) const
+{
+ nMemberId &= ~CONVERT_TWIPS;
+ switch ( nMemberId )
+ {
+ case 0:
+ {
+ rVal <<= com::sun::star::awt::Rectangle( aVal.getX(),
+ aVal.getY(),
+ aVal.getWidth(),
+ aVal.getHeight() );
+ break;
+ }
+ case MID_RECT_LEFT: rVal <<= aVal.getX(); break;
+ case MID_RECT_RIGHT: rVal <<= aVal.getY(); break;
+ case MID_WIDTH: rVal <<= aVal.getWidth(); break;
+ case MID_HEIGHT: rVal <<= aVal.getHeight(); break;
+ default: DBG_ERROR("Wrong MemberID!"); return false;
+ }
+
+ return true;
+}
+
+// -----------------------------------------------------------------------
+bool SfxRectangleItem::PutValue( const com::sun::star::uno::Any& rVal,
+ BYTE nMemberId )
+{
+ bool bRet = false;
+ nMemberId &= ~CONVERT_TWIPS;
+ com::sun::star::awt::Rectangle aValue;
+ sal_Int32 nVal = 0;
+ if ( !nMemberId )
+ bRet = (rVal >>= aValue);
+ else
+ bRet = (rVal >>= nVal);
+
+ if ( bRet )
+ {
+ switch ( nMemberId )
+ {
+ case 0:
+ aVal.setX( aValue.X );
+ aVal.setY( aValue.Y );
+ aVal.setWidth( aValue.Width );
+ aVal.setHeight( aValue.Height );
+ break;
+ case MID_RECT_LEFT: aVal.setX( nVal ); break;
+ case MID_RECT_RIGHT: aVal.setY( nVal ); break;
+ case MID_WIDTH: aVal.setWidth( nVal ); break;
+ case MID_HEIGHT: aVal.setHeight( nVal ); break;
+ default: DBG_ERROR("Wrong MemberID!"); return false;
+ }
+ }
+
+ return bRet;
+}
+
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items/svt_rngitem.cxx b/binfilter/bf_svtools/source/items/svt_rngitem.cxx
new file mode 100644
index 000000000000..d7b49e5f6b91
--- /dev/null
+++ b/binfilter/bf_svtools/source/items/svt_rngitem.cxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/stream.hxx>
+
+#ifndef NUMTYPE
+
+#define NUMTYPE USHORT
+#define SfxXRangeItem SfxRangeItem
+#define SfxXRangesItem SfxUShortRangesItem
+#include <bf_svtools/rngitem.hxx>
+#include "svt_rngitem_inc.cxx"
+
+#define NUMTYPE sal_uInt32
+#define SfxXRangeItem SfxULongRangeItem
+#define SfxXRangesItem SfxULongRangesItem
+#include <bf_svtools/rngitem.hxx>
+#include "svt_rngitem_inc.cxx"
+
+#else
+
+// We leave this condition just in case NUMTYPE has been defined externally to this
+// file and we are supposed to define the SfxXRangeItem based on that.
+
+#include "svt_rngitem_inc.cxx"
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items/svt_rngitem_inc.cxx b/binfilter/bf_svtools/source/items/svt_rngitem_inc.cxx
new file mode 100644
index 000000000000..8b66b81afb0b
--- /dev/null
+++ b/binfilter/bf_svtools/source/items/svt_rngitem_inc.cxx
@@ -0,0 +1,228 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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.
+ *
+ ************************************************************************/
+
+namespace binfilter
+{
+
+// This snippet of code is included by rngitem.cxx but not compiled directly.
+// Ugly hack, probably due to lack of templates in the 20th century.
+
+static inline NUMTYPE Count_Impl(const NUMTYPE * pRanges)
+{
+ NUMTYPE nCount = 0;
+ for (; *pRanges; pRanges += 2) nCount += 2;
+ return nCount;
+}
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1_AUTOFACTORY(SfxXRangeItem, SfxPoolItem);
+TYPEINIT1_AUTOFACTORY(SfxXRangesItem, SfxPoolItem);
+
+NUMTYPE Count_Impl( const NUMTYPE *pRanges );
+
+// -----------------------------------------------------------------------
+
+SfxXRangeItem::SfxXRangeItem()
+{
+ nFrom = 0;
+ nTo = 0;
+}
+
+// -----------------------------------------------------------------------
+
+SfxXRangeItem::SfxXRangeItem( USHORT which, NUMTYPE from, NUMTYPE to ):
+ SfxPoolItem( which ),
+ nFrom( from ),
+ nTo( to )
+{
+}
+
+
+// -----------------------------------------------------------------------
+
+SfxXRangeItem::SfxXRangeItem( const SfxXRangeItem& rItem ) :
+ SfxPoolItem( rItem )
+{
+ nFrom = rItem.nFrom;
+ nTo = rItem.nTo;
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemPresentation SfxXRangeItem::GetPresentation
+(
+ SfxItemPresentation /*ePresentation*/,
+ SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/,
+ XubString& rText,
+ const ::IntlWrapper *
+) const
+{
+ rText = UniString::CreateFromInt64(nFrom);
+ rText += ':';
+ rText += UniString::CreateFromInt64(nTo);
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+// -----------------------------------------------------------------------
+
+int SfxXRangeItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+ SfxXRangeItem* pT = (SfxXRangeItem*)&rItem;
+ if( nFrom==pT->nFrom && nTo==pT->nTo )
+ return 1;
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxXRangeItem::Clone(SfxItemPool *) const
+{
+ return new SfxXRangeItem( Which(), nFrom, nTo );
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxXRangeItem::Create(SvStream &rStream, USHORT) const
+{
+ NUMTYPE nVon, nBis;
+ rStream >> nVon;
+ rStream >> nBis;
+ return new SfxXRangeItem( Which(), nVon, nBis );
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SfxXRangeItem::Store(SvStream &rStream, USHORT) const
+{
+ rStream << nFrom;
+ rStream << nTo;
+ return rStream;
+}
+
+//=========================================================================
+
+SfxXRangesItem::SfxXRangesItem()
+: _pRanges(0)
+{
+}
+
+//-------------------------------------------------------------------------
+
+SfxXRangesItem::SfxXRangesItem( USHORT nWID, SvStream &rStream )
+: SfxPoolItem( nWID )
+{
+ NUMTYPE nCount;
+ rStream >> nCount;
+ _pRanges = new NUMTYPE[nCount + 1];
+ for ( NUMTYPE n = 0; n < nCount; ++n )
+ rStream >> _pRanges[n];
+ _pRanges[nCount] = 0;
+}
+
+//-------------------------------------------------------------------------
+
+SfxXRangesItem::SfxXRangesItem( const SfxXRangesItem& rItem )
+: SfxPoolItem( rItem )
+{
+ NUMTYPE nCount = Count_Impl(rItem._pRanges) + 1;
+ _pRanges = new NUMTYPE[nCount];
+ memcpy( _pRanges, rItem._pRanges, sizeof(NUMTYPE) * nCount );
+}
+
+//-------------------------------------------------------------------------
+
+SfxXRangesItem::~SfxXRangesItem()
+{
+ delete _pRanges;
+}
+
+//-------------------------------------------------------------------------
+
+int SfxXRangesItem::operator==( const SfxPoolItem &rItem ) const
+{
+ const SfxXRangesItem &rOther = (const SfxXRangesItem&) rItem;
+ if ( !_pRanges && !rOther._pRanges )
+ return TRUE;
+ if ( _pRanges || rOther._pRanges )
+ return FALSE;
+
+ NUMTYPE n;
+ for ( n = 0; _pRanges[n] && rOther._pRanges[n]; ++n )
+ if ( *_pRanges != rOther._pRanges[n] )
+ return 0;
+
+ return !_pRanges[n] && !rOther._pRanges[n];
+}
+
+//-------------------------------------------------------------------------
+
+SfxItemPresentation SfxXRangesItem::GetPresentation( SfxItemPresentation /*ePres*/,
+ SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresMetric*/,
+ XubString &/*rText*/,
+ const ::IntlWrapper * ) const
+{
+ HACK(n. i.)
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+//-------------------------------------------------------------------------
+
+SfxPoolItem* SfxXRangesItem::Clone( SfxItemPool * ) const
+{
+ return new SfxXRangesItem( *this );
+}
+
+//-------------------------------------------------------------------------
+
+SfxPoolItem* SfxXRangesItem::Create( SvStream &rStream, USHORT ) const
+{
+ return new SfxXRangesItem( Which(), rStream );
+}
+
+//-------------------------------------------------------------------------
+
+SvStream& SfxXRangesItem::Store( SvStream &rStream, USHORT ) const
+{
+ NUMTYPE nCount = Count_Impl( _pRanges );
+ rStream >> nCount;
+ for ( NUMTYPE n = 0; _pRanges[n]; ++n )
+ rStream >> _pRanges[n];
+ return rStream;
+}
+
+
+#undef NUMTYPE
+#undef SfxXRangeItem
+#undef SfxXRangesItem
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items/svt_stritem.cxx b/binfilter/bf_svtools/source/items/svt_stritem.cxx
new file mode 100644
index 000000000000..fb4115060803
--- /dev/null
+++ b/binfilter/bf_svtools/source/items/svt_stritem.cxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/stritem.hxx>
+
+namespace binfilter
+{
+
+
+//============================================================================
+//
+// class SfxStringItem
+//
+//============================================================================
+
+TYPEINIT1_AUTOFACTORY(SfxStringItem, CntUnencodedStringItem)
+
+//============================================================================
+// virtual
+SfxStringItem::SfxStringItem(USHORT which, SvStream & rStream):
+ CntUnencodedStringItem(which)
+{
+ UniString aValue;
+ readByteString(rStream, aValue);
+ SetValue(aValue);
+}
+
+
+//============================================================================
+// virtual
+SfxPoolItem * SfxStringItem::Create(SvStream & rStream, USHORT) const
+{
+ return new SfxStringItem(Which(), rStream);
+}
+
+//============================================================================
+// virtual
+SvStream & SfxStringItem::Store(SvStream & rStream, USHORT) const
+{
+ writeByteString(rStream, GetValue());
+ return rStream;
+}
+
+//============================================================================
+// virtual
+SfxPoolItem * SfxStringItem::Clone(SfxItemPool *) const
+{
+ return new SfxStringItem(*this);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items/svt_style.cxx b/binfilter/bf_svtools/source/items/svt_style.cxx
new file mode 100644
index 000000000000..4844552a6a12
--- /dev/null
+++ b/binfilter/bf_svtools/source/items/svt_style.cxx
@@ -0,0 +1,1202 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+#define _SVSTDARR_STRINGS
+#define _SVSTDARR_STRINGSSORTDTOR
+#define _SVSTDARR_BYTESTRINGS
+#define _SVSTDARR_BYTESTRINGSSORTDTOR
+
+#include <tools/tenccvt.hxx>
+#include <comphelper/processfactory.hxx>
+#include <unotools/intlwrapper.hxx>
+#include <bf_svtools/smplhint.hxx>
+#include <bf_svtools/poolitem.hxx>
+#include <bf_svtools/itemset.hxx>
+#include <bf_svtools/itempool.hxx>
+#include <poolio.hxx>
+#include <bf_svtools/filerec.hxx>
+#include <bf_svtools/itemiter.hxx>
+#include <bf_svtools/style.hxx>
+#include <bf_svtools/svstdarr.hxx>
+#include <vcl/svapp.hxx>
+
+#define STYLESTREAM "SfxStyleSheets"
+#define STYLESTREAM_VERSION USHORT(50)
+
+namespace binfilter
+{
+
+
+TYPEINIT0(SfxStyleSheetBase)
+
+TYPEINIT3(SfxStyleSheet, SfxStyleSheetBase, SfxListener, SfxBroadcaster)
+
+
+//=========================================================================
+
+TYPEINIT1(SfxStyleSheetHint, SfxHint);
+TYPEINIT1(SfxStyleSheetHintExtended, SfxStyleSheetHint);
+TYPEINIT1(SfxStyleSheetPoolHint, SfxHint);
+
+SfxStyleSheetHintExtended::SfxStyleSheetHintExtended
+(
+ USHORT nAction, // SFX_STYLESHEET_... (s.o.)
+ const String& rOldName,
+ SfxStyleSheetBase& rStyleSheet // geh"ort weiterhin dem Aufrufer
+)
+: SfxStyleSheetHint( nAction, rStyleSheet ),
+ aName( rOldName )
+{}
+
+//-------------------------------------------------------------------------
+
+SfxStyleSheetHint::SfxStyleSheetHint
+(
+ USHORT nAction, // SFX_STYLESHEET_... (s.o.)
+ SfxStyleSheetBase& rStyleSheet // geh"ort weiterhin dem Aufrufer
+)
+: pStyleSh( &rStyleSheet ),
+ nHint( nAction )
+{}
+
+//=========================================================================
+
+class SfxStyleSheetBasePool_Impl
+{
+ public:
+ SfxStyles aStyles;
+ SfxStyleSheetIterator *pIter;
+ SfxStyleSheetBasePool_Impl() : pIter(0){}
+ ~SfxStyleSheetBasePool_Impl(){delete pIter;}
+};
+
+
+//////////////////////////// SfxStyleSheetBase ///////////////////////////////
+
+// Konstruktoren
+
+SfxStyleSheetBase::SfxStyleSheetBase
+ ( const XubString& rName, SfxStyleSheetBasePool& r, SfxStyleFamily eFam, USHORT mask )
+ : rPool( r )
+ , nFamily( eFam )
+ , aName( rName )
+ , aParent()
+ , aFollow( rName )
+ , pSet( NULL )
+ , nMask(mask)
+ , nHelpId( 0 )
+ , bMySet( FALSE )
+{
+}
+
+SfxStyleSheetBase::SfxStyleSheetBase( const SfxStyleSheetBase& r )
+ : rPool( r.rPool )
+ , nFamily( r.nFamily )
+ , aName( r.aName )
+ , aParent( r.aParent )
+ , aFollow( r.aFollow )
+ , aHelpFile( r.aHelpFile )
+ , nMask( r.nMask )
+ , nHelpId( r.nHelpId )
+ , bMySet( r.bMySet )
+{
+ if( r.pSet )
+ pSet = bMySet ? new SfxItemSet( *r.pSet ) : r.pSet;
+ else
+ pSet = NULL;
+}
+
+SfxStyleSheetBase::~SfxStyleSheetBase()
+{
+ if( bMySet )
+ {
+ delete pSet;
+ pSet = 0;
+ }
+}
+
+USHORT SfxStyleSheetBase::GetVersion() const
+{
+ return 0x0000;
+}
+
+// Namen aendern
+
+const XubString& SfxStyleSheetBase::GetName() const
+{
+ return aName;
+}
+
+BOOL SfxStyleSheetBase::SetName( const XubString& rName )
+{
+ if(rName.Len() == 0)
+ return FALSE;
+ if( aName != rName )
+ {
+ String aOldName = aName;
+ SfxStyleSheetBase *pOther = rPool.Find( rName, nFamily ) ;
+ if ( pOther && pOther != this )
+ return FALSE;
+
+ SfxStyleFamily eTmpFam=rPool.GetSearchFamily();
+ USHORT nTmpMask=rPool.GetSearchMask();
+
+ rPool.SetSearchMask(nFamily);
+
+ if ( aName.Len() )
+ rPool.ChangeParent( aName, rName, FALSE );
+ if ( aFollow.Equals( aName ) )
+ aFollow = rName;
+ aName = rName;
+ rPool.SetSearchMask(eTmpFam, nTmpMask);
+ rPool.Broadcast( SfxStyleSheetHintExtended(
+ SFX_STYLESHEET_MODIFIED, aOldName, *this ) );
+ }
+ return TRUE;
+}
+
+// Parent aendern
+
+const XubString& SfxStyleSheetBase::GetParent() const
+{
+ return aParent;
+}
+
+BOOL SfxStyleSheetBase::SetParent( const XubString& rName )
+{
+ if ( rName == aName )
+ return FALSE;
+
+ if( aParent != rName )
+ {
+ SfxStyleSheetBase* pIter = rPool.Find(rName, nFamily);
+ if( rName.Len() && !pIter )
+ {
+ DBG_ERROR( "StyleSheet-Parent nicht gefunden" );
+ return FALSE;
+ }
+ // rekursive Verknuepfungen verhindern
+ if( aName.Len() )
+ while(pIter)
+ {
+ if(pIter->GetName() == aName && aName != rName)
+ return FALSE;
+ pIter = rPool.Find(pIter->GetParent(), nFamily);
+ }
+ aParent = rName;
+ }
+ rPool.Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, *this ) );
+ return TRUE;
+}
+
+// Follow aendern
+
+const XubString& SfxStyleSheetBase::GetFollow() const
+{
+ return aFollow;
+}
+
+BOOL SfxStyleSheetBase::SetFollow( const XubString& rName )
+{
+ if( aFollow != rName )
+ {
+ if( !rPool.Find( rName, nFamily ) )
+ {
+ DBG_ERROR( "StyleSheet-Follow nicht gefunden" );
+ return FALSE;
+ }
+ aFollow = rName;
+ }
+ rPool.Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, *this ) );
+ return TRUE;
+}
+
+// Itemset setzen. Die Dflt-Implementation legt ein neues Set an.
+
+SfxItemSet& SfxStyleSheetBase::GetItemSet()
+{
+ if( !pSet )
+ {
+ pSet = new SfxItemSet( rPool.GetPool() );
+ bMySet = TRUE;
+ }
+ return *pSet;
+}
+
+// Hilfe-Datei und -ID setzen und abfragen
+
+ULONG SfxStyleSheetBase::GetHelpId( String& rFile )
+{
+ rFile = aHelpFile;
+ return nHelpId;
+}
+
+void SfxStyleSheetBase::SetHelpId( const String& rFile, ULONG nId )
+{
+ aHelpFile = rFile;
+ nHelpId = nId;
+}
+
+// Folgevorlage m"oglich? Default: Ja
+
+BOOL SfxStyleSheetBase::HasFollowSupport() const
+{
+ return TRUE;
+}
+
+// Basisvorlage m"oglich? Default: Ja
+
+BOOL SfxStyleSheetBase::HasParentSupport() const
+{
+ return TRUE;
+}
+
+// Basisvorlage uf NULL setzen m"oglich? Default: Nein
+
+BOOL SfxStyleSheetBase::HasClearParentSupport() const
+{
+ return FALSE;
+}
+
+// Defaultmaessig sind alle StyleSheets Used
+
+BOOL SfxStyleSheetBase::IsUsed() const
+{
+ return TRUE;
+}
+
+// eingestellte Attribute ausgeben
+
+
+XubString SfxStyleSheetBase::GetDescription()
+{
+ return GetDescription( SFX_MAPUNIT_CM );
+}
+
+// eingestellte Attribute ausgeben
+
+XubString SfxStyleSheetBase::GetDescription( SfxMapUnit )
+{
+ XubString aEmpty;
+ return aEmpty;
+}
+
+/////////////////////////// SfxStyleSheetIterator ///////////////////////////////
+
+SfxStyleFamily SfxStyleSheetIterator::GetSearchFamily() const
+{
+ return nSearchFamily;
+}
+
+inline BOOL SfxStyleSheetIterator::IsTrivialSearch()
+{
+ return nMask == 0xFFFF && GetSearchFamily() == SFX_STYLE_FAMILY_ALL;
+}
+
+BOOL SfxStyleSheetIterator::DoesStyleMatch(SfxStyleSheetBase *pStyle)
+{
+ return ((GetSearchFamily() == SFX_STYLE_FAMILY_ALL) ||
+ ( pStyle->GetFamily() == GetSearchFamily() ))
+ && (( pStyle->GetMask() & ( GetSearchMask() & ~SFXSTYLEBIT_USED )) ||
+ ( bSearchUsed ? pStyle->IsUsed() : FALSE ) ||
+ GetSearchMask() == SFXSTYLEBIT_ALL );
+}
+
+
+SfxStyleSheetIterator::SfxStyleSheetIterator(SfxStyleSheetBasePool *pBase,
+ SfxStyleFamily eFam, USHORT n)
+{
+ pBasePool=pBase;
+ nSearchFamily=eFam;
+ bSearchUsed=FALSE;
+ if((n != SFXSTYLEBIT_ALL ) && ((n & SFXSTYLEBIT_USED) == SFXSTYLEBIT_USED))
+ {
+ bSearchUsed = TRUE;
+ n &= ~SFXSTYLEBIT_USED;
+ }
+ nMask=n;
+}
+
+SfxStyleSheetIterator::~SfxStyleSheetIterator()
+{
+}
+
+
+USHORT SfxStyleSheetIterator::Count()
+{
+ USHORT n = 0;
+ if( IsTrivialSearch())
+ n = (USHORT) pBasePool->aStyles.Count();
+ else
+ for(USHORT i=0; i<pBasePool->aStyles.Count(); i++)
+ {
+ SfxStyleSheetBase* pStyle = pBasePool->aStyles.GetObject(i);
+ if(DoesStyleMatch(pStyle))
+ n++;
+ }
+ return n;
+}
+
+SfxStyleSheetBase* SfxStyleSheetIterator::operator[](USHORT nIdx)
+{
+ if( IsTrivialSearch())
+ return pBasePool->aStyles.GetObject(nIdx);
+
+ USHORT z = 0;
+ for(USHORT n=0; n<pBasePool->aStyles.Count(); n++)
+ {
+ SfxStyleSheetBase* pStyle = pBasePool->aStyles.GetObject(n);
+ if( DoesStyleMatch(pStyle))
+ {
+ if(z == nIdx)
+ {
+ nAktPosition=n;
+ return pAktStyle=pStyle;
+ }
+ ++z;
+ }
+ }
+ DBG_ERROR("falscher Index");
+ return 0;
+}
+
+SfxStyleSheetBase* SfxStyleSheetIterator::First()
+{
+ INT32 nIdx = -1;
+
+ if ( IsTrivialSearch() && pBasePool->aStyles.Count() )
+ nIdx = 0;
+ else
+ for( USHORT n = 0; n < pBasePool->aStyles.Count(); n++ )
+ {
+ SfxStyleSheetBase* pStyle = pBasePool->aStyles.GetObject(n);
+
+ if ( DoesStyleMatch( pStyle ) )
+ {
+ nIdx = n;
+ break;
+ }
+ }
+
+ if ( nIdx != -1 )
+ {
+ nAktPosition = (USHORT)nIdx;
+ return pAktStyle = pBasePool->aStyles.GetObject(nIdx);
+ }
+ return 0;
+}
+
+
+SfxStyleSheetBase* SfxStyleSheetIterator::Next()
+{
+ INT32 nIdx = -1;
+
+ if ( IsTrivialSearch() &&
+ (USHORT)pBasePool->aStyles.Count() > nAktPosition + 1 )
+ nIdx = nAktPosition + 1;
+ else
+ for( USHORT n = nAktPosition + 1; n < pBasePool->aStyles.Count(); n++ )
+ {
+ SfxStyleSheetBase* pStyle = pBasePool->aStyles.GetObject(n);
+
+ if ( DoesStyleMatch( pStyle ) )
+ {
+ nIdx = n;
+ break;
+ }
+ }
+
+ if ( nIdx != -1 )
+ {
+ nAktPosition = (USHORT)nIdx;
+ return pAktStyle = pBasePool->aStyles.GetObject(nIdx);
+ }
+ return 0;
+}
+
+
+SfxStyleSheetBase* SfxStyleSheetIterator::Find(const XubString& rStr)
+{
+ for ( USHORT n = 0; n < pBasePool->aStyles.Count(); n++ )
+ {
+ SfxStyleSheetBase* pStyle = pBasePool->aStyles.GetObject(n);
+
+ // #98454# performance: in case of bSearchUsed==TRUE it may be
+ // significant to first compare the name and only if it matches to call
+ // the style sheet IsUsed() method in DoesStyleMatch().
+ if ( pStyle->GetName().Equals( rStr ) && DoesStyleMatch( pStyle ) )
+ {
+ nAktPosition = n;
+ return pAktStyle = pStyle;
+ }
+ }
+ return 0;
+}
+
+
+USHORT SfxStyleSheetIterator::GetSearchMask() const
+{
+ USHORT mask = nMask;
+
+ if ( bSearchUsed )
+ mask |= SFXSTYLEBIT_USED;
+ return mask;
+}
+
+/////////////////////////// SfxStyleSheetBasePool ///////////////////////////////
+
+
+void SfxStyleSheetBasePool::Replace(
+ SfxStyleSheetBase& rSource, SfxStyleSheetBase& rTarget )
+{
+ rTarget.SetFollow( rSource.GetFollow() );
+ rTarget.SetParent( rSource.GetParent() );
+ SfxItemSet& rSourceSet = rSource.GetItemSet();
+ SfxItemSet& rTargetSet = rTarget.GetItemSet();
+ rTargetSet.Intersect( rSourceSet );
+ rTargetSet.Put( rSourceSet );
+}
+
+SfxStyleSheetIterator& SfxStyleSheetBasePool::GetIterator_Impl()
+{
+ SfxStyleSheetIterator*& rpIter = pImp->pIter;
+ if( !rpIter || rpIter->GetSearchMask() != nMask ||
+ rpIter->GetSearchFamily() != nSearchFamily )
+ {
+ delete rpIter;
+ rpIter = CreateIterator( nSearchFamily, nMask );
+ }
+ return *rpIter;
+}
+
+
+SfxStyleSheetBasePool::SfxStyleSheetBasePool( SfxItemPool& r )
+ : aAppName(r.GetName())
+ , rPool(r)
+ , nSearchFamily(SFX_STYLE_FAMILY_PARA)
+ , nMask(0xFFFF)
+{
+ pImp = new SfxStyleSheetBasePool_Impl;
+}
+
+SfxStyleSheetBasePool::SfxStyleSheetBasePool( const SfxStyleSheetBasePool& r )
+ : SfxBroadcaster( r )
+ , aAppName(r.aAppName)
+ , rPool(r.rPool)
+ , nSearchFamily(r.nSearchFamily)
+ , nMask( r.nMask )
+{
+ pImp = new SfxStyleSheetBasePool_Impl;
+ *this += r;
+}
+
+SfxStyleSheetBasePool::~SfxStyleSheetBasePool()
+{
+ Broadcast( SfxSimpleHint(SFX_HINT_DYING) );
+ Clear();
+ delete pImp;
+}
+
+BOOL SfxStyleSheetBasePool::SetParent(SfxStyleFamily eFam, const XubString& rStyle, const XubString& rParent)
+{
+ SfxStyleSheetIterator aIter(this,eFam,SFXSTYLEBIT_ALL);
+ SfxStyleSheetBase *pStyle =
+ aIter.Find(rStyle);
+ DBG_ASSERT(pStyle, "Vorlage nicht gefunden. Writer mit Solar <2541??");
+ if(pStyle)
+ return pStyle->SetParent(rParent);
+ else
+ return FALSE;
+}
+
+
+void SfxStyleSheetBasePool::SetSearchMask(SfxStyleFamily eFam, USHORT n)
+{
+ nSearchFamily = eFam; nMask = n;
+}
+
+USHORT SfxStyleSheetBasePool::GetSearchMask() const
+{
+ return nMask;
+}
+
+
+// Der Name des Streams
+
+String SfxStyleSheetBasePool::GetStreamName()
+{
+ return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(STYLESTREAM));
+}
+
+/////////////////////////////////// Factory ////////////////////////////////
+
+
+
+SfxStyleSheetIterator* SfxStyleSheetBasePool::CreateIterator
+(
+ SfxStyleFamily eFam,
+ USHORT mask
+)
+{
+ return new SfxStyleSheetIterator(this,eFam,mask);
+}
+
+
+SfxStyleSheetBase* SfxStyleSheetBasePool::Create
+(
+ const XubString& rName,
+ SfxStyleFamily eFam,
+ USHORT mask
+)
+{
+ return new SfxStyleSheetBase( rName, *this, eFam, mask );
+}
+
+SfxStyleSheetBase* SfxStyleSheetBasePool::Create( const SfxStyleSheetBase& r )
+{
+ return new SfxStyleSheetBase( r );
+}
+
+SfxStyleSheetBase& SfxStyleSheetBasePool::Make( const XubString& rName,
+ SfxStyleFamily eFam, USHORT mask, USHORT nPos)
+{
+ DBG_ASSERT( eFam != SFX_STYLE_FAMILY_ALL, "FamilyAll als Familie nicht erlaubt" );
+
+ SfxStyleSheetIterator aIter(this, eFam, mask);
+ SfxStyleSheetBase* p = aIter.Find( rName );
+ DBG_ASSERT( !p, "StyleSheet bereits vorhanden" );
+ SfxStyleSheetIterator& rIter = GetIterator_Impl();
+
+ if( !p )
+ {
+ p = Create( rName, eFam, mask );
+ if(0xffff == nPos || nPos == aStyles.Count() ||
+ nPos == rIter.Count())
+ aStyles.Insert( p, aStyles.Count() );
+ else
+ {
+ rIter[nPos];
+ aStyles.Insert(p, rIter.GetPos());
+ }
+ Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *p ) );
+ }
+ return *p;
+}
+
+/////////////////////////////// Kopieren ///////////////////////////////////
+
+// Hilfsroutine: Falls eine Vorlage dieses Namens existiert, wird
+// sie neu erzeugt. Alle Vorlagen, die diese Vorlage zum Parent haben,
+// werden umgehaengt.
+
+SfxStyleSheetBase& SfxStyleSheetBasePool::Add( SfxStyleSheetBase& rSheet )
+{
+ SfxStyleSheetIterator aIter(this, rSheet.GetFamily(), nMask);
+ SfxStyleSheetBase* pOld = aIter.Find( rSheet.GetName() );
+ Erase( pOld );
+ SfxStyleSheetBase* pNew = Create( rSheet );
+ aStyles.Insert( pNew, aStyles.Count() );
+ Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CHANGED, *pNew ) );
+ return *pNew;
+}
+
+SfxStyleSheetBasePool& SfxStyleSheetBasePool::operator=( const SfxStyleSheetBasePool& r )
+{
+ if( &r != this )
+ {
+ Clear();
+ *this += r;
+ }
+ return *this;
+}
+
+SfxStyleSheetBasePool& SfxStyleSheetBasePool::operator+=( const SfxStyleSheetBasePool& rP )
+{
+ if( &rP != this )
+ {
+ // kopieren
+ SfxStyleSheetBasePool& r = (SfxStyleSheetBasePool&) rP;
+ for( SfxStyleSheetBase* p = r.aStyles.First(); p; p = r.aStyles.Next() )
+ Add(*p);
+
+ }
+ return *this;
+}
+
+//////////////////////////////// Suchen ////////////////////////////////////
+
+USHORT SfxStyleSheetBasePool::Count()
+{
+ return GetIterator_Impl().Count();
+}
+
+SfxStyleSheetBase *SfxStyleSheetBasePool::operator[](USHORT nIdx)
+{
+ return GetIterator_Impl()[nIdx];
+}
+
+SfxStyleSheetBase* SfxStyleSheetBasePool::Find(const XubString& rName,
+ SfxStyleFamily eFam,
+ USHORT mask)
+{
+ SfxStyleSheetIterator aIter(this,eFam,mask);
+ return aIter.Find(rName);
+}
+
+SfxStyleSheetBase* SfxStyleSheetBasePool::First()
+{
+ return GetIterator_Impl().First();
+}
+
+SfxStyleSheetBase* SfxStyleSheetBasePool::Next()
+{
+ return GetIterator_Impl().Next();
+}
+
+//////////////////////////////// Loeschen /////////////////////////////////
+
+SfxStyleSheetBase* SfxStyleSheetBasePool::Remove( SfxStyleSheetBase* p )
+{
+ if( p )
+ {
+ // Alle Styles umsetzen, deren Parent dieser hier ist
+ ChangeParent( p->GetName(), p->GetParent() );
+ aStyles.Remove( p );
+ Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_ERASED, *p ) );
+ }
+ return p;
+}
+
+void SfxStyleSheetBasePool::Erase( SfxStyleSheetBase* p )
+{
+ if( p )
+ {
+ Remove(p);
+ delete p;
+ }
+}
+
+void SfxStyleSheetBasePool::Insert( SfxStyleSheetBase* p )
+{
+ DBG_ASSERT( p, "Kein StyleSheet?" );
+ SfxStyleSheetIterator aIter(
+ this, p->GetFamily(), p->GetMask());
+ SfxStyleSheetBase* pOld = aIter.Find( p->GetName() );
+ DBG_ASSERT( !pOld, "StyleSheet bereits vorhanden" );
+ if( p->GetParent().Len() )
+ {
+ pOld = aIter.Find( p->GetParent() );
+ DBG_ASSERT( pOld, "Parent nicht mehr vorhanden" );
+ }
+ aStyles.Insert( p, aStyles.Count() );
+ Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *p ) );
+}
+
+void SfxStyleSheetBasePool::Clear()
+{
+ while( aStyles.Count() )
+ {
+ SfxStyleSheetBase* p = aStyles.First();
+ aStyles.Remove( p );
+ Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_ERASED, *p ) );
+ delete p;
+ }
+}
+
+/////////////////////////// Parents umsetzen ////////////////////////////////
+
+void SfxStyleSheetBasePool::ChangeParent(const XubString& rOld,
+ const XubString& rNew,
+ BOOL bVirtual)
+{
+ const ULONG nPos = aStyles.GetCurPos();
+ const USHORT nTmpMask = GetSearchMask();
+ SetSearchMask(GetSearchFamily(), 0xffff);
+ for( SfxStyleSheetBase* p = First(); p; p = Next() )
+ {
+ if( p->GetParent().Equals( rOld ) )
+ {
+ if(bVirtual)
+ p->SetParent( rNew );
+ else
+ p->aParent = rNew;
+ }
+ }
+ SetSearchMask(GetSearchFamily(), nTmpMask);
+ aStyles.Seek(nPos);
+}
+
+/////////////////////////// Laden/Speichern /////////////////////////////////
+
+void SfxStyleSheetBase::Load( SvStream&, USHORT )
+{
+}
+
+void SfxStyleSheetBase::Store( SvStream& )
+{
+}
+
+
+BOOL SfxStyleSheetBasePool::Load( SvStream& rStream )
+{
+ // alte Version?
+ if ( !rPool.IsVer2_Impl() )
+ return Load1_Impl( rStream );
+
+ // gesamten StyleSheetPool in neuer Version aus einem MiniRecord lesen
+ SfxMiniRecordReader aPoolRec( &rStream, SFX_STYLES_REC );
+
+ // Header-Record lesen
+ short nCharSet = 0;
+ if ( !rStream.GetError() )
+ {
+ SfxSingleRecordReader aHeaderRec( &rStream, SFX_STYLES_REC_HEADER );
+ if ( !aHeaderRec.IsValid() )
+ return FALSE;
+
+ aAppName = rPool.GetName();
+ rStream >> nCharSet;
+ }
+
+ // Styles-Record lesen
+ if ( !rStream.GetError() )
+ {
+ SfxMultiRecordReader aStylesRec( &rStream, SFX_STYLES_REC_STYLES );
+ if ( !aStylesRec.IsValid() )
+ return FALSE;
+
+ rtl_TextEncoding eEnc = GetSOLoadTextEncoding(
+ (rtl_TextEncoding)nCharSet,
+ sal::static_int_cast< USHORT >(rStream.GetVersion()) );
+ rtl_TextEncoding eOldEnc = rStream.GetStreamCharSet();
+ rStream.SetStreamCharSet( eEnc );
+
+ USHORT nStyles;
+ for ( nStyles = 0; aStylesRec.GetContent(); nStyles++ )
+ {
+ // kann nicht mehr weiterlesen?
+ if ( rStream.GetError() )
+ break;
+
+ // Globale Teile
+ XubString aName, aParent, aFollow;
+ String aHelpFile;
+ USHORT nFamily, nStyleMask,nCount;
+ sal_uInt32 nHelpId;
+ rStream.ReadByteString(aName, eEnc );
+ rStream.ReadByteString(aParent, eEnc );
+ rStream.ReadByteString(aFollow, eEnc );
+ rStream >> nFamily >> nStyleMask;
+ SfxPoolItem::readByteString(rStream, aHelpFile);
+ rStream >> nHelpId;
+
+ SfxStyleSheetBase& rSheet = Make( aName, (SfxStyleFamily)nFamily , nStyleMask);
+ rSheet.SetHelpId( aHelpFile, nHelpId );
+ // Hier erst einmal Parent und Follow zwischenspeichern
+ rSheet.aParent = aParent;
+ rSheet.aFollow = aFollow;
+ UINT32 nPos = rStream.Tell();
+ rStream >> nCount;
+ if(nCount)
+ {
+ rStream.Seek( nPos );
+ // Das Laden des ItemSets bedient sich der Methode GetItemSet(),
+ // damit eigene ItemSets untergeschoben werden koennen
+ SfxItemSet& rSet = rSheet.GetItemSet();
+ rSet.ClearItem();
+ //! SfxItemSet aTmpSet( *pTmpPool );
+ /*!aTmpSet*/ rSet.Load( rStream );
+ //! rSet.Put( aTmpSet );
+ }
+ // Lokale Teile
+ UINT32 nSize;
+ USHORT nVer;
+ rStream >> nVer >> nSize;
+ nPos = rStream.Tell() + nSize;
+ rSheet.Load( rStream, nVer );
+ rStream.Seek( nPos );
+ }
+
+ // #72939# only loop through the styles that were really inserted
+ ULONG n = aStyles.Count();
+
+ //! delete pTmpPool;
+ // Jetzt Parent und Follow setzen. Alle Sheets sind geladen.
+ // Mit Setxxx() noch einmal den String eintragen, da diese
+ // virtuellen Methoden evtl. ueberlagert sind.
+ for ( ULONG i = 0; i < n; i++ )
+ {
+ SfxStyleSheetBase* p = aStyles.GetObject( i );
+ XubString aText = p->aParent;
+ p->aParent.Erase();
+ p->SetParent( aText );
+ aText = p->aFollow;
+ p->aFollow.Erase();
+ p->SetFollow( aText );
+ }
+
+ rStream.SetStreamCharSet( eOldEnc );
+ }
+
+ // alles klar?
+ return BOOL( rStream.GetError() == SVSTREAM_OK );
+}
+
+BOOL SfxStyleSheetBasePool::Load1_Impl( SvStream& rStream )
+{
+ aAppName = rPool.GetName();
+ USHORT nVersion;
+ short nCharSet;
+ rStream >> nVersion;
+
+ if(nVersion!=STYLESTREAM_VERSION)
+ nCharSet=nVersion;
+ else
+ rStream >> nCharSet;
+
+ rtl_TextEncoding eEnc = GetSOLoadTextEncoding(
+ (rtl_TextEncoding)nCharSet,
+ sal::static_int_cast< USHORT >(rStream.GetVersion()) );
+ rtl_TextEncoding eOldEnc = rStream.GetStreamCharSet();
+ rStream.SetStreamCharSet( eEnc );
+
+ USHORT nStyles;
+ rStream >> nStyles;
+ USHORT i;
+ for ( i = 0; i < nStyles; i++ )
+ {
+ // kann nicht mehr weiterlesen?
+ if ( rStream.GetError() )
+ {
+ nStyles = i;
+ break;
+ }
+
+ // Globale Teile
+ XubString aName, aParent, aFollow;
+ String aHelpFile;
+ USHORT nFamily, nStyleMask,nCount;
+ sal_uInt32 nHelpId;
+ rStream.ReadByteString(aName, eEnc );
+ rStream.ReadByteString(aParent, eEnc );
+ rStream.ReadByteString(aFollow, eEnc );
+ rStream >> nFamily >> nStyleMask;
+ SfxPoolItem::readByteString(rStream, aHelpFile);
+ if(nVersion!=STYLESTREAM_VERSION)
+ {
+ USHORT nTmpHelpId;
+ rStream >> nTmpHelpId;
+ nHelpId=nTmpHelpId;
+ }
+ else
+ rStream >> nHelpId;
+
+ SfxStyleSheetBase& rSheet = Make( aName, (SfxStyleFamily)nFamily , nStyleMask);
+ rSheet.SetHelpId( aHelpFile, nHelpId );
+ // Hier erst einmal Parent und Follow zwischenspeichern
+ rSheet.aParent = aParent;
+ rSheet.aFollow = aFollow;
+ UINT32 nPos = rStream.Tell();
+ rStream >> nCount;
+ if(nCount) {
+ rStream.Seek( nPos );
+ // Das Laden des ItemSets bedient sich der Methode GetItemSet(),
+ // damit eigene ItemSets untergeschoben werden koennen
+ SfxItemSet& rSet = rSheet.GetItemSet();
+ rSet.ClearItem();
+//! SfxItemSet aTmpSet( *pTmpPool );
+ /*!aTmpSet*/ rSet.Load( rStream );
+ //! rSet.Put( aTmpSet );
+ }
+ // Lokale Teile
+ UINT32 nSize;
+ USHORT nVer;
+ rStream >> nVer >> nSize;
+ nPos = rStream.Tell() + nSize;
+ rSheet.Load( rStream, nVer );
+ rStream.Seek( nPos );
+ }
+
+ //! delete pTmpPool;
+ // Jetzt Parent und Follow setzen. Alle Sheets sind geladen.
+ // Mit Setxxx() noch einmal den String eintragen, da diese
+ // virtuellen Methoden evtl. ueberlagert sind.
+ for ( i = 0; i < nStyles; i++ )
+ {
+ SfxStyleSheetBase* p = aStyles.GetObject( i );
+ XubString aText = p->aParent;
+ p->aParent.Erase();
+ p->SetParent( aText );
+ aText = p->aFollow;
+ p->aFollow.Erase();
+ p->SetFollow( aText );
+ }
+
+ rStream.SetStreamCharSet( eOldEnc );
+
+ return BOOL( rStream.GetError() == SVSTREAM_OK );
+}
+
+BOOL SfxStyleSheetBasePool::Store( SvStream& rStream, BOOL bUsed )
+{
+ // den ganzen StyleSheet-Pool in einen Mini-Record
+ SfxMiniRecordWriter aPoolRec( &rStream, SFX_STYLES_REC );
+
+ // Erst einmal die Dummies rauszaehlen; die werden nicht gespeichert
+ USHORT nCount = 0;
+ for( SfxStyleSheetBase* p = First(); p; p = Next() )
+ {
+ if(!bUsed || p->IsUsed())
+ nCount++;
+ }
+
+ // einen Header-Record vorweg
+ rtl_TextEncoding eEnc
+ = ::GetSOStoreTextEncoding(
+ rStream.GetStreamCharSet(),
+ sal::static_int_cast< USHORT >(rStream.GetVersion()) );
+ rtl_TextEncoding eOldEnc = rStream.GetStreamCharSet();
+ rStream.SetStreamCharSet( eEnc );
+
+ {
+ SfxSingleRecordWriter aHeaderRec( &rStream,
+ SFX_STYLES_REC_HEADER,
+ STYLESTREAM_VERSION );
+ rStream << (short) eEnc;
+ }
+
+ // die StyleSheets in einen MultiVarRecord
+ {
+ // Bug 79478:
+ // make a check loop, to be shure, that the converted names are also
+ // unique like the originals! In other cases we get a loop.
+ SvStringsSortDtor aSortOrigNames( 0, 128 );
+ SvStrings aOrigNames( 0, 128 );
+ SvByteStringsSortDtor aSortConvNames( 0, 128 );
+ SvByteStrings aConvNames( 0, 128 );
+
+ {
+
+ for( SfxStyleSheetBase* p = First(); p; p = Next() )
+ {
+ if(!bUsed || p->IsUsed())
+ {
+ USHORT nFamily = (USHORT)p->GetFamily();
+ String* pName = new String( p->GetName() );
+ ByteString* pConvName = new ByteString( *pName, eEnc );
+
+ pName->Insert( (sal_Unicode)nFamily, 0 );
+ pConvName->Insert( " ", 0 );
+ pConvName->SetChar(
+ 0,
+ sal::static_int_cast< char >(0xff & (nFamily >> 8)) );
+ pConvName->SetChar(
+ 1, sal::static_int_cast< char >(0xff & nFamily) );
+
+ USHORT nInsPos, nAdd = aSortConvNames.Count();
+ while( !aSortConvNames.Insert( pConvName, nInsPos ) )
+ (pConvName->Append( '_' )).Append(
+ ByteString::CreateFromInt32( nAdd++ ));
+ aOrigNames.Insert( pName, nInsPos );
+ }
+ }
+
+ // now we have the list of the names, sorted by convertede names
+ // But now we need the sorted list of orignames.
+ {
+ USHORT nInsPos, nEnd = aOrigNames.Count();
+ const ByteStringPtr* ppB = aSortConvNames.GetData();
+ for( USHORT n = 0; n < nEnd; ++n, ++ppB )
+ {
+ String* p = aOrigNames.GetObject( n );
+ aSortOrigNames.Insert( p, nInsPos );
+ aConvNames.Insert( *ppB, nInsPos );
+ }
+
+ }
+ }
+
+
+ ByteString sEmpty;
+ USHORT nFndPos;
+ String sNm;
+ SfxMultiVarRecordWriter aStylesRec( &rStream, SFX_STYLES_REC_STYLES, 0 );
+ for( SfxStyleSheetBase* p = First(); p; p = Next() )
+ {
+ if(!bUsed || p->IsUsed())
+ {
+ aStylesRec.NewContent();
+
+ // Globale Teile speichern
+ String aHelpFile;
+ sal_uInt32 nHelpId = p->GetHelpId( aHelpFile );
+ USHORT nFamily = sal::static_int_cast< USHORT >(p->GetFamily());
+ String sFamily( (sal_Unicode)nFamily );
+
+ (sNm = sFamily) += p->GetName();
+ if( aSortOrigNames.Seek_Entry( &sNm, &nFndPos ))
+ rStream.WriteByteString( aConvNames.GetObject( nFndPos )->Copy( 2 ));
+ else
+ rStream.WriteByteString( sEmpty );
+
+ (sNm = sFamily) += p->GetParent();
+ if( aSortOrigNames.Seek_Entry( &sNm, &nFndPos ))
+ rStream.WriteByteString( aConvNames.GetObject( nFndPos )->Copy( 2 ));
+ else
+ rStream.WriteByteString( sEmpty );
+
+ (sNm = sFamily) += p->GetFollow();
+ if( aSortOrigNames.Seek_Entry( &sNm, &nFndPos ))
+ rStream.WriteByteString( aConvNames.GetObject( nFndPos )->Copy( 2 ));
+ else
+ rStream.WriteByteString( sEmpty );
+
+ rStream << nFamily << p->GetMask();
+ SfxPoolItem::writeByteString(rStream, aHelpFile);
+ rStream << nHelpId;
+ if(p->pSet)
+ p->pSet->Store( rStream );
+ else
+ rStream << (USHORT)0;
+
+ // Lokale Teile speichern
+ // Vor dem lokalen Teil wird die Laenge der lokalen Daten
+ // als UINT32 sowie die Versionsnummer gespeichert.
+ rStream << (USHORT) p->GetVersion();
+ ULONG nPos1 = rStream.Tell();
+ rStream << (UINT32) 0;
+ p->Store( rStream );
+ ULONG nPos2 = rStream.Tell();
+ rStream.Seek( nPos1 );
+ rStream << (UINT32) ( nPos2 - nPos1 - sizeof( UINT32 ) );
+ rStream.Seek( nPos2 );
+ if( rStream.GetError() != SVSTREAM_OK )
+ break;
+ }
+ }
+ }
+
+ rStream.SetStreamCharSet( eOldEnc );
+
+ return BOOL( rStream.GetError() == SVSTREAM_OK );
+}
+
+SfxItemPool& SfxStyleSheetBasePool::GetPool()
+{
+ return rPool;
+}
+
+const SfxItemPool& SfxStyleSheetBasePool::GetPool() const
+{
+ return rPool;
+}
+
+/////////////////////// SfxStyleSheet /////////////////////////////////
+
+SfxStyleSheet::SfxStyleSheet(const XubString &rName,
+ SfxStyleSheetBasePool& r_Pool,
+ SfxStyleFamily eFam,
+ USHORT mask ):
+ SfxStyleSheetBase(rName, r_Pool, eFam, mask)
+{}
+
+SfxStyleSheet::SfxStyleSheet(const SfxStyleSheet& rStyle) :
+ SfxStyleSheetBase(rStyle),
+ SfxListener( rStyle ),
+ SfxBroadcaster( rStyle )
+{}
+
+SfxStyleSheet::~SfxStyleSheet()
+{
+ Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_INDESTRUCTION, *this ) );
+}
+
+
+BOOL SfxStyleSheet::SetParent( const XubString& rName )
+{
+ if(aParent == rName)
+ return TRUE;
+ const XubString aOldParent(aParent);
+ if(SfxStyleSheetBase::SetParent(rName)) {
+ // aus der Benachrichtigungskette des alten
+ // Parents gfs. austragen
+ if(aOldParent.Len()) {
+ SfxStyleSheet *pParent = (SfxStyleSheet *)rPool.Find(aOldParent, nFamily, 0xffff);
+ if(pParent)
+ EndListening(*pParent);
+ }
+ // in die Benachrichtigungskette des neuen
+ // Parents eintragen
+ if(aParent.Len()) {
+ SfxStyleSheet *pParent = (SfxStyleSheet *)rPool.Find(aParent, nFamily, 0xffff);
+ if(pParent)
+ StartListening(*pParent);
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+// alle Zuhoerer benachtichtigen
+
+void SfxStyleSheet::SFX_NOTIFY(SfxBroadcaster& rBC, const TypeId& rBCType,
+ const SfxHint& rHint, const TypeId& rHintType )
+{
+ SFX_FORWARD(rBC, rBCType, rHint, rHintType);
+}
+
+//////////////////////// SfxStyleSheetPool ///////////////////////////////
+
+SfxStyleSheetPool::SfxStyleSheetPool( SfxItemPool& rSet):
+ SfxStyleSheetBasePool(rSet)
+{}
+
+/////////////////////////////////// Factory ////////////////////////////////
+
+SfxStyleSheetBase* SfxStyleSheetPool::Create( const XubString& rName,
+ SfxStyleFamily eFam, USHORT mask )
+{
+ return new SfxStyleSheet( rName, *this, eFam, mask );
+}
+
+SfxStyleSheetBase* SfxStyleSheetPool::Create( const SfxStyleSheet& r )
+{
+ return new SfxStyleSheet( r );
+}
+/*
+BOOL SfxStyleSheetPool::CopyTo(SfxStyleSheetPool &, const String &)
+{
+ return FALSE;
+}
+*/
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items/svt_szitem.cxx b/binfilter/bf_svtools/source/items/svt_szitem.cxx
new file mode 100644
index 000000000000..9bc710fc34c8
--- /dev/null
+++ b/binfilter/bf_svtools/source/items/svt_szitem.cxx
@@ -0,0 +1,210 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/szitem.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/awt/Size.hpp>
+
+#include <tools/stream.hxx>
+#include <tools/gen.hxx>
+
+#include <bf_svtools/poolitem.hxx>
+#include "memberid.hrc"
+
+namespace binfilter
+{
+
+// STATIC DATA -----------------------------------------------------------
+
+DBG_NAME(SfxSizeItem)
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1_AUTOFACTORY(SfxSizeItem, SfxPoolItem);
+
+// -----------------------------------------------------------------------
+
+SfxSizeItem::SfxSizeItem()
+{
+ DBG_CTOR(SfxSizeItem, 0);
+}
+
+// -----------------------------------------------------------------------
+
+SfxSizeItem::SfxSizeItem( USHORT nW, const Size& rVal ) :
+ SfxPoolItem( nW ),
+ aVal( rVal )
+{
+ DBG_CTOR(SfxSizeItem, 0);
+}
+
+// -----------------------------------------------------------------------
+
+SfxSizeItem::SfxSizeItem( const SfxSizeItem& rItem ) :
+ SfxPoolItem( rItem ),
+ aVal( rItem.aVal )
+{
+ DBG_CTOR(SfxSizeItem, 0);
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemPresentation SfxSizeItem::GetPresentation
+(
+ SfxItemPresentation /*ePresentation*/,
+ SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/,
+ XubString& rText,
+ const ::IntlWrapper *
+) const
+{
+ DBG_CHKTHIS(SfxSizeItem, 0);
+ rText = UniString::CreateFromInt32(aVal.Width());
+ rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ rText += UniString::CreateFromInt32(aVal.Height());
+ rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+// -----------------------------------------------------------------------
+
+int SfxSizeItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_CHKTHIS(SfxSizeItem, 0);
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+ return ((SfxSizeItem&)rItem).aVal == aVal;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxSizeItem::Clone(SfxItemPool *) const
+{
+ DBG_CHKTHIS(SfxSizeItem, 0);
+ return new SfxSizeItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxSizeItem::Create(SvStream &rStream, USHORT ) const
+{
+ DBG_CHKTHIS(SfxSizeItem, 0);
+ Size aStr;
+ rStream >> aStr;
+ return new SfxSizeItem(Which(), aStr);
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SfxSizeItem::Store(SvStream &rStream, USHORT ) const
+{
+ DBG_CHKTHIS(SfxSizeItem, 0);
+ rStream << aVal;
+ return rStream;
+}
+
+// -----------------------------------------------------------------------
+bool SfxSizeItem::QueryValue( ::com::sun::star::uno::Any& rVal,
+ BYTE nMemberId ) const
+{
+ sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+
+ Size aTmp(aVal);
+ if( bConvert )
+ {
+ aTmp.Height() = ( aTmp.Height() * 127 + 36) / 72;
+ aTmp.Width() = ( aTmp.Width() * 127 + 36) / 72;
+ }
+
+ switch ( nMemberId )
+ {
+ case 0:
+ {
+ rVal <<= com::sun::star::awt::Size( aTmp.getWidth(), aTmp.getHeight() );
+ break;
+ }
+ case MID_WIDTH:
+ rVal <<= aTmp.getWidth(); break;
+ case MID_HEIGHT:
+ rVal <<= aTmp.getHeight(); break;
+ default: DBG_ERROR("Wrong MemberId!"); return false;
+ }
+
+ return false;
+}
+
+// -----------------------------------------------------------------------
+bool SfxSizeItem::PutValue( const com::sun::star::uno::Any& rVal,
+ BYTE nMemberId )
+{
+ sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+
+ bool bRet = false;
+ com::sun::star::awt::Size aValue;
+ sal_Int32 nVal = 0;
+ if ( !nMemberId )
+ bRet = ( rVal >>= aValue );
+ else
+ {
+ bRet = ( rVal >>= nVal );
+ if ( nMemberId == MID_WIDTH )
+ {
+ aValue.Width = nVal;
+ aValue.Height = aVal.Height();
+ }
+ else
+ {
+ aValue.Height = nVal;
+ aValue.Width = aVal.Width();
+ }
+ }
+
+ if ( bRet )
+ {
+ Size aTmp( aValue.Width, aValue.Height );
+ if( bConvert )
+ {
+ aTmp.Height() = ( aTmp.Height() * 72 + 63) / 127;
+ aTmp.Width() = ( aTmp.Width() * 72 + 63) / 127;
+ }
+
+ aVal = aTmp;
+ }
+
+ return bRet;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/makefile.mk b/binfilter/bf_svtools/source/items1/makefile.mk
new file mode 100644
index 000000000000..05a84a67de74
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/makefile.mk
@@ -0,0 +1,71 @@
+#*************************************************************************
+#
+# DO NOT ALTER 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=binfilter
+TARGET=items1
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=\
+ $(SLO)$/svt_bintitem.obj \
+ $(SLO)$/svt_cenumitm.obj \
+ $(SLO)$/svt_cintitem.obj \
+ $(SLO)$/svt_cntwall.obj \
+ $(SLO)$/svt_cstitem.obj \
+ $(SLO)$/svt_ctypeitm.obj \
+ $(SLO)$/svt_custritm.obj \
+ $(SLO)$/svt_dateitem.obj \
+ $(SLO)$/svt_dtritem.obj \
+ $(SLO)$/svt_frqitem.obj \
+ $(SLO)$/svt_ilstitem.obj \
+ $(SLO)$/svt_itemiter.obj \
+ $(SLO)$/svt_itempool.obj \
+ $(SLO)$/svt_itemprop.obj \
+ $(SLO)$/svt_itemset.obj \
+ $(SLO)$/svt_lckbitem.obj \
+ $(SLO)$/svt_poolio.obj \
+ $(SLO)$/svt_stylepool.obj \
+ $(SLO)$/svt_poolitem.obj \
+ $(SLO)$/svt_sfontitm.obj \
+ $(SLO)$/svt_sitem.obj \
+ $(SLO)$/svt_slstitm.obj \
+ $(SLO)$/svt_tfrmitem.obj \
+ $(SLO)$/svt_tresitem.obj \
+ $(SLO)$/svt_whiter.obj \
+ $(SLO)$/svt_visitem.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/binfilter/bf_svtools/source/items1/svt_bintitem.cxx b/binfilter/bf_svtools/source/items1/svt_bintitem.cxx
new file mode 100644
index 000000000000..15cb930ec65a
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_bintitem.cxx
@@ -0,0 +1,168 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <com/sun/star/uno/Any.hxx>
+
+#include <tools/stream.hxx>
+
+#include <tools/bigint.hxx>
+
+#include <bf_svtools/bintitem.hxx>
+
+// STATIC DATA
+namespace binfilter
+{
+
+DBG_NAME(SfxBigIntItem)
+
+// RTTI
+TYPEINIT1_AUTOFACTORY(SfxBigIntItem, SfxPoolItem);
+
+// SfxBigIntItem
+
+//============================================================================
+SfxBigIntItem::SfxBigIntItem()
+ : SfxPoolItem(0),
+ aVal(0)
+{
+ DBG_CTOR(SfxBigIntItem, 0);
+}
+
+//============================================================================
+SfxBigIntItem::SfxBigIntItem(USHORT which, SvStream &rStream)
+ : SfxPoolItem(which)
+{
+ DBG_CTOR(SfxBigIntItem, 0);
+ ByteString sTmp;
+ rStream.ReadByteString(sTmp);
+ BigInt aTmp(sTmp);
+ aVal = aTmp;
+}
+
+//============================================================================
+SfxBigIntItem::SfxBigIntItem(const SfxBigIntItem& rItem)
+ : SfxPoolItem(rItem),
+ aVal(rItem.aVal)
+{
+ DBG_CTOR(SfxBigIntItem, 0);
+}
+
+//============================================================================
+SfxItemPresentation SfxBigIntItem::GetPresentation(
+ SfxItemPresentation /*ePresentation*/,
+ SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/,
+ XubString& rText,
+ const ::IntlWrapper * ) const
+{
+ DBG_CHKTHIS(SfxBigIntItem, 0);
+ rText = aVal.GetString();
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+//============================================================================
+int SfxBigIntItem::operator==(const SfxPoolItem& rItem) const
+{
+ DBG_CHKTHIS(SfxBigIntItem, 0);
+ DBG_ASSERT(SfxPoolItem::operator==(rItem), "unequal type");
+ return ((SfxBigIntItem&)rItem).aVal == aVal;
+}
+
+//============================================================================
+int SfxBigIntItem::Compare(const SfxPoolItem& rItem) const
+{
+ DBG_CHKTHIS(SfxBigIntItem, 0);
+ DBG_ASSERT(SfxPoolItem::operator==(rItem), "unequal type");
+
+ if (((const SfxBigIntItem&)rItem ).aVal < aVal )
+ return -1;
+ else if (((const SfxBigIntItem&)rItem ).aVal == aVal)
+ return 0;
+ else
+ return 1;
+}
+
+//============================================================================
+SfxPoolItem* SfxBigIntItem::Clone(SfxItemPool *) const
+{
+ DBG_CHKTHIS(SfxBigIntItem, 0);
+ return new SfxBigIntItem(*this);
+}
+
+//============================================================================
+SfxPoolItem* SfxBigIntItem::Create(SvStream &rStream, USHORT) const
+{
+ DBG_CHKTHIS(SfxBigIntItem, 0);
+ return new SfxBigIntItem(Which(), rStream);
+}
+
+//============================================================================
+SvStream& SfxBigIntItem::Store(SvStream &rStream, USHORT ) const
+{
+ DBG_CHKTHIS(SfxBigIntItem, 0);
+ rStream.WriteByteString( aVal.GetByteString() );
+ return rStream;
+}
+
+//============================================================================
+SfxFieldUnit SfxBigIntItem::GetUnit() const
+{
+ DBG_CHKTHIS(SfxBigIntItem, 0);
+ return SFX_FUNIT_NONE;
+}
+
+//============================================================================
+// virtual
+bool SfxBigIntItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE )
+{
+ double aValue = 0.0;
+ if ( rVal >>= aValue )
+ {
+ SetValue( aValue );
+ return true;
+ }
+
+ DBG_ERROR( "SfxBigIntItem::PutValue - Wrong type!" );
+ return false;
+}
+
+//============================================================================
+// virtual
+bool SfxBigIntItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE ) const
+{
+ double aValue = GetValue();
+ rVal <<= aValue;
+ return true;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_cenumitm.cxx b/binfilter/bf_svtools/source/items1/svt_cenumitm.cxx
new file mode 100644
index 000000000000..be24da8baf47
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_cenumitm.cxx
@@ -0,0 +1,302 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <com/sun/star/uno/Any.hxx>
+#include <tools/stream.hxx>
+
+#include <bf_svtools/cenumitm.hxx>
+
+#include <whassert.hxx>
+
+#include <cppuhelper/extract.hxx>
+
+namespace binfilter
+{
+
+//============================================================================
+//
+// class SfxEnumItemInterface
+//
+//============================================================================
+
+DBG_NAME(SfxEnumItemInterface)
+
+//============================================================================
+TYPEINIT1(SfxEnumItemInterface, SfxPoolItem)
+
+//============================================================================
+// virtual
+int SfxEnumItemInterface::operator ==(const SfxPoolItem & rItem) const
+{
+ SFX_ASSERT(SfxPoolItem::operator ==(rItem), Which(), "unequal type");
+ return GetEnumValue()
+ == static_cast< const SfxEnumItemInterface * >(&rItem)->
+ GetEnumValue();
+}
+
+//============================================================================
+// virtual
+SfxItemPresentation
+SfxEnumItemInterface::GetPresentation(SfxItemPresentation, SfxMapUnit,
+ SfxMapUnit, XubString & rText,
+ const ::IntlWrapper *) const
+{
+ rText = XubString::CreateFromInt32(GetEnumValue());
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+//============================================================================
+// virtual
+bool SfxEnumItemInterface::QueryValue(::com::sun::star::uno::Any& rVal, BYTE)
+ const
+{
+ rVal <<= sal_Int32(GetEnumValue());
+ return true;
+}
+
+//============================================================================
+// virtual
+bool SfxEnumItemInterface::PutValue(const ::com::sun::star::uno::Any& rVal,
+ BYTE)
+{
+ sal_Int32 nTheValue = 0;
+
+ if ( ::cppu::enum2int( nTheValue, rVal ) )
+ {
+ SetEnumValue(USHORT(nTheValue));
+ return true;
+ }
+ DBG_ERROR("SfxEnumItemInterface::PutValue(): Wrong type");
+ return false;
+}
+
+//============================================================================
+XubString SfxEnumItemInterface::GetValueTextByPos(USHORT) const
+{
+ DBG_WARNING("SfxEnumItemInterface::GetValueTextByPos(): Pure virtual");
+ return XubString();
+}
+
+//============================================================================
+// virtual
+USHORT SfxEnumItemInterface::GetValueByPos(USHORT nPos) const
+{
+ return nPos;
+}
+
+//============================================================================
+// virtual
+USHORT SfxEnumItemInterface::GetPosByValue(USHORT nValue) const
+{
+ USHORT nCount = GetValueCount();
+ for (USHORT i = 0; i < nCount; ++i)
+ if (GetValueByPos(i) == nValue)
+ return i;
+ return USHRT_MAX;
+}
+
+BOOL SfxEnumItemInterface::IsEnabled(USHORT) const
+{
+ return TRUE;
+}
+
+//============================================================================
+// virtual
+int SfxEnumItemInterface::HasBoolValue() const
+{
+ return false;
+}
+
+//============================================================================
+// virtual
+BOOL SfxEnumItemInterface::GetBoolValue() const
+{
+ return false;
+}
+
+//============================================================================
+// virtual
+void SfxEnumItemInterface::SetBoolValue(BOOL)
+{}
+
+//============================================================================
+//
+// class CntEnumItem
+//
+//============================================================================
+
+DBG_NAME(CntEnumItem)
+
+//============================================================================
+CntEnumItem::CntEnumItem(USHORT which, SvStream & rStream):
+ SfxEnumItemInterface(which)
+{
+ m_nValue = 0;
+ rStream >> m_nValue;
+}
+
+//============================================================================
+TYPEINIT1(CntEnumItem, SfxEnumItemInterface)
+
+//============================================================================
+// virtual
+SvStream & CntEnumItem::Store(SvStream & rStream, USHORT) const
+{
+ rStream << m_nValue;
+ return rStream;
+}
+
+//============================================================================
+// virtual
+USHORT CntEnumItem::GetEnumValue() const
+{
+ return GetValue();
+}
+
+//============================================================================
+// virtual
+void CntEnumItem::SetEnumValue(USHORT nTheValue)
+{
+ SetValue(nTheValue);
+}
+
+//============================================================================
+//
+// class CntBoolItem
+//
+//============================================================================
+
+DBG_NAME(CntBoolItem)
+
+//============================================================================
+TYPEINIT1_AUTOFACTORY(CntBoolItem, SfxPoolItem)
+
+//============================================================================
+CntBoolItem::CntBoolItem(USHORT which, SvStream & rStream):
+ SfxPoolItem(which)
+{
+ m_bValue = false;
+ rStream >> m_bValue;
+}
+
+//============================================================================
+// virtual
+int CntBoolItem::operator ==(const SfxPoolItem & rItem) const
+{
+ DBG_ASSERT(rItem.ISA(CntBoolItem),
+ "CntBoolItem::operator ==(): Bad type");
+ return m_bValue == static_cast< CntBoolItem const * >(&rItem)->m_bValue;
+}
+
+//============================================================================
+// virtual
+int CntBoolItem::Compare(const SfxPoolItem & rWith) const
+{
+ DBG_ASSERT(rWith.ISA(CntBoolItem), "CntBoolItem::Compare(): Bad type");
+ return m_bValue == static_cast< CntBoolItem const * >(&rWith)->m_bValue ?
+ 0 : m_bValue ? -1 : 1;
+}
+
+//============================================================================
+// virtual
+SfxItemPresentation CntBoolItem::GetPresentation(SfxItemPresentation,
+ SfxMapUnit, SfxMapUnit,
+ UniString & rText,
+ const ::IntlWrapper *) const
+{
+ rText = GetValueTextByVal(m_bValue);
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+//============================================================================
+// virtual
+bool CntBoolItem::QueryValue(com::sun::star::uno::Any& rVal, BYTE) const
+{
+ rVal <<= sal_Bool(m_bValue);
+ return true;
+}
+
+//============================================================================
+// virtual
+bool CntBoolItem::PutValue(const com::sun::star::uno::Any& rVal, BYTE)
+{
+ sal_Bool bTheValue = sal_Bool();
+ if (rVal >>= bTheValue)
+ {
+ m_bValue = bTheValue;
+ return true;
+ }
+ DBG_ERROR("CntBoolItem::PutValue(): Wrong type");
+ return false;
+}
+
+//============================================================================
+// virtual
+SfxPoolItem * CntBoolItem::Create(SvStream & rStream, USHORT) const
+{
+ return new CntBoolItem(Which(), rStream);
+}
+
+//============================================================================
+// virtual
+SvStream & CntBoolItem::Store(SvStream & rStream, USHORT) const
+{
+ rStream << m_bValue;
+ return rStream;
+}
+
+//============================================================================
+// virtual
+SfxPoolItem * CntBoolItem::Clone(SfxItemPool *) const
+{
+ return new CntBoolItem(*this);
+}
+
+//============================================================================
+// virtual
+USHORT CntBoolItem::GetValueCount() const
+{
+ return 2;
+}
+
+//============================================================================
+// virtual
+UniString CntBoolItem::GetValueTextByVal(BOOL bTheValue) const
+{
+ return
+ bTheValue ?
+ UniString::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("TRUE")) :
+ UniString::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("FALSE"));
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_cintitem.cxx b/binfilter/bf_svtools/source/items1/svt_cintitem.cxx
new file mode 100644
index 000000000000..0c276f000a0d
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_cintitem.cxx
@@ -0,0 +1,564 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <com/sun/star/uno/Any.hxx>
+
+#include <tools/stream.hxx>
+
+#include <bf_svtools/cintitem.hxx>
+
+namespace binfilter
+{
+
+//============================================================================
+//
+// class CntByteItem
+//
+//============================================================================
+
+DBG_NAME(CntByteItem)
+
+//============================================================================
+TYPEINIT1_AUTOFACTORY(CntByteItem, SfxPoolItem);
+
+//============================================================================
+// virtual
+int CntByteItem::operator ==(const SfxPoolItem & rItem) const
+{
+ DBG_CHKTHIS(CntByteItem, 0);
+ DBG_ASSERT(rItem.ISA(CntByteItem),
+ "CntByteItem::operator ==(): Bad type");
+ return m_nValue == SAL_STATIC_CAST(const CntByteItem *, &rItem)->m_nValue;
+}
+
+//============================================================================
+// virtual
+int CntByteItem::Compare(const SfxPoolItem & rWith) const
+{
+ DBG_CHKTHIS(CntByteItem, 0);
+ DBG_ASSERT(rWith.ISA(CntByteItem), "CntByteItem::Compare(): Bad type");
+ return SAL_STATIC_CAST(const CntByteItem *, &rWith)->m_nValue < m_nValue ?
+ -1 :
+ SAL_STATIC_CAST(const CntByteItem *, &rWith)->m_nValue
+ == m_nValue ?
+ 0 : 1;
+}
+
+//============================================================================
+// virtual
+SfxItemPresentation CntByteItem::GetPresentation(SfxItemPresentation,
+ SfxMapUnit, SfxMapUnit,
+ XubString & rText,
+ const ::IntlWrapper *) const
+{
+ DBG_CHKTHIS(CntByteItem, 0);
+ rText = XubString::CreateFromInt32(m_nValue);
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+//============================================================================
+// virtual
+bool CntByteItem::QueryValue(com::sun::star::uno::Any& rVal,BYTE) const
+{
+ sal_Int8 nValue = m_nValue;
+ rVal <<= nValue;
+ return true;
+}
+
+//============================================================================
+// virtual
+bool CntByteItem::PutValue(const com::sun::star::uno::Any& rVal,BYTE)
+{
+ sal_Int8 nValue = sal_Int8();
+ if (rVal >>= nValue)
+ {
+ m_nValue = nValue;
+ return true;
+ }
+
+ DBG_ERROR( "CntByteItem::PutValue - Wrong type!" );
+ return false;
+}
+
+//============================================================================
+// virtual
+SfxPoolItem * CntByteItem::Create(SvStream & rStream, USHORT) const
+{
+ DBG_CHKTHIS(CntByteItem, 0);
+ short nTheValue = 0;
+ rStream >> nTheValue;
+ return new CntByteItem(Which(), BYTE(nTheValue));
+}
+
+//============================================================================
+// virtual
+SvStream & CntByteItem::Store(SvStream & rStream, USHORT) const
+{
+ DBG_CHKTHIS(CntByteItem, 0);
+ rStream << short(m_nValue);
+ return rStream;
+}
+
+//============================================================================
+// virtual
+SfxPoolItem * CntByteItem::Clone(SfxItemPool *) const
+{
+ DBG_CHKTHIS(CntByteItem, 0);
+ return new CntByteItem(*this);
+}
+
+//============================================================================
+// virtual
+BYTE CntByteItem::GetMin() const
+{
+ DBG_CHKTHIS(CntByteItem, 0);
+ return 0;
+}
+
+//============================================================================
+// virtual
+BYTE CntByteItem::GetMax() const
+{
+ DBG_CHKTHIS(CntByteItem, 0);
+ return 255;
+}
+
+//============================================================================
+// virtual
+SfxFieldUnit CntByteItem::GetUnit() const
+{
+ DBG_CHKTHIS(CntByteItem, 0);
+ return SFX_FUNIT_NONE;
+}
+
+//============================================================================
+//
+// class CntUInt16Item
+//
+//============================================================================
+
+DBG_NAME(CntUInt16Item);
+
+//============================================================================
+TYPEINIT1_AUTOFACTORY(CntUInt16Item, SfxPoolItem);
+
+//============================================================================
+CntUInt16Item::CntUInt16Item(USHORT which, SvStream & rStream) :
+ SfxPoolItem(which)
+{
+ DBG_CTOR(CntUInt16Item, 0);
+ USHORT nTheValue = 0;
+ rStream >> nTheValue;
+ m_nValue = nTheValue;
+}
+
+//============================================================================
+// virtual
+int CntUInt16Item::operator ==(const SfxPoolItem & rItem) const
+{
+ DBG_CHKTHIS(CntUInt16Item, 0);
+ DBG_ASSERT(rItem.ISA(CntUInt16Item),
+ "CntUInt16Item::operator ==(): Bad type");
+ return m_nValue == SAL_STATIC_CAST(const CntUInt16Item *, &rItem)->
+ m_nValue;
+}
+
+//============================================================================
+// virtual
+int CntUInt16Item::Compare(const SfxPoolItem & rWith) const
+{
+ DBG_CHKTHIS(CntUInt16Item, 0);
+ DBG_ASSERT(rWith.ISA(CntUInt16Item),
+ "CntUInt16Item::Compare(): Bad type");
+ return SAL_STATIC_CAST(const CntUInt16Item *, &rWith)->m_nValue
+ < m_nValue ?
+ -1 :
+ SAL_STATIC_CAST(const CntUInt16Item *, &rWith)->m_nValue
+ == m_nValue ?
+ 0 : 1;
+}
+
+//============================================================================
+// virtual
+SfxItemPresentation CntUInt16Item::GetPresentation(SfxItemPresentation,
+ SfxMapUnit, SfxMapUnit,
+ XubString & rText,
+ const ::IntlWrapper *)
+ const
+{
+ DBG_CHKTHIS(CntUInt16Item, 0);
+ rText = XubString::CreateFromInt32(m_nValue);
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+//============================================================================
+// virtual
+bool CntUInt16Item::QueryValue(com::sun::star::uno::Any& rVal,BYTE) const
+{
+ sal_Int32 nValue = m_nValue;
+ rVal <<= nValue;
+ return true;
+}
+
+//============================================================================
+// virtual
+bool CntUInt16Item::PutValue(const com::sun::star::uno::Any& rVal,BYTE)
+{
+ sal_Int32 nValue = 0;
+ if (rVal >>= nValue)
+ {
+ DBG_ASSERT( nValue <= USHRT_MAX, "Overflow in UInt16 value!");
+ m_nValue = (sal_uInt16)nValue;
+ return true;
+ }
+
+ DBG_ERROR( "CntUInt16Item::PutValue - Wrong type!" );
+ return false;
+}
+
+//============================================================================
+// virtual
+SfxPoolItem * CntUInt16Item::Create(SvStream & rStream, USHORT) const
+{
+ DBG_CHKTHIS(CntUInt16Item, 0);
+ return new CntUInt16Item(Which(), rStream);
+}
+
+//============================================================================
+// virtual
+SvStream & CntUInt16Item::Store(SvStream &rStream, USHORT) const
+{
+ DBG_CHKTHIS(CntUInt16Item, 0);
+ rStream << USHORT(m_nValue);
+ return rStream;
+}
+
+//============================================================================
+// virtual
+SfxPoolItem * CntUInt16Item::Clone(SfxItemPool *) const
+{
+ DBG_CHKTHIS(CntUInt16Item, 0);
+ return new CntUInt16Item(*this);
+}
+
+//============================================================================
+// virtual
+UINT16 CntUInt16Item::GetMin() const
+{
+ DBG_CHKTHIS(CntUInt16Item, 0);
+ return 0;
+}
+
+//============================================================================
+// virtual
+UINT16 CntUInt16Item::GetMax() const
+{
+ DBG_CHKTHIS(CntUInt16Item, 0);
+ return 65535;
+}
+
+//============================================================================
+// virtual
+SfxFieldUnit CntUInt16Item::GetUnit() const
+{
+ DBG_CHKTHIS(CntUInt16Item, 0);
+ return SFX_FUNIT_NONE;
+}
+
+//============================================================================
+//
+// class CntInt32Item
+//
+//============================================================================
+
+DBG_NAME(CntInt32Item);
+
+//============================================================================
+TYPEINIT1_AUTOFACTORY(CntInt32Item, SfxPoolItem);
+
+//============================================================================
+CntInt32Item::CntInt32Item(USHORT which, SvStream & rStream) :
+ SfxPoolItem(which)
+{
+ DBG_CTOR(CntInt32Item, 0);
+ long nTheValue = 0;
+ rStream >> nTheValue;
+ m_nValue = nTheValue;
+}
+
+//============================================================================
+// virtual
+int CntInt32Item::operator ==(const SfxPoolItem & rItem) const
+{
+ DBG_CHKTHIS(CntInt32Item, 0);
+ DBG_ASSERT(rItem.ISA(CntInt32Item),
+ "CntInt32Item::operator ==(): Bad type");
+ return m_nValue == SAL_STATIC_CAST(const CntInt32Item *, &rItem)->
+ m_nValue;
+}
+
+//============================================================================
+// virtual
+int CntInt32Item::Compare(const SfxPoolItem & rWith) const
+{
+ DBG_CHKTHIS(CntInt32Item, 0);
+ DBG_ASSERT(rWith.ISA(CntInt32Item), "CntInt32Item::Compare(): Bad type");
+ return SAL_STATIC_CAST(const CntInt32Item *, &rWith)->m_nValue
+ < m_nValue ?
+ -1 :
+ SAL_STATIC_CAST(const CntInt32Item *, &rWith)->m_nValue
+ == m_nValue ?
+ 0 : 1;
+}
+
+//============================================================================
+// virtual
+SfxItemPresentation CntInt32Item::GetPresentation(SfxItemPresentation,
+ SfxMapUnit, SfxMapUnit,
+ XubString & rText,
+ const ::IntlWrapper *) const
+{
+ DBG_CHKTHIS(CntInt32Item, 0);
+ rText = XubString::CreateFromInt32(m_nValue);
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+//============================================================================
+// virtual
+bool CntInt32Item::QueryValue(com::sun::star::uno::Any& rVal,BYTE) const
+{
+ sal_Int32 nValue = m_nValue;
+ rVal <<= nValue;
+ return true;
+}
+
+//============================================================================
+// virtual
+bool CntInt32Item::PutValue(const com::sun::star::uno::Any& rVal,BYTE)
+{
+ sal_Int32 nValue = 0;
+ if (rVal >>= nValue)
+ {
+ m_nValue = nValue;
+ return true;
+ }
+
+ DBG_ERROR( "CntInt32Item::PutValue - Wrong type!" );
+ return false;
+}
+
+//============================================================================
+// virtual
+SfxPoolItem * CntInt32Item::Create(SvStream & rStream, USHORT) const
+{
+ DBG_CHKTHIS(CntInt32Item, 0);
+ return new CntInt32Item(Which(), rStream);
+}
+
+//============================================================================
+// virtual
+SvStream & CntInt32Item::Store(SvStream &rStream, USHORT) const
+{
+ DBG_CHKTHIS(CntInt32Item, 0);
+ rStream << long(m_nValue);
+ return rStream;
+}
+
+//============================================================================
+// virtual
+SfxPoolItem * CntInt32Item::Clone(SfxItemPool *) const
+{
+ DBG_CHKTHIS(CntInt32Item, 0);
+ return new CntInt32Item(*this);
+}
+
+//============================================================================
+// virtual
+INT32 CntInt32Item::GetMin() const
+{
+ DBG_CHKTHIS(CntInt32Item, 0);
+ return INT32(0x80000000);
+}
+
+//============================================================================
+// virtual
+INT32 CntInt32Item::GetMax() const
+{
+ DBG_CHKTHIS(CntInt32Item, 0);
+ return 0x7FFFFFFF;
+}
+
+//============================================================================
+// virtual
+SfxFieldUnit CntInt32Item::GetUnit() const
+{
+ DBG_CHKTHIS(CntInt32Item, 0);
+ return SFX_FUNIT_NONE;
+}
+
+//============================================================================
+//
+// class CntUInt32Item
+//
+//============================================================================
+
+DBG_NAME(CntUInt32Item);
+
+//============================================================================
+TYPEINIT1_AUTOFACTORY(CntUInt32Item, SfxPoolItem);
+
+//============================================================================
+CntUInt32Item::CntUInt32Item(USHORT which, SvStream & rStream) :
+ SfxPoolItem(which)
+{
+ DBG_CTOR(CntUInt32Item, 0);
+ sal_uInt32 nTheValue = 0;
+ rStream >> nTheValue;
+ m_nValue = nTheValue;
+}
+
+//============================================================================
+// virtual
+int CntUInt32Item::operator ==(const SfxPoolItem & rItem) const
+{
+ DBG_CHKTHIS(CntUInt32Item, 0);
+ DBG_ASSERT(rItem.ISA(CntUInt32Item),
+ "CntUInt32Item::operator ==(): Bad type");
+ return m_nValue == SAL_STATIC_CAST(const CntUInt32Item *, &rItem)->
+ m_nValue;
+}
+
+//============================================================================
+// virtual
+int CntUInt32Item::Compare(const SfxPoolItem & rWith) const
+{
+ DBG_CHKTHIS(CntUInt32Item, 0);
+ DBG_ASSERT(rWith.ISA(CntUInt32Item),
+ "CntUInt32Item::operator ==(): Bad type");
+ return SAL_STATIC_CAST(const CntUInt32Item *, &rWith)->m_nValue
+ < m_nValue ?
+ -1 :
+ SAL_STATIC_CAST(const CntUInt32Item *, &rWith)->m_nValue
+ == m_nValue ?
+ 0 : 1;
+}
+
+//============================================================================
+// virtual
+SfxItemPresentation CntUInt32Item::GetPresentation(SfxItemPresentation,
+ SfxMapUnit, SfxMapUnit,
+ XubString & rText,
+ const ::IntlWrapper *)
+ const
+{
+ DBG_CHKTHIS(CntUInt32Item, 0);
+ rText = XubString::CreateFromInt64(m_nValue);
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+//============================================================================
+// virtual
+bool CntUInt32Item::QueryValue(com::sun::star::uno::Any& rVal,BYTE) const
+{
+ sal_Int32 nValue = m_nValue;
+ DBG_ASSERT( nValue>=0, "Overflow in UInt32 value!");
+ rVal <<= nValue;
+ return true;
+}
+
+//============================================================================
+// virtual
+bool CntUInt32Item::PutValue(const com::sun::star::uno::Any& rVal,BYTE)
+{
+ sal_Int32 nValue = 0;
+ if (rVal >>= nValue)
+ {
+ DBG_ASSERT( nValue>=0, "Overflow in UInt32 value!");
+ m_nValue = nValue;
+ return true;
+ }
+
+ DBG_ERROR( "CntUInt32Item::PutValue - Wrong type!" );
+ return false;
+}
+
+//============================================================================
+// virtual
+SfxPoolItem * CntUInt32Item::Create(SvStream & rStream, USHORT) const
+{
+ DBG_CHKTHIS(CntUInt32Item, 0);
+ return new CntUInt32Item(Which(), rStream);
+}
+
+//============================================================================
+// virtual
+SvStream & CntUInt32Item::Store(SvStream &rStream, USHORT) const
+{
+ DBG_CHKTHIS(CntUInt32Item, 0);
+ rStream << static_cast<sal_uInt32>(m_nValue);
+ return rStream;
+}
+
+//============================================================================
+// virtual
+SfxPoolItem * CntUInt32Item::Clone(SfxItemPool *) const
+{
+ DBG_CHKTHIS(CntUInt32Item, 0);
+ return new CntUInt32Item(*this);
+}
+
+//============================================================================
+// virtual
+UINT32 CntUInt32Item::GetMin() const
+{
+ DBG_CHKTHIS(CntUInt32Item, 0);
+ return 0;
+}
+
+//============================================================================
+// virtual
+UINT32 CntUInt32Item::GetMax() const
+{
+ DBG_CHKTHIS(CntUInt32Item, 0);
+ return 0xFFFFFFFF;
+}
+
+//============================================================================
+// virtual
+SfxFieldUnit CntUInt32Item::GetUnit() const
+{
+ DBG_CHKTHIS(CntUInt32Item, 0);
+ return SFX_FUNIT_NONE;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_cntwall.cxx b/binfilter/bf_svtools/source/items1/svt_cntwall.cxx
new file mode 100644
index 000000000000..5661284afb9f
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_cntwall.cxx
@@ -0,0 +1,169 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/debug.hxx>
+#include <tools/string.hxx>
+#include <tools/stream.hxx>
+
+#include <tools/vcompat.hxx>
+
+#include <bf_svtools/cntwall.hxx>
+
+#define CNTWALLPAPERITEM_STREAM_MAGIC ( (UINT32)0xfefefefe )
+#define CNTWALLPAPERITEM_STREAM_SEEKREL (-( (long)( sizeof( UINT32 ) ) ) )
+
+namespace binfilter
+{
+
+TYPEINIT1( CntWallpaperItem, SfxPoolItem );
+
+// -----------------------------------------------------------------------
+CntWallpaperItem::CntWallpaperItem( USHORT which, SvStream& rStream, USHORT nVersion )
+ : SfxPoolItem( which ), _nColor( COL_TRANSPARENT ), _nStyle( 0 )
+{
+ UINT32 nMagic = 0;
+ rStream >> nMagic;
+ if ( nMagic == CNTWALLPAPERITEM_STREAM_MAGIC )
+ {
+ // Okay, data were stored by CntWallpaperItem.
+
+ readUnicodeString(rStream, _aURL, nVersion >= 1);
+ // !!! Color stream operators do not work - they discard any
+ // transparency info !!!
+ _nColor.Read( rStream, TRUE );
+ rStream >> _nStyle;
+ }
+ else
+ {
+ rStream.SeekRel( CNTWALLPAPERITEM_STREAM_SEEKREL );
+
+ // Data were stored by SfxWallpaperItem ( SO < 6.0 ). The only
+ // thing we can do here is to get the URL and to position the stream.
+
+ {
+ // "Read" Wallpaper member - The version compat object positions
+ // the stream after the wallpaper data in its dtor. We must use
+ // this trick here as no VCL must be used here ( No Wallpaper
+ // object allowed ).
+ VersionCompat aCompat( rStream, STREAM_READ );
+ }
+
+ // Read SfxWallpaperItem's string member _aURL.
+ readUnicodeString(rStream, _aURL, false);
+
+ // "Read" SfxWallpaperItem's string member _aFilter.
+ ByteString aDummy;
+ rStream.ReadByteString(aDummy);
+ }
+}
+
+// -----------------------------------------------------------------------
+CntWallpaperItem::CntWallpaperItem( const CntWallpaperItem& rItem ) :
+ SfxPoolItem( rItem ),
+ _aURL( rItem._aURL ),
+ _nColor( rItem._nColor ),
+ _nStyle( rItem._nStyle )
+{
+}
+
+// -----------------------------------------------------------------------
+CntWallpaperItem::~CntWallpaperItem()
+{
+}
+
+// -----------------------------------------------------------------------
+int CntWallpaperItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+
+ const CntWallpaperItem& rWallItem = (const CntWallpaperItem&)rItem;
+
+ if( ( rWallItem._nStyle == _nStyle ) &&
+ ( rWallItem._nColor == _nColor ) &&
+ ( rWallItem._aURL == _aURL ) )
+ return TRUE;
+ else
+ return FALSE;
+}
+
+//============================================================================
+// virtual
+USHORT CntWallpaperItem::GetVersion(USHORT) const
+{
+ return 1; // because it uses SfxPoolItem::read/writeUnicodeString()
+}
+
+// -----------------------------------------------------------------------
+SfxPoolItem* CntWallpaperItem::Create( SvStream& rStream, USHORT nVersion) const
+{
+ return new CntWallpaperItem( Which(), rStream, nVersion );
+}
+
+// -----------------------------------------------------------------------
+SvStream& CntWallpaperItem::Store( SvStream& rStream, USHORT ) const
+{
+ rStream << CNTWALLPAPERITEM_STREAM_MAGIC;
+ writeUnicodeString(rStream, _aURL);
+ // !!! Color stream operators do not work - they discard any
+ // transparency info !!!
+ // ??? Why the hell Color::Write(...) isn't const ???
+ SAL_CONST_CAST( CntWallpaperItem*, this )->_nColor.Write( rStream, TRUE );
+ rStream << _nStyle;
+
+ return rStream;
+}
+
+// -----------------------------------------------------------------------
+SfxPoolItem* CntWallpaperItem::Clone( SfxItemPool* ) const
+{
+ return new CntWallpaperItem( *this );
+}
+
+//----------------------------------------------------------------------------
+// virtual
+bool CntWallpaperItem::QueryValue( com::sun::star::uno::Any&,BYTE ) const
+{
+ DBG_ERROR("Not implemented!");
+ return false;
+}
+
+//----------------------------------------------------------------------------
+// virtual
+bool CntWallpaperItem::PutValue( const com::sun::star::uno::Any&,BYTE )
+{
+ DBG_ERROR("Not implemented!");
+ return false;
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_cstitem.cxx b/binfilter/bf_svtools/source/items1/svt_cstitem.cxx
new file mode 100644
index 000000000000..c5e14decffb2
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_cstitem.cxx
@@ -0,0 +1,160 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <com/sun/star/uno/Any.hxx>
+
+#include <unotools/intlwrapper.hxx>
+
+#include <tools/stream.hxx>
+#include <tools/debug.hxx>
+#include <tools/datetime.hxx>
+
+#include <bf_svtools/svtdata.hxx>
+#include <bf_svtools/cstitem.hxx>
+
+#include <bf_svtools/svtools.hrc>
+
+#include <com/sun/star/lang/Locale.hpp>
+
+namespace binfilter
+{
+
+DBG_NAME( SfxCrawlStatusItem )
+TYPEINIT1( SfxCrawlStatusItem, SfxPoolItem );
+
+// -----------------------------------------------------------------------
+
+SfxCrawlStatusItem::SfxCrawlStatusItem( USHORT which, CrawlStatus eStat ) :
+ SfxPoolItem( which ),
+ eStatus( eStat )
+{
+ DBG_CTOR( SfxCrawlStatusItem, 0 );
+}
+
+// -----------------------------------------------------------------------
+
+SfxCrawlStatusItem::SfxCrawlStatusItem( const SfxCrawlStatusItem& rItem ) :
+ SfxPoolItem( rItem ),
+ eStatus( rItem.eStatus )
+{
+ DBG_CTOR( SfxCrawlStatusItem, 0 );
+}
+
+// -----------------------------------------------------------------------
+
+int SfxCrawlStatusItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_CHKTHIS( SfxCrawlStatusItem, 0 );
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+
+ return ((SfxCrawlStatusItem&)rItem).eStatus == eStatus;
+}
+
+// -----------------------------------------------------------------------
+
+int SfxCrawlStatusItem::Compare( const SfxPoolItem& rItem ) const
+{
+ DBG_CHKTHIS( SfxCrawlStatusItem, 0 );
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+
+ if( ((const SfxCrawlStatusItem&)rItem).eStatus < eStatus )
+ return -1;
+ else if( ((const SfxCrawlStatusItem&)rItem).eStatus == eStatus )
+ return 0;
+ else
+ return 1;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxCrawlStatusItem::Create( SvStream& rStream, USHORT ) const
+{
+ DBG_CHKTHIS(SfxCrawlStatusItem, 0);
+
+ USHORT _eStatus;
+ rStream >> _eStatus;
+
+ return new SfxCrawlStatusItem( Which(), (CrawlStatus)_eStatus );
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SfxCrawlStatusItem::Store( SvStream& rStream, USHORT ) const
+{
+ DBG_CHKTHIS( SfxCrawlStatusItem, 0 );
+
+ USHORT nStatus = (USHORT)eStatus;
+ rStream << (USHORT) nStatus;
+
+ return rStream;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxCrawlStatusItem::Clone( SfxItemPool* ) const
+{
+ DBG_CHKTHIS( SfxCrawlStatusItem, 0 );
+ return new SfxCrawlStatusItem( *this );
+}
+// -----------------------------------------------------------------------
+
+SfxItemPresentation SfxCrawlStatusItem::GetPresentation( SfxItemPresentation, SfxMapUnit, SfxMapUnit, XubString&, const ::IntlWrapper * ) const
+{
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+//----------------------------------------------------------------------------
+// virtual
+bool SfxCrawlStatusItem::PutValue( const com::sun::star::uno::Any& rVal,BYTE )
+{
+ sal_Int16 aValue = sal_Int16();
+ if ( rVal >>= aValue )
+ {
+ SetStatus( static_cast< CrawlStatus >( aValue ) );
+ return true;
+ }
+
+ DBG_ERROR( "SfxCrawlStatusItem::PutValue - Wrong type!" );
+ return false;
+}
+
+//----------------------------------------------------------------------------
+// virtual
+bool SfxCrawlStatusItem::QueryValue( com::sun::star::uno::Any& rVal,BYTE ) const
+{
+ sal_Int16 aValue = sal::static_int_cast< sal_Int16 >(GetStatus());
+ rVal <<= aValue;
+ return true;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_ctypeitm.cxx b/binfilter/bf_svtools/source/items1/svt_ctypeitm.cxx
new file mode 100644
index 000000000000..125a3a34cb58
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_ctypeitm.cxx
@@ -0,0 +1,246 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <com/sun/star/uno/Any.hxx>
+
+#include <unotools/intlwrapper.hxx>
+
+#include <tools/stream.hxx>
+#include <bf_svtools/ctypeitm.hxx>
+
+namespace binfilter
+{
+
+//============================================================================
+// The following defines are copied from chaos/source/items/cstritem.cxx:
+#define CNTSTRINGITEM_STREAM_MAGIC ( (UINT32)0xfefefefe )
+#define CNTSTRINGITEM_STREAM_SEEKREL (-( (long)( sizeof( UINT32 ) ) ) )
+
+//============================================================================
+//
+// class CntContentTypeItem Implementation.
+//
+//============================================================================
+
+TYPEINIT1_AUTOFACTORY( CntContentTypeItem, CntUnencodedStringItem );
+
+#define CONTENT_TYPE_NOT_INIT ( (INetContentType)-1 )
+
+//----------------------------------------------------------------------------
+CntContentTypeItem::CntContentTypeItem()
+: CntUnencodedStringItem(),
+ _eType( CONTENT_TYPE_NOT_INIT )
+{
+}
+
+//----------------------------------------------------------------------------
+CntContentTypeItem::CntContentTypeItem( USHORT which, const XubString& rType )
+: CntUnencodedStringItem( which, rType ),
+ _eType( CONTENT_TYPE_NOT_INIT )
+{
+}
+
+//----------------------------------------------------------------------------
+CntContentTypeItem::CntContentTypeItem( const CntContentTypeItem& rOrig )
+: CntUnencodedStringItem( rOrig ),
+ _eType( rOrig._eType ),
+ _aPresentation( rOrig._aPresentation )
+{
+}
+
+//============================================================================
+// virtual
+USHORT CntContentTypeItem::GetVersion(USHORT) const
+{
+ return 1; // because it uses SfxPoolItem::read/writeUnicodeString()
+}
+
+//----------------------------------------------------------------------------
+// virtual
+SfxPoolItem* CntContentTypeItem::Create( SvStream& rStream,
+ USHORT nItemVersion ) const
+{
+ // CntContentTypeItem used to be derived from CntStringItem, so take that
+ // into account:
+ UniString aValue;
+ readUnicodeString(rStream, aValue, nItemVersion >= 1);
+ UINT32 nMagic = 0;
+ rStream >> nMagic;
+ if (nMagic == CNTSTRINGITEM_STREAM_MAGIC)
+ {
+ BOOL bEncrypted = FALSE;
+ rStream >> bEncrypted;
+ DBG_ASSERT(!bEncrypted,
+ "CntContentTypeItem::Create() reads encrypted data");
+ }
+ else
+ rStream.SeekRel(CNTSTRINGITEM_STREAM_SEEKREL);
+
+ return new CntContentTypeItem(Which(), aValue);
+}
+
+//----------------------------------------------------------------------------
+// virtual
+SvStream & CntContentTypeItem::Store(SvStream & rStream, USHORT) const
+{
+ // CntContentTypeItem used to be derived from CntStringItem, so take that
+ // into account:
+ writeUnicodeString(rStream, GetValue());
+ rStream << CNTSTRINGITEM_STREAM_MAGIC << BOOL(FALSE);
+ return rStream;
+}
+
+//----------------------------------------------------------------------------
+// virtual
+int CntContentTypeItem::operator==( const SfxPoolItem& rOrig ) const
+{
+ const CntContentTypeItem& rOther = (const CntContentTypeItem&)rOrig;
+
+ if ( ( _eType != CONTENT_TYPE_NOT_INIT ) &&
+ ( rOther._eType != CONTENT_TYPE_NOT_INIT ) )
+ return _eType == rOther._eType;
+ else
+ return CntUnencodedStringItem::operator==( rOther );
+}
+
+//----------------------------------------------------------------------------
+// virtual
+SfxPoolItem* CntContentTypeItem::Clone( SfxItemPool* /* pPool */ ) const
+{
+ return new CntContentTypeItem( *this );
+}
+
+//----------------------------------------------------------------------------
+void CntContentTypeItem::SetValue( const XubString& rNewVal )
+{
+ // De-initialize enum type and presentation.
+ _eType = CONTENT_TYPE_NOT_INIT;
+ _aPresentation.Erase();
+
+ CntUnencodedStringItem::SetValue( rNewVal );
+}
+
+//----------------------------------------------------------------------------
+int CntContentTypeItem::Compare( const SfxPoolItem &rWith, const ::IntlWrapper& rIntlWrapper ) const
+{
+ String aOwnText, aWithText;
+ GetPresentation( SFX_ITEM_PRESENTATION_NAMELESS,
+ SFX_MAPUNIT_APPFONT, SFX_MAPUNIT_APPFONT, aOwnText, &rIntlWrapper );
+ rWith.GetPresentation( SFX_ITEM_PRESENTATION_NAMELESS,
+ SFX_MAPUNIT_APPFONT, SFX_MAPUNIT_APPFONT, aWithText, &rIntlWrapper );
+ return rIntlWrapper.getCollator()->compareString( aOwnText, aWithText );
+}
+
+//----------------------------------------------------------------------------
+SfxItemPresentation CntContentTypeItem::GetPresentation(
+ SfxItemPresentation ePres,
+ SfxMapUnit eCoreMetric,
+ SfxMapUnit ePresMetric,
+ XubString & rText,
+ const ::IntlWrapper * pIntlWrapper) const
+{
+ if (_aPresentation.Len() == 0)
+ {
+ DBG_ASSERT(pIntlWrapper,
+ "CntContentTypeItem::GetPresentation(): No IntlWrapper");
+ if (pIntlWrapper)
+ SAL_CONST_CAST(CntContentTypeItem *, this)->_aPresentation
+ = INetContentTypes::GetPresentation(GetEnumValue(),
+ pIntlWrapper->
+ getLocale());
+ }
+ if (_aPresentation.Len() > 0)
+ {
+ rText = _aPresentation;
+ return SFX_ITEM_PRESENTATION_COMPLETE;
+ }
+ else
+ return CntUnencodedStringItem::GetPresentation(ePres, eCoreMetric,
+ ePresMetric, rText,
+ pIntlWrapper);
+}
+
+//----------------------------------------------------------------------------
+INetContentType CntContentTypeItem::GetEnumValue() const
+{
+ if ( _eType == CONTENT_TYPE_NOT_INIT )
+ {
+ // Not yet initialized... Get enum value for string content type.
+
+ CntContentTypeItem* pVarThis = SAL_CONST_CAST( CntContentTypeItem*, this );
+
+ pVarThis->_eType = INetContentTypes::GetContentType( GetValue() );
+ }
+
+ return _eType;
+}
+
+//----------------------------------------------------------------------------
+void CntContentTypeItem::SetValue( const INetContentType eType )
+{
+ SetValue( INetContentTypes::GetContentType( eType ) );
+
+ // Note: SetValue( const String& ....) resets _eType. Set new enum value
+ // after(!) calling it.
+ _eType = eType;
+}
+
+//----------------------------------------------------------------------------
+// virtual
+bool CntContentTypeItem::QueryValue( com::sun::star::uno::Any& rVal,BYTE ) const
+{
+ rVal <<= rtl::OUString(GetValue());
+ return true;
+}
+
+//----------------------------------------------------------------------------
+// virtual
+bool CntContentTypeItem::PutValue( const com::sun::star::uno::Any& rVal,BYTE )
+{
+ rtl::OUString aValue;
+ if ( rVal >>= aValue )
+ {
+ // SetValue with an empty string resets the item; so call that
+ // function when PutValue is called with an empty string
+ if (aValue.getLength() == 0)
+ SetValue(aValue);
+ else
+ SetValue(
+ INetContentTypes::RegisterContentType(aValue, UniString()));
+ return true;
+ }
+
+ DBG_ERROR( "CntContentTypeItem::PutValue - Wrong type!" );
+ return false;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_custritm.cxx b/binfilter/bf_svtools/source/items1/svt_custritm.cxx
new file mode 100644
index 000000000000..e9ac2f113b32
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_custritm.cxx
@@ -0,0 +1,148 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <com/sun/star/uno/Any.hxx>
+
+#include <unotools/intlwrapper.hxx>
+
+#include <tools/stream.hxx>
+
+#include <bf_svtools/custritm.hxx>
+
+namespace binfilter
+{
+
+//============================================================================
+//
+// class CntUnencodedStringItem
+//
+//============================================================================
+
+DBG_NAME(CntUnencodedStringItem)
+
+//============================================================================
+TYPEINIT1_AUTOFACTORY(CntUnencodedStringItem, SfxPoolItem)
+
+//============================================================================
+// virtual
+int CntUnencodedStringItem::operator ==(const SfxPoolItem & rItem) const
+{
+ DBG_CHKTHIS(CntUnencodedStringItem, 0);
+ DBG_ASSERT(rItem.ISA(CntUnencodedStringItem),
+ "CntUnencodedStringItem::operator ==(): Bad type");
+ return m_aValue
+ == SAL_STATIC_CAST(const CntUnencodedStringItem *, &rItem)->
+ m_aValue;
+}
+
+//============================================================================
+// virtual
+int CntUnencodedStringItem::Compare(SfxPoolItem const & rWith) const
+{
+ DBG_ERROR("CntUnencodedStringItem::Compare(): No international");
+ DBG_CHKTHIS(CntUnencodedStringItem, 0);
+ DBG_ASSERT(rWith.ISA(CntUnencodedStringItem),
+ "CntUnencodedStringItem::Compare(): Bad type");
+ switch (m_aValue.CompareTo(static_cast< CntUnencodedStringItem const * >(
+ &rWith)->
+ m_aValue))
+ {
+ case COMPARE_LESS:
+ return -1;
+
+ case COMPARE_EQUAL:
+ return 0;
+
+ default: // COMPARE_GREATER
+ return 1;
+ }
+}
+
+//============================================================================
+// virtual
+int CntUnencodedStringItem::Compare(SfxPoolItem const & rWith,
+ IntlWrapper const & rIntlWrapper)
+ const
+{
+ DBG_CHKTHIS(CntUnencodedStringItem, 0);
+ DBG_ASSERT(rWith.ISA(CntUnencodedStringItem),
+ "CntUnencodedStringItem::Compare(): Bad type");
+ return rIntlWrapper.getCollator()->compareString( m_aValue,
+ static_cast< CntUnencodedStringItem const * >(&rWith)->m_aValue );
+}
+
+//============================================================================
+// virtual
+SfxItemPresentation
+CntUnencodedStringItem::GetPresentation(SfxItemPresentation, SfxMapUnit,
+ SfxMapUnit, XubString & rText,
+ const ::IntlWrapper *) const
+{
+ DBG_CHKTHIS(CntUnencodedStringItem, 0);
+ rText = m_aValue;
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+//============================================================================
+// virtual
+bool CntUnencodedStringItem::QueryValue(com::sun::star::uno::Any& rVal, BYTE)
+ const
+{
+ rVal <<= rtl::OUString(m_aValue);
+ return true;
+}
+
+//============================================================================
+// virtual
+bool CntUnencodedStringItem::PutValue(const com::sun::star::uno::Any& rVal,
+ BYTE)
+{
+ rtl::OUString aTheValue;
+ if (rVal >>= aTheValue)
+ {
+ m_aValue = UniString(aTheValue);
+ return true;
+ }
+ DBG_ERROR("CntUnencodedStringItem::PutValue(): Wrong type");
+ return false;
+}
+
+//============================================================================
+// virtual
+SfxPoolItem * CntUnencodedStringItem::Clone(SfxItemPool *) const
+{
+ DBG_CHKTHIS(CntUnencodedStringItem, 0);
+ return new CntUnencodedStringItem(*this);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_dateitem.cxx b/binfilter/bf_svtools/source/items1/svt_dateitem.cxx
new file mode 100644
index 000000000000..4a13a950fda1
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_dateitem.cxx
@@ -0,0 +1,235 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 ---------------------------------------------------------------
+
+#define _DATETIMEITEM_CXX
+#include <bf_svtools/dateitem.hxx>
+
+#include <unotools/intlwrapper.hxx>
+#include <comphelper/processfactory.hxx>
+
+
+#include <tools/stream.hxx>
+#include <tools/debug.hxx>
+#include <tools/datetime.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+
+
+#include <vcl/svapp.hxx>
+
+#include <bf_svtools/svtdata.hxx>
+#include <bf_svtools/svtools.hrc>
+
+namespace binfilter
+{
+
+// STATIC DATA -----------------------------------------------------------
+
+DBG_NAME(SfxDateTimeItem)
+
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1(SfxDateTimeItem, SfxPoolItem);
+
+// -----------------------------------------------------------------------
+
+SfxDateTimeItem::SfxDateTimeItem( USHORT which, const DateTime& rDT ) :
+ SfxPoolItem( which ),
+ aDateTime( rDT )
+
+{
+ DBG_CTOR(SfxDateTimeItem, 0);
+}
+
+// -----------------------------------------------------------------------
+
+SfxDateTimeItem::SfxDateTimeItem( const SfxDateTimeItem& rItem ) :
+ SfxPoolItem( rItem ),
+ aDateTime( rItem.aDateTime )
+{
+ DBG_CTOR(SfxDateTimeItem, 0);
+}
+
+// -----------------------------------------------------------------------
+
+int SfxDateTimeItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_CHKTHIS(SfxDateTimeItem, 0);
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+ return ( ( (SfxDateTimeItem&)rItem ).aDateTime == aDateTime );
+}
+
+// -----------------------------------------------------------------------
+
+int SfxDateTimeItem::Compare( const SfxPoolItem& rItem ) const
+{
+ DBG_CHKTHIS(SfxDateTimeItem, 0);
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+
+ // da X.Compare( Y ) am String einem Compare( Y, X ) entspricht,
+ // vergleichen wir hier Y mit X
+ if ( ( (const SfxDateTimeItem&)rItem ).aDateTime < aDateTime )
+ return -1;
+ else if ( ( (const SfxDateTimeItem&)rItem ).aDateTime == aDateTime )
+ return 0;
+ else
+ return 1;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxDateTimeItem::Create( SvStream& rStream, USHORT ) const
+{
+ DBG_CHKTHIS(SfxDateTimeItem, 0);
+ sal_uInt32 nDate = 0;
+ sal_Int32 nTime = 0;
+ rStream >> nDate;
+ rStream >> nTime;
+ DateTime aDT(nDate, nTime);
+ return new SfxDateTimeItem( Which(), aDT );
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SfxDateTimeItem::Store( SvStream& rStream, USHORT ) const
+{
+ DBG_CHKTHIS(SfxDateTimeItem, 0);
+ rStream << aDateTime.GetDate();
+ rStream << aDateTime.GetTime();
+ return rStream;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxDateTimeItem::Clone( SfxItemPool* ) const
+{
+ DBG_CHKTHIS(SfxDateTimeItem, 0);
+ return new SfxDateTimeItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemPresentation SfxDateTimeItem::GetPresentation
+(
+ SfxItemPresentation /*ePresentation*/,
+ SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/,
+ XubString& rText,
+ const ::IntlWrapper * pIntlWrapper
+) const
+{
+ DBG_CHKTHIS(SfxDateTimeItem, 0);
+ if (aDateTime.IsValid())
+ if (pIntlWrapper)
+ {
+ rText = pIntlWrapper->getLocaleData()->getDate(aDateTime);
+ rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ rText += pIntlWrapper->getLocaleData()->getTime(aDateTime);
+ }
+ else
+ {
+ DBG_WARNING("SfxDateTimeItem::GetPresentation():"
+ " Using default en_US IntlWrapper");
+ const ::IntlWrapper aIntlWrapper(
+ ::comphelper::getProcessServiceFactory(), LANGUAGE_ENGLISH_US );
+ rText = aIntlWrapper.getLocaleData()->getDate(aDateTime);
+ rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ rText += aIntlWrapper.getLocaleData()->getTime(aDateTime);
+ }
+ else
+ rText.Erase();
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+//----------------------------------------------------------------------------
+// virtual
+bool SfxDateTimeItem::PutValue( const com::sun::star::uno::Any& rVal,
+ BYTE nMemberId )
+{
+ nMemberId &= ~CONVERT_TWIPS;
+ com::sun::star::util::DateTime aValue;
+ if ( rVal >>= aValue )
+ {
+ aDateTime = DateTime( Date( aValue.Day,
+ aValue.Month,
+ aValue.Year ),
+ Time( aValue.Hours,
+ aValue.Minutes,
+ aValue.Seconds,
+ aValue.HundredthSeconds ) );
+ return true;
+ }
+
+ DBG_ERROR( "SfxDateTimeItem::PutValue - Wrong type!" );
+ return false;
+}
+
+//----------------------------------------------------------------------------
+// virtual
+bool SfxDateTimeItem::QueryValue( com::sun::star::uno::Any& rVal,
+ BYTE nMemberId ) const
+{
+ nMemberId &= ~CONVERT_TWIPS;
+ com::sun::star::util::DateTime aValue( aDateTime.Get100Sec(),
+ aDateTime.GetSec(),
+ aDateTime.GetMin(),
+ aDateTime.GetHour(),
+ aDateTime.GetDay(),
+ aDateTime.GetMonth(),
+ aDateTime.GetYear() );
+ rVal <<= aValue;
+ return true;
+}
+
+// -----------------------------------------------------------------------
+// -----------------------------------------------------------------------
+// -----------------------------------------------------------------------
+/*
+TYPEINIT1(SfxColumnDateTimeItem, SfxDateTimeItem);
+
+SfxPoolItem* SfxColumnDateTimeItem::Clone( SfxItemPool* ) const
+{
+ return new SfxColumnDateTimeItem( *this );
+}
+
+SfxItemPresentation SfxColumnDateTimeItem::GetPresentation( SfxItemPresentation, SfxMapUnit, SfxMapUnit, XubString&, const ::IntlWrapper * ) const
+{
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+*/
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_dtritem.cxx b/binfilter/bf_svtools/source/items1/svt_dtritem.cxx
new file mode 100644
index 000000000000..9ab3e86ebf59
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_dtritem.cxx
@@ -0,0 +1,240 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/util/DateTimeRange.hpp>
+
+#include <unotools/intlwrapper.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <tools/stream.hxx>
+#include <tools/debug.hxx>
+#include <tools/datetime.hxx>
+#include <rtl/math.hxx>
+
+#include <vcl/svapp.hxx>
+
+#include <bf_svtools/dtritem.hxx>
+
+namespace binfilter
+{
+
+DBG_NAME( SfxDateTimeRangeItem )
+TYPEINIT1( SfxDateTimeRangeItem, SfxPoolItem );
+
+// -----------------------------------------------------------------------
+
+SfxDateTimeRangeItem::SfxDateTimeRangeItem( USHORT which, const DateTime& rStartDT,
+ const DateTime& rEndDT ) :
+ SfxPoolItem( which ),
+ aStartDateTime( rStartDT ),
+ aEndDateTime( rEndDT )
+{
+ DBG_CTOR( SfxDateTimeRangeItem, 0 );
+}
+
+// -----------------------------------------------------------------------
+
+SfxDateTimeRangeItem::SfxDateTimeRangeItem( const SfxDateTimeRangeItem& rItem ) :
+ SfxPoolItem( rItem ),
+ aStartDateTime( rItem.aStartDateTime ),
+ aEndDateTime( rItem.aEndDateTime )
+{
+ DBG_CTOR( SfxDateTimeRangeItem, 0 );
+}
+
+// -----------------------------------------------------------------------
+
+int SfxDateTimeRangeItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_CHKTHIS( SfxDateTimeRangeItem, 0 );
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+
+ return ((SfxDateTimeRangeItem&)rItem ).aStartDateTime == aStartDateTime &&
+ ((SfxDateTimeRangeItem&)rItem ).aEndDateTime == aEndDateTime;
+}
+
+// -----------------------------------------------------------------------
+
+int SfxDateTimeRangeItem::Compare( const SfxPoolItem& rItem ) const
+{
+ DBG_CHKTHIS( SfxDateTimeRangeItem, 0 );
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+
+ double fThisRange = aEndDateTime - aStartDateTime;
+ double fRange = ((const SfxDateTimeRangeItem&)rItem).aEndDateTime -
+ ((const SfxDateTimeRangeItem&)rItem).aStartDateTime;
+
+ if ( ::rtl::math::approxEqual( fRange, fThisRange ) )
+ return 0;
+ else if ( fRange < fThisRange )
+ return -1;
+ else
+ return 1;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxDateTimeRangeItem::Create( SvStream& rStream, USHORT ) const
+{
+ DBG_CHKTHIS(SfxDateTimeRangeItem, 0);
+
+ sal_uInt32 nStartDate, nEndDate;
+ sal_Int32 nStartTime, nEndTime;
+
+ rStream >> nStartDate;
+ rStream >> nStartTime;
+
+ rStream >> nEndDate;
+ rStream >> nEndTime;
+
+ DateTime aStartDT, aEndDT;
+
+ aStartDT.SetDate( nStartDate );
+ aStartDT.SetTime( nStartTime );
+
+ aEndDT.SetDate( nEndDate );
+ aEndDT.SetTime( nEndTime );
+
+ return new SfxDateTimeRangeItem( Which(), aStartDT, aEndDT );
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SfxDateTimeRangeItem::Store( SvStream& rStream, USHORT ) const
+{
+ DBG_CHKTHIS( SfxDateTimeRangeItem, 0 );
+
+ rStream << aStartDateTime.GetDate();
+ rStream << aStartDateTime.GetTime();
+
+ rStream << aEndDateTime.GetDate();
+ rStream << aEndDateTime.GetTime();
+
+ return rStream;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxDateTimeRangeItem::Clone( SfxItemPool* ) const
+{
+ DBG_CHKTHIS( SfxDateTimeRangeItem, 0 );
+
+ return new SfxDateTimeRangeItem( *this );
+}
+// -----------------------------------------------------------------------
+
+SfxItemPresentation SfxDateTimeRangeItem::GetPresentation
+(
+ SfxItemPresentation /*ePresentation*/,
+ SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/,
+ XubString& rText,
+ const ::IntlWrapper * pIntlWrapper
+) const
+{
+ DBG_CHKTHIS(SfxDateTimeRangeItem, 0);
+ DateTime aRange(aEndDateTime - (const Time&)aStartDateTime);
+ if (pIntlWrapper)
+ {
+ rText = pIntlWrapper->getLocaleData()->getDate(aRange);
+ rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ rText += pIntlWrapper->getLocaleData()->getTime(aRange);
+ }
+ else
+ {
+ DBG_WARNING("SfxDateTimeRangeItem::GetPresentation():"
+ " Using default en_US IntlWrapper");
+ const ::IntlWrapper aIntlWrapper(
+ ::comphelper::getProcessServiceFactory(), LANGUAGE_ENGLISH_US );
+ rText = aIntlWrapper.getLocaleData()->getDate(aRange);
+ rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ rText += aIntlWrapper.getLocaleData()->getTime(aRange);
+ }
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+//----------------------------------------------------------------------------
+// virtual
+bool SfxDateTimeRangeItem::PutValue( const com::sun::star::uno::Any& rVal,BYTE )
+{
+ com::sun::star::util::DateTimeRange aValue;
+ if ( rVal >>= aValue )
+ {
+ aStartDateTime = DateTime( Date( aValue.StartDay,
+ aValue.StartMonth,
+ aValue.StartYear ),
+ Time( aValue.StartHours,
+ aValue.StartMinutes,
+ aValue.StartSeconds,
+ aValue.StartHundredthSeconds ) );
+ aEndDateTime = DateTime( Date( aValue.EndDay,
+ aValue.EndMonth,
+ aValue.EndYear ),
+ Time( aValue.EndHours,
+ aValue.EndMinutes,
+ aValue.EndSeconds,
+ aValue.EndHundredthSeconds ) );
+ return true;
+ }
+
+ DBG_ERROR( "SfxDateTimeRangeItem::PutValue - Wrong type!" );
+ return false;
+}
+
+//----------------------------------------------------------------------------
+// virtual
+bool SfxDateTimeRangeItem::QueryValue( com::sun::star::uno::Any& rVal,
+ BYTE nMemberId ) const
+{
+ nMemberId &= ~CONVERT_TWIPS;
+ com::sun::star::util::DateTimeRange aValue( aStartDateTime.Get100Sec(),
+ aStartDateTime.GetSec(),
+ aStartDateTime.GetMin(),
+ aStartDateTime.GetHour(),
+ aStartDateTime.GetDay(),
+ aStartDateTime.GetMonth(),
+ aStartDateTime.GetYear(),
+ aEndDateTime.Get100Sec(),
+ aEndDateTime.GetSec(),
+ aEndDateTime.GetMin(),
+ aEndDateTime.GetHour(),
+ aEndDateTime.GetDay(),
+ aEndDateTime.GetMonth(),
+ aEndDateTime.GetYear() );
+ rVal <<= aValue;
+ return true;
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_frqitem.cxx b/binfilter/bf_svtools/source/items1/svt_frqitem.cxx
new file mode 100644
index 000000000000..5926c53563a2
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_frqitem.cxx
@@ -0,0 +1,211 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <unotools/intlwrapper.hxx>
+
+#include <tools/stream.hxx>
+#include <tools/debug.hxx>
+#include <tools/datetime.hxx>
+
+#include <bf_svtools/frqitem.hxx>
+
+namespace binfilter
+{
+
+DBG_NAME( SfxFrequencyItem )
+
+TYPEINIT1( SfxFrequencyItem, SfxPoolItem );
+
+#define MAX_GOTO 32000
+
+#define DECL_SAVE_GOTO() \
+ ULONG nSafetyMeasures = 0;
+
+#define SAVE_GOTO(tag) \
+ if(nSafetyMeasures < MAX_GOTO) \
+ { nSafetyMeasures++; goto tag; }
+
+// -----------------------------------------------------------------------
+
+SfxFrequencyItem::SfxFrequencyItem( USHORT which, FrequencyMode eMode, FrequencyTimeMode eTMode,
+ USHORT nDI1, USHORT nDI2, USHORT nDI3, USHORT nTI1,
+ const Time& rT1, const Time& rT2 ) :
+ SfxPoolItem ( which ),
+ eFrqMode ( eMode ),
+ eFrqTimeMode ( eTMode ),
+ nDInterval1 ( nDI1 ),
+ nDInterval2 ( nDI2 ),
+ nDInterval3 ( nDI3 ),
+ nTInterval1 ( nTI1 ),
+ aTime1 ( rT1 ),
+ aTime2 ( rT2 ),
+ bMissingDate ( FALSE )
+{
+ DBG_CTOR( SfxFrequencyItem, 0 );
+}
+
+// -----------------------------------------------------------------------
+
+SfxFrequencyItem::SfxFrequencyItem( const SfxFrequencyItem& rItem ) :
+ SfxPoolItem ( rItem ),
+ eFrqMode ( rItem.eFrqMode ),
+ eFrqTimeMode ( rItem.eFrqTimeMode ),
+ nDInterval1 ( rItem.nDInterval1 ),
+ nDInterval2 ( rItem.nDInterval2 ),
+ nDInterval3 ( rItem.nDInterval3 ),
+ nTInterval1 ( rItem.nTInterval1 ),
+ aTime1 ( rItem.aTime1 ),
+ aTime2 ( rItem.aTime2 ),
+ bMissingDate ( rItem.bMissingDate )
+{
+ DBG_CTOR( SfxFrequencyItem, 0 );
+}
+
+// -----------------------------------------------------------------------
+
+int SfxFrequencyItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_CHKTHIS( SfxFrequencyItem, 0 );
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+
+ return ((SfxFrequencyItem&)rItem ).eFrqMode == eFrqMode &&
+ ((SfxFrequencyItem&)rItem ).eFrqTimeMode == eFrqTimeMode &&
+ ((SfxFrequencyItem&)rItem ).nDInterval1 == nDInterval1 &&
+ ((SfxFrequencyItem&)rItem ).nDInterval2 == nDInterval2 &&
+ ((SfxFrequencyItem&)rItem ).nDInterval3 == nDInterval3 &&
+ ((SfxFrequencyItem&)rItem ).nTInterval1 == nTInterval1 &&
+ ((SfxFrequencyItem&)rItem ).aTime1 == aTime1 &&
+ ((SfxFrequencyItem&)rItem ).aTime2 == aTime2;
+}
+
+// -----------------------------------------------------------------------
+
+int SfxFrequencyItem::Compare( const SfxPoolItem&
+#ifdef DBG_UTIL
+rItem
+#endif
+) const
+{
+ DBG_CHKTHIS( SfxFrequencyItem, 0 );
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+
+/* DateTime aThisRange( aEndDateTime - aStartDateTime );
+ DateTime aRange(((const SfxFrequencyItem&)rItem).aEndDateTime -
+ ((const SfxFrequencyItem&)rItem).aStartDateTime );
+ if( aRange < aThisRange )
+ return -1;
+ else if( aRange == aThisRange )
+ return 0;
+ else
+*/
+ return 1;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxFrequencyItem::Create( SvStream& rStream, USHORT ) const
+{
+ DBG_CHKTHIS(SfxFrequencyItem, 0);
+
+ USHORT _eFrqMode;
+ USHORT _eFrqTimeMode;
+ USHORT _nDInterval1;
+ USHORT _nDInterval2;
+ USHORT _nDInterval3;
+ USHORT _nTInterval1;
+ long _nTime1;
+ long _nTime2;
+
+ rStream >> _eFrqMode;
+ rStream >> _eFrqTimeMode;
+ rStream >> _nDInterval1;
+ rStream >> _nDInterval2;
+ rStream >> _nDInterval3;
+ rStream >> _nTInterval1;
+ rStream >> _nTime1;
+ rStream >> _nTime2;
+
+ return new SfxFrequencyItem( Which(), (FrequencyMode)_eFrqMode,
+ (FrequencyTimeMode) _eFrqTimeMode, _nDInterval1, _nDInterval2, _nDInterval3,
+ _nTInterval1, Time(_nTime1), Time(_nTime2) );
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SfxFrequencyItem::Store( SvStream& rStream, USHORT ) const
+{
+ DBG_CHKTHIS( SfxFrequencyItem, 0 );
+
+ USHORT nEMode = (USHORT)eFrqMode;
+ USHORT nETimeMode = (USHORT)eFrqTimeMode;
+
+ rStream << (USHORT) nEMode;
+ rStream << (USHORT) nETimeMode;
+
+ rStream << nDInterval1;
+ rStream << nDInterval2;
+ rStream << nDInterval3;
+
+ rStream << nTInterval1;
+ rStream << aTime1.GetTime();
+ rStream << aTime2.GetTime();
+
+ return rStream;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxFrequencyItem::Clone( SfxItemPool* ) const
+{
+ DBG_CHKTHIS( SfxFrequencyItem, 0 );
+ return new SfxFrequencyItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemPresentation SfxFrequencyItem::GetPresentation
+(
+ SfxItemPresentation /*ePresentation*/,
+ SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/,
+ XubString& rText,
+ const ::IntlWrapper *
+) const
+{
+ DBG_CHKTHIS(SfxFrequencyItem, 0);
+ rText.AssignAscii(RTL_CONSTASCII_STRINGPARAM("SNIY"));
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+// -----------------------------------------------------------------------
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_ilstitem.cxx b/binfilter/bf_svtools/source/items1/svt_ilstitem.cxx
new file mode 100644
index 000000000000..91d9a66722fd
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_ilstitem.cxx
@@ -0,0 +1,98 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <com/sun/star/script/XTypeConverter.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include <comphelper/processfactory.hxx>
+
+#include <bf_svtools/ilstitem.hxx>
+
+#define _SVSTDARR_ULONGS
+#include <bf_svtools/svstdarr.hxx>
+
+namespace binfilter
+{
+
+TYPEINIT1_AUTOFACTORY(SfxIntegerListItem, SfxPoolItem);
+
+SfxIntegerListItem::SfxIntegerListItem()
+{
+}
+
+SfxIntegerListItem::SfxIntegerListItem( const SfxIntegerListItem& rItem )
+ : SfxPoolItem( rItem )
+{
+ m_aList = rItem.m_aList;
+}
+
+SfxIntegerListItem::~SfxIntegerListItem()
+{
+}
+
+int SfxIntegerListItem::operator==( const SfxPoolItem& rPoolItem ) const
+{
+ if ( !rPoolItem.ISA( SfxIntegerListItem ) )
+ return FALSE;
+
+ const SfxIntegerListItem rItem = (const SfxIntegerListItem&) rPoolItem;
+ return rItem.m_aList == m_aList;
+}
+
+SfxPoolItem* SfxIntegerListItem::Clone( SfxItemPool * ) const
+{
+ return new SfxIntegerListItem( *this );
+}
+
+bool SfxIntegerListItem::PutValue ( const com::sun::star::uno::Any& rVal, BYTE )
+{
+ ::com::sun::star::uno::Reference < ::com::sun::star::script::XTypeConverter > xConverter
+ ( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.script.Converter")),
+ ::com::sun::star::uno::UNO_QUERY );
+ ::com::sun::star::uno::Any aNew;
+ try { aNew = xConverter->convertTo( rVal, ::getCppuType((const ::com::sun::star::uno::Sequence < sal_Int32 >*)0) ); }
+ catch (::com::sun::star::uno::Exception&)
+ {
+ return false;
+ }
+
+ return ( aNew >>= m_aList );
+}
+
+bool SfxIntegerListItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE ) const
+{
+ rVal <<= m_aList;
+ return true;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_itemiter.cxx b/binfilter/bf_svtools/source/items1/svt_itemiter.cxx
new file mode 100644
index 000000000000..3fb2f8586a7a
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_itemiter.cxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/itemiter.hxx>
+#include <bf_svtools/itempool.hxx>
+#include <bf_svtools/itemset.hxx>
+
+namespace binfilter
+{
+
+// STATIC DATA -----------------------------------------------------------
+
+DBG_NAME(SfxItemIter)
+
+// --------------------------------------------------------------------------
+
+
+SfxItemIter::SfxItemIter( const SfxItemSet& rItemSet )
+ : _rSet( rItemSet )
+{
+ DBG_CTOR(SfxItemIter, 0);
+ DBG_ASSERTWARNING( _rSet.Count(), "es gibt gar keine Attribute" );
+
+ if ( !_rSet._nCount )
+ {
+ _nStt = 1;
+ _nEnd = 0;
+ }
+ else
+ {
+ SfxItemArray ppFnd = _rSet._aItems;
+
+ // suche das 1. gesetzte Item
+ for ( _nStt = 0; !*(ppFnd + _nStt ); ++_nStt )
+ ; // empty loop
+ if ( 1 < _rSet.Count() )
+ for( _nEnd = _rSet.TotalCount(); !*( ppFnd + --_nEnd); )
+ ; // empty loop
+ else
+ _nEnd = _nStt;
+ }
+
+ _nAkt = _nStt;
+}
+
+// --------------------------------------------------------------------------
+
+
+SfxItemIter::~SfxItemIter()
+{
+ DBG_DTOR(SfxItemIter, 0);
+}
+
+// --------------------------------------------------------------------------
+
+
+const SfxPoolItem* SfxItemIter::NextItem()
+{
+ DBG_CHKTHIS(SfxItemIter, 0);
+ SfxItemArray ppFnd = _rSet._aItems;
+
+ if( _nAkt < _nEnd )
+ {
+ do {
+ _nAkt++;
+ } while( _nAkt < _nEnd && !*(ppFnd + _nAkt ) );
+ return *(ppFnd+_nAkt);
+ }
+ return 0;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_itempool.cxx b/binfilter/bf_svtools/source/items1/svt_itempool.cxx
new file mode 100644
index 000000000000..13555f6c2d4c
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_itempool.cxx
@@ -0,0 +1,1085 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <string.h>
+#include <stdio.h>
+
+#include <bf_svtools/itempool.hxx>
+#include "whassert.hxx"
+#include <bf_svtools/brdcst.hxx>
+#include <bf_svtools/smplhint.hxx>
+#include "poolio.hxx"
+
+// STATIC DATA -----------------------------------------------------------
+
+namespace binfilter
+{
+
+
+//========================================================================
+
+SV_IMPL_PTRARR( SfxPoolVersionArr_Impl, SfxPoolVersion_Impl* );
+
+//========================================================================
+
+
+const SfxPoolItem* SfxItemPool::GetPoolDefaultItem( USHORT nWhich ) const
+{
+ DBG_CHKTHIS(SfxItemPool, 0);
+ const SfxPoolItem* pRet;
+ if( IsInRange( nWhich ) )
+ pRet = *(ppPoolDefaults + GetIndex_Impl( nWhich ));
+ else if( pSecondary )
+ pRet = pSecondary->GetPoolDefaultItem( nWhich );
+ else
+ {
+ SFX_ASSERT( 0, nWhich, "unknown Which-Id - cannot get pool default" );
+ pRet = 0;
+ }
+ return pRet;
+}
+
+// -----------------------------------------------------------------------
+
+inline FASTBOOL SfxItemPool::IsItemFlag_Impl( USHORT nPos, USHORT nFlag ) const
+{
+ USHORT nItemFlag = pItemInfos[nPos]._nFlags;
+ return nFlag == (nItemFlag & nFlag);
+}
+
+// -----------------------------------------------------------------------
+
+FASTBOOL SfxItemPool::IsItemFlag( USHORT nWhich, USHORT nFlag ) const
+{
+ for ( const SfxItemPool *pPool = this; pPool; pPool = pPool->pSecondary )
+ {
+ if ( pPool->IsInRange(nWhich) )
+ return pPool->IsItemFlag_Impl( pPool->GetIndex_Impl(nWhich), nFlag);
+ }
+ DBG_ASSERT( !IsWhich(nWhich), "unknown which-id" );
+ return FALSE;
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemPool::SfxItemPool
+(
+ UniString const & rName, /* Name des Pools zur Idetifikation
+ im File-Format */
+ USHORT nStartWhich, /* erste Which-Id des Pools */
+ USHORT nEndWhich, /* letzte Which-Id des Pools */
+#ifdef TF_POOLABLE
+ const SfxItemInfo* pInfos, /* SID-Map und Item-Flags */
+#endif
+ SfxPoolItem** pDefaults, /* Pointer auf statische Defaults,
+ wird direkt vom Pool referenziert,
+ jedoch kein Eigent"umer"ubergang */
+#ifndef TF_POOLABLE
+ USHORT* pSlotIdArray, /* Zuordnung von Slot-Ids zu Which-Ids */
+#endif
+ FASTBOOL bLoadRefCounts /* Ref-Counts mitladen oder auf 1 setzen */
+)
+
+/* [Beschreibung]
+
+ Der im Normalfall verwendete Konstruktor der Klasse SfxItemPool. Es
+ wird eine SfxItemPool-Instanz initialisiert, die Items im b"undigen
+ Which-Bereich von 'nStartWhich' bis 'nEndWhich' verwalten kann.
+
+ F"ur jede dieser Which-Ids mu\s ein statischer Default im Array 'pDefaults'
+ vorhanden sein, die dort beginnend mit einem <SfxPoolItem> mit der
+ Which-Id 'nStartWhich' nach Which-Ids sortiert aufeinanderfolgend
+ eingetragen sein m"ussen.
+
+ 'pItemInfos' ist ein identisch angeordnetes Array von USHORTs, die
+ Slot-Ids darstellen und Flags. Die Slot-Ids k"onnen 0 sein, wenn die
+ betreffenden Items ausschlie\slich in der Core verwendet werden.
+ "Uber die Flags kann z.B. bestimmt werden, ob Value-Sharing
+ (SFX_ITEM_POOLABLE) stattfinden soll.
+
+ [Anmerkung]
+
+ Wenn der Pool <SfxSetItem>s enthalten soll, k"onnen im Konstruktor noch
+ keine static-Defaults angegeben werden. Dies mu\s dann nachtr"aglich
+ mit <SfxItemPool::SetDefaults(SfxItemPool**)> geschehen.
+
+
+ [Querverweise]
+
+ <SfxItemPool::SetDefaults(SfxItemPool**)>
+ <SfxItemPool::ReleaseDefaults(SfxPoolItem**,USHORT,BOOL)>
+ <SfxItemPool::ReldaseDefaults(BOOL)>
+*/
+
+: aName(rName),
+ nStart(nStartWhich),
+ nEnd(nEndWhich),
+#ifdef TF_POOLABLE
+ pItemInfos(pInfos),
+#else
+ pSlotIds(pSlotIdArray),
+#endif
+ pImp( new SfxItemPool_Impl( nStart, nEnd ) ),
+ ppStaticDefaults(0),
+ ppPoolDefaults(new SfxPoolItem* [ nEndWhich - nStartWhich + 1]),
+ pSecondary(0),
+ pMaster(this),
+ _pPoolRanges( 0 ),
+ bPersistentRefCounts(bLoadRefCounts)
+{
+ DBG_CTOR(SfxItemPool, 0);
+ DBG_ASSERT(nStart, "Start-Which-Id must be greater 0" );
+
+ pImp->eDefMetric = SFX_MAPUNIT_TWIP;
+ pImp->nVersion = 0;
+ pImp->bStreaming = FALSE;
+ pImp->nLoadingVersion = 0;
+ pImp->nInitRefCount = 1;
+ pImp->nVerStart = nStart;
+ pImp->nVerEnd = nEnd;
+ pImp->bInSetItem = FALSE;
+ pImp->nStoringStart = nStartWhich;
+ pImp->nStoringEnd = nEndWhich;
+
+ memset( ppPoolDefaults, 0, sizeof( SfxPoolItem* ) * (nEnd - nStart + 1));
+
+ if ( pDefaults )
+ SetDefaults(pDefaults);
+}
+
+// -----------------------------------------------------------------------
+
+
+SfxItemPool::SfxItemPool
+(
+ const SfxItemPool& rPool, // von dieser Instanz kopieren
+ BOOL bCloneStaticDefaults /* TRUE
+ statische Defaults kopieren
+
+ FALSE
+ statische Defaults
+ "ubernehehmen */
+)
+
+/* [Beschreibung]
+
+ Copy-Konstruktor der Klasse SfxItemPool.
+
+
+ [Querverweise]
+
+ <SfxItemPool::Clone()const>
+*/
+
+: aName(rPool.aName),
+ nStart(rPool.nStart),
+ nEnd(rPool.nEnd),
+#ifdef TF_POOLABLE
+ pItemInfos(rPool.pItemInfos),
+#else
+ pSlotIds(rPool.pSlotIds),
+#endif
+ pImp( new SfxItemPool_Impl( nStart, nEnd ) ),
+ ppStaticDefaults(0),
+ ppPoolDefaults(new SfxPoolItem* [ nEnd - nStart + 1]),
+ pSecondary(0),
+ pMaster(this),
+ _pPoolRanges( 0 ),
+ bPersistentRefCounts(rPool.bPersistentRefCounts )
+{
+ DBG_CTOR(SfxItemPool, 0);
+ pImp->eDefMetric = rPool.pImp->eDefMetric;
+ pImp->nVersion = rPool.pImp->nVersion;
+ pImp->bStreaming = FALSE;
+ pImp->nLoadingVersion = 0;
+ pImp->nInitRefCount = 1;
+ pImp->nVerStart = rPool.pImp->nVerStart;
+ pImp->nVerEnd = rPool.pImp->nVerEnd;
+ pImp->bInSetItem = FALSE;
+ pImp->nStoringStart = nStart;
+ pImp->nStoringEnd = nEnd;
+
+ memset( ppPoolDefaults, 0, sizeof( SfxPoolItem* ) * (nEnd - nStart + 1));
+
+ // Static Defaults "ubernehmen
+ if ( bCloneStaticDefaults )
+ {
+ SfxPoolItem **ppDefaults = new SfxPoolItem*[nEnd-nStart+1];
+ for ( USHORT n = 0; n <= nEnd - nStart; ++n )
+ {
+ (*( ppDefaults + n )) = (*( rPool.ppStaticDefaults + n ))->Clone(this);
+ (*( ppDefaults + n ))->SetKind( SFX_ITEMS_STATICDEFAULT );
+ }
+
+ SetDefaults( ppDefaults );
+ }
+ else
+ SetDefaults( rPool.ppStaticDefaults );
+
+ // Pool Defaults kopieren
+ for ( USHORT n = 0; n <= nEnd - nStart; ++n )
+ if ( (*( rPool.ppPoolDefaults + n )) )
+ {
+ (*( ppPoolDefaults + n )) = (*( rPool.ppPoolDefaults + n ))->Clone(this);
+ (*( ppPoolDefaults + n ))->SetKind( SFX_ITEMS_POOLDEFAULT );
+ }
+
+ // Version-Map kopieren
+ USHORT nVerCount = rPool.pImp->aVersions.Count();
+ for ( USHORT nVer = 0; nVer < nVerCount; ++nVer )
+ {
+ const SfxPoolVersion_Impl *pOld = rPool.pImp->aVersions.GetObject(nVer);
+ const SfxPoolVersion_Impl *pNew = new SfxPoolVersion_Impl( *pOld );
+ pImp->aVersions.Insert( pNew, nVer );
+ }
+
+ // Verkettung wiederherstellen
+ if ( rPool.pSecondary )
+ SetSecondaryPool( rPool.pSecondary->Clone() );
+}
+
+// -----------------------------------------------------------------------
+
+void SfxItemPool::SetDefaults( SfxPoolItem **pDefaults )
+{
+ DBG_CHKTHIS(SfxItemPool, 0);
+ DBG_ASSERT( pDefaults, "erst wollen, dann nichts geben..." );
+ DBG_ASSERT( !ppStaticDefaults, "habe schon defaults" );
+
+ ppStaticDefaults = pDefaults;
+ //! if ( (*ppStaticDefaults)->GetKind() != SFX_ITEMS_STATICDEFAULT )
+ //! geht wohl nicht im Zshg mit SetItems, die hinten stehen
+ {
+ DBG_ASSERT( (*ppStaticDefaults)->GetRefCount() == 0 ||
+ IsDefaultItem( (*ppStaticDefaults) ),
+ "das sind keine statics" );
+ for ( USHORT n = 0; n <= nEnd - nStart; ++n )
+ {
+ SFX_ASSERT( (*( ppStaticDefaults + n ))->Which() == n + nStart,
+ n + nStart, "static defaults not sorted" );
+ (*( ppStaticDefaults + n ))->SetKind( SFX_ITEMS_STATICDEFAULT );
+ DBG_ASSERT( !(pImp->ppPoolItems[n]), "defaults with setitems with items?!" );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SfxItemPool::ReleaseDefaults
+(
+ BOOL bDelete /* TRUE
+ l"oscht sowohl das Array als auch die einzelnen
+ statischen Defaults
+
+ FALSE
+ l"oscht weder das Array noch die einzelnen
+ statischen Defaults */
+)
+
+/* [Beschreibung]
+
+ Gibt die statischen Defaults der betreffenden SfxItemPool-Instanz frei
+ und l"oscht ggf. die statischen Defaults.
+
+ Nach Aufruf dieser Methode darf die SfxItemPool-Instanz nicht mehr
+ verwendet werden, einzig ist der Aufruf des Destruktors zu"lassig.
+*/
+
+{
+ DBG_ASSERT( ppStaticDefaults, "keine Arme keine Kekse" );
+ ReleaseDefaults( ppStaticDefaults, nEnd - nStart + 1, bDelete );
+
+ // KSO (22.10.98): ppStaticDefaults zeigt auf geloeschten Speicher,
+ // wenn bDelete == TRUE.
+ if ( bDelete )
+ ppStaticDefaults = 0;
+}
+
+// -----------------------------------------------------------------------
+
+void SfxItemPool::ReleaseDefaults
+(
+ SfxPoolItem** pDefaults, /* freizugebende statische Defaults */
+
+ USHORT nCount, /* Anzahl der statischen Defaults */
+
+ BOOL bDelete /* TRUE
+ l"oscht sowohl das Array als auch die
+ einzelnen statischen Defaults
+
+ FALSE
+ l"oscht weder das Array noch die
+ einzelnen statischen Defaults */
+)
+
+/* [Beschreibung]
+
+ Gibt die angegebenen statischen Defaults frei und l"oscht ggf.
+ die statischen Defaults.
+
+ Diese Methode darf erst nach Zerst"orung aller SfxItemPool-Instanzen,
+ welche die angegebenen statischen Defaults 'pDefault' verwenden,
+ aufgerufen werden.
+*/
+
+{
+ DBG_ASSERT( pDefaults, "erst wollen, dann nichts geben..." );
+
+ for ( USHORT n = 0; n < nCount; ++n )
+ {
+ SFX_ASSERT( IsStaticDefaultItem( *(pDefaults+n) ),
+ n, "das ist kein static-default" );
+ (*( pDefaults + n ))->SetRefCount( 0 );
+ if ( bDelete )
+ { delete *( pDefaults + n ); *(pDefaults + n) = 0; }
+ }
+
+ if ( bDelete )
+ { delete[] pDefaults; pDefaults = 0; }
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemPool::~SfxItemPool()
+{
+ DBG_DTOR(SfxItemPool, 0);
+ DBG_ASSERT( pMaster == this, "destroying active Secondary-Pool" );
+
+ if ( pImp->ppPoolItems && ppPoolDefaults )
+ Delete();
+ delete[] _pPoolRanges;
+ delete pImp;
+}
+// -----------------------------------------------------------------------
+
+
+void SfxItemPool::SetSecondaryPool( SfxItemPool *pPool )
+{
+ // ggf. an abgeh"angten Pools den Master zur"ucksetzen
+ if ( pSecondary )
+ {
+#ifdef DBG_UTIL
+ HACK( "fuer Image, dort gibt es derzeit keine Statics - Bug" )
+ if ( ppStaticDefaults )
+ {
+ // Delete() ist noch nicht gelaufen?
+ if ( pImp->ppPoolItems && pSecondary->pImp->ppPoolItems )
+ {
+ // hat der master SetItems?
+ BOOL bHasSetItems = FALSE;
+ for ( USHORT i = 0; !bHasSetItems && i < nEnd-nStart; ++i )
+ bHasSetItems = ppStaticDefaults[i]->ISA(SfxSetItem);
+
+ // abgehaengte Pools muessen leer sein
+ BOOL bOK = bHasSetItems;
+ for ( USHORT n = 0;
+ bOK && n <= pSecondary->nEnd - pSecondary->nStart;
+ ++n )
+ {
+ SfxPoolItemArray_Impl** ppItemArr =
+ pSecondary->pImp->ppPoolItems + n;
+ if ( *ppItemArr )
+ {
+ SfxPoolItem** ppHtArr =
+ (SfxPoolItem**)(*ppItemArr)->GetData();
+ for( USHORT i = (*ppItemArr)->Count(); i; ++ppHtArr, --i )
+ if ( !(*ppHtArr) )
+ {
+ DBG_ERROR( "old secondary pool must be empty" );
+ bOK = FALSE;
+ break;
+ }
+ }
+ }
+ }
+ }
+#endif
+
+ pSecondary->pMaster = pSecondary;
+ for ( SfxItemPool *p = pSecondary->pSecondary; p; p = p->pSecondary )
+ p->pMaster = pSecondary;
+ }
+
+ // ggf. den Master der neuen Secondary-Pools setzen
+ DBG_ASSERT( !pPool || pPool->pMaster == pPool, "Secondary tanzt auf zwei Hochzeiten " );
+ SfxItemPool *pNewMaster = pMaster ? pMaster : this;
+ for ( SfxItemPool *p = pPool; p; p = p->pSecondary )
+ p->pMaster = pNewMaster;
+
+ // neuen Secondary-Pool merken
+ pSecondary = pPool;
+}
+
+// -----------------------------------------------------------------------
+
+SfxMapUnit SfxItemPool::GetMetric( USHORT ) const
+{
+ DBG_CHKTHIS(SfxItemPool, 0);
+
+ return pImp->eDefMetric;
+}
+
+// -----------------------------------------------------------------------
+
+void SfxItemPool::SetDefaultMetric( SfxMapUnit eNewMetric )
+{
+ DBG_CHKTHIS(SfxItemPool, 0);
+
+ pImp->eDefMetric = eNewMetric;
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemPresentation SfxItemPool::GetPresentation
+(
+ const SfxPoolItem& rItem, /* IN: <SfxPoolItem>, dessen textuelle
+ Wert-Darstellung geliefert werden
+ soll */
+ SfxItemPresentation ePresent, /* IN: gew"unschte Art der Darstellung;
+ siehe <SfxItemPresentation> */
+ SfxMapUnit eMetric, /* IN: gew"unschte Ma\seinheit der Darstellung */
+ XubString& rText, /* OUT: textuelle Darstellung von 'rItem' */
+ const ::IntlWrapper * pIntlWrapper
+) const
+
+/* [Beschreibung]
+
+ "Uber diese virtuelle Methode k"onnen textuelle Darstellungen der
+ von der jeweilige SfxItemPool-Subklasse verwalteten SfxPoolItems
+ angefordert werden.
+
+ In Ableitungen sollte diese Methode "uberladen werden und auf
+ SfxPoolItems reagiert werden, die bei <SfxPoolItem::GetPresentation()const>
+ keine vollst"andige Information liefern k"onnen.
+
+ Die Basisklasse liefert die unver"anderte Presentation von 'rItem'.
+*/
+
+{
+ DBG_CHKTHIS(SfxItemPool, 0);
+ return rItem.GetPresentation(
+ ePresent, GetMetric(rItem.Which()), eMetric, rText, pIntlWrapper );
+}
+
+
+// -----------------------------------------------------------------------
+
+SfxItemPool* SfxItemPool::Clone() const
+{
+ DBG_CHKTHIS(SfxItemPool, 0);
+
+ SfxItemPool *pPool = new SfxItemPool( *this );
+ return pPool;
+}
+
+// ----------------------------------------------------------------------
+
+void SfxItemPool::Delete()
+{
+ DBG_CHKTHIS(SfxItemPool, 0);
+
+ // schon deleted?
+ if ( !pImp->ppPoolItems || !ppPoolDefaults )
+ return;
+
+ // z.B. laufenden Requests bescheidsagen
+ pImp->aBC.Broadcast( SfxSimpleHint( SFX_HINT_DYING ) );
+
+ //MA 16. Apr. 97: Zweimal durchlaufen, in der ersten Runde fuer die SetItems.
+ //Der Klarheit halber wird das jetzt in zwei besser lesbare Schleifen aufgeteilt.
+
+ SfxPoolItemArray_Impl** ppItemArr = pImp->ppPoolItems;
+ SfxPoolItem** ppDefaultItem = ppPoolDefaults;
+ SfxPoolItem** ppStaticDefaultItem = ppStaticDefaults;
+ USHORT nArrCnt;
+
+ //Erst die SetItems abraeumen
+ HACK( "fuer Image, dort gibt es derzeit keine Statics - Bug" )
+ if ( ppStaticDefaults )
+ {
+ for ( nArrCnt = GetSize_Impl();
+ nArrCnt;
+ --nArrCnt, ++ppItemArr, ++ppDefaultItem, ++ppStaticDefaultItem )
+ {
+ // KSO (22.10.98): *ppStaticDefaultItem kann im dtor einer
+ // von SfxItemPool abgeleiteten Klasse bereits geloescht worden
+ // sein! -> CHAOS Itempool
+ if ( *ppStaticDefaultItem && (*ppStaticDefaultItem)->ISA(SfxSetItem) )
+ {
+ if ( *ppItemArr )
+ {
+ SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData();
+ for ( USHORT n = (*ppItemArr)->Count(); n; --n, ++ppHtArr )
+ if (*ppHtArr)
+ {
+#ifdef DBG_UTIL
+ ReleaseRef( **ppHtArr, (*ppHtArr)->GetRefCount() );
+#endif
+ delete *ppHtArr;
+ }
+ DELETEZ( *ppItemArr );
+ }
+ if ( *ppDefaultItem )
+ {
+#ifdef DBG_UTIL
+ SetRefCount( **ppDefaultItem, 0 );
+#endif
+ DELETEZ( *ppDefaultItem );
+ }
+ }
+ }
+ }
+
+ ppItemArr = pImp->ppPoolItems;
+ ppDefaultItem = ppPoolDefaults;
+
+ //Jetzt die 'einfachen' Items
+ for ( nArrCnt = GetSize_Impl();
+ nArrCnt;
+ --nArrCnt, ++ppItemArr, ++ppDefaultItem )
+ {
+ if ( *ppItemArr )
+ {
+ SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData();
+ for ( USHORT n = (*ppItemArr)->Count(); n; --n, ++ppHtArr )
+ if (*ppHtArr)
+ {
+#ifdef DBG_UTIL
+ ReleaseRef( **ppHtArr, (*ppHtArr)->GetRefCount() );
+#endif
+ delete *ppHtArr;
+ }
+ delete *ppItemArr;
+ }
+ if ( *ppDefaultItem )
+ {
+#ifdef DBG_UTIL
+ SetRefCount( **ppDefaultItem, 0 );
+#endif
+ delete *ppDefaultItem;
+ }
+ }
+
+ pImp->DeleteItems();
+ delete[] ppPoolDefaults; ppPoolDefaults = 0;
+}
+
+// ----------------------------------------------------------------------
+
+void SfxItemPool::SetPoolDefaultItem(const SfxPoolItem &rItem)
+{
+ DBG_CHKTHIS(SfxItemPool, 0);
+ if ( IsInRange(rItem.Which()) )
+ {
+ SfxPoolItem **ppOldDefault =
+ ppPoolDefaults + GetIndex_Impl(rItem.Which());
+ SfxPoolItem *pNewDefault = rItem.Clone(this);
+ pNewDefault->SetKind(SFX_ITEMS_POOLDEFAULT);
+ if ( *ppOldDefault )
+ {
+ (*ppOldDefault)->SetRefCount(0);
+ DELETEZ( *ppOldDefault );
+ }
+ *ppOldDefault = pNewDefault;
+ }
+ else if ( pSecondary )
+ pSecondary->SetPoolDefaultItem(rItem);
+ else
+ {
+ SFX_ASSERT( 0, rItem.Which(), "unknown Which-Id - cannot set pool default" );
+ }
+}
+
+// ----------------------------------------------------------------------
+
+void SfxItemPool::ResetPoolDefaultItem( USHORT nWhichId )
+
+/* [Beschreibung]
+
+ Diese Methode setzt den Default f"ur die angegeben <Which-Id> zur"uck
+ auf den statischen Default. Falls ein Pool-Default exisitiert, wird
+ dieser gel"oscht.
+*/
+
+{
+ DBG_CHKTHIS(SfxItemPool, 0);
+ if ( IsInRange(nWhichId) )
+ {
+ SfxPoolItem **ppOldDefault =
+ ppPoolDefaults + GetIndex_Impl( nWhichId );
+ if ( *ppOldDefault )
+ {
+ (*ppOldDefault)->SetRefCount(0);
+ DELETEZ( *ppOldDefault );
+ }
+ }
+ else if ( pSecondary )
+ pSecondary->ResetPoolDefaultItem(nWhichId);
+ else
+ {
+ SFX_ASSERT( 0, nWhichId, "unknown Which-Id - cannot set pool default" );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, USHORT nWhich )
+{
+ DBG_ASSERT( !rItem.ISA(SfxSetItem) ||
+ 0 != &((const SfxSetItem&)rItem).GetItemSet(),
+ "SetItem without ItemSet" );
+
+ DBG_CHKTHIS(SfxItemPool, 0);
+ if ( 0 == nWhich )
+ nWhich = rItem.Which();
+
+ // richtigen Secondary-Pool finden
+ BOOL bSID = nWhich > SFX_WHICH_MAX;
+ if ( !bSID && !IsInRange(nWhich) )
+ {
+ if ( pSecondary )
+ return pSecondary->Put( rItem, nWhich );
+ DBG_ERROR( "unknown Which-Id - cannot put item" );
+ }
+
+ // SID oder nicht poolable (neue Definition)?
+ USHORT nIndex = bSID ? USHRT_MAX : GetIndex_Impl(nWhich);
+ if ( USHRT_MAX == nIndex ||
+ IsItemFlag_Impl( nIndex, SFX_ITEM_NOT_POOLABLE ) )
+ {
+ SFX_ASSERT( USHRT_MAX != nIndex || rItem.Which() != nWhich ||
+ !IsDefaultItem(&rItem) || rItem.GetKind() == SFX_ITEMS_DELETEONIDLE,
+ nWhich, "ein nicht Pool-Item ist Default?!" );
+ SfxPoolItem *pPoolItem = rItem.Clone(pMaster);
+ pPoolItem->SetWhich(nWhich);
+ AddRef( *pPoolItem );
+ return *pPoolItem;
+ }
+
+ SFX_ASSERT( rItem.IsA(GetDefaultItem(nWhich).Type()), nWhich,
+ "SFxItemPool: wrong item type in Put" );
+
+ SfxPoolItemArray_Impl** ppItemArr = pImp->ppPoolItems + nIndex;
+ if( !*ppItemArr )
+ *ppItemArr = new SfxPoolItemArray_Impl;
+
+ SfxPoolItem **ppFree = 0;
+ SfxPoolItem** ppHtArray = (SfxPoolItem**)(*ppItemArr)->GetData();
+ if ( IsItemFlag_Impl( nIndex, SFX_ITEM_POOLABLE ) )
+ {
+ // wenn es ueberhaupt gepoolt ist, koennte es schon drin sein
+ if ( IsPooledItem(&rItem) )
+ {
+ // 1. Schleife: teste ob der Pointer vorhanden ist.
+ for( USHORT n = (*ppItemArr)->Count(); n; ++ppHtArray, --n )
+ if( &rItem == (*ppHtArray) )
+ {
+ AddRef( **ppHtArray );
+ return **ppHtArray;
+ }
+ }
+
+ // 2. Schleife: dann muessen eben die Attribute verglichen werden
+ USHORT n;
+ for ( n = (*ppItemArr)->Count(), ppHtArray = (SfxPoolItem**)(*ppItemArr)->GetData();
+ n; ++ppHtArray, --n )
+ {
+ if ( *ppHtArray )
+ {
+ if( **ppHtArray == rItem )
+ {
+ AddRef( **ppHtArray );
+ return **ppHtArray;
+ }
+ }
+ else
+ if ( !ppFree )
+ ppFree = ppHtArray;
+ }
+ }
+ else
+ {
+ // freien Platz suchen
+ SfxPoolItem** ppHtArr;
+ USHORT n, nCount = (*ppItemArr)->Count();
+ for ( n = (*ppItemArr)->nFirstFree,
+ ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData() + n;
+ n < nCount;
+ ++ppHtArr, ++n )
+ if ( !*ppHtArr )
+ {
+ ppFree = ppHtArr;
+ break;
+ }
+
+ // naechstmoeglichen freien Platz merken
+ (*ppItemArr)->nFirstFree = n;
+ }
+
+ // nicht vorhanden, also im PtrArray eintragen
+ SfxPoolItem* pNewItem = rItem.Clone(pMaster);
+ pNewItem->SetWhich(nWhich);
+#ifdef DBG_UTIL
+ SFX_ASSERT( rItem.Type() == pNewItem->Type(), nWhich, "unequal types in Put(): no Clone()?" )
+#ifdef TF_POOLABLE
+ if ( !rItem.ISA(SfxSetItem) )
+ {
+ SFX_ASSERT( !IsItemFlag(nWhich, SFX_ITEM_POOLABLE) ||
+ rItem == *pNewItem,
+ nWhich, "unequal items in Put(): no operator==?" );
+ SFX_ASSERT( !IsItemFlag(*pNewItem, SFX_ITEM_POOLABLE) ||
+ *pNewItem == rItem,
+ nWhich, "unequal items in Put(): no operator==?" );
+ }
+#endif
+#endif
+ AddRef( *pNewItem, pImp->nInitRefCount );
+ const SfxPoolItem* pTemp = pNewItem;
+ if ( !ppFree )
+ (*ppItemArr)->Insert( pTemp, (*ppItemArr)->Count() );
+ else
+ {
+ DBG_ASSERT( *ppFree == 0, "using surrogate in use" );
+ *ppFree = pNewItem;
+ }
+ return *pNewItem;
+}
+
+// -----------------------------------------------------------------------
+
+void SfxItemPool::Remove( const SfxPoolItem& rItem )
+{
+ DBG_CHKTHIS(SfxItemPool, 0);
+
+ DBG_ASSERT( !rItem.ISA(SfxSetItem) ||
+ 0 != &((const SfxSetItem&)rItem).GetItemSet(),
+ "SetItem without ItemSet" );
+
+ SFX_ASSERT( !IsPoolDefaultItem(&rItem), rItem.Which(),
+ "wo kommt denn hier ein Pool-Default her" );
+
+ // richtigen Secondary-Pool finden
+ const USHORT nWhich = rItem.Which();
+ BOOL bSID = nWhich > SFX_WHICH_MAX;
+ if ( !bSID && !IsInRange(nWhich) )
+ {
+ if ( pSecondary )
+ {
+ pSecondary->Remove( rItem );
+ return;
+ }
+ DBG_ERROR( "unknown Which-Id - cannot remove item" );
+ }
+
+ // SID oder nicht poolable (neue Definition)?
+ USHORT nIndex = bSID ? USHRT_MAX : GetIndex_Impl(nWhich);
+ if ( bSID || IsItemFlag_Impl( nIndex, SFX_ITEM_NOT_POOLABLE ) )
+ {
+ SFX_ASSERT( USHRT_MAX != nIndex ||
+ !IsDefaultItem(&rItem), rItem.Which(),
+ "ein nicht Pool-Item ist Default?!" );
+ if ( 0 == ReleaseRef(rItem) )
+ {
+ SfxPoolItem *pItem = &(SfxPoolItem &)rItem;
+ delete pItem;
+ }
+ return;
+ }
+
+ SFX_ASSERT( rItem.GetRefCount(), rItem.Which(), "RefCount == 0, Remove unmoeglich" );
+
+ // statische Defaults sind eben einfach da
+ if ( rItem.GetKind() == SFX_ITEMS_STATICDEFAULT &&
+ &rItem == *( ppStaticDefaults + GetIndex_Impl(nWhich) ) )
+ return;
+
+ // Item im eigenen Pool suchen
+ SfxPoolItemArray_Impl** ppItemArr = (pImp->ppPoolItems + nIndex);
+ SFX_ASSERT( *ppItemArr, rItem.Which(), "removing Item not in Pool" );
+ SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData();
+ for( USHORT n = (*ppItemArr)->Count(); n; ++ppHtArr, --n )
+ if( *ppHtArr == &rItem )
+ {
+ if ( (*ppHtArr)->GetRefCount() ) //!
+ ReleaseRef( **ppHtArr );
+ else
+ {
+ SFX_ASSERT( 0, rItem.Which(), "removing Item without ref" );
+ SFX_TRACE( "to be removed, but not no refs: ", *ppHtArr );
+ }
+
+ // ggf. kleinstmoegliche freie Position merken
+ USHORT nPos = (*ppItemArr)->Count() - n;
+ if ( (*ppItemArr)->nFirstFree > nPos )
+ (*ppItemArr)->nFirstFree = nPos;
+
+ //! MI: Hack, solange wir das Problem mit dem Outliner haben
+ //! siehe anderes MI-REF
+ if ( 0 == (*ppHtArr)->GetRefCount() && nWhich < 4000 )
+ DELETEZ(*ppHtArr);
+ return;
+ }
+
+ // nicht vorhanden
+ SFX_ASSERT( 0, rItem.Which(), "removing Item not in Pool" );
+ SFX_TRACE( "to be removed, but not in pool: ", &rItem );
+}
+
+// -----------------------------------------------------------------------
+
+const SfxPoolItem& SfxItemPool::GetDefaultItem( USHORT nWhich ) const
+{
+ DBG_CHKTHIS(SfxItemPool, 0);
+
+ if ( !IsInRange(nWhich) )
+ {
+ if ( pSecondary )
+ return pSecondary->GetDefaultItem( nWhich );
+ SFX_ASSERT( 0, nWhich, "unknown which - dont ask me for defaults" );
+ }
+
+ DBG_ASSERT( ppStaticDefaults, "no defaults known - dont ask me for defaults" );
+ USHORT nPos = GetIndex_Impl(nWhich);
+ SfxPoolItem *pDefault = *(ppPoolDefaults + nPos);
+ if ( pDefault )
+ return *pDefault;
+ return **(ppStaticDefaults + nPos);
+}
+
+// -----------------------------------------------------------------------
+
+
+void SfxItemPool::FreezeIdRanges()
+
+/* [Beschreibung]
+
+ This method should be called at the master pool, when all secondary
+ pools are appended to it.
+
+ It calculates the ranges of 'which-ids' for fast construction of
+ item-sets, which contains all 'which-ids'.
+*/
+
+{
+ FillItemIdRanges_Impl( _pPoolRanges );
+}
+
+
+// -----------------------------------------------------------------------
+
+void SfxItemPool::FillItemIdRanges_Impl( USHORT*& pWhichRanges ) const
+{
+ DBG_CHKTHIS(SfxItemPool, 0);
+ DBG_ASSERT( !_pPoolRanges, "GetFrozenRanges() would be faster!" );
+
+ const SfxItemPool *pPool;
+ USHORT nLevel = 0;
+ for( pPool = this; pPool; pPool = pPool->pSecondary )
+ ++nLevel;
+
+ pWhichRanges = new USHORT[ 2*nLevel + 1 ];
+
+ nLevel = 0;
+ for( pPool = this; pPool; pPool = pPool->pSecondary )
+ {
+ *(pWhichRanges+(nLevel++)) = pPool->nStart;
+ *(pWhichRanges+(nLevel++)) = pPool->nEnd;
+ *(pWhichRanges+nLevel) = 0;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+const SfxPoolItem *SfxItemPool::GetItem(USHORT nWhich, USHORT nOfst) const
+{
+ DBG_CHKTHIS(SfxItemPool, 0);
+
+ if ( !IsInRange(nWhich) )
+ {
+ if ( pSecondary )
+ return pSecondary->GetItem( nWhich, nOfst );
+ SFX_ASSERT( 0, nWhich, "unknown Which-Id - cannot resolve surrogate" );
+ return 0;
+ }
+
+ // dflt-Attribut?
+ if ( nOfst == SFX_ITEMS_STATICDEFAULT )
+ return *(ppStaticDefaults + GetIndex_Impl(nWhich));
+
+ SfxPoolItemArray_Impl* pItemArr = *(pImp->ppPoolItems + GetIndex_Impl(nWhich));
+ if( pItemArr && nOfst < pItemArr->Count() )
+ return (*pItemArr)[nOfst];
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SfxItemPool::GetItemCount(USHORT nWhich) const
+{
+ DBG_CHKTHIS(SfxItemPool, 0);
+
+ if ( !IsInRange(nWhich) )
+ {
+ if ( pSecondary )
+ return pSecondary->GetItemCount( nWhich );
+ SFX_ASSERT( 0, nWhich, "unknown Which-Id - cannot resolve surrogate" );
+ return 0;
+ }
+
+ SfxPoolItemArray_Impl* pItemArr = *(pImp->ppPoolItems + GetIndex_Impl(nWhich));
+ if ( pItemArr )
+ return pItemArr->Count();
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SfxItemPool::GetWhich( USHORT nSlotId, BOOL bDeep ) const
+{
+ if ( !IsSlot(nSlotId) )
+ return nSlotId;
+
+#ifdef TF_POOLABLE
+ USHORT nCount = nEnd - nStart + 1;
+ for ( USHORT nOfs = 0; nOfs < nCount; ++nOfs )
+ if ( pItemInfos[nOfs]._nSID == nSlotId )
+ return nOfs + nStart;
+#else
+ if ( pSlotIds )
+ {
+ USHORT nCount = nEnd - nStart + 1;
+ for ( USHORT nOfs = 0; nOfs < nCount; ++nOfs )
+ if ( pSlotIds[nOfs] == nSlotId )
+ return nOfs + nStart;
+ }
+#endif
+ if ( pSecondary && bDeep )
+ return pSecondary->GetWhich(nSlotId);
+ return nSlotId;
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SfxItemPool::GetSlotId( USHORT nWhich, BOOL bDeep ) const
+{
+ if ( !IsWhich(nWhich) )
+ return nWhich;
+
+ if ( !IsInRange( nWhich ) )
+ {
+ if ( pSecondary && bDeep )
+ return pSecondary->GetSlotId(nWhich);
+ SFX_ASSERT( 0, nWhich, "unknown Which-Id - cannot get slot-id" );
+ return 0;
+ }
+#ifdef TF_POOLABLE
+
+ USHORT nSID = pItemInfos[nWhich - nStart]._nSID;
+ return nSID ? nSID : nWhich;
+#else
+ else if ( pSlotIds )
+ return pSlotIds[nWhich - nStart];
+ return nWhich;
+#endif
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SfxItemPool::GetTrueWhich( USHORT nSlotId, BOOL bDeep ) const
+{
+ if ( !IsSlot(nSlotId) )
+ return 0;
+
+#ifdef TF_POOLABLE
+ USHORT nCount = nEnd - nStart + 1;
+ for ( USHORT nOfs = 0; nOfs < nCount; ++nOfs )
+ if ( pItemInfos[nOfs]._nSID == nSlotId )
+ return nOfs + nStart;
+#else
+ if ( pSlotIds )
+ {
+ USHORT nCount = nEnd - nStart + 1;
+ for ( USHORT nOfs = 0; nOfs < nCount; ++nOfs )
+ if ( pSlotIds[nOfs] == nSlotId )
+ return nOfs + nStart;
+ }
+#endif
+ if ( pSecondary && bDeep )
+ return pSecondary->GetTrueWhich(nSlotId);
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SfxItemPool::GetTrueSlotId( USHORT nWhich, BOOL bDeep ) const
+{
+ if ( !IsWhich(nWhich) )
+ return 0;
+
+ if ( !IsInRange( nWhich ) )
+ {
+ if ( pSecondary && bDeep )
+ return pSecondary->GetTrueSlotId(nWhich);
+ SFX_ASSERT( 0, nWhich, "unknown Which-Id - cannot get slot-id" );
+ return 0;
+ }
+#ifdef TF_POOLABLE
+ return pItemInfos[nWhich - nStart]._nSID;
+#else
+ else if ( pSlotIds )
+ return pSlotIds[nWhich - nStart];
+ else
+ return 0;
+#endif
+}
+// -----------------------------------------------------------------------
+void SfxItemPool::SetFileFormatVersion( USHORT nFileFormatVersion )
+
+/* [Description]
+
+ You must call this function to set the file format version after
+ concatenating your secondary-pools but before you store any
+ pool, itemset or item. Only set the version at the master pool,
+ never at any secondary pool.
+*/
+
+{
+ DBG_ASSERT( this == pMaster,
+ "SfxItemPool::SetFileFormatVersion() but not a master pool" );
+ for ( SfxItemPool *pPool = this; pPool; pPool = pPool->pSecondary )
+ pPool->_nFileFormatVersion = nFileFormatVersion;
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_itemprop.cxx b/binfilter/bf_svtools/source/items1/svt_itemprop.cxx
new file mode 100644
index 000000000000..c62e6c574c34
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_itemprop.cxx
@@ -0,0 +1,482 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <string.h>
+
+#include <bf_svtools/itemprop.hxx>
+#include <bf_svtools/itempool.hxx>
+#include <bf_svtools/itemset.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+/*************************************************************************
+ UNO III Implementation
+*************************************************************************/
+using namespace com::sun::star::beans;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace ::rtl;
+
+namespace binfilter
+{
+
+/* -----------------------------21.02.00 11:26--------------------------------
+
+ ---------------------------------------------------------------------------*/
+const SfxItemPropertyMap* SfxItemPropertyMap::GetByName(
+ const SfxItemPropertyMap *pMap, const OUString &rName )
+{
+ while ( pMap->pName )
+ {
+ if( rName.equalsAsciiL( pMap->pName, pMap->nNameLen ) )
+ return pMap;
+ ++pMap;
+ }
+ return 0;
+}
+/* -----------------------------21.02.00 11:26--------------------------------
+
+ ---------------------------------------------------------------------------*/
+BOOL SfxItemPropertySet::FillItem(SfxItemSet&, USHORT, BOOL) const
+{
+ return FALSE;
+}
+/* -----------------------------06.06.01 12:32--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SfxItemPropertySet::getPropertyValue( const SfxItemPropertyMap& rMap,
+ const SfxItemSet& rSet, Any& rAny ) const
+ throw(RuntimeException)
+{
+ // item holen
+ const SfxPoolItem* pItem = 0;
+ SfxItemState eState = rSet.GetItemState( rMap.nWID, TRUE, &pItem );
+ if(SFX_ITEM_SET != eState && SFX_WHICH_MAX > rMap.nWID )
+ pItem = &rSet.GetPool()->GetDefaultItem(rMap.nWID);
+ // item-Wert als UnoAny zurueckgeben
+ if(eState >= SFX_ITEM_DEFAULT && pItem)
+ {
+ pItem->QueryValue( rAny, rMap.nMemberId );
+ }
+ else
+ {
+ SfxItemSet aSet(*rSet.GetPool(), rMap.nWID, rMap.nWID);
+ if(FillItem(aSet, rMap.nWID, TRUE))
+ {
+ const SfxPoolItem& rItem = aSet.Get(rMap.nWID);
+ rItem.QueryValue( rAny, rMap.nMemberId );
+ }
+ else if(0 == (rMap.nFlags & PropertyAttribute::MAYBEVOID))
+ throw RuntimeException();
+ }
+
+
+ // allgemeine SfxEnumItem Values in konkrete wandeln
+ if( rMap.pType && TypeClass_ENUM == rMap.pType->getTypeClass() &&
+ rAny.getValueTypeClass() == TypeClass_LONG )
+ {
+ INT32 nTmp = *(INT32*)rAny.getValue();
+ rAny.setValue( &nTmp, *rMap.pType );
+ }
+}
+
+
+/* -----------------------------15.11.00 12:32--------------------------------
+
+ ---------------------------------------------------------------------------*/
+Any SfxItemPropertySet::getPropertyValue( const SfxItemPropertyMap& rMap,
+ const SfxItemSet& rSet ) const
+ throw(RuntimeException)
+{
+ Any aAny;
+ getPropertyValue(rMap, rSet, aAny);
+ return aAny;
+}
+
+/* -----------------------------06.06.01 12:32--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SfxItemPropertySet::getPropertyValue( const OUString &rName,
+ const SfxItemSet& rSet, Any& rAny ) const
+ throw(RuntimeException, UnknownPropertyException)
+{
+ // which-id ermitteln
+ const SfxItemPropertyMap* pMap = SfxItemPropertyMap::GetByName( _pMap, rName );
+ if ( !pMap )
+ throw UnknownPropertyException();
+ getPropertyValue( *pMap,rSet, rAny );
+}
+/* -----------------------------21.02.00 11:26--------------------------------
+
+ ---------------------------------------------------------------------------*/
+Any SfxItemPropertySet::getPropertyValue( const OUString &rName,
+ const SfxItemSet& rSet ) const
+ throw(RuntimeException, UnknownPropertyException)
+{
+ Any aVal;
+ getPropertyValue( rName,rSet, aVal );
+ return aVal;
+}
+/* -----------------------------15.11.00 14:46--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SfxItemPropertySet::setPropertyValue( const SfxItemPropertyMap& rMap,
+ const Any& aVal,
+ SfxItemSet& rSet ) const
+ throw(RuntimeException,
+ IllegalArgumentException)
+{
+ // item holen
+ const SfxPoolItem* pItem = 0;
+ SfxPoolItem *pNewItem = 0;
+ SfxItemState eState = rSet.GetItemState( rMap.nWID, TRUE, &pItem );
+ if(SFX_ITEM_SET != eState && SFX_WHICH_MAX > rMap.nWID )
+ pItem = &rSet.GetPool()->GetDefaultItem(rMap.nWID);
+ //maybe there's another way to find an Item
+ if(eState < SFX_ITEM_DEFAULT)
+ {
+ SfxItemSet aSet(*rSet.GetPool(), rMap.nWID, rMap.nWID);
+ if(FillItem(aSet, rMap.nWID, FALSE))
+ {
+ const SfxPoolItem &rItem = aSet.Get(rMap.nWID);
+ pNewItem = rItem.Clone();
+ }
+ }
+ if(!pNewItem && pItem)
+ {
+ pNewItem = pItem->Clone();
+ }
+ if(pNewItem)
+ {
+ if( !pNewItem->PutValue( aVal, rMap.nMemberId ) )
+ {
+ DELETEZ(pNewItem);
+ throw IllegalArgumentException();
+ }
+ // neues item in itemset setzen
+ rSet.Put( *pNewItem, rMap.nWID );
+ delete pNewItem;
+ }
+}
+/* -----------------------------21.02.00 11:26--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SfxItemPropertySet::setPropertyValue( const OUString &rName,
+ const Any& aVal,
+ SfxItemSet& rSet ) const
+ throw(RuntimeException,
+ IllegalArgumentException,
+ UnknownPropertyException)
+{
+ const SfxItemPropertyMap* pMap = SfxItemPropertyMap::GetByName( _pMap, rName );
+ if ( !pMap )
+ {
+ throw UnknownPropertyException();
+ }
+ setPropertyValue(*pMap, aVal, rSet);
+}
+/* -----------------------------21.02.00 11:26--------------------------------
+
+ ---------------------------------------------------------------------------*/
+PropertyState SfxItemPropertySet::getPropertyState(const SfxItemPropertyMap& rMap, const SfxItemSet& rSet)
+ throw()
+{
+ PropertyState eRet = PropertyState_DIRECT_VALUE;
+ USHORT nWhich = rMap.nWID;
+
+ // item state holen
+ SfxItemState eState = rSet.GetItemState( nWhich, FALSE );
+ // item-Wert als UnoAny zurueckgeben
+ if(eState == SFX_ITEM_DEFAULT)
+ eRet = PropertyState_DEFAULT_VALUE;
+ else if(eState < SFX_ITEM_DEFAULT)
+ eRet = PropertyState_AMBIGUOUS_VALUE;
+ return eRet;
+}
+
+PropertyState SfxItemPropertySet::getPropertyState(
+ const OUString& rName, const SfxItemSet& rSet)
+ throw(UnknownPropertyException)
+{
+ PropertyState eRet = PropertyState_DIRECT_VALUE;
+
+ // which-id ermitteln
+ const SfxItemPropertyMap* pMap = SfxItemPropertyMap::GetByName( _pMap, rName );
+ USHORT nWhich = pMap ? pMap->nWID : 0;
+ if ( !nWhich )
+ {
+ throw UnknownPropertyException();
+ }
+
+ // item holen
+ const SfxPoolItem* pItem = 0;
+ SfxItemState eState = rSet.GetItemState( nWhich, FALSE, &pItem );
+ if(!pItem && nWhich != rSet.GetPool()->GetSlotId(nWhich))
+ pItem = &rSet.GetPool()->GetDefaultItem(nWhich);
+ // item-Wert als UnoAny zurueckgeben
+ if(eState == SFX_ITEM_DEFAULT)
+ eRet = PropertyState_DEFAULT_VALUE;
+ else if(eState < SFX_ITEM_DEFAULT)
+ eRet = PropertyState_AMBIGUOUS_VALUE;
+ return eRet;
+}
+/* -----------------------------21.02.00 11:26--------------------------------
+
+ ---------------------------------------------------------------------------*/
+Reference<XPropertySetInfo>
+ SfxItemPropertySet::getPropertySetInfo() const
+{
+ Reference<XPropertySetInfo> aRef(new SfxItemPropertySetInfo( _pMap ));
+ return aRef;
+}
+
+/* -----------------------------21.02.00 11:09--------------------------------
+
+ ---------------------------------------------------------------------------*/
+Sequence< Property > SAL_CALL
+ SfxItemPropertySetInfo::getProperties( )
+ throw(RuntimeException)
+{
+ USHORT n = 0;
+ {
+ for ( const SfxItemPropertyMap *pMap = _pMap; pMap->pName; ++pMap )
+ ++n;
+ }
+
+ Sequence<Property> aPropSeq( n );
+ n = 0;
+ for ( const SfxItemPropertyMap *pMap = _pMap; pMap->pName; ++pMap )
+ {
+ aPropSeq.getArray()[n].Name = OUString::createFromAscii( pMap->pName );
+ aPropSeq.getArray()[n].Handle = pMap->nWID;
+ if(pMap->pType)
+ aPropSeq.getArray()[n].Type = *pMap->pType;
+ aPropSeq.getArray()[n].Attributes =
+ sal::static_int_cast< sal_Int16 >(pMap->nFlags);
+ n++;
+ }
+
+ return aPropSeq;
+}
+/* -----------------------------21.02.00 11:27--------------------------------
+
+ ---------------------------------------------------------------------------*/
+Property SAL_CALL
+ SfxItemPropertySetInfo::getPropertyByName( const ::rtl::OUString& rName )
+ throw(UnknownPropertyException, RuntimeException)
+{
+ Property aProp;
+ for( const SfxItemPropertyMap *pMap = _pMap; pMap->pName; ++pMap )
+ {
+ if( rName.equalsAsciiL( pMap->pName, pMap->nNameLen ))
+ {
+ aProp.Name = rName;
+ aProp.Handle = pMap->nWID;
+ if(pMap->pType)
+ aProp.Type = *pMap->pType;
+ aProp.Attributes = sal::static_int_cast< sal_Int16 >(pMap->nFlags);
+ break;
+ }
+ }
+ if(!aProp.Name.getLength())
+ throw UnknownPropertyException();
+ return aProp;
+}
+/* -----------------------------21.02.00 11:28--------------------------------
+
+ ---------------------------------------------------------------------------*/
+sal_Bool SAL_CALL
+ SfxItemPropertySetInfo::hasPropertyByName( const ::rtl::OUString& rName )
+ throw(RuntimeException)
+{
+ for ( const SfxItemPropertyMap *pMap = _pMap; pMap->pName; ++pMap )
+ {
+ if( rName.equalsAsciiL( pMap->pName, pMap->nNameLen ))
+ return TRUE;
+ }
+ return FALSE;
+}
+/* -----------------------------21.02.00 12:03--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SfxExtItemPropertySetInfo::SfxExtItemPropertySetInfo(
+ const SfxItemPropertyMap *pMap,
+ const Sequence<Property>& rPropSeq ) :
+ _pExtMap(pMap)
+{
+ long nLen = rPropSeq.getLength();
+ long nExtLen = 0;
+ while(pMap[nExtLen].pName)
+ nExtLen++;
+ aPropertySeq.realloc(nExtLen + nLen);
+
+
+ long nNewLen = aPropertySeq.getLength();
+ Property* pNewArr = aPropertySeq.getArray();
+ long nCount1 = 0;//map
+ long nCount2 = 0;//sequence
+ long nDouble = 0;//Anzahl gleicher Property-Namen
+ BOOL bFromMap, bZero = FALSE;
+
+ const Property* pPropSeqArr = rPropSeq.getConstArray();
+ for( long i = 0; i < nNewLen; i++)
+ {
+ bFromMap = FALSE;
+ if(nCount1 < nExtLen && nCount2 < nLen)
+ {
+// int nDiff = strcmp(pMap[nCount1].pName, OUStringToString(rPropSeq.getConstArray()[nCount2].Name, CHARSET_SYSTEM ));
+ sal_Int32 nDiff = pPropSeqArr[nCount2].Name.compareToAscii(pMap[nCount1].pName, pMap[nCount1].nNameLen );
+ if(nDiff > 0)
+ {
+ bFromMap = TRUE;
+ }
+ else if(0 == nDiff)
+ {
+ nDouble++;
+ bFromMap = TRUE;
+ nCount2++;
+ }
+ }
+ else
+ {
+ if(nCount1 < nExtLen)
+ bFromMap = TRUE;
+ else if(nCount2>= nLen)
+ bZero = TRUE;
+ }
+ if(bFromMap)
+ {
+ pNewArr[i].Name = OUString::createFromAscii( pMap[nCount1].pName );
+ pNewArr[i].Handle = pMap[nCount1].nWID;
+ if(pMap[nCount1].pType)
+ pNewArr[i].Type = *pMap[nCount1].pType;
+ pNewArr[i].Attributes = sal::static_int_cast< sal_Int16 >(
+ pMap[nCount1].nFlags);
+ nCount1++;
+ }
+ else if(!bZero)
+ {
+ pNewArr[i] = pPropSeqArr[nCount2];
+ nCount2++;
+ }
+ }
+ if(nDouble)
+ aPropertySeq.realloc(nExtLen + nLen - nDouble);
+}
+/* -----------------------------21.02.00 12:03--------------------------------
+
+ ---------------------------------------------------------------------------*/
+Sequence< Property > SAL_CALL
+ SfxExtItemPropertySetInfo::getProperties( ) throw(RuntimeException)
+{
+ return aPropertySeq;
+}
+/* -----------------------------21.02.00 12:03--------------------------------
+
+ ---------------------------------------------------------------------------*/
+Property SAL_CALL
+ SfxExtItemPropertySetInfo::getPropertyByName( const OUString& aPropertyName )
+ throw(UnknownPropertyException, RuntimeException)
+{
+ const Property* pPropArr = aPropertySeq.getConstArray();
+ long nLen = aPropertySeq.getLength();
+ for( long i = 0; i < nLen; i++)
+ {
+ if(aPropertyName == pPropArr[i].Name)
+ return pPropArr[i];
+ }
+ return Property();
+}
+/* -----------------------------21.02.00 12:03--------------------------------
+
+ ---------------------------------------------------------------------------*/
+sal_Bool SAL_CALL
+ SfxExtItemPropertySetInfo::hasPropertyByName( const OUString& aPropertyName )
+ throw(RuntimeException)
+{
+ const Property* pPropArr = aPropertySeq.getConstArray();
+ long nLen = aPropertySeq.getLength();
+ for( long i = 0; i < nLen; i++)
+ {
+ if(aPropertyName == pPropArr[i].Name)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+// --------------------------------------------------------------------
+// SfxItemPropertySetInfo
+// --------------------------------------------------------------------
+
+::com::sun::star::uno::Any SAL_CALL SfxItemPropertySetInfo::queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return cppu::WeakImplHelper1<com::sun::star::beans::XPropertySetInfo>::queryInterface( aType );
+}
+
+// --------------------------------------------------------------------
+
+void SAL_CALL SfxItemPropertySetInfo::acquire( ) throw ()
+{
+ cppu::WeakImplHelper1<com::sun::star::beans::XPropertySetInfo>::release();
+}
+
+// --------------------------------------------------------------------
+
+void SAL_CALL SfxItemPropertySetInfo::release( ) throw ()
+{
+ cppu::WeakImplHelper1<com::sun::star::beans::XPropertySetInfo>::release();
+}
+
+// --------------------------------------------------------------------
+// SfxExtItemPropertySetInfo
+// --------------------------------------------------------------------
+
+::com::sun::star::uno::Any SAL_CALL SfxExtItemPropertySetInfo::queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return cppu::WeakImplHelper1<com::sun::star::beans::XPropertySetInfo>::queryInterface( aType );
+}
+
+// --------------------------------------------------------------------
+
+void SAL_CALL SfxExtItemPropertySetInfo::acquire( ) throw ()
+{
+ cppu::WeakImplHelper1<com::sun::star::beans::XPropertySetInfo>::release();
+}
+
+// --------------------------------------------------------------------
+
+void SAL_CALL SfxExtItemPropertySetInfo::release( ) throw ()
+{
+ cppu::WeakImplHelper1<com::sun::star::beans::XPropertySetInfo>::release();
+}
+
+// --------------------------------------------------------------------
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_itemset.cxx b/binfilter/bf_svtools/source/items1/svt_itemset.cxx
new file mode 100644
index 000000000000..7b6700cac5f7
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_itemset.cxx
@@ -0,0 +1,2065 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <string.h>
+
+#if STLPORT_VERSION>=321
+#include <cstdarg>
+#endif
+
+#define _SVSTDARR_USHORTS
+#define _SVSTDARR_ULONGS
+
+#include <bf_svtools/svstdarr.hxx>
+#include <bf_svtools/itemset.hxx>
+#include <bf_svtools/itempool.hxx>
+#include <bf_svtools/itemiter.hxx>
+#include "whiter.hxx"
+#include <bf_svtools/nranges.hxx>
+#include "whassert.hxx"
+
+#include <tools/stream.hxx>
+#include <tools/solar.h>
+
+namespace binfilter
+{
+
+// STATIC DATA -----------------------------------------------------------
+
+static const USHORT nInitCount = 10; // einzelne USHORTs => 5 Paare ohne '0'
+#ifdef DBG_UTIL
+static ULONG nRangesCopyCount = 0; // wie oft wurden Ranges kopiert
+#endif
+
+DBG_NAME(SfxItemSet)
+
+//========================================================================
+
+#define NUMTYPE USHORT
+#define SvNums SvUShorts
+#define SfxNumRanges SfxUShortRanges
+#include "svt_nranges.cxx"
+#undef NUMTYPE
+#undef SvNums
+#undef SfxNumRanges
+
+#define NUMTYPE ULONG
+#define SvNums SvULongs
+#define SfxNumRanges SfxULongRanges
+#include "svt_nranges.cxx"
+#undef NUMTYPE
+#undef SvNums
+#undef SfxNumRanges
+
+//========================================================================
+
+#ifdef DBG_UTIL
+
+
+const sal_Char *DbgCheckItemSet( const void* pVoid )
+{
+ const SfxItemSet *pSet = (const SfxItemSet*) pVoid;
+ SfxWhichIter aIter( *pSet );
+ USHORT nCount = 0, n = 0;
+ for ( USHORT nWh = aIter.FirstWhich(); nWh; nWh = aIter.NextWhich(), ++n )
+ {
+ const SfxPoolItem *pItem = pSet->_aItems[n];
+ if ( pItem )
+ {
+ ++nCount;
+ DBG_ASSERT( IsInvalidItem(pItem) ||
+ pItem->Which() == 0 || pItem->Which() == nWh,
+ "SfxItemSet: invalid which-id" );
+ DBG_ASSERT( IsInvalidItem(pItem) || !pItem->Which() ||
+ !SfxItemPool::IsWhich(pItem->Which()) ||
+ pSet->GetPool()->IsItemFlag(nWh, SFX_ITEM_NOT_POOLABLE) ||
+ SFX_ITEMS_NULL != pSet->GetPool()->GetSurrogate(pItem),
+ "SfxItemSet: item in set which is not in pool" );
+ }
+
+ }
+ DBG_ASSERT( pSet->_nCount == nCount, "wrong SfxItemSet::nCount detected" );
+
+ return 0;
+}
+
+#endif
+// -----------------------------------------------------------------------
+
+SfxItemSet::SfxItemSet
+(
+ SfxItemPool& rPool, /* der Pool, in dem die SfxPoolItems,
+ welche in dieses SfxItemSet gelangen,
+ aufgenommen werden sollen */
+ BOOL
+#ifdef DBG_UTIL
+#ifdef SFX_ITEMSET_NO_DEFAULT_CTOR
+
+ bTotalRanges /* komplette Pool-Ranges uebernehmen,
+ muss auf TRUE gesetzt werden */
+#endif
+#endif
+)
+/* [Beschreibung]
+
+ Konstruktor fuer ein SfxItemSet mit genau den Which-Bereichen, welche
+ dem angegebenen <SfxItemPool> bekannt sind.
+
+
+ [Anmerkung]
+
+ F"ur Sfx-Programmierer ein derart konstruiertes SfxItemSet kann
+ keinerlei Items mit Slot-Ids als Which-Werte aufnehmen!
+*/
+
+: _pPool( &rPool ),
+ _pParent( 0 ),
+ _nCount( 0 )
+{
+ DBG_CTOR(SfxItemSet, DbgCheckItemSet);
+ DBG_ASSERTWARNING( _pPool == _pPool->GetMasterPool(), "kein Master-Pool" );
+ DBG( _pChildCountCtor; *_pChildCount(this) = 0 );
+// DBG_ASSERT( bTotalRanges || abs( &bTotalRanges - this ) < 1000,
+// "please use suitable ranges" );
+#ifdef DBG_UTIL
+#ifdef SFX_ITEMSET_NO_DEFAULT_CTOR
+ if ( !bTotalRanges )
+ *(int*)0 = 0; // GPF
+#endif
+#endif
+
+ _pWhichRanges = (USHORT*) _pPool->GetFrozenIdRanges();
+ DBG_ASSERT( _pWhichRanges, "don't create ItemSets with full range before FreezeIdRanges()" );
+ if ( !_pWhichRanges )
+ _pPool->FillItemIdRanges_Impl( _pWhichRanges );
+
+ const USHORT nSize = TotalCount();
+ _aItems = new const SfxPoolItem* [ nSize ];
+ memset( (void*) _aItems, 0, nSize * sizeof( SfxPoolItem* ) );
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemSet::SfxItemSet( SfxItemPool& rPool, USHORT nWhich1, USHORT nWhich2 ):
+ _pPool( &rPool ),
+ _pParent( 0 ),
+ _nCount( 0 )
+{
+ DBG_CTOR(SfxItemSet, DbgCheckItemSet);
+ DBG_ASSERT( nWhich1 <= nWhich2, "Ungueltiger Bereich" );
+ DBG_ASSERTWARNING( _pPool == _pPool->GetMasterPool(), "kein Master-Pool" );
+ DBG( _pChildCountCtor; *_pChildCount(this) = 0 );
+
+ InitRanges_Impl(nWhich1, nWhich2);
+}
+
+// -----------------------------------------------------------------------
+
+void SfxItemSet::InitRanges_Impl(USHORT nWh1, USHORT nWh2)
+{
+ DBG_CHKTHIS(SfxItemSet, 0);
+ _pWhichRanges = new USHORT[ 3 ];
+ *(_pWhichRanges+0) = nWh1;
+ *(_pWhichRanges+1) = nWh2;
+ *(_pWhichRanges+2) = 0;
+ const USHORT nRg = nWh2 - nWh1 + 1;
+ _aItems = new const SfxPoolItem* [ nRg ];
+ memset( (void*) _aItems, 0, nRg * sizeof( SfxPoolItem* ) );
+}
+
+//------------------------------------------------------------------------
+
+USHORT InitializeRanges_Impl( USHORT *&rpRanges, va_list pArgs,
+ USHORT nWh1, USHORT nWh2, USHORT nNull )
+
+/** <H3>Description</H3>
+
+ Creates an USHORT-ranges-array in 'rpRanges' using 'nWh1' and 'nWh2' as
+ first range, 'nNull' as terminator or start of 2nd range and 'pArgs' as
+ remaider.
+
+ It returns the number of USHORTs which are contained in the described
+ set of USHORTs.
+*/
+
+{
+ USHORT nSize = 0, nIns = 0;
+ USHORT nCnt = 0;
+ SvUShorts aNumArr( 11, 8 );
+ aNumArr.Insert( nWh1, nCnt++ );
+ aNumArr.Insert( nWh2, nCnt++ );
+ DBG_ASSERT( nWh1 <= nWh2, "Ungueltiger Bereich" );
+ nSize += nWh2 - nWh1 + 1;
+ aNumArr.Insert( nNull, nCnt++ );
+ while ( 0 !=
+ ( nIns =
+ sal::static_int_cast< USHORT >(
+ va_arg( pArgs, USHORT_ARG ) ) ) )
+ {
+ aNumArr.Insert( nIns, nCnt++ );
+ if ( 0 == (nCnt & 1) ) // 4,6,8, usw.
+ {
+ DBG_ASSERT( aNumArr[ nCnt-2 ] <= nIns, "Ungueltiger Bereich" );
+ nSize += nIns - aNumArr[ nCnt-2 ] + 1;
+ }
+ }
+ va_end( pArgs );
+
+ DBG_ASSERT( 0 == (nCnt & 1), "ungerade Anzahl von Which-Paaren!" );
+
+ // so, jetzt sind alle Bereiche vorhanden und
+ rpRanges = new USHORT[ nCnt+1 ];
+ memcpy( rpRanges, aNumArr.GetData(), sizeof(USHORT) * nCnt );
+ *(rpRanges+nCnt) = 0;
+
+ return nSize;
+}
+
+// -----------------------------------------------------------------------
+
+void SfxItemSet::InitRanges_Impl(va_list pArgs, USHORT nWh1, USHORT nWh2, USHORT nNull)
+{
+ DBG_CHKTHIS(SfxItemSet, 0);
+
+ USHORT nSize = InitializeRanges_Impl( _pWhichRanges, pArgs, nWh1, nWh2, nNull );
+ _aItems = new const SfxPoolItem* [ nSize ];
+ memset( (void*) _aItems, 0, sizeof( SfxPoolItem* ) * nSize );
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemSet::SfxItemSet( SfxItemPool& rPool,
+ USHORT_ARG nWh1, USHORT_ARG nWh2, USHORT_ARG nNull, ... ):
+ _pPool( &rPool ),
+ _pParent( 0 ),
+ _pWhichRanges( 0 ),
+ _nCount( 0 )
+{
+ DBG_CTOR(SfxItemSet, DbgCheckItemSet);
+ DBG_ASSERT( nWh1 <= nWh2, "Ungueltiger Bereich" );
+ DBG_ASSERTWARNING( _pPool == _pPool->GetMasterPool(), "kein Master-Pool" );
+ DBG( _pChildCountCtor; *_pChildCount(this) = 0 );
+
+ if(!nNull)
+ InitRanges_Impl(
+ sal::static_int_cast< USHORT >(nWh1),
+ sal::static_int_cast< USHORT >(nWh2));
+ else {
+ va_list pArgs;
+ va_start( pArgs, nNull );
+ InitRanges_Impl(
+ pArgs, sal::static_int_cast< USHORT >(nWh1),
+ sal::static_int_cast< USHORT >(nWh2),
+ sal::static_int_cast< USHORT >(nNull));
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SfxItemSet::InitRanges_Impl(const USHORT *pWhichPairTable)
+{
+ DBG_CHKTHIS(SfxItemSet, 0);
+ DBG_TRACE1("SfxItemSet: Ranges-CopyCount==%ul", ++nRangesCopyCount);
+
+ USHORT nCnt = 0;
+ const USHORT* pPtr = pWhichPairTable;
+ while( *pPtr )
+ {
+ nCnt += ( *(pPtr+1) - *pPtr ) + 1;
+ pPtr += 2;
+ }
+
+ _aItems = new const SfxPoolItem* [ nCnt ];
+ memset( (void*) _aItems, 0, sizeof( SfxPoolItem* ) * nCnt );
+
+ std::ptrdiff_t cnt = pPtr - pWhichPairTable +1;
+ _pWhichRanges = new USHORT[ cnt ];
+ memcpy( _pWhichRanges, pWhichPairTable, sizeof( USHORT ) * cnt );
+}
+
+
+// -----------------------------------------------------------------------
+
+SfxItemSet::SfxItemSet( SfxItemPool& rPool, const USHORT* pWhichPairTable ):
+ _pPool( &rPool ),
+ _pParent( 0 ),
+ _pWhichRanges(0),
+ _nCount( 0 )
+{
+ DBG_CTOR(SfxItemSet, 0);
+ DBG_ASSERTWARNING( _pPool == _pPool->GetMasterPool(), "kein Master-Pool" );
+ DBG( _pChildCountCtor; *_pChildCount(this) = 0 );
+
+ // pWhichPairTable == 0 ist f"ur das SfxAllEnumItemSet
+ if ( pWhichPairTable )
+ InitRanges_Impl(pWhichPairTable);
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemSet::SfxItemSet( const SfxItemSet& rASet ):
+ _pPool( rASet._pPool ),
+ _pParent( rASet._pParent ),
+ _nCount( rASet._nCount )
+{
+ DBG_CTOR(SfxItemSet, DbgCheckItemSet);
+ DBG_ASSERTWARNING( _pPool == _pPool->GetMasterPool(), "kein Master-Pool" );
+ DBG( _pChildCountCtor; *_pChildCount(this) = 0 );
+ DBG( ++*_pChildCount(_pParent) );
+
+ // errechne die Anzahl von Attributen
+ USHORT nCnt = 0;
+ USHORT* pPtr = rASet._pWhichRanges;
+ while( *pPtr )
+ {
+ nCnt += ( *(pPtr+1) - *pPtr ) + 1;
+ pPtr += 2;
+ }
+
+ _aItems = new const SfxPoolItem* [ nCnt ];
+
+ // Attribute kopieren
+ SfxItemArray ppDst = _aItems, ppSrc = rASet._aItems;
+ for( USHORT n = nCnt; n; --n, ++ppDst, ++ppSrc )
+ if ( 0 == *ppSrc || // aktueller Default?
+ IsInvalidItem(*ppSrc) || // Dont Care?
+ IsStaticDefaultItem(*ppSrc) ) // nicht zu poolende Defaults
+ // einfach Pointer kopieren
+ *ppDst = *ppSrc;
+ else if ( _pPool->IsItemFlag( **ppSrc, SFX_ITEM_POOLABLE ) )
+ {
+ // einfach Pointer kopieren und Ref-Count erh"ohen
+ *ppDst = *ppSrc;
+ ( (SfxPoolItem*) (*ppDst) )->AddRef();
+ }
+ else if ( !(*ppSrc)->Which() )
+ *ppDst = (*ppSrc)->Clone();
+ else
+ // !IsPoolable() => via Pool zuweisen
+ *ppDst = &_pPool->Put( **ppSrc );
+
+ // dann noch die Which Ranges kopieren
+ DBG_TRACE1("SfxItemSet: Ranges-CopyCount==%ul", ++nRangesCopyCount);
+ std::ptrdiff_t cnt = pPtr - rASet._pWhichRanges+1;
+ _pWhichRanges = new USHORT[ cnt ];
+ memcpy( _pWhichRanges, rASet._pWhichRanges, sizeof( USHORT ) * cnt);
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemSet::~SfxItemSet()
+{
+ DBG_DTOR(SfxItemSet, DbgCheckItemSet);
+#ifdef DBG_UTIL
+ DBG( DBG_ASSERT( 0 == *_pChildCount(this), "SfxItemSet: deleting parent-itemset" ) )
+#endif
+
+ USHORT nCount = TotalCount();
+ if( Count() )
+ {
+ SfxItemArray ppFnd = _aItems;
+ for( USHORT nCnt = nCount; nCnt; --nCnt, ++ppFnd )
+ if( *ppFnd && !IsInvalidItem(*ppFnd) )
+ {
+ if( !(*ppFnd)->Which() )
+ delete (SfxPoolItem*) *ppFnd;
+ else {
+ // noch mehrer Referenzen vorhanden, also nur den
+ // ReferenzCounter manipulieren
+ if ( 1 < (*ppFnd)->GetRefCount() && !IsDefaultItem(*ppFnd) )
+ (*ppFnd)->ReleaseRef();
+ else
+ if ( !IsDefaultItem(*ppFnd) )
+ // aus dem Pool loeschen
+ _pPool->Remove( **ppFnd );
+ }
+ }
+ }
+
+ // FIXME: could be delete[] (SfxPoolItem **)_aItems;
+ delete[] _aItems;
+ if ( _pWhichRanges != _pPool->GetFrozenIdRanges() )
+ delete[] _pWhichRanges;
+ _pWhichRanges = 0; // for invariant-testing
+
+ DBG( --*_pChildCount(_pParent) );
+ DBG( delete _pChildCount(this); _pChildCountDtor );
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SfxItemSet::ClearItem( USHORT nWhich )
+
+// einzelnes Item oder alle Items (nWhich==0) l"oschen
+
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ if( !Count() )
+ return 0;
+
+ USHORT nDel = 0;
+ SfxItemArray ppFnd = _aItems;
+
+ if( nWhich )
+ {
+ const USHORT* pPtr = _pWhichRanges;
+ while( *pPtr )
+ {
+ // in diesem Bereich?
+ if( *pPtr <= nWhich && nWhich <= *(pPtr+1) )
+ {
+ // "uberhaupt gesetzt?
+ ppFnd += nWhich - *pPtr;
+ if( *ppFnd )
+ {
+ // wegen der Assertions ins Sub-Calls mu\s das hier sein
+ --_nCount;
+ const SfxPoolItem *pItemToClear = *ppFnd;
+ *ppFnd = 0;
+
+ if ( !IsInvalidItem(pItemToClear) )
+ {
+ if ( nWhich <= SFX_WHICH_MAX )
+ {
+ const SfxPoolItem& rNew = _pParent
+ ? _pParent->Get( nWhich, TRUE )
+ : _pPool->GetDefaultItem( nWhich );
+
+ Changed( *pItemToClear, rNew );
+ }
+ if ( pItemToClear->Which() )
+ _pPool->Remove( *pItemToClear );
+ }
+ ++nDel;
+ }
+
+ // gefunden => raus
+ break;
+ }
+ ppFnd += *(pPtr+1) - *pPtr + 1;
+ pPtr += 2;
+ }
+ }
+ else
+ {
+ nDel = _nCount;
+
+ USHORT* pPtr = _pWhichRanges;
+ while( *pPtr )
+ {
+ for( nWhich = *pPtr; nWhich <= *(pPtr+1); ++nWhich, ++ppFnd )
+ if( *ppFnd )
+ {
+ // wegen der Assertions ins Sub-Calls mu\s das hier sein
+ --_nCount;
+ const SfxPoolItem *pItemToClear = *ppFnd;
+ *ppFnd = 0;
+
+ if ( !IsInvalidItem(pItemToClear) )
+ {
+ if ( nWhich <= SFX_WHICH_MAX )
+ {
+ const SfxPoolItem& rNew = _pParent
+ ? _pParent->Get( nWhich, TRUE )
+ : _pPool->GetDefaultItem( nWhich );
+
+ Changed( *pItemToClear, rNew );
+ }
+
+ // #i32448#
+ // Take care of disabled items, too.
+ if(!pItemToClear->nWhich)
+ {
+ // item is disabled, delete it
+ delete pItemToClear;
+ }
+ else
+ {
+ // remove item from pool
+ _pPool->Remove( *pItemToClear );
+ }
+ }
+ }
+ pPtr += 2;
+ }
+ }
+ return nDel;
+}
+
+// -----------------------------------------------------------------------
+
+void SfxItemSet::ClearInvalidItems( BOOL bHardDefault )
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ USHORT* pPtr = _pWhichRanges;
+ SfxItemArray ppFnd = _aItems;
+ if ( bHardDefault )
+ while( *pPtr )
+ {
+ for ( USHORT nWhich = *pPtr; nWhich <= *(pPtr+1); ++nWhich, ++ppFnd )
+ if ( IsInvalidItem(*ppFnd) )
+ *ppFnd = &_pPool->Put( _pPool->GetDefaultItem(nWhich) );
+ pPtr += 2;
+ }
+ else
+ while( *pPtr )
+ {
+ for( USHORT nWhich = *pPtr; nWhich <= *(pPtr+1); ++nWhich, ++ppFnd )
+ if( IsInvalidItem(*ppFnd) )
+ {
+ *ppFnd = 0;
+ --_nCount;
+ }
+ pPtr += 2;
+ }
+}
+
+//------------------------------------------------------------------------
+
+
+void SfxItemSet::InvalidateAllItems()
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ DBG_ASSERT( !_nCount, "Es sind noch Items gesetzt" );
+
+ memset( (void*)_aItems, -1, ( _nCount = TotalCount() ) * sizeof( SfxPoolItem*) );
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemState SfxItemSet::GetItemState( USHORT nWhich,
+ BOOL bSrchInParent,
+ const SfxPoolItem **ppItem ) const
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ // suche den Bereich in dem das Which steht:
+ const SfxItemSet* pAktSet = this;
+ SfxItemState eRet = SFX_ITEM_UNKNOWN;
+ do
+ {
+ SfxItemArray ppFnd = pAktSet->_aItems;
+ const USHORT* pPtr = pAktSet->_pWhichRanges;
+ if (pPtr)
+ {
+ while ( *pPtr )
+ {
+ if ( *pPtr <= nWhich && nWhich <= *(pPtr+1) )
+ {
+ // in diesem Bereich
+ ppFnd += nWhich - *pPtr;
+ if ( !*ppFnd )
+ {
+ eRet = SFX_ITEM_DEFAULT;
+ if( !bSrchInParent )
+ return eRet; // nicht vorhanden
+ break; // JP: in den Parents weitersuchen !!!
+ }
+
+ if ( (SfxPoolItem*) -1 == *ppFnd )
+ // Unterschiedlich vorhanden
+ return SFX_ITEM_DONTCARE;
+
+ if ( (*ppFnd)->IsA(TYPE(SfxVoidItem)) )
+ return SFX_ITEM_DISABLED;
+
+ if (ppItem)
+ {
+ #ifdef DBG_UTIL
+ const SfxPoolItem *pItem = *ppFnd;
+ DBG_ASSERT( !pItem->ISA(SfxSetItem) ||
+ 0 != &((const SfxSetItem*)pItem)->GetItemSet(),
+ "SetItem without ItemSet" );
+ #endif
+ *ppItem = *ppFnd;
+ }
+ return SFX_ITEM_SET;
+ }
+ ppFnd += *(pPtr+1) - *pPtr + 1;
+ pPtr += 2;
+ }
+ }
+ } while( bSrchInParent && 0 != ( pAktSet = pAktSet->_pParent ));
+ return eRet;
+}
+
+// -----------------------------------------------------------------------
+
+const SfxPoolItem* SfxItemSet::Put( const SfxPoolItem& rItem, USHORT nWhich )
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ DBG_ASSERT( !rItem.ISA(SfxSetItem) ||
+ 0 != &((const SfxSetItem&)rItem).GetItemSet(),
+ "SetItem without ItemSet" );
+ if ( !nWhich )
+ return 0; //! nur wegen Outliner-Bug
+ SfxItemArray ppFnd = _aItems;
+ const USHORT* pPtr = _pWhichRanges;
+ while( *pPtr )
+ {
+ if( *pPtr <= nWhich && nWhich <= *(pPtr+1) )
+ {
+ // in diesem Bereich
+ ppFnd += nWhich - *pPtr;
+ if( *ppFnd ) // schon einer vorhanden
+ {
+ // selbes Item bereits vorhanden?
+ if ( *ppFnd == &rItem )
+ return 0;
+
+ // wird dontcare oder disabled mit was echtem ueberschrieben?
+ if ( rItem.Which() && ( IsInvalidItem(*ppFnd) || !(*ppFnd)->Which() ) )
+ {
+ *ppFnd = &_pPool->Put( rItem, nWhich );
+ return *ppFnd;
+ }
+
+ // wird disabled?
+ if( !rItem.Which() )
+ {
+ *ppFnd = rItem.Clone(_pPool);
+ return 0;
+ }
+ else
+ {
+ // selber Wert bereits vorhanden?
+ if ( rItem == **ppFnd )
+ return 0;
+
+ // den neuen eintragen, den alten austragen
+ const SfxPoolItem& rNew = _pPool->Put( rItem, nWhich );
+ const SfxPoolItem* pOld = *ppFnd;
+ *ppFnd = &rNew;
+ if(nWhich <= SFX_WHICH_MAX)
+ Changed( *pOld, rNew );
+ _pPool->Remove( *pOld );
+ }
+ }
+ else
+ {
+ ++_nCount;
+ if( !rItem.Which() )
+ *ppFnd = rItem.Clone(_pPool);
+ else {
+ const SfxPoolItem& rNew = _pPool->Put( rItem, nWhich );
+ *ppFnd = &rNew;
+ if (nWhich <= SFX_WHICH_MAX )
+ {
+ const SfxPoolItem& rOld = _pParent
+ ? _pParent->Get( nWhich, TRUE )
+ : _pPool->GetDefaultItem( nWhich );
+ Changed( rOld, rNew );
+ }
+ }
+ }
+ SFX_ASSERT( !_pPool->IsItemFlag(nWhich, SFX_ITEM_POOLABLE) ||
+ rItem.ISA(SfxSetItem) || **ppFnd == rItem,
+ nWhich, "putted Item unequal" );
+ return *ppFnd;
+ }
+ ppFnd += *(pPtr+1) - *pPtr + 1;
+ pPtr += 2;
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+int SfxItemSet::Put( const SfxItemSet& rSet, BOOL bInvalidAsDefault )
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ BOOL bRet = FALSE;
+ if( rSet.Count() )
+ {
+ SfxItemArray ppFnd = rSet._aItems;
+ const USHORT* pPtr = rSet._pWhichRanges;
+ while ( *pPtr )
+ {
+ for ( USHORT nWhich = *pPtr; nWhich <= *(pPtr+1); ++nWhich, ++ppFnd )
+ if( *ppFnd )
+ {
+ if ( IsInvalidItem( *ppFnd ) )
+ {
+ if ( bInvalidAsDefault )
+ bRet |= 0 != ClearItem( nWhich );
+ // gab GPF bei non.WIDs:
+ // bRet |= 0 != Put( rSet.GetPool()->GetDefaultItem(nWhich), nWhich );
+ else
+ InvalidateItem( nWhich );
+ }
+ else
+ bRet |= 0 != Put( **ppFnd, nWhich );
+ }
+ pPtr += 2;
+ }
+ }
+ return bRet;
+}
+
+// -----------------------------------------------------------------------
+
+void SfxItemSet::PutExtended
+(
+ const SfxItemSet& rSet, // Quelle der zu puttenden Items
+ SfxItemState eDontCareAs, // was mit DontCare-Items passiert
+ SfxItemState eDefaultAs // was mit Default-Items passiert
+)
+
+/* [Beschreibung]
+
+ Diese Methode "ubernimmt die Items aus 'rSet' in '*this'. Die
+ Which-Bereiche in '*this', die in 'rSet' nicht vorkommen bleiben unver-
+ "andert. Der Which-Bereich von '*this' bleibt auch unver"andert.
+
+ In 'rSet' gesetzte Items werden auch in '*this*' gesetzt. Default-
+ (0 Pointer) und Invalid- (-1 Pointer) Items werden je nach Parameter
+ ('eDontCareAs' und 'eDefaultAs' behandelt:
+
+ SFX_ITEM_SET: hart auf Default des Pools gesetzt
+ SFX_ITEM_DEFAULT: gel"oscht (0 Pointer)
+ SFX_ITEM_DONTCARE: invalidiert (-1 Pointer)
+
+ Alle anderen Werte f"ur 'eDontCareAs' und 'eDefaultAs' sind ung"ultig.
+*/
+
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+
+ // don't "optimize" with "if( rSet.Count()" because of dont-care + defaults
+ SfxItemArray ppFnd = rSet._aItems;
+ const USHORT* pPtr = rSet._pWhichRanges;
+ while ( *pPtr )
+ {
+ for ( USHORT nWhich = *pPtr; nWhich <= *(pPtr+1); ++nWhich, ++ppFnd )
+ if( *ppFnd )
+ {
+ if ( IsInvalidItem( *ppFnd ) )
+ {
+ // Item ist DontCare:
+ switch ( eDontCareAs )
+ {
+ case SFX_ITEM_SET:
+ Put( rSet.GetPool()->GetDefaultItem(nWhich), nWhich );
+ break;
+
+ case SFX_ITEM_DEFAULT:
+ ClearItem( nWhich );
+ break;
+
+ case SFX_ITEM_DONTCARE:
+ InvalidateItem( nWhich );
+ break;
+
+ default:
+ DBG_ERROR( "invalid Argument for eDontCareAs" );
+ }
+ }
+ else
+ // Item ist gesetzt:
+ Put( **ppFnd, nWhich );
+ }
+ else
+ {
+ // Item ist Default:
+ switch ( eDefaultAs )
+ {
+ case SFX_ITEM_SET:
+ Put( rSet.GetPool()->GetDefaultItem(nWhich), nWhich );
+ break;
+
+ case SFX_ITEM_DEFAULT:
+ ClearItem( nWhich );
+ break;
+
+ case SFX_ITEM_DONTCARE:
+ InvalidateItem( nWhich );
+ break;
+
+ default:
+ DBG_ERROR( "invalid Argument for eDefaultAs" );
+ }
+ }
+ pPtr += 2;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+int SfxItemSet::Set
+(
+ const SfxItemSet& rSet, /* das SfxItemSet, dessen SfxPoolItems
+ "ubernommen werden sollen */
+
+ BOOL bDeep /* TRUE (default)
+ auch die SfxPoolItems aus den ggf. an
+ rSet vorhandenen Parents werden direkt
+ in das SfxItemSet "ubernommen
+
+ FALSE
+ die SfxPoolItems aus den Parents von
+ rSet werden nicht ber"ucksichtigt */
+)
+
+/* [Beschreibung]
+
+ Das SfxItemSet nimmt genau die SfxPoolItems an, die auch in
+ rSet gesetzt sind und im eigenen <Which-Bereich> liegen. Alle
+ anderen werden entfernt. Der SfxItemPool wird dabei beibehalten,
+ so da"s die "ubernommenen SfxPoolItems dabei ggf. vom SfxItemPool
+ von rSet in den SfxItemPool von *this "ubernommen werden.
+
+ SfxPoolItems, f"ur die in rSet IsInvalidItem() == TRUE gilt,
+ werden als Invalid-Item "ubernommen.
+
+
+ [R"uckgabewert]
+
+ int TRUE
+ es wurden SfxPoolItems "ubernommen
+
+ FALSE
+ es wurden keine SfxPoolItems "ubernommen,
+ da z.B. die Which-Bereiche der SfxItemSets
+ keine Schnittmenge haben oder in der
+ Schnittmenge keine SfxPoolItems in rSet
+ gesetzt sind
+
+*/
+
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ int bRet = FALSE;
+ if ( _nCount )
+ ClearItem();
+ if ( bDeep )
+ {
+ SfxWhichIter aIter(*this);
+ USHORT nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rSet.GetItemState( nWhich, TRUE, &pItem ) )
+ bRet |= 0 != Put( *pItem, pItem->Which() );
+ nWhich = aIter.NextWhich();
+ }
+ }
+ else
+ bRet = Put(rSet, FALSE);
+
+ return bRet;
+}
+
+//------------------------------------------------------------------------
+
+const SfxPoolItem* SfxItemSet::GetItem
+(
+ USHORT nId, // Slot-Id oder Which-Id des Items
+ BOOL bSrchInParent, // TRUE: auch in Parent-ItemSets suchen
+ TypeId aItemType // != 0 => RTTI Pruefung mit Assertion
+) const
+
+/* [Beschreibung]
+
+ Mit dieser Methode wird der Zugriff auf einzelne Items im
+ SfxItemSet wesentlich vereinfacht. Insbesondere wird die Typpr"ufung
+ (per Assertion) durchgef"uhrt, wodurch die Applikations-Sourcen
+ wesentlich "ubersichtlicher werden. In der PRODUCT-Version wird
+ eine 0 zur"uckgegeben, wenn das gefundene Item nicht von der
+ angegebenen Klasse ist. Ist kein Item mit der Id 'nWhich' in dem ItemSet,
+ so wird 0 zurueckgegeben.
+*/
+
+{
+ // ggf. in Which-Id umrechnen
+ USHORT nWhich = GetPool()->GetWhich(nId);
+
+ // ist das Item gesetzt oder bei bDeep==TRUE verf"ugbar?
+ const SfxPoolItem *pItem = 0;
+ SfxItemState eState = GetItemState( nWhich, bSrchInParent, &pItem );
+ if ( bSrchInParent && SFX_ITEM_AVAILABLE == eState &&
+ nWhich <= SFX_WHICH_MAX )
+ pItem = &_pPool->GetDefaultItem(nWhich);
+ if ( pItem )
+ {
+ // stimmt der Typ "uberein?
+ if ( !aItemType || pItem->IsA(aItemType) )
+ return pItem;
+
+ // sonst Fehler melden
+ DBG_ERROR( "invalid argument type" );
+ }
+
+ // kein Item gefunden oder falschen Typ gefunden
+ return 0;
+}
+
+
+//------------------------------------------------------------------------
+
+
+const SfxPoolItem& SfxItemSet::Get( USHORT nWhich, BOOL bSrchInParent) const
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ // suche den Bereich in dem das Which steht:
+ const SfxItemSet* pAktSet = this;
+ do
+ {
+ if( pAktSet->Count() )
+ {
+ SfxItemArray ppFnd = pAktSet->_aItems;
+ const USHORT* pPtr = pAktSet->_pWhichRanges;
+ while( *pPtr )
+ {
+ if( *pPtr <= nWhich && nWhich <= *(pPtr+1) )
+ {
+ // in diesem Bereich
+ ppFnd += nWhich - *pPtr;
+ if( *ppFnd )
+ {
+ if( (SfxPoolItem*)-1 == *ppFnd ) {
+ //?MI: folgender code ist Doppelt (unten)
+ SFX_ASSERT(_pPool, nWhich, "kein Pool, aber Status uneindeutig");
+ //!((SfxAllItemSet *)this)->aDefault.SetWhich(nWhich);
+ //!return aDefault;
+ return _pPool->GetDefaultItem( nWhich );
+ }
+#ifdef DBG_UTIL
+ const SfxPoolItem *pItem = *ppFnd;
+ DBG_ASSERT( !pItem->ISA(SfxSetItem) ||
+ 0 != &((const SfxSetItem*)pItem)->GetItemSet(),
+ "SetItem without ItemSet" );
+ if ( pItem->ISA(SfxVoidItem) || !pItem->Which() )
+ DBG_WARNING( "SFX_WARNING: Getting disabled Item" );
+#endif
+ return **ppFnd;
+ }
+ break; // dann beim Parent suchen
+ }
+ ppFnd += *(pPtr+1) - *pPtr + 1;
+ pPtr += 2;
+ }
+ }
+// bis zum Ende vom Such-Bereich: was nun ? zum Parent, oder Default ??
+// if( !*pPtr ) // bis zum Ende vom Such-Bereich ?
+// break;
+ } while( bSrchInParent && 0 != ( pAktSet = pAktSet->_pParent ));
+
+ // dann das Default vom Pool holen und returnen
+ SFX_ASSERT(_pPool, nWhich, "kein Pool, aber Status uneindeutig");
+ const SfxPoolItem *pItem = &_pPool->GetDefaultItem( nWhich );
+ DBG_ASSERT( !pItem->ISA(SfxSetItem) ||
+ 0 != &((const SfxSetItem*)pItem)->GetItemSet(),
+ "SetItem without ItemSet" );
+ return *pItem;
+}
+
+ // Notification-Callback
+// -----------------------------------------------------------------------
+
+void SfxItemSet::Changed( const SfxPoolItem&, const SfxPoolItem& )
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SfxItemSet::TotalCount() const
+{
+ DBG_CHKTHIS(SfxItemSet, 0); // wird im Ctor benutzt bevor vollst. init.
+ USHORT nRet = 0;
+ USHORT* pPtr = _pWhichRanges;
+ while( *pPtr )
+ {
+ nRet += ( *(pPtr+1) - *pPtr ) + 1;
+ pPtr += 2;
+ }
+ return nRet;
+}
+// -----------------------------------------------------------------------
+
+// behalte nur die Items, die auch in rSet enthalten sein (Wert egal)
+
+void SfxItemSet::Intersect( const SfxItemSet& rSet )
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ DBG_ASSERT(_pPool, "nicht implementiert ohne Pool");
+ if( !Count() ) // gar keine gesetzt ?
+ return;
+
+ // loesche alle Items, die im rSet nicht mehr vorhanden sind
+ if( !rSet.Count() )
+ {
+ ClearItem(); // alles loeschen
+ return;
+ }
+
+ // teste mal, ob sich die Which-Bereiche unterscheiden.
+ BOOL bEqual = TRUE;
+ USHORT* pWh1 = _pWhichRanges;
+ USHORT* pWh2 = rSet._pWhichRanges;
+ USHORT nSize = 0;
+
+ for( USHORT n = 0; *pWh1 && *pWh2; ++pWh1, ++pWh2, ++n )
+ {
+ if( *pWh1 != *pWh2 )
+ {
+ bEqual = FALSE;
+ break;
+ }
+ if( n & 1 )
+ nSize += ( *(pWh1) - *(pWh1-1) ) + 1;
+ }
+ bEqual = *pWh1 == *pWh2; // auch die 0 abpruefen
+
+ // sind die Bereiche identisch, ist es einfacher zu handhaben !
+ if( bEqual )
+ {
+ SfxItemArray ppFnd1 = _aItems;
+ SfxItemArray ppFnd2 = rSet._aItems;
+
+ for( ; nSize; --nSize, ++ppFnd1, ++ppFnd2 )
+ if( *ppFnd1 && !*ppFnd2 )
+ {
+ // aus dem Pool loeschen
+ if( !IsInvalidItem( *ppFnd1 ) )
+ {
+ USHORT nWhich = (*ppFnd1)->Which();
+ if(nWhich <= SFX_WHICH_MAX)
+ {
+ const SfxPoolItem& rNew = _pParent
+ ? _pParent->Get( nWhich, TRUE )
+ : _pPool->GetDefaultItem( nWhich );
+
+ Changed( **ppFnd1, rNew );
+ }
+ _pPool->Remove( **ppFnd1 );
+ }
+ *ppFnd1 = 0;
+ --_nCount;
+ }
+ }
+ else
+ {
+ SfxItemIter aIter( *this );
+ const SfxPoolItem* pItem = aIter.GetCurItem();
+ while( TRUE )
+ {
+ USHORT nWhich = IsInvalidItem( pItem )
+ ? GetWhichByPos( aIter.GetCurPos() )
+ : pItem->Which();
+ if( 0 == rSet.GetItemState( nWhich, FALSE ) )
+ ClearItem( nWhich ); // loeschen
+ if( aIter.IsAtEnd() )
+ break;
+ pItem = aIter.NextItem();
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SfxItemSet::Differentiate( const SfxItemSet& rSet )
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ if( !Count() || !rSet.Count() ) // gar keine gesetzt ?
+ return;
+
+ // teste mal, ob sich die Which-Bereiche unterscheiden.
+ BOOL bEqual = TRUE;
+ USHORT* pWh1 = _pWhichRanges;
+ USHORT* pWh2 = rSet._pWhichRanges;
+ USHORT nSize = 0;
+
+ for( USHORT n = 0; *pWh1 && *pWh2; ++pWh1, ++pWh2, ++n )
+ {
+ if( *pWh1 != *pWh2 )
+ {
+ bEqual = FALSE;
+ break;
+ }
+ if( n & 1 )
+ nSize += ( *(pWh1) - *(pWh1-1) ) + 1;
+ }
+ bEqual = *pWh1 == *pWh2; // auch die 0 abpruefen
+
+ // sind die Bereiche identisch, ist es einfacher zu handhaben !
+ if( bEqual )
+ {
+ SfxItemArray ppFnd1 = _aItems;
+ SfxItemArray ppFnd2 = rSet._aItems;
+
+ for( ; nSize; --nSize, ++ppFnd1, ++ppFnd2 )
+ if( *ppFnd1 && *ppFnd2 )
+ {
+ // aus dem Pool loeschen
+ if( !IsInvalidItem( *ppFnd1 ) )
+ {
+ USHORT nWhich = (*ppFnd1)->Which();
+ if(nWhich <= SFX_WHICH_MAX)
+ {
+ const SfxPoolItem& rNew = _pParent
+ ? _pParent->Get( nWhich, TRUE )
+ : _pPool->GetDefaultItem( nWhich );
+
+ Changed( **ppFnd1, rNew );
+ }
+ _pPool->Remove( **ppFnd1 );
+ }
+ *ppFnd1 = 0;
+ --_nCount;
+ }
+ }
+ else
+ {
+ SfxItemIter aIter( *this );
+ const SfxPoolItem* pItem = aIter.GetCurItem();
+ while( TRUE )
+ {
+ USHORT nWhich = IsInvalidItem( pItem )
+ ? GetWhichByPos( aIter.GetCurPos() )
+ : pItem->Which();
+ if( SFX_ITEM_SET == rSet.GetItemState( nWhich, FALSE ) )
+ ClearItem( nWhich ); // loeschen
+ if( aIter.IsAtEnd() )
+ break;
+ pItem = aIter.NextItem();
+ }
+
+ }
+}
+
+// -----------------------------------------------------------------------
+/* Entscheidungstabelle fuer MergeValue[s]
+
+Grundsaetze:
+ 1. Ist der Which-Wert im 1.Set "unknown", dann folgt niemals eine Aktion.
+ 2. Ist der Which-Wert im 2.Set "unknown", dann gilt er als "default".
+ 3. Es gelten fuer Vergleiche die Werte der "default"-Items.
+
+1.-Item 2.-Item Values bIgnoreDefs Remove Assign Add
+
+set set == FALSE - - -
+default set == FALSE - - -
+dontcare set == FALSE - - -
+unknown set == FALSE - - -
+set default == FALSE - - -
+default default == FALSE - - -
+dontcare default == FALSE - - -
+unknown default == FALSE - - -
+set dontcare == FALSE 1.-Item -1 -
+default dontcare == FALSE - -1 -
+dontcare dontcare == FALSE - - -
+unknown dontcare == FALSE - - -
+set unknown == FALSE 1.-Item -1 -
+default unknown == FALSE - - -
+dontcare unknown == FALSE - - -
+unknown unknown == FALSE - - -
+
+set set != FALSE 1.-Item -1 -
+default set != FALSE - -1 -
+dontcare set != FALSE - - -
+unknown set != FALSE - - -
+set default != FALSE 1.-Item -1 -
+default default != FALSE - - -
+dontcare default != FALSE - - -
+unknown default != FALSE - - -
+set dontcare != FALSE 1.-Item -1 -
+default dontcare != FALSE - -1 -
+dontcare dontcare != FALSE - - -
+unknown dontcare != FALSE - - -
+set unknown != FALSE 1.-Item -1 -
+default unknown != FALSE - - -
+dontcare unknown != FALSE - - -
+unknown unknown != FALSE - - -
+
+set set == TRUE - - -
+default set == TRUE - 2.-Item 2.-Item
+dontcare set == TRUE - - -
+unknown set == TRUE - - -
+set default == TRUE - - -
+default default == TRUE - - -
+dontcare default == TRUE - - -
+unknown default == TRUE - - -
+set dontcare == TRUE - - -
+default dontcare == TRUE - -1 -
+dontcare dontcare == TRUE - - -
+unknown dontcare == TRUE - - -
+set unknown == TRUE - - -
+default unknown == TRUE - - -
+dontcare unknown == TRUE - - -
+unknown unknown == TRUE - - -
+
+set set != TRUE 1.-Item -1 -
+default set != TRUE - 2.-Item 2.-Item
+dontcare set != TRUE - - -
+unknown set != TRUE - - -
+set default != TRUE - - -
+default default != TRUE - - -
+dontcare default != TRUE - - -
+unknown default != TRUE - - -
+set dontcare != TRUE 1.-Item -1 -
+default dontcare != TRUE - -1 -
+dontcare dontcare != TRUE - - -
+unknown dontcare != TRUE - - -
+set unknown != TRUE - - -
+default unknown != TRUE - - -
+dontcare unknown != TRUE - - -
+unknown unknown != TRUE - - -
+*/
+
+
+static void MergeItem_Impl( SfxItemPool *_pPool, USHORT &rCount,
+ const SfxPoolItem **ppFnd1, const SfxPoolItem *pFnd2,
+ BOOL bIgnoreDefaults )
+{
+ DBG_ASSERT( ppFnd1 != 0, "Merging to 0-Item" );
+
+ // 1. Item ist default?
+ if ( !*ppFnd1 )
+ {
+ if ( IsInvalidItem(pFnd2) )
+ // Entscheidungstabelle: default, dontcare, egal, egal
+ *ppFnd1 = (SfxPoolItem*) -1;
+
+ else if ( pFnd2 && !bIgnoreDefaults &&
+ _pPool->GetDefaultItem(pFnd2->Which()) != *pFnd2 )
+ // Entscheidungstabelle: default, set, !=, FALSE
+ *ppFnd1 = (SfxPoolItem*) -1;
+
+ else if ( pFnd2 && bIgnoreDefaults )
+ // Entscheidungstabelle: default, set, egal, TRUE
+ *ppFnd1 = &_pPool->Put( *pFnd2 );
+
+ if ( *ppFnd1 )
+ ++rCount;
+ }
+
+ // 1. Item ist gesetzt?
+ else if ( !IsInvalidItem(*ppFnd1) )
+ {
+ if ( !pFnd2 )
+ {
+ // 2. Item ist default
+ if ( !bIgnoreDefaults &&
+ **ppFnd1 != _pPool->GetDefaultItem((*ppFnd1)->Which()) )
+ {
+ // Entscheidungstabelle: set, default, !=, FALSE
+ _pPool->Remove( **ppFnd1 );
+ *ppFnd1 = (SfxPoolItem*) -1;
+ }
+ }
+ else if ( IsInvalidItem(pFnd2) )
+ {
+ // 2. Item ist dontcare
+ if ( !bIgnoreDefaults ||
+ **ppFnd1 != _pPool->GetDefaultItem( (*ppFnd1)->Which()) )
+ {
+ // Entscheidungstabelle: set, dontcare, egal, FALSE
+ // oder: set, dontcare, !=, TRUE
+ _pPool->Remove( **ppFnd1 );
+ *ppFnd1 = (SfxPoolItem*) -1;
+ }
+ }
+ else
+ {
+ // 2. Item ist gesetzt
+ if ( **ppFnd1 != *pFnd2 )
+ {
+ // Entscheidungstabelle: set, set, !=, egal
+ _pPool->Remove( **ppFnd1 );
+ *ppFnd1 = (SfxPoolItem*) -1;
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SfxItemSet::MergeValues( const SfxItemSet& rSet, BOOL bIgnoreDefaults )
+{
+ // Achtung!!! Bei Aenderungen/Bugfixes immer obenstehende Tabelle pflegen!
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ DBG_ASSERT( GetPool() == rSet.GetPool(), "MergeValues mit verschiedenen Pools" );
+
+ // teste mal, ob sich die Which-Bereiche unterscheiden.
+ BOOL bEqual = TRUE;
+ USHORT* pWh1 = _pWhichRanges;
+ USHORT* pWh2 = rSet._pWhichRanges;
+ USHORT nSize = 0;
+
+ for( USHORT n = 0; *pWh1 && *pWh2; ++pWh1, ++pWh2, ++n )
+ {
+ if( *pWh1 != *pWh2 )
+ {
+ bEqual = FALSE;
+ break;
+ }
+ if( n & 1 )
+ nSize += ( *(pWh1) - *(pWh1-1) ) + 1;
+ }
+ bEqual = *pWh1 == *pWh2; // auch die 0 abpruefen
+
+ // sind die Bereiche identisch, ist es effizieter zu handhaben !
+ if( bEqual )
+ {
+ SfxItemArray ppFnd1 = _aItems;
+ SfxItemArray ppFnd2 = rSet._aItems;
+
+ for( ; nSize; --nSize, ++ppFnd1, ++ppFnd2 )
+ MergeItem_Impl( _pPool, _nCount, ppFnd1, *ppFnd2, bIgnoreDefaults );
+ }
+ else
+ {
+ SfxWhichIter aIter( rSet );
+ register USHORT nWhich;
+ while( 0 != ( nWhich = aIter.NextWhich() ) )
+ {
+ const SfxPoolItem* pItem = 0;
+ rSet.GetItemState( nWhich, TRUE, &pItem );
+ if( !pItem )
+ {
+ // nicht gesetzt, also default
+ if ( !bIgnoreDefaults )
+ MergeValue( rSet.GetPool()->GetDefaultItem( nWhich ), bIgnoreDefaults );
+ }
+ else if( IsInvalidItem( pItem ) )
+ // dont care
+ InvalidateItem( nWhich );
+ else
+ MergeValue( *pItem, bIgnoreDefaults );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SfxItemSet::MergeValue( const SfxPoolItem& rAttr, BOOL bIgnoreDefaults )
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ SfxItemArray ppFnd = _aItems;
+ const USHORT* pPtr = _pWhichRanges;
+ const USHORT nWhich = rAttr.Which();
+ while( *pPtr )
+ {
+ // in diesem Bereich?
+ if( *pPtr <= nWhich && nWhich <= *(pPtr+1) )
+ {
+ ppFnd += nWhich - *pPtr;
+ MergeItem_Impl( _pPool, _nCount, ppFnd, &rAttr, bIgnoreDefaults );
+ break;
+ }
+ ppFnd += *(pPtr+1) - *pPtr + 1;
+ pPtr += 2;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SfxItemSet::InvalidateItem( USHORT nWhich )
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ SfxItemArray ppFnd = _aItems;
+ const USHORT* pPtr = _pWhichRanges;
+ while( *pPtr )
+ {
+ if( *pPtr <= nWhich && nWhich <= *(pPtr+1) )
+ {
+ // in diesem Bereich
+ ppFnd += nWhich - *pPtr;
+
+ if( *ppFnd ) // bei mir gesetzt
+ {
+ if( (SfxPoolItem*)-1 != *ppFnd ) // noch nicht dontcare !
+ {
+ _pPool->Remove( **ppFnd );
+ *ppFnd = (SfxPoolItem*)-1;
+ }
+ }
+ else
+ {
+ *ppFnd = (SfxPoolItem*)-1;
+ ++_nCount;
+ }
+ break;
+ }
+ ppFnd += *(pPtr+1) - *pPtr + 1;
+ pPtr += 2;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SfxItemSet::GetWhichByPos( USHORT nPos ) const
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ USHORT n = 0;
+ USHORT* pPtr = _pWhichRanges;
+ while( *pPtr )
+ {
+ n = ( *(pPtr+1) - *pPtr ) + 1;
+ if( nPos < n )
+ return *(pPtr)+nPos;
+ nPos = nPos - n;
+ pPtr += 2;
+ }
+ DBG_ASSERT( FALSE, "Hier sind wir falsch" );
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+SvStream &SfxItemSet::Store
+(
+ SvStream& rStream, // Zielstream f"ur normale Items
+ FASTBOOL bDirect // TRUE: Items direkt speicher, FALSE: Surrogate
+) const
+
+/* [Beschreibung]
+
+ Speichert die <SfxItemSet>-Instanz in den angegebenen Stream. Dabei
+ werden die Surrorage der gesetzten <SfxPoolItem>s bzw. ('bDirect==TRUE')
+ die gesetzten Items selbst wie folgt im Stream abgelegt:
+
+ USHORT (Count) Anzahl der gesetzten Items
+ Count* _pPool->StoreItem() siehe <SfxItemPool::StoreItem()const>
+
+
+ [Querverweise]
+
+ <SfxItemSet::Load(SvStream&,BOOL,const SfxItemPool*)>
+*/
+
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ DBG_ASSERT( _pPool, "Kein Pool" );
+ DBG_ASSERTWARNING( _pPool == _pPool->GetMasterPool(), "kein Master-Pool" );
+
+ // Position des Counts merken, um ggf. zu korrigieren
+ ULONG nCountPos = rStream.Tell();
+ rStream << _nCount;
+
+ // wenn nichts zu speichern ist, auch keinen ItemIter aufsetzen!
+ if ( _nCount )
+ {
+ // mitz"ahlen wieviel Items tats"achlich gespeichert werden
+ USHORT nWrittenCount = 0; // Anzahl in 'rStream' gestreamter Items
+
+ // "uber alle gesetzten Items iterieren
+ SfxItemIter aIter(*this);
+ for ( const SfxPoolItem *pItem = aIter.FirstItem();
+ pItem;
+ pItem = aIter.NextItem() )
+ {
+ // Item (ggf. als Surrogat) via Pool speichern lassen
+ DBG_ASSERT( !IsInvalidItem(pItem), "can't store invalid items" );
+ if ( !IsInvalidItem(pItem) &&
+ _pPool->StoreItem( rStream, *pItem, bDirect ) )
+ // Item wurde in 'rStream' gestreamt
+ ++nWrittenCount;
+ };
+
+ // weniger geschrieben als enthalten (z.B. altes Format)
+ if ( nWrittenCount != _nCount )
+ {
+ // tats"achlichen Count im Stream ablegen
+ ULONG nPos = rStream.Tell();
+ rStream.Seek( nCountPos );
+ rStream << nWrittenCount;
+ rStream.Seek( nPos );
+ }
+ }
+
+ return rStream;
+}
+
+// -----------------------------------------------------------------------
+
+SvStream &SfxItemSet::Load
+(
+ SvStream& rStream, // Stream, aus dem geladen werden soll
+
+ FASTBOOL bDirect, /* TRUE
+ Items werden direkt aus dem Stream
+ gelesen, nicht "uber Surrogate
+
+ FALSE (default)
+ Items werden "uber Surrogate gelesen */
+
+ const SfxItemPool* pRefPool /* Pool, der die Surrogate aufl"osen kann
+ (z.B. zum Einf"ugen von Dokumenten) */
+)
+
+/* [Beschreibung]
+
+ Diese Methode l"adt ein <SfxItemSet> aus einem Stream. Falls der
+ <SfxItemPool> ohne Ref-Counts geladen wurde, werden die geladenen
+ Item-Referenzen in den Items hochgez"ahlt, ansonsten wird vorausgesetzt,
+ da\s sie schon beim Laden des SfxItemPools ber"ucksichtigt waren.
+
+ [Querverweise]
+
+ <SfxItemSet::Store(Stream&,BOOL)const>
+*/
+
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ DBG_ASSERT( _pPool, "Kein Pool");
+ DBG_ASSERTWARNING( _pPool == _pPool->GetMasterPool(), "Kein Master-Pool");
+
+ // kein Ref-Pool => Surrogate mit Pool des ItemSets aufl"osen
+ if ( !pRefPool )
+ pRefPool = _pPool;
+
+ // Anzahl der zu ladenden Items laden und dann ebensoviele Items
+ USHORT nCount = 0;
+ rStream >> nCount;
+ for ( USHORT i = 0; i < nCount; ++i )
+ {
+ // Surrogat/Item laden und (Surrogat) aufl"osen lassen
+ const SfxPoolItem *pItem =
+ _pPool->LoadItem( rStream, bDirect, pRefPool );
+
+ // konnte ein Item geladen oder via Surrogat aufgel"ost werden?
+ if ( pItem )
+ {
+ // Position f"ur Item-Pointer im Set suchen
+ USHORT nWhich = pItem->Which();
+ SfxItemArray ppFnd = _aItems;
+ const USHORT* pPtr = _pWhichRanges;
+ while ( *pPtr )
+ {
+ // in diesem Bereich?
+ if ( *pPtr <= nWhich && nWhich <= *(pPtr+1) )
+ {
+ // Item-Pointer im Set merken
+ ppFnd += nWhich - *pPtr;
+ SFX_ASSERT( !*ppFnd, nWhich, "Item doppelt eingetragen");
+ *ppFnd = pItem;
+ ++_nCount;
+ break;
+ }
+
+ // im Range-Array und Item-Array zum n"achsten Which-Range
+ ppFnd += *(pPtr+1) - *pPtr + 1;
+ pPtr += 2;
+ }
+ }
+ }
+
+ return rStream;
+}
+
+// -----------------------------------------------------------------------
+
+int SfxItemSet::operator==(const SfxItemSet &rCmp) const
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ DBG_CHKOBJ(&rCmp, SfxItemSet, DbgCheckItemSet);
+
+ // besonders schnell zu ermittelnde Werte muessen gleich sein
+ if ( _pParent != rCmp._pParent ||
+ _pPool != rCmp._pPool ||
+ Count() != rCmp.Count() )
+ return FALSE;
+
+ // Ranges durchzaehlen lassen dauert laenger, muss aber auch gleich sein
+ USHORT nCount1 = TotalCount();
+ USHORT nCount2 = rCmp.TotalCount();
+ if ( nCount1 != nCount2 )
+ return FALSE;
+
+ // sind die Ranges selbst ungleich?
+ for ( USHORT nRange = 0; _pWhichRanges[nRange]; nRange += 2 )
+ if ( _pWhichRanges[nRange] != rCmp._pWhichRanges[nRange] ||
+ _pWhichRanges[nRange+1] != rCmp._pWhichRanges[nRange+1] )
+ {
+ // dann m"ussen wir die langsame Methode verwenden
+ SfxWhichIter aIter( *this );
+ for ( USHORT nWh = aIter.FirstWhich();
+ nWh;
+ nWh = aIter.NextWhich() )
+ {
+ // wenn die Pointer von poolable Items ungleich sind,
+ // muessen die Items gleich sein
+ const SfxPoolItem *pItem1 = 0, *pItem2 = 0;
+ if ( GetItemState( nWh, FALSE, &pItem1 ) !=
+ rCmp.GetItemState( nWh, FALSE, &pItem2 ) ||
+ ( pItem1 != pItem2 &&
+ ( !pItem1 || IsInvalidItem(pItem1) ||
+ ( _pPool->IsItemFlag(*pItem1, SFX_ITEM_POOLABLE) &&
+ *pItem1 != *pItem2 ) ) ) )
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ // Pointer alle gleich?
+ if ( 0 == memcmp( _aItems, rCmp._aItems, nCount1 * sizeof(_aItems[0]) ) )
+ return TRUE;
+
+ // dann werden wir wohl alle einzeln vergleichen muessen
+ const SfxPoolItem **ppItem1 = (const SfxPoolItem**) _aItems;
+ const SfxPoolItem **ppItem2 = (const SfxPoolItem**) rCmp._aItems;
+ for ( USHORT nPos = 0; nPos < nCount1; ++nPos )
+ {
+ // wenn die Pointer von poolable Items ungleich sind,
+ // muessen die Items gleich sein
+ if ( *ppItem1 != *ppItem2 &&
+ ( ( !*ppItem1 || !*ppItem2 ) ||
+ ( IsInvalidItem(*ppItem1) || IsInvalidItem(*ppItem2) ) ||
+ ( _pPool->IsItemFlag(**ppItem1, SFX_ITEM_POOLABLE) ) ||
+ **ppItem1 != **ppItem2 ) )
+ return FALSE;
+
+ ++ppItem1;
+ ++ppItem2;
+ }
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemSet *SfxItemSet::Clone(BOOL bItems, SfxItemPool *pToPool ) const
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ if ( pToPool && pToPool != _pPool )
+ {
+ SfxItemSet *pNewSet = new SfxItemSet( *pToPool, _pWhichRanges );
+ if ( bItems )
+ {
+ SfxWhichIter aIter(*pNewSet);
+ USHORT nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ const SfxPoolItem* pItem;
+ if ( SFX_ITEM_SET == GetItemState( nWhich, FALSE, &pItem ) )
+ pNewSet->Put( *pItem, pItem->Which() );
+ nWhich = aIter.NextWhich();
+ }
+ }
+ return pNewSet;
+ }
+ else
+ return bItems
+ ? new SfxItemSet(*this)
+ : new SfxItemSet(*_pPool, _pWhichRanges);
+}
+
+// -----------------------------------------------------------------------
+
+int SfxItemSet::PutDirect(const SfxPoolItem &rItem)
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ SfxItemArray ppFnd = _aItems;
+ const USHORT* pPtr = _pWhichRanges;
+ const USHORT nWhich = rItem.Which();
+#ifdef DBG_UTIL
+ IsPoolDefaultItem(&rItem) || _pPool->GetSurrogate(&rItem);
+ // nur Assertion in den callees provozieren
+#endif
+ while( *pPtr )
+ {
+ if( *pPtr <= nWhich && nWhich <= *(pPtr+1) )
+ {
+ // in diesem Bereich
+ ppFnd += nWhich - *pPtr;
+ const SfxPoolItem* pOld = *ppFnd;
+ if( pOld ) // schon einer vorhanden
+ {
+ if( rItem == **ppFnd )
+ return FALSE; // schon vorhanden !
+ _pPool->Remove( *pOld );
+ }
+ else
+ ++_nCount;
+
+ // den neuen eintragen
+ if( IsPoolDefaultItem(&rItem) )
+ *ppFnd = &_pPool->Put( rItem );
+ else
+ {
+ *ppFnd = &rItem;
+ if( !IsStaticDefaultItem( &rItem ) )
+ rItem.AddRef();
+ }
+
+ return TRUE;
+ }
+ ppFnd += *(pPtr+1) - *pPtr + 1;
+ pPtr += 2;
+ }
+ return FALSE;
+}
+
+// -----------------------------------------------------------------------
+
+SfxAllItemSet::SfxAllItemSet( SfxItemPool &rPool )
+: SfxItemSet(rPool, (const USHORT*) 0),
+ aDefault(0),
+ nFree(nInitCount)
+{
+ // initial keine Items
+ _aItems = 0;
+
+ // nInitCount Paare an USHORTs fuer Ranges allozieren
+ _pWhichRanges = new USHORT[ nInitCount + 1 ];
+ memset( _pWhichRanges, 0, ( nInitCount + 1 ) * sizeof(USHORT) );
+}
+
+
+// -----------------------------------------------------------------------
+
+
+SfxAllItemSet::SfxAllItemSet(const SfxItemSet &rCopy)
+: SfxItemSet(rCopy),
+ aDefault(0),
+ nFree(0)
+{
+}
+
+// -----------------------------------------------------------------------
+
+
+
+SfxAllItemSet::SfxAllItemSet(const SfxAllItemSet &rCopy)
+: SfxItemSet(rCopy),
+ aDefault(0),
+ nFree(0)
+/* [Anmerkung]
+
+ Der mu\s sein, da sonst vom Compiler einer generiert wird, er nimmt
+ nicht den Ctor mit der 'const SfxItemSet&'!
+*/
+{
+}
+
+// -----------------------------------------------------------------------
+
+static USHORT *AddRanges_Impl(
+ USHORT *pUS, std::ptrdiff_t nOldSize, USHORT nIncr)
+
+/* Diese interne Funktion erzeugt ein neues Which-Range-Array, welches von
+ dem 'nOldSize'-USHORTs langen 'pUS' kopiert wird und hinten an Platz
+ f"ur 'nIncr' neue USHORTs hat. Das terminierende USHORT mit der '0'
+ wird weder in 'nOldSize' noch in 'nIncr' mitgez"ahlt, sondern implizit
+ hinzugerechnet.
+
+ Das neue Which-Range-Array wird als Returnwert zur"uckgegeben, das alte
+ 'pUS' freigegeben.
+*/
+
+{
+ // neues Which-Range-Array anlegen
+ USHORT *pNew = new USHORT[ nOldSize + nIncr + 1 ];
+
+ // die alten Ranges "ubernehmen
+ memcpy( pNew, pUS, nOldSize * sizeof(USHORT) );
+
+ // die neuen auf 0 initialisieren
+ memset( pNew + nOldSize, 0, ( nIncr + 1 ) * sizeof(USHORT) );
+
+ // das alte Array freigeben
+ delete[] pUS;
+
+ return pNew;
+}
+
+// -----------------------------------------------------------------------
+
+static SfxItemArray AddItem_Impl(SfxItemArray pItems, USHORT nOldSize, USHORT nPos)
+
+/* Diese interne Funktion erzeugt ein neues ItemArray, welches von 'pItems'
+ kopiert wird, an der Position 'nPos' jedoch Platz f"ur einen neuen
+ ItemPointer hat.
+
+ Das neue ItemArray wird als Returnwert zur"uckgegeben, das alte 'pItems'
+ wird freigegeben.
+*/
+
+{
+ // neues ItemArray anlegen
+ SfxItemArray pNew = new const SfxPoolItem*[nOldSize+1];
+
+ // war schon vorher eins da?
+ if ( pItems )
+ {
+ // alte Items vor nPos kopieren
+ if ( nPos )
+ memcpy( (void*) pNew, pItems, nPos * sizeof(SfxPoolItem **) );
+
+ // alte Items hinter nPos kopieren
+ if ( nPos < nOldSize )
+ memcpy( (void*) (pNew + nPos + 1), pItems + nPos,
+ (nOldSize-nPos) * sizeof(SfxPoolItem **) );
+ }
+
+ // neues Item initialisieren
+ *(pNew + nPos) = 0;
+
+ // altes ItemArray freigeben
+ delete[] pItems;
+
+ return pNew;
+}
+
+// -----------------------------------------------------------------------
+
+const SfxPoolItem* SfxAllItemSet::Put( const SfxPoolItem& rItem, USHORT nWhich )
+
+// Putten mit automatischer Erweiterung der Whichs-Ids um die ID
+// des Items.
+
+{
+ USHORT nPos = 0; // Position f"ur 'rItem' in '_aItems'
+ const USHORT nItemCount = TotalCount();
+
+ // erstmal sehen, ob es schon einen passenden Bereich gibt
+ USHORT *pPtr = _pWhichRanges;
+ while ( *pPtr )
+ {
+ // Which-Id liegt in diesem Bereich?
+ if( *pPtr <= nWhich && nWhich <= *(pPtr+1) )
+ {
+ // Einfuegen
+ nPos += nWhich - *pPtr;
+ break;
+ }
+
+ // Position des Items in _aItems mitf"uhren
+ nPos += *(pPtr+1) - *pPtr + 1;
+
+ // zum n"achsten Bereich
+ pPtr += 2;
+ }
+
+ // Which-Id noch nicht vorhanden?
+ if ( !*pPtr )
+ {
+ // suchen, ob man sie irgendwo dranpacken kann
+ pPtr = _pWhichRanges;
+ nPos = 0;
+ while ( *pPtr )
+ {
+ // Which-Id liegt exakt vor diesem Bereich?
+ if ( (nWhich+1) == *pPtr )
+ {
+ // Bereich waechst nach unten
+ (*pPtr)--;
+
+ // vor erstem Item dieses Bereichs Platz schaffen
+ _aItems = AddItem_Impl(_aItems, nItemCount, nPos);
+ break;
+ }
+
+ // Which-Id liegt exakt hinter diesem Bereich?
+ else if ( (nWhich-1) == *(pPtr+1) )
+ {
+ // Bereich waechst nach oben
+ (*(pPtr+1))++;
+
+ // hinter letztem Item dieses Bereichs Platz schaffen
+ nPos += nWhich - *pPtr;
+ _aItems = AddItem_Impl(_aItems, nItemCount, nPos);
+ break;
+ }
+
+ // Position des Items in _aItems mitf"uhren
+ nPos += *(pPtr+1) - *pPtr + 1;
+
+ // zum n"achsten Bereich
+ pPtr += 2;
+ }
+ }
+
+ // keinen erweiterbaren Bereich gefunden?
+ if ( !*pPtr )
+ {
+ // kein Platz mehr in _pWhichRanges => erweitern
+ std::ptrdiff_t nSize = pPtr - _pWhichRanges;
+ if( !nFree )
+ {
+ _pWhichRanges = AddRanges_Impl(_pWhichRanges, nSize, nInitCount);
+ nFree += nInitCount;
+ }
+
+ // neuen Which-Range anh"angen
+ pPtr = _pWhichRanges + nSize;
+ *pPtr++ = nWhich;
+ *pPtr = nWhich;
+ nFree -= 2;
+
+ // Itemarray vergroessern
+ nPos = nItemCount;
+ _aItems = AddItem_Impl(_aItems, nItemCount, nPos);
+ }
+
+ // neues Item in Pool aufnehmen
+ const SfxPoolItem& rNew = _pPool->Put( rItem, nWhich );
+
+ // altes Item merken
+ BOOL bIncrementCount = FALSE;
+ const SfxPoolItem* pOld = *( _aItems + nPos );
+ if ( reinterpret_cast< SfxPoolItem* >( -1 ) == pOld ) // state "dontcare"
+ pOld = NULL;
+ if ( !pOld )
+ {
+ bIncrementCount = TRUE;
+ pOld = _pParent ?
+ &_pParent->Get( nWhich, TRUE )
+ : nWhich <= SFX_WHICH_MAX ? &_pPool->GetDefaultItem( nWhich ) : 0;
+ }
+
+ // neue Item in ItemSet aufnehmen
+ *(_aItems + nPos) = &rNew;
+
+ // Changed Notification versenden
+ if ( pOld )
+ {
+ Changed( *pOld, rNew );
+ if ( !IsDefaultItem(pOld) )
+ _pPool->Remove( *pOld );
+ }
+
+ if ( bIncrementCount )
+ ++_nCount;
+
+ return &rNew;
+}
+
+// -----------------------------------------------------------------------
+
+
+/* Diese Methode wird forwarded, damit sie nicht durch die anderen
+ Put-Methoden dieser SubClass gehided wird.
+*/
+
+int SfxAllItemSet::Put( const SfxItemSet& rSet, BOOL bInvalidAsDefault )
+{
+ //? pruefen, ob Which-Ranges erweitert werden
+ return SfxItemSet::Put( rSet, bInvalidAsDefault );
+}
+
+// -----------------------------------------------------------------------
+// Item disablen, wenn durch ein VoidItem mit dem Which-Wert 0 ausgedrueckt
+
+void SfxItemSet::DisableItem(USHORT nWhich)
+{
+ DBG_CHKTHIS(SfxItemSet, 0);
+ Put( SfxVoidItem(0), nWhich );
+}
+
+// -----------------------------------------------------------------------
+
+#if 0
+BOOL SfxAllItemSet::Remove(USHORT nWhich)
+{
+ DBG_CHKTHIS(SfxAllItemSet, 0);
+ USHORT *pPtr = _pWhichRanges;
+ USHORT nPos = 0;
+ while( *pPtr )
+ {
+ if( *pPtr <= nWhich && nWhich <= *(pPtr+1) )
+ {
+ USHORT *pTmp = pPtr;
+ USHORT nLeft = 0;
+ USHORT nRest = 0;
+ while(*++pTmp){
+ if( nLeft & 1 )
+ nRest = *pTmp - *(pTmp-1) + 1;
+ ++nLeft;
+ }
+
+ // in diesem Bereich
+ nPos += nWhich - *pPtr;
+ nRest -= nWhich - *pPtr;
+ // 3,3
+ if(*pPtr == nWhich && *(pPtr+1) == nWhich) {
+ memmove(pPtr, pPtr + 2, nLeft * sizeof(USHORT));
+ nFree += 2;
+ }
+ // Anfang
+ else if(*pPtr == nWhich)
+ (*pPtr)++;
+ // Ende
+ else if(*(pPtr+1) == nWhich)
+ (*(pPtr+1))--;
+ else {
+ if(nPos + nRest + 2 > nFree) {
+ USHORT nOf = pPtr - _pWhichRanges;
+ _pWhichRanges = IncrSize(_pWhichRanges, nPos + nRest, nInitCount);
+ nFree += nInitCount;
+ pPtr = _pWhichRanges + nOf;
+ }
+ memmove(pPtr +2, pPtr, (nLeft+2) * sizeof(USHORT));
+ *++pPtr = nWhich-1;
+ *++pPtr = nWhich+1;
+ nFree -= 2;
+ }
+ SfxPoolItem* pItem = *( _aItems + nPos );
+ if( pItem )
+ {
+ if(_pPool)
+ _pPool->Remove(*pItem );
+ else
+ delete pItem;
+ --_nCount;
+ }
+ memmove(_aItems + nPos +1, _aItems + nPos,
+ sizeof(SfxPoolItem *) * (nRest - 1));
+ break; // dann beim Parent suchen
+ }
+ nPos += *(pPtr+1) - *pPtr + 1;
+ pPtr += 2;
+ }
+ return *pPtr? TRUE: FALSE;
+}
+#endif
+
+// -----------------------------------------------------------------------
+
+SfxItemSet *SfxAllItemSet::Clone(BOOL bItems, SfxItemPool *pToPool ) const
+{
+ DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+ if ( pToPool && pToPool != _pPool )
+ {
+ SfxAllItemSet *pNewSet = new SfxAllItemSet( *pToPool );
+ if ( bItems )
+ pNewSet->Set( *this );
+ return pNewSet;
+ }
+ else
+ return bItems ? new SfxAllItemSet(*this) : new SfxAllItemSet(*_pPool);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_lckbitem.cxx b/binfilter/bf_svtools/source/items1/svt_lckbitem.cxx
new file mode 100644
index 000000000000..d46b6fdf4c97
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_lckbitem.cxx
@@ -0,0 +1,193 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+#define _LCKBITEM_CXX
+#include <bf_svtools/lckbitem.hxx>
+
+#include <bf_svtools/poolitem.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <tools/cachestr.hxx>
+
+// STATIC DATA -----------------------------------------------------------
+
+namespace binfilter
+{
+
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1_AUTOFACTORY(SfxLockBytesItem, SfxPoolItem);
+
+// -----------------------------------------------------------------------
+
+SfxLockBytesItem::SfxLockBytesItem()
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxLockBytesItem::SfxLockBytesItem( USHORT nW, SvStream &rStream )
+: SfxPoolItem( nW )
+{
+ rStream.Seek( 0L );
+ _xVal = new SvLockBytes( new SvCacheStream(), TRUE );
+
+ SvStream aLockBytesStream( _xVal );
+ rStream >> aLockBytesStream;
+}
+
+// -----------------------------------------------------------------------
+
+SfxLockBytesItem::SfxLockBytesItem( const SfxLockBytesItem& rItem )
+: SfxPoolItem( rItem ),
+ _xVal( rItem._xVal )
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxLockBytesItem::~SfxLockBytesItem()
+{
+}
+
+// -----------------------------------------------------------------------
+
+int SfxLockBytesItem::operator==( const SfxPoolItem& rItem ) const
+{
+ return ((SfxLockBytesItem&)rItem)._xVal == _xVal;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxLockBytesItem::Clone(SfxItemPool *) const
+{
+ return new SfxLockBytesItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+#define MAX_BUF 32000
+
+SfxPoolItem* SfxLockBytesItem::Create( SvStream &rStream, USHORT ) const
+{
+ sal_uInt32 nSize = 0;
+ ULONG nActRead = 0;
+ sal_Char cTmpBuf[MAX_BUF];
+ SvMemoryStream aNewStream;
+ rStream >> nSize;
+
+ do {
+ ULONG nToRead;
+ if( (nSize - nActRead) > MAX_BUF )
+ nToRead = MAX_BUF;
+ else
+ nToRead = nSize - nActRead;
+ nActRead += rStream.Read( cTmpBuf, nToRead );
+ aNewStream.Write( cTmpBuf, nToRead );
+ } while( nSize > nActRead );
+
+ return new SfxLockBytesItem( Which(), aNewStream );
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SfxLockBytesItem::Store(SvStream &rStream, USHORT ) const
+{
+ SvStream aLockBytesStream( _xVal );
+ sal_uInt32 nSize = aLockBytesStream.Seek( STREAM_SEEK_TO_END );
+ aLockBytesStream.Seek( 0L );
+
+ rStream << nSize;
+ rStream << aLockBytesStream;
+
+ return rStream;
+}
+
+//----------------------------------------------------------------------------
+// virtual
+bool SfxLockBytesItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE )
+{
+ com::sun::star::uno::Sequence< sal_Int8 > aSeq;
+ if ( rVal >>= aSeq )
+ {
+ if ( aSeq.getLength() )
+ {
+ SvCacheStream* pStream = new SvCacheStream;
+ pStream->Write( (void*)aSeq.getConstArray(), aSeq.getLength() );
+ pStream->Seek(0);
+
+ _xVal = new SvLockBytes( pStream, TRUE );
+ }
+ else
+ _xVal = NULL;
+
+ return true;
+ }
+
+ DBG_ERROR( "SfxLockBytesItem::PutValue - Wrong type!" );
+ return false;
+}
+
+//----------------------------------------------------------------------------
+// virtual
+bool SfxLockBytesItem::QueryValue( com::sun::star::uno::Any& rVal,BYTE ) const
+{
+ if ( _xVal.Is() )
+ {
+ sal_uInt32 nLen;
+ SvLockBytesStat aStat;
+
+ if ( _xVal->Stat( &aStat, SVSTATFLAG_DEFAULT ) == ERRCODE_NONE )
+ nLen = aStat.nSize;
+ else
+ return false;
+
+ ULONG nRead = 0;
+ com::sun::star::uno::Sequence< sal_Int8 > aSeq( nLen );
+
+ _xVal->ReadAt( 0, aSeq.getArray(), nLen, &nRead );
+ rVal <<= aSeq;
+ }
+ else
+ {
+ com::sun::star::uno::Sequence< sal_Int8 > aSeq( 0 );
+ rVal <<= aSeq;
+ }
+
+ return true;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_nranges.cxx b/binfilter/bf_svtools/source/items1/svt_nranges.cxx
new file mode 100644
index 000000000000..f9c3a8e74f21
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_nranges.cxx
@@ -0,0 +1,682 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+// compiled via include from itemset.cxx only!
+
+//========================================================================
+
+#ifdef DBG_UTIL
+
+#define DBG_CHECK_RANGES(NUMTYPE, pArr) \
+ for ( const NUMTYPE *pRange = pArr; *pRange; pRange += 2 ) \
+ { \
+ DBG_ASSERT( pRange[0] <= pRange[1], "ranges must be sorted" ); \
+ DBG_ASSERT( !pRange[2] || ( pRange[2] - pRange[1] ) > 1, \
+ "ranges must be sorted and discrete" ); \
+ }
+
+#else
+
+#define DBG_CHECK_RANGES(NUMTYPE,pArr)
+
+#endif
+
+//============================================================================
+inline void Swap_Impl(const NUMTYPE *& rp1, const NUMTYPE *& rp2)
+{
+ const NUMTYPE * pTemp = rp1;
+ rp1 = rp2;
+ rp2 = pTemp;
+}
+
+//========================================================================
+
+NUMTYPE Count_Impl( const NUMTYPE *pRanges )
+
+/** <H3>Description</H3>
+
+ Determines the number of NUMTYPEs in an 0-terminated array of pairs of
+ NUMTYPEs. The terminating 0 is not included in the count.
+*/
+
+{
+ NUMTYPE nCount = 0;
+ while ( *pRanges )
+ {
+ nCount += 2;
+ pRanges += 2;
+ }
+ return nCount;
+}
+
+//------------------------------------------------------------------------
+
+NUMTYPE Capacity_Impl( const NUMTYPE *pRanges )
+
+/** <H3>Description</H3>
+
+ Determines the total number of NUMTYPEs described in an 0-terminated
+ array of pairs of NUMTYPEs, each representing an range of NUMTYPEs.
+*/
+
+{
+ NUMTYPE nCount = 0;
+
+ if ( pRanges )
+ {
+ while ( *pRanges )
+ {
+ nCount += pRanges[1] - pRanges[0] + 1;
+ pRanges += 2;
+ }
+ }
+ return nCount;
+}
+
+//------------------------------------------------------------------------
+
+SfxNumRanges::SfxNumRanges( const SfxNumRanges &rOrig )
+
+/** <H3>Description</H3>
+
+ Copy-Ctor.
+*/
+
+{
+ if ( rOrig._pRanges )
+ {
+ NUMTYPE nCount = Count_Impl( rOrig._pRanges ) + 1;
+ _pRanges = new NUMTYPE[nCount];
+ memcpy( _pRanges, rOrig._pRanges, sizeof(NUMTYPE) * nCount );
+ }
+ else
+ _pRanges = 0;
+}
+
+//------------------------------------------------------------------------
+
+BOOL SfxNumRanges::operator==( const SfxNumRanges &rOther ) const
+{
+ // Object pointers equal?
+ if ( this == &rOther )
+ return TRUE;
+
+ // Ranges pointers equal?
+ if ( _pRanges == rOther._pRanges )
+ return TRUE;
+
+ // Counts equal?
+ NUMTYPE nCount = Count();
+ if ( nCount != rOther.Count() )
+ return FALSE;
+
+ // Check arrays.
+ NUMTYPE n = 0;
+ while( _pRanges[ n ] != 0 )
+ {
+ // Elements at current position equal?
+ if ( _pRanges[ n ] != rOther._pRanges[ n ] )
+ return FALSE;
+
+ ++n;
+ }
+
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+
+SfxNumRanges& SfxNumRanges::operator =
+(
+ const SfxNumRanges &rRanges
+)
+
+/** <H3>Description</H3>
+
+ Assigns ranges from 'rRanges' to '*this'.
+*/
+
+{
+ // special case: assign itself
+ if ( &rRanges == this )
+ return *this;
+
+ delete[] _pRanges;
+
+ // special case: 'rRanges' is empty
+ if ( rRanges.IsEmpty() )
+ _pRanges = 0;
+ else
+ {
+ // copy ranges
+ NUMTYPE nCount = Count_Impl( rRanges._pRanges ) + 1;
+ _pRanges = new NUMTYPE[ nCount ];
+ memcpy( _pRanges, rRanges._pRanges, sizeof(NUMTYPE) * nCount );
+ }
+ return *this;
+}
+
+//------------------------------------------------------------------------
+
+SfxNumRanges& SfxNumRanges::operator +=
+(
+ const SfxNumRanges &rRanges
+)
+
+/** <H3>Description</H3>
+
+ Merges *this with 'rRanges'.
+
+ for each NUMTYPE n:
+ this->Contains( n ) || rRanges.Contains( n ) => this'->Contains( n )
+ !this->Contains( n ) && !rRanges.Contains( n ) => !this'->Contains( n )
+*/
+
+{
+ // special cases: one is empty
+ if ( rRanges.IsEmpty() )
+ return *this;
+ if ( IsEmpty() )
+ return *this = rRanges;
+
+ // First, run thru _pRanges and rRanges._pRanges and determine the size of
+ // the new, merged ranges:
+ NUMTYPE nCount = 0;
+ const NUMTYPE * pRA = _pRanges;
+ const NUMTYPE * pRB = rRanges._pRanges;
+
+ for (;;)
+ {
+ // The first pair of pRA has a lower lower bound than the first pair
+ // of pRB:
+ if (pRA[0] > pRB[0])
+ Swap_Impl(pRA, pRB);
+
+ // We are done with the merging if at least pRA is exhausted:
+ if (!pRA[0])
+ break;
+
+ for (;;)
+ {
+ // Skip those pairs in pRB that completely lie in the first pair
+ // of pRA:
+ while (pRB[1] <= pRA[1])
+ {
+ pRB += 2;
+
+ // Watch out for exhaustion of pRB:
+ if (!pRB[0])
+ {
+ Swap_Impl(pRA, pRB);
+ goto count_rest;
+ }
+ }
+
+ // If the next pair of pRA does not at least touch the current new
+ // pair, we are done with the current new pair:
+ if (pRB[0] > pRA[1] + 1)
+ break;
+
+ // The next pair of pRB extends the current new pair; first,
+ // extend the current new pair (we are done if pRB is then
+ // exhausted); second, switch the roles of pRA and pRB in order to
+ // merge in those following pairs of the original pRA that will
+ // lie in the (now larger) current new pair or will even extend it
+ // further:
+ pRA += 2;
+ if (!pRA[0])
+ goto count_rest;
+ Swap_Impl(pRA, pRB);
+ }
+
+ // Done with the current new pair:
+ pRA += 2;
+ nCount += 2;
+ }
+
+ // Only pRB has more pairs available, pRA is already exhausted:
+count_rest:
+ for (; pRB[0]; pRB += 2)
+ nCount += 2;
+
+ // Now, create new ranges of the correct size and, on a second run thru
+ // _pRanges and rRanges._pRanges, copy the merged pairs into the new
+ // ranges:
+ NUMTYPE * pNew = new NUMTYPE[nCount + 1];
+ pRA = _pRanges;
+ pRB = rRanges._pRanges;
+ NUMTYPE * pRN = pNew;
+
+ for (;;)
+ {
+ // The first pair of pRA has a lower lower bound than the first pair
+ // of pRB:
+ if (pRA[0] > pRB[0])
+ Swap_Impl(pRA, pRB);
+
+ // We are done with the merging if at least pRA is exhausted:
+ if (!pRA[0])
+ break;
+
+ // Lower bound of current new pair is already known:
+ *pRN++ = pRA[0];
+
+ for (;;)
+ {
+ // Skip those pairs in pRB that completely lie in the first pair
+ // of pRA:
+ while (pRB[1] <= pRA[1])
+ {
+ pRB += 2;
+
+ // Watch out for exhaustion of pRB:
+ if (!pRB[0])
+ {
+ Swap_Impl(pRA, pRB);
+ ++pRB;
+ goto copy_rest;
+ }
+ }
+
+ // If the next pair of pRA does not at least touch the current new
+ // pair, we are done with the current new pair:
+ if (pRB[0] > pRA[1] + 1)
+ break;
+
+ // The next pair of pRB extends the current new pair; first,
+ // extend the current new pair (we are done if pRB is then
+ // exhausted); second, switch the roles of pRA and pRB in order to
+ // merge in those following pairs of the original pRA that will
+ // lie in the (now larger) current new pair or will even extend it
+ // further:
+ pRA += 2;
+ if (!pRA[0])
+ {
+ ++pRB;
+ goto copy_rest;
+ }
+ Swap_Impl(pRA, pRB);
+ }
+
+ // Done with the current new pair, now upper bound is also known:
+ *pRN++ = pRA[1];
+ pRA += 2;
+ }
+
+ // Only pRB has more pairs available (which are copied to the new ranges
+ // unchanged), pRA is already exhausted:
+copy_rest:
+ for (; *pRB;)
+ *pRN++ = *pRB++;
+ *pRN = 0;
+
+ delete[] _pRanges;
+ _pRanges = pNew;
+
+ return *this;
+}
+
+//------------------------------------------------------------------------
+
+SfxNumRanges& SfxNumRanges::operator -=
+(
+ const SfxNumRanges &rRanges
+)
+
+/** <H3>Description</H3>
+
+ Removes 'rRanges' from '*this'.
+
+ for each NUMTYPE n:
+ this->Contains( n ) && rRanges.Contains( n ) => !this'->Contains( n )
+ this->Contains( n ) && !rRanges.Contains( n ) => this'->Contains( n )
+ !this->Contains( n ) => !this'->Contains( n )
+*/
+
+{
+ // special cases: one is empty
+ if ( rRanges.IsEmpty() || IsEmpty() )
+ return *this;
+
+ // differentiate 'rRanges' in a temporary copy of '*this'
+ // (size is computed for maximal possibly split-count plus terminating 0)
+ NUMTYPE nThisSize = Count_Impl(_pRanges);
+ NUMTYPE nTargetSize = 1 + ( nThisSize + Count_Impl(rRanges._pRanges) );
+ NUMTYPE *pTarget = new NUMTYPE[ nTargetSize ];
+ memset( pTarget, 0, sizeof(NUMTYPE)*nTargetSize );
+ memcpy( pTarget, _pRanges, sizeof(NUMTYPE)*nThisSize );
+
+ NUMTYPE nPos1 = 0, nPos2 = 0, nTargetPos = 0;
+ while( _pRanges[ nPos1 ] )
+ {
+ NUMTYPE l1 = _pRanges[ nPos1 ]; // lower bound of interval 1
+ NUMTYPE u1 = _pRanges[ nPos1+1 ]; // upper bound of interval 1
+ NUMTYPE l2 = rRanges._pRanges[ nPos2 ]; // lower bound of interval 2
+ NUMTYPE u2 = rRanges._pRanges[ nPos2+1 ]; // upper bound of interval 2
+
+ // boundary cases
+ // * subtrahend is empty -> copy the minuend
+ if( !l2 )
+ {
+ pTarget[ nTargetPos ] = l1;
+ pTarget[ nTargetPos+1 ] = u1;
+ nTargetPos += 2;
+ nPos1 += 2;
+ continue;
+ }
+ // * next subtrahend interval is completely higher -> copy the minuend
+ if( u1 < l2 )
+ {
+ pTarget[ nTargetPos ] = l1;
+ pTarget[ nTargetPos+1 ] = u1;
+ nTargetPos += 2;
+ nPos1 += 2;
+ continue;
+ }
+
+ // * next subtrahend interval is completely lower -> try next
+ if( u2 < l1 )
+ {
+ nPos2 += 2;
+ continue;
+ }
+
+ // intersecting cases
+ // * subtrahend cuts out from the beginning of the minuend
+ if( l2 <= l1 && u2 <= u1 )
+ {
+ // reduce minuend interval, try again (minuend might be affected by other subtrahend intervals)
+ _pRanges[ nPos1 ] = u2 + 1;
+ nPos2 += 2; // this cannot hurt any longer
+ continue;
+ }
+
+ // * subtrahend cuts out from the end of the minuend
+ if( l1 <= l2 && u1 <= u2 )
+ {
+ // copy remaining part of minuend (cannot be affected by other intervals)
+ if( l1 < l2 ) // anything left at all?
+ {
+ pTarget[ nTargetPos ] = l1;
+ pTarget[ nTargetPos+1 ] = l2 - 1;
+ nTargetPos += 2;
+ // do not increment nPos2, might affect next minuend interval, too
+ }
+ nPos1 += 2; // nothing left at all
+ continue;
+ }
+
+ // * subtrahend completely deletes minuend (larger or same at both ends)
+ if( l1 >= l2 && u1 <= u2 )
+ {
+ nPos1 += 2; // minuend deleted
+ // do not increment nPos2, might affect next minuend interval, too
+ continue;
+ }
+
+ // * subtrahend divides minuend into two pieces
+ if( l1 <= l2 && u1 >= u2 ) // >= and <= since they may be something left only at one side
+ {
+ // left side
+ if( l1 < l2 ) // anything left at all
+ {
+ pTarget[ nTargetPos ] = l1;
+ pTarget[ nTargetPos+1 ] = l2 - 1;
+ nTargetPos += 2;
+ }
+
+ // right side
+ if( u1 > u2 ) // anything left at all
+ {
+ // reduce minuend interval, try again (minuend might be affected by other subtrahend itnervals )
+ _pRanges[ nPos1 ] = u2 + 1;
+ }
+
+ // subtrahend is completely used
+ nPos2 += 2;
+ continue;
+ }
+
+ // we should never be here
+ DBG_ERROR( "SfxNumRanges::operator-=: internal error" );
+ } // while
+
+ pTarget[ nTargetPos ] = 0;
+
+ // assign the differentiated ranges
+ delete[] _pRanges;
+
+ NUMTYPE nUShorts = Count_Impl(pTarget) + 1;
+ if ( 1 != nUShorts )
+ {
+ _pRanges = new NUMTYPE[ nUShorts ];
+ memcpy( _pRanges, pTarget, nUShorts * sizeof(NUMTYPE) );
+ }
+ else
+ _pRanges = 0;
+
+ delete [] pTarget;
+ return *this;
+
+ /* untested code from MI commented out (MDA, 28.01.97)
+ do
+ {
+ // 1st range is smaller than 2nd range?
+ if ( pRange1[1] < pRange2[0] )
+ // => keep 1st range
+ pRange1 += 2;
+
+ // 2nd range is smaller than 1st range?
+ else if ( pRange2[1] < pRange1[0] )
+ // => skip 2nd range
+ pRange2 += 2;
+
+ // 2nd range totally overlaps the 1st range?
+ else if ( pRange2[0] <= pRange1[0] && pRange2[1] >= pRange1[1] )
+ // => remove 1st range
+ memmove( pRange1, pRange1+2, sizeof(NUMTYPE) * (pEndOfTarget-pRange1+2) );
+
+ // 2nd range overlaps only the beginning of 1st range?
+ else if ( pRange2[0] <= pRange1[0] && pRange2[1] < pRange1[1] )
+ {
+ // => cut the beginning of 1st range and goto next 2nd range
+ pRange1[0] = pRange2[1] + 1;
+ pRange2 += 2;
+ }
+
+ // 2nd range overlaps only the end of 1st range?
+ else if ( pRange2[0] > pRange1[0] && pRange2[1] >= pRange1[0] )
+ // => cut the beginning of 1st range
+ pRange1[0] = pRange2[1]+1;
+
+ // 2nd range is a real subset of 1st range
+ else
+ {
+ // => split 1st range and goto next 2nd range
+ memmove( pRange1+3, pRange1+1, sizeof(NUMTYPE) * (pEndOfTarget-pRange1-1) );
+ pRange1[1] = pRange2[0] - 1;
+ pRange1[2] = pRange2[1] + 1;
+ pRange1 += 2;
+ pRange2 += 2;
+ }
+ }
+ while ( *pRange1 && *pRange2 );
+
+ // assign the differentiated ranges
+ delete[] _pRanges;
+ NUMTYPE nUShorts = Count_Impl(pTarget) + 1;
+ if ( 1 != nUShorts )
+ {
+ _pRanges = new NUMTYPE[ nUShorts ];
+ memcpy( _pRanges, pTarget, nUShorts * sizeof(NUMTYPE) );
+ _pRanges[ nUShorts-1 ] = 0;
+ }
+ else
+ _pRanges = 0;
+ return *this;
+ */
+}
+
+//------------------------------------------------------------------------
+
+SfxNumRanges& SfxNumRanges::operator /=
+(
+ const SfxNumRanges &rRanges
+)
+
+/** <H3>Description</H3>
+
+ Determines intersection of '*this' with 'rRanges'.
+
+ for each NUMTYPE n:
+ this->Contains( n ) && rRanges.Contains( n ) => this'->Contains( n )
+ !this->Contains( n ) => !this'->Contains( n )
+ !rRanges.Contains( n ) => !this'->Contains( n )
+*/
+
+{
+ // boundary cases
+ // * first set is empty -> nothing to be done
+ // * second set is empty -> delete first set
+ if( rRanges.IsEmpty() )
+ {
+ delete[] _pRanges;
+
+ _pRanges = new NUMTYPE[1];
+ _pRanges[0] = 0;
+
+ return *this;
+ }
+
+ // intersect 'rRanges' in a temporary copy of '*this'
+ // (size is computed for maximal possibly split-count plus terminating 0)
+ NUMTYPE nThisSize = Count_Impl(_pRanges);
+ NUMTYPE nTargetSize = 1 + ( nThisSize + Count_Impl(rRanges._pRanges) );
+ NUMTYPE *pTarget = new NUMTYPE[ nTargetSize ];
+ memset( pTarget, 0, sizeof(NUMTYPE)*nTargetSize );
+ memcpy( pTarget, _pRanges, sizeof(NUMTYPE)*nThisSize );
+
+ NUMTYPE nPos1 = 0, nPos2 = 0, nTargetPos = 0;
+ while( _pRanges[ nPos1 ] != 0 && rRanges._pRanges[ nPos2 ] != 0 )
+ {
+ NUMTYPE l1 = _pRanges[ nPos1 ]; // lower bound of interval 1
+ NUMTYPE u1 = _pRanges[ nPos1+1 ]; // upper bound of interval 1
+ NUMTYPE l2 = rRanges._pRanges[ nPos2 ]; // lower bound of interval 2
+ NUMTYPE u2 = rRanges._pRanges[ nPos2+1 ]; // upper bound of interval 2
+
+ if( u1 < l2 )
+ {
+ // current interval in s1 is completely before ci in s2
+ nPos1 += 2;
+ continue;
+ }
+ if( u2 < l1 )
+ {
+ // ci in s2 is completely before ci in s1
+ nPos2 += 2;
+ continue;
+ }
+
+ // assert: there exists an intersection between ci1 and ci2
+
+ if( l1 <= l2 )
+ {
+ // c1 "is more to the left" than c2
+
+ if( u1 <= u2 )
+ {
+ pTarget[ nTargetPos ] = l2;
+ pTarget[ nTargetPos+1 ] = u1;
+ nTargetPos += 2;
+ nPos1 += 2;
+ continue;
+ }
+ else
+ {
+ pTarget[ nTargetPos ] = l2;
+ pTarget[ nTargetPos+1 ] = u2;
+ nTargetPos += 2;
+ nPos2 += 2;
+ }
+ }
+ else
+ {
+ // c2 "is more to the left" than c1"
+
+ if( u1 > u2 )
+ {
+ pTarget[ nTargetPos ] = l1;
+ pTarget[ nTargetPos+1 ] = u2;
+ nTargetPos += 2;
+ nPos2 += 2;
+ }
+ else
+ {
+ pTarget[ nTargetPos ] = l1;
+ pTarget[ nTargetPos+1 ] = u1;
+ nTargetPos += 2;
+ nPos1 += 2;
+ }
+ }
+ }; // while
+ pTarget[ nTargetPos ] = 0;
+
+ // assign the intersected ranges
+ delete[] _pRanges;
+
+ NUMTYPE nUShorts = Count_Impl(pTarget) + 1;
+ if ( 1 != nUShorts )
+ {
+ _pRanges = new NUMTYPE[ nUShorts ];
+ memcpy( _pRanges, pTarget, nUShorts * sizeof(NUMTYPE) );
+ }
+ else
+ _pRanges = 0;
+
+ delete [] pTarget;
+ return *this;
+}
+
+//------------------------------------------------------------------------
+
+NUMTYPE SfxNumRanges::Count() const
+
+/** <H3>Description</H3>
+
+ Determines the number of USHORTs in the set described by the ranges
+ of USHORTs in '*this'.
+*/
+
+{
+ return Capacity_Impl( _pRanges );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_poolio.cxx b/binfilter/bf_svtools/source/items1/svt_poolio.cxx
new file mode 100644
index 000000000000..5f8be561ceee
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_poolio.cxx
@@ -0,0 +1,1680 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <string.h>
+#include <stdio.h>
+
+#include <tools/solar.h>
+#include <bf_svtools/itempool.hxx>
+#include "whassert.hxx"
+#include <bf_svtools/brdcst.hxx>
+#include <bf_svtools/filerec.hxx>
+#include <bf_svtools/svtdata.hxx>
+#include "poolio.hxx"
+
+namespace binfilter
+{
+
+// STATIC DATA -----------------------------------------------------------
+
+DBG_NAME(SfxItemPool)
+
+//========================================================================
+
+void SfxItemPool::SetStoringPool( const SfxItemPool *pStoringPool )
+
+/* [Beschreibung]
+
+ Diese Methode setzt den <SfxItemPool>, der gerade gespeichert wird.
+ Sie sollte nur in Notf"allen verwendet werden, um z.B. File-Format-
+ Kompatibilit"at zu gew"ahrleisten o."o. - z.B. in der "uberladung eines
+ <SfxPoolItem::Store()> zus"atzliche Daten aus dem dazuge"horigen
+ Pool mit <SfxItemPool::GetStoringPool()> zu besorgen.
+
+ Sie wird von <SfxItemPool::Store()> bedient, kann jedoch f"ur nicht
+ poolable Items auch direkt gerufen werden. Bitte m"oglichst nicht
+ f"ur jedes Item einzeln, da 2 Calls!
+*/
+
+{
+ ImpSvtData::GetSvtData().pStoringPool = pStoringPool;
+}
+
+//-------------------------------------------------------------------------
+
+const SfxItemPool* SfxItemPool::GetStoringPool()
+
+/* [Beschreibung]
+
+ Diese Methode liefert den <SfxItemPool>, der gerade gespeichert wird.
+ Sie sollte nur in Notf"allen verwendet werden, um z.B. File-Format-
+ Kompatibilit"at zu gew"ahrleisten o."o. - z.B. in der "uberladung eines
+ <SfxPoolItem::Store()> zus"atzliche Daten aus dem dazuge"horigen
+ Pool zu besorgen.
+*/
+
+{
+ return ImpSvtData::GetSvtData().pStoringPool;
+}
+
+//-------------------------------------------------------------------------
+
+SvStream &SfxItemPool::Store(SvStream &rStream) const
+
+/* [Beschreibung]
+
+ Der SfxItemPool wird inklusive aller seiner Sekund"arpools mit
+ Pool-Defaults und gepoolten Items in dem angegebenen Stream gespeichert.
+ Die statischen Defaults werden nicht gespeichert.
+
+
+ [Fileformat]
+
+ ;zun"achst ein Kompatiblit"ats-Header-Block
+ Start: 0x1111 SFX_ITEMPOOL_TAG_STARTPOOLS(_4/_5)
+ BYTE MAJOR_VER ;SfxItemPool-Version
+ BYTE MINOR_VER ;"
+ 0xFFFF SFX_ITEMPOOL_TAG_TRICK4OLD ;ex. GetVersion()
+ USHORT 0x0000 ;Pseudo-StyleSheetPool
+ USHORT 0x0000 ;Pseudo-StyleSheetPool
+
+ ;den ganzen Pool in einen Record
+ record SfxMiniRecod(SFX_ITEMPOOL_REC)
+
+ ;je ein Header vorweg
+ Header: record SfxMiniRecord(SFX_ITEMPOOL_REC_HEADER)
+ USHORT GetVersion() ;Which-Ranges etc.
+ String GetName() ;Pool-Name
+
+ ;die Versions-Map, um WhichIds neuer File-Versionen mappen zu k"onnen
+ Versions: record SfxMultiRecord(SFX_ITEMPOOL_REC_VERSIONS, 0)
+ USHORT OldVersion
+ USHORT OldStartWhich
+ USHORT OldEndWhich
+ USHORT[] NewWhich (OldEndWhich-OldStartWhich+1)
+
+ ;jetzt die gepoolten Items (zuerst nicht-SfxSetItems)
+ Items: record SfxMultiRecord(SFX_ITEMPOOL_REC_WHICHIDS, 0)
+ content SlotId, 0
+ USHORT WhichId
+ USHORT pItem->GetVersion()
+ USHORT Array-Size
+ record SfxMultiRecord(SFX_, 0)
+ content Surrogate
+ USHORT RefCount
+ unknown pItem->Store()
+
+ ;jetzt die gesetzten Pool-Defaults
+ Defaults: record SfxMultiRecord(SFX_ITEMPOOL_REC_DEFAULTS, 0)
+ content SlotId, 0
+ USHORT WhichId
+ USHORT pPoolDef->GetVersion()
+ unknown pPoolDef->Store();
+
+ ;dahinter folgt ggf. der Secondary ohne Kompatiblit"ats-Header-Block
+*/
+
+{
+ DBG_CHKTHIS(SfxItemPool, 0);
+
+ // Store-Master finden
+ SfxItemPool *pStoreMaster = pMaster != this ? pMaster : 0;
+ while ( pStoreMaster && !pStoreMaster->pImp->bStreaming )
+ pStoreMaster = pStoreMaster->pSecondary;
+
+ // Alter-Header (Version des Pools an sich und Inhalts-Version 0xffff)
+ pImp->bStreaming = TRUE;
+ if ( !pStoreMaster )
+ {
+ rStream << ( rStream.GetVersion() >= SOFFICE_FILEFORMAT_50
+ ? SFX_ITEMPOOL_TAG_STARTPOOL_5
+ : SFX_ITEMPOOL_TAG_STARTPOOL_4 );
+ rStream << SFX_ITEMPOOL_VER_MAJOR << SFX_ITEMPOOL_VER_MINOR;
+ rStream << SFX_ITEMPOOL_TAG_TRICK4OLD;
+
+ // SfxStyleSheet-Bug umgehen
+ rStream << UINT16(0); // Version
+ rStream << UINT16(0); // Count (2. Schleife f"allt sonst auf die Fresse)
+ }
+
+ // jeder Pool ist als ganzes ein Record
+ SfxMiniRecordWriter aPoolRec( &rStream, SFX_ITEMPOOL_REC );
+ ImpSvtData::GetSvtData().pStoringPool = this;
+
+ // Einzel-Header (Version des Inhalts und Name)
+ {
+ SfxMiniRecordWriter aPoolHeaderRec( &rStream, SFX_ITEMPOOL_REC_HEADER);
+ rStream << pImp->nVersion;
+ SfxPoolItem::writeByteString(rStream, aName);
+ }
+
+ // Version-Maps
+ {
+ SfxMultiVarRecordWriter aVerRec( &rStream, SFX_ITEMPOOL_REC_VERSIONMAP, 0 );
+ for ( USHORT nVerNo = 0; nVerNo < pImp->aVersions.Count(); ++nVerNo )
+ {
+ aVerRec.NewContent();
+ SfxPoolVersion_Impl *pVer = pImp->aVersions[nVerNo];
+ rStream << pVer->_nVer << pVer->_nStart << pVer->_nEnd;
+ USHORT nCount = pVer->_nEnd - pVer->_nStart + 1;
+ USHORT nNewWhich = 0;
+ for ( USHORT n = 0; n < nCount; ++n )
+ {
+ nNewWhich = pVer->_pMap[n];
+ rStream << nNewWhich;
+ }
+
+ // Workaround gegen Bug in SetVersionMap der 312
+ if ( SOFFICE_FILEFORMAT_31 == _nFileFormatVersion )
+ rStream << USHORT(nNewWhich+1);
+ }
+ }
+
+ // gepoolte Items
+ {
+ SfxMultiMixRecordWriter aWhichIdsRec( &rStream, SFX_ITEMPOOL_REC_WHICHIDS, 0 );
+
+ // erst Atomaren-Items und dann die Sets schreiben (wichtig beim Laden)
+ for ( pImp->bInSetItem = FALSE; pImp->bInSetItem <= TRUE && !rStream.GetError(); ++pImp->bInSetItem )
+ {
+ SfxPoolItemArray_Impl **pArr = pImp->ppPoolItems;
+ SfxPoolItem **ppDefItem = ppStaticDefaults;
+ const USHORT nSize = GetSize_Impl();
+ for ( USHORT i = 0; i < nSize && !rStream.GetError(); ++i, ++pArr, ++ppDefItem )
+ {
+ // Version des Items feststellen
+ USHORT nItemVersion = (*ppDefItem)->GetVersion( _nFileFormatVersion );
+ if ( USHRT_MAX == nItemVersion )
+ // => kam in zu exportierender Version gar nicht vor
+ continue;
+
+ // !poolable wird gar nicht im Pool gespeichert
+ // und itemsets/plain-items je nach Runde
+#ifdef TF_POOLABLE
+ if ( *pArr && IsItemFlag(**ppDefItem, SFX_ITEM_POOLABLE) &&
+#else
+ if ( *pArr && (*ppDefItem)->IsPoolable() &&
+#endif
+ pImp->bInSetItem == (*ppDefItem)->ISA(SfxSetItem) )
+ {
+ // eigene Kennung, globale Which-Id und Item-Version
+ USHORT nSlotId = GetSlotId( (*ppDefItem)->Which(), FALSE );
+ aWhichIdsRec.NewContent(nSlotId, 0);
+ rStream << (*ppDefItem)->Which();
+ rStream << nItemVersion;
+ const USHORT nCount = (*pArr)->Count();
+ DBG_ASSERT(nCount, "ItemArr ist leer");
+ rStream << nCount;
+
+ // Items an sich schreiben
+ SfxMultiMixRecordWriter aItemsRec( &rStream, SFX_ITEMPOOL_REC_ITEMS, 0 );
+ for ( USHORT j = 0; j < nCount; ++j )
+ {
+ // Item selbst besorgen
+ const SfxPoolItem *pItem = (*pArr)->GetObject(j);
+ if ( pItem && pItem->GetRefCount() ) //! siehe anderes MI-REF
+ {
+ aItemsRec.NewContent(j, 'X' );
+
+ if ( pItem->GetRefCount() == SFX_ITEMS_SPECIAL )
+ rStream << (USHORT) pItem->GetKind();
+ else
+ {
+ rStream << (USHORT) pItem->GetRefCount();
+ if( pItem->GetRefCount() > SFX_ITEMS_OLD_MAXREF )
+ rStream.SetError( ERRCODE_IO_NOTSTORABLEINBINARYFORMAT );
+ }
+
+ if ( !rStream.GetError() )
+ pItem->Store(rStream, nItemVersion);
+ else
+ break;
+#ifdef DBG_UTIL_MI
+ if ( !pItem->ISA(SfxSetItem) )
+ {
+ ULONG nMark = rStream.Tell();
+ rStream.Seek( nItemStartPos + sizeof(USHORT) );
+ SfxPoolItem *pClone = pItem->Create(rStream, nItemVersion );
+ USHORT nWh = pItem->Which();
+ SFX_ASSERT( rStream.Tell() == nMark, nWh,"asymmetric store/create" );
+ SFX_ASSERT( *pClone == *pItem, nWh, "unequal after store/create" );
+ delete pClone;
+ }
+#endif
+ }
+ }
+ }
+ }
+ }
+
+ pImp->bInSetItem = FALSE;
+ }
+
+ // die gesetzten Defaults speichern (Pool-Defaults)
+ if ( !rStream.GetError() )
+ {
+ SfxMultiMixRecordWriter aDefsRec( &rStream, SFX_ITEMPOOL_REC_DEFAULTS, 0 );
+ USHORT nCount = GetSize_Impl();
+ for ( USHORT n = 0; n < nCount; ++n )
+ {
+ const SfxPoolItem* pDefaultItem = ppPoolDefaults[n];
+ if ( pDefaultItem )
+ {
+ // Version ermitteln
+ USHORT nItemVersion = pDefaultItem->GetVersion( _nFileFormatVersion );
+ if ( USHRT_MAX == nItemVersion )
+ // => gab es in der Version noch nicht
+ continue;
+
+ // eigene Kennung, globale Kennung, Version
+ USHORT nSlotId = GetSlotId( pDefaultItem->Which(), FALSE );
+ aDefsRec.NewContent( nSlotId, 0 );
+ rStream << pDefaultItem->Which();
+ rStream << nItemVersion;
+
+ // Item an sich
+ pDefaultItem->Store( rStream, nItemVersion );
+ }
+ }
+ }
+
+ // weitere Pools rausschreiben
+ ImpSvtData::GetSvtData().pStoringPool = 0;
+ aPoolRec.Close();
+ if ( !rStream.GetError() && pSecondary )
+ pSecondary->Store( rStream );
+
+ pImp->bStreaming = FALSE;
+ return rStream;
+}
+
+// -----------------------------------------------------------------------
+
+void SfxItemPool::LoadCompleted()
+
+/* [Beschreibung]
+
+ Wurde der SfxItemPool mit 'bRefCounts' == FALSE geladen, mu\s das
+ Laden der Dokumentinhalte mit einem Aufruf dieser Methode beendet
+ werden. Ansonsten hat der Aufruf dieser Methode keine Funktion.
+
+
+ [Anmerkung]
+
+ Beim Laden ohne Ref-Counts werden diese tats"achlich auf 1 gesetzt,
+ damit nicht w"ahrend des Ladevorgangs SfxPoolItems gel"oscht werden,
+ die danach, aber auch noch beim Ladevorgang, ben"otigt werden. Diese
+ Methode setzt den Ref-Count wieder zur"uck und entfernt dabei
+ gleichzeitig alle nicht mehr ben"otigten Items.
+
+
+ [Querverweise]
+
+ <SfxItemPool::Load()>
+*/
+
+{
+ // wurden keine Ref-Counts mitgeladen?
+ if ( pImp->nInitRefCount > 1 )
+ {
+
+ // "uber alle Which-Werte iterieren
+ SfxPoolItemArray_Impl** ppItemArr = pImp->ppPoolItems;
+ for( USHORT nArrCnt = GetSize_Impl(); nArrCnt; --nArrCnt, ++ppItemArr )
+ {
+ // ist "uberhaupt ein Item mit dem Which-Wert da?
+ if ( *ppItemArr )
+ {
+ // "uber alle Items mit dieser Which-Id iterieren
+ SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData();
+ for( USHORT n = (*ppItemArr)->Count(); n; --n, ++ppHtArr )
+ if (*ppHtArr)
+ {
+ #ifdef DBG_UTIL
+ const SfxPoolItem &rItem = **ppHtArr;
+ DBG_ASSERT( !rItem.ISA(SfxSetItem) ||
+ 0 != &((const SfxSetItem&)rItem).GetItemSet(),
+ "SetItem without ItemSet" );
+ #endif
+
+ if ( !ReleaseRef( **ppHtArr, 1 ) )
+ DELETEZ( *ppHtArr );
+ }
+ }
+ }
+
+ // from now on normal initial ref count
+ pImp->nInitRefCount = 1;
+ }
+
+ // notify secondary pool
+ if ( pSecondary )
+ pSecondary->LoadCompleted();
+}
+
+//============================================================================
+// This had to be moved to a method of its own to keep Solaris GCC happy:
+void SfxItemPool::readTheItems (
+ SvStream & rStream, USHORT nItemCount, USHORT nVersion,
+ SfxPoolItem * pDefItem, SfxPoolItemArray_Impl ** ppArr)
+{
+ SfxMultiRecordReader aItemsRec( &rStream, SFX_ITEMPOOL_REC_ITEMS );
+
+ SfxPoolItemArray_Impl *pNewArr = new SfxPoolItemArray_Impl( nItemCount );
+ SfxPoolItem *pItem = 0;
+
+ USHORT n, nLastSurrogate = USHORT(-1);
+ while (aItemsRec.GetContent())
+ {
+ // n"achstes Surrogat holen
+ USHORT nSurrogate = aItemsRec.GetContentTag();
+ DBG_ASSERT( aItemsRec.GetContentVersion() == 'X',
+ "not an item content" );
+
+ // fehlende auff"ullen
+ for ( pItem = 0, n = nLastSurrogate+1; n < nSurrogate; ++n )
+ pNewArr->C40_INSERT(SfxPoolItem, pItem, n);
+ nLastSurrogate = nSurrogate;
+
+ // Ref-Count und Item laden
+ USHORT nRef;
+ rStream >> nRef;
+
+ pItem = pDefItem->Create(rStream, nVersion);
+ pNewArr->C40_INSERT(SfxPoolItem, pItem, nSurrogate);
+
+ if ( !bPersistentRefCounts )
+ // bis <SfxItemPool::LoadCompleted()> festhalten
+ AddRef(*pItem, 1);
+ else
+ {
+ if ( nRef > SFX_ITEMS_OLD_MAXREF )
+ pItem->SetKind( nRef );
+ else
+ AddRef(*pItem, nRef);
+ }
+ }
+
+ // fehlende auff"ullen
+ for ( pItem = 0, n = nLastSurrogate+1; n < nItemCount; ++n )
+ pNewArr->C40_INSERT(SfxPoolItem, pItem, n);
+
+ SfxPoolItemArray_Impl *pOldArr = *ppArr;
+ *ppArr = pNewArr;
+
+ // die Items merken, die schon im Pool sind
+ int bEmpty = TRUE;
+ if ( 0 != pOldArr )
+ for ( n = 0; bEmpty && n < pOldArr->Count(); ++n )
+ bEmpty = pOldArr->GetObject(n) == 0;
+ DBG_ASSERTWARNING( bEmpty, "loading non-empty pool" );
+ if ( !bEmpty )
+ {
+ // f"ur alle alten suchen, ob ein gleiches neues existiert
+ for ( USHORT nOld = 0; nOld < pOldArr->Count(); ++nOld )
+ {
+ SfxPoolItem *pOldItem = (*pOldArr)[nOld];
+ if ( pOldItem )
+ {
+ USHORT nFree = USHRT_MAX;
+ int bFound = FALSE;
+ USHORT nCount = (*ppArr)->Count();
+ for ( USHORT nNew = nCount; !bFound && nNew--; )
+ {
+ // geladenes Item
+ SfxPoolItem *&rpNewItem =
+ (SfxPoolItem*&)(*ppArr)->GetData()[nNew];
+
+ // surrogat unbenutzt?
+ if ( !rpNewItem )
+ nFree = nNew;
+
+ // gefunden?
+ else if ( *rpNewItem == *pOldItem )
+ {
+ // wiederverwenden
+ AddRef( *pOldItem, rpNewItem->GetRefCount() );
+ SetRefCount( *rpNewItem, 0 );
+ delete rpNewItem;
+ rpNewItem = pOldItem;
+ bFound = TRUE;
+ }
+ }
+
+ // vorhervorhandene, nicht geladene uebernehmen
+ if ( !bFound )
+ {
+ if ( nFree != USHRT_MAX )
+ (SfxPoolItem*&)(*ppArr)->GetData()[nFree] = pOldItem;
+ else
+ (*ppArr)->C40_INSERT( SfxPoolItem, pOldItem, nCount );
+ }
+ }
+ }
+ }
+ delete pOldArr;
+}
+
+// -----------------------------------------------------------------------
+
+SvStream &SfxItemPool::Load(SvStream &rStream)
+{
+ DBG_CHKTHIS(SfxItemPool, 0);
+ DBG_ASSERT(ppStaticDefaults, "kein DefaultArray");
+
+ // protect items by increasing ref count
+ if ( !bPersistentRefCounts )
+ {
+
+ // "uber alle Which-Werte iterieren
+ SfxPoolItemArray_Impl** ppItemArr = pImp->ppPoolItems;
+ for( USHORT nArrCnt = GetSize_Impl(); nArrCnt; --nArrCnt, ++ppItemArr )
+ {
+ // ist "uberhaupt ein Item mit dem Which-Wert da?
+ if ( *ppItemArr )
+ {
+ // "uber alle Items mit dieser Which-Id iterieren
+ SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData();
+ for( USHORT n = (*ppItemArr)->Count(); n; --n, ++ppHtArr )
+ if (*ppHtArr)
+ {
+ #ifdef DBG_UTIL
+ const SfxPoolItem &rItem = **ppHtArr;
+ DBG_ASSERT( !rItem.ISA(SfxSetItem) ||
+ 0 != &((const SfxSetItem&)rItem).GetItemSet(),
+ "SetItem without ItemSet" );
+ DBG_WARNING( "loading non-empty ItemPool" );
+ #endif
+
+ AddRef( **ppHtArr, 1 );
+ }
+ }
+ }
+
+ // during loading (until LoadCompleted()) protect all items
+ pImp->nInitRefCount = 2;
+ }
+
+ // Load-Master finden
+ SfxItemPool *pLoadMaster = pMaster != this ? pMaster : 0;
+ while ( pLoadMaster && !pLoadMaster->pImp->bStreaming )
+ pLoadMaster = pLoadMaster->pSecondary;
+
+ // Gesamt Header einlesen
+ pImp->bStreaming = TRUE;
+ if ( !pLoadMaster )
+ {
+ // Format-Version laden
+ CHECK_FILEFORMAT2( rStream,
+ SFX_ITEMPOOL_TAG_STARTPOOL_5, SFX_ITEMPOOL_TAG_STARTPOOL_4 );
+ rStream >> pImp->nMajorVer >> pImp->nMinorVer;
+
+ // Format-Version in Master-Pool "ubertragen
+ pMaster->pImp->nMajorVer = pImp->nMajorVer;
+ pMaster->pImp->nMinorVer = pImp->nMinorVer;
+
+ // altes Format?
+ if ( pImp->nMajorVer < 2 )
+ // pImp->bStreaming wird von Load1_Impl() zur"uckgesetzt
+ return Load1_Impl( rStream );
+
+ // zu neues Format?
+ if ( pImp->nMajorVer > SFX_ITEMPOOL_VER_MAJOR )
+ {
+ rStream.SetError(SVSTREAM_FILEFORMAT_ERROR);
+ pImp->bStreaming = FALSE;
+ return rStream;
+ }
+
+ // Version 1.2-Trick-Daten "uberspringen
+ CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_TRICK4OLD );
+ rStream.SeekRel( 4 ); // Hack-Daten wegen SfxStyleSheetPool-Bug skippen
+ }
+
+ // neues Record-orientiertes Format
+ SfxMiniRecordReader aPoolRec( &rStream, SFX_ITEMPOOL_REC );
+ if ( rStream.GetError() )
+ {
+ pImp->bStreaming = FALSE;
+ return rStream;
+ }
+
+ // Einzel-Header
+ int bOwnPool = TRUE;
+ UniString aExternName;
+ {
+ // Header-Record suchen
+ SfxMiniRecordReader aPoolHeaderRec( &rStream, SFX_ITEMPOOL_REC_HEADER );
+ if ( rStream.GetError() )
+ {
+ pImp->bStreaming = FALSE;
+ return rStream;
+ }
+
+ // Header-lesen
+ rStream >> pImp->nLoadingVersion;
+ SfxPoolItem::readByteString(rStream, aExternName);
+ bOwnPool = aExternName == aName;
+
+ //! solange wir keine fremden Pools laden k"onnen
+ if ( !bOwnPool )
+ {
+ rStream.SetError(SVSTREAM_FILEFORMAT_ERROR);
+ aPoolRec.Skip();
+ pImp->bStreaming = FALSE;
+ return rStream;
+ }
+ }
+
+ // Version-Maps
+ {
+ SfxMultiRecordReader aVerRec( &rStream, SFX_ITEMPOOL_REC_VERSIONMAP );
+ if ( rStream.GetError() )
+ {
+ pImp->bStreaming = FALSE;
+ return rStream;
+ }
+
+ // Versions-Maps einlesen
+ USHORT nOwnVersion = pImp->nVersion;
+ for ( USHORT nVerNo = 0; aVerRec.GetContent(); ++nVerNo )
+ {
+ // Header f"ur einzelne Version einlesen
+ USHORT nVersion, nHStart, nHEnd;
+ rStream >> nVersion >> nHStart >> nHEnd;
+ USHORT nCount = nHEnd - nHStart + 1;
+
+ // Version neuer als bekannt?
+ if ( nVerNo >= pImp->aVersions.Count() )
+ {
+ // neue Version hinzufuegen
+ USHORT *pMap = new USHORT[nCount];
+ for ( USHORT n = 0; n < nCount; ++n )
+ rStream >> pMap[n];
+ SetVersionMap( nVersion, nHStart, nHEnd, pMap );
+ }
+ }
+ pImp->nVersion = nOwnVersion;
+ }
+
+ // Items laden
+ FASTBOOL bSecondaryLoaded = FALSE;
+ long nSecondaryEnd = 0;
+ {
+ SfxMultiRecordReader aWhichIdsRec( &rStream, SFX_ITEMPOOL_REC_WHICHIDS);
+ while ( aWhichIdsRec.GetContent() )
+ {
+ // SlotId, Which-Id und Item-Version besorgen
+ USHORT nCount, nVersion, nWhich;
+ //!USHORT nSlotId = aWhichIdsRec.GetContentTag();
+ rStream >> nWhich;
+ if ( pImp->nLoadingVersion != pImp->nVersion )
+ // Which-Id aus File-Version in Pool-Version verschieben
+ nWhich = GetNewWhich( nWhich );
+
+ // unbekanntes Item aus neuerer Version
+ if ( !IsInRange(nWhich) )
+ continue;
+
+ rStream >> nVersion;
+ rStream >> nCount;
+ //!SFX_ASSERTWARNING( !nSlotId || !HasMap() ||
+ //! ( nSlotId == GetSlotId( nWhich, FALSE ) ) ||
+ //! !GetSlotId( nWhich, FALSE ),
+ //! nWhich, "Slot/Which mismatch" );
+
+ USHORT nIndex = GetIndex_Impl(nWhich);
+ SfxPoolItemArray_Impl **ppArr = pImp->ppPoolItems + nIndex;
+
+ // SfxSetItems k"onnten Items aus Sekund"arpools beinhalten
+ SfxPoolItem *pDefItem = *(ppStaticDefaults + nIndex);
+ pImp->bInSetItem = pDefItem->ISA(SfxSetItem);
+ if ( !bSecondaryLoaded && pSecondary && pImp->bInSetItem )
+ {
+ // an das Ende des eigenen Pools seeken
+ ULONG nLastPos = rStream.Tell();
+ aPoolRec.Skip();
+
+ // Sekund"arpool einlesen
+ pSecondary->Load( rStream );
+ bSecondaryLoaded = TRUE;
+ nSecondaryEnd = rStream.Tell();
+
+ // zur"uck zu unseren eigenen Items
+ rStream.Seek(nLastPos);
+ }
+
+ // Items an sich lesen
+ readTheItems(rStream, nCount, nVersion, pDefItem, ppArr);
+
+ pImp->bInSetItem = FALSE;
+ }
+ }
+
+ // Pool-Defaults lesen
+ {
+ SfxMultiRecordReader aDefsRec( &rStream, SFX_ITEMPOOL_REC_DEFAULTS );
+
+ while ( aDefsRec.GetContent() )
+ {
+ // SlotId, Which-Id und Item-Version besorgen
+ USHORT nVersion, nWhich;
+ //!USHORT nSlotId = aDefsRec.GetContentTag();
+ rStream >> nWhich;
+ if ( pImp->nLoadingVersion != pImp->nVersion )
+ // Which-Id aus File-Version in Pool-Version verschieben
+ nWhich = GetNewWhich( nWhich );
+
+ // unbekanntes Item aus neuerer Version
+ if ( !IsInRange(nWhich) )
+ continue;
+
+ rStream >> nVersion;
+ //!SFX_ASSERTWARNING( !HasMap() || ( nSlotId == GetSlotId( nWhich, FALSE ) ),
+ //! nWhich, "Slot/Which mismatch" );
+
+ // Pool-Default-Item selbst laden
+ SfxPoolItem *pItem =
+ ( *( ppStaticDefaults + GetIndex_Impl(nWhich) ) )
+ ->Create( rStream, nVersion );
+ pItem->SetKind( SFX_ITEMS_POOLDEFAULT );
+ *( ppPoolDefaults + GetIndex_Impl(nWhich) ) = pItem;
+ }
+ }
+
+ // ggf. Secondary-Pool laden
+ aPoolRec.Skip();
+ if ( pSecondary )
+ {
+ if ( !bSecondaryLoaded )
+ pSecondary->Load( rStream );
+ else
+ rStream.Seek( nSecondaryEnd );
+ }
+
+ // wenn nicht own-Pool, dann kein Name
+ if ( aExternName != aName )
+ aName.Erase();
+
+ pImp->bStreaming = FALSE;
+ return rStream;
+};
+
+// -----------------------------------------------------------------------
+
+SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
+{
+ // beim Master ist der Header schon von <Load()> geladen worden
+ if ( !pImp->bStreaming )
+ {
+ // Header des Secondary lesen
+ CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_STARTPOOL_4 );
+ rStream >> pImp->nMajorVer >> pImp->nMinorVer;
+ }
+ sal_uInt32 nAttribSize;
+ int bOwnPool = TRUE;
+ UniString aExternName;
+ if ( pImp->nMajorVer > 1 || pImp->nMinorVer >= 2 )
+ rStream >> pImp->nLoadingVersion;
+ SfxPoolItem::readByteString(rStream, aExternName);
+ bOwnPool = aExternName == aName;
+ pImp->bStreaming = TRUE;
+
+ //! solange wir keine fremden laden k"onnen
+ if ( !bOwnPool )
+ {
+ rStream.SetError(SVSTREAM_FILEFORMAT_ERROR);
+ pImp->bStreaming = FALSE;
+ return rStream;
+ }
+
+ // Versionen bis 1.3 k"onnen noch keine Which-Verschiebungen lesen
+ if ( pImp->nMajorVer == 1 && pImp->nMinorVer <= 2 &&
+ pImp->nVersion < pImp->nLoadingVersion )
+ {
+ rStream.SetError(ERRCODE_IO_WRONGVERSION);
+ pImp->bStreaming = FALSE;
+ return rStream;
+ }
+
+ // Size-Table liegt hinter den eigentlichen Attributen
+ rStream >> nAttribSize;
+
+ // Size-Table einlesen
+ ULONG nStartPos = rStream.Tell();
+ rStream.SeekRel( nAttribSize );
+ CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_SIZES );
+ sal_uInt32 nSizeTableLen;
+ rStream >> nSizeTableLen;
+ sal_Char *pBuf = new sal_Char[nSizeTableLen];
+ rStream.Read( pBuf, nSizeTableLen );
+ ULONG nEndOfSizes = rStream.Tell();
+ SvMemoryStream aSizeTable( pBuf, nSizeTableLen, STREAM_READ );
+
+ // ab Version 1.3 steht in der Size-Table eine Versions-Map
+ if ( pImp->nMajorVer > 1 || pImp->nMinorVer >= 3 )
+ {
+ // Version-Map finden (letztes ULONG der Size-Table gibt Pos an)
+ rStream.Seek( nEndOfSizes - sizeof(sal_uInt32) );
+ sal_uInt32 nVersionMapPos;
+ rStream >> nVersionMapPos;
+ rStream.Seek( nVersionMapPos );
+
+ // Versions-Maps einlesen
+ CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_VERSIONMAP );
+ USHORT nVerCount;
+ rStream >> nVerCount;
+ for ( USHORT nVerNo = 0; nVerNo < nVerCount; ++nVerNo )
+ {
+ // Header f"ur einzelne Version einlesen
+ USHORT nVersion, nHStart, nHEnd;
+ rStream >> nVersion >> nHStart >> nHEnd;
+ USHORT nCount = nHEnd - nHStart + 1;
+ USHORT nBytes = (nCount)*sizeof(USHORT);
+
+ // Version neuer als bekannt?
+ if ( nVerNo >= pImp->aVersions.Count() )
+ {
+ // neue Version hinzufuegen
+ USHORT *pMap = new USHORT[nCount];
+ for ( USHORT n = 0; n < nCount; ++n )
+ rStream >> pMap[n];
+ SetVersionMap( nVersion, nHStart, nHEnd, pMap );
+ }
+ else
+ // Version schon bekannt => "uberspringen
+ rStream.SeekRel( nBytes );
+ }
+ }
+
+ // Items laden
+ rStream.Seek( nStartPos );
+ CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_ITEMS );
+ FASTBOOL bSecondaryLoaded = FALSE;
+ long nSecondaryEnd = 0;
+ USHORT nWhich, nSlot;
+ while ( rStream >> nWhich, nWhich )
+ {
+ // ggf. Which-Id aus alter Version verschieben?
+ if ( pImp->nLoadingVersion != pImp->nVersion )
+ nWhich = GetNewWhich( nWhich );
+
+ rStream >> nSlot;
+ USHORT nMappedWhich = GetWhich(nSlot, FALSE);
+ int bKnownItem = bOwnPool || IsWhich(nMappedWhich);
+
+ USHORT nRef, nCount, nVersion;
+ sal_uInt32 nAttrSize;
+ rStream >> nVersion >> nCount;
+
+ SfxPoolItemArray_Impl **ppArr = 0;
+ SfxPoolItemArray_Impl *pNewArr = 0;
+ SfxPoolItem *pDefItem = 0;
+ if ( bKnownItem )
+ {
+ if ( !bOwnPool )
+ nWhich = nMappedWhich;
+
+ //!SFX_ASSERTWARNING( !nSlot || !HasMap() ||
+ //! ( nSlot == GetSlotId( nWhich, FALSE ) ) ||
+ //! !GetSlotId( nWhich, FALSE ),
+ //! nWhich, "Slot/Which mismatch" );
+
+ USHORT nIndex = GetIndex_Impl(nWhich);
+ ppArr = pImp->ppPoolItems + nIndex;
+ pNewArr = new SfxPoolItemArray_Impl( nCount );
+ pDefItem = *(ppStaticDefaults + nIndex);
+ }
+
+ // Position vor ersten Item merken
+ ULONG nLastPos = rStream.Tell();
+
+ // SfxSetItems k"onnten Items aus Sekund"arpools beinhalten
+ if ( !bSecondaryLoaded && pSecondary && pDefItem->ISA(SfxSetItem) )
+ {
+ // an das Ende des eigenen Pools seeken
+ rStream.Seek(nEndOfSizes);
+ CHECK_FILEFORMAT_RELEASE( rStream, SFX_ITEMPOOL_TAG_ENDPOOL, pNewArr );
+ CHECK_FILEFORMAT_RELEASE( rStream, SFX_ITEMPOOL_TAG_ENDPOOL, pNewArr );
+
+ // Sekund"arpool einlesen
+ pSecondary->Load1_Impl( rStream );
+ bSecondaryLoaded = TRUE;
+ nSecondaryEnd = rStream.Tell();
+
+ // zur"uck zu unseren eigenen Items
+ rStream.Seek(nLastPos);
+ }
+
+ // Items an sich lesen
+ for ( USHORT j = 0; j < nCount; ++j )
+ {
+ ULONG nPos = nLastPos;
+ rStream >> nRef;
+
+ if ( bKnownItem )
+ {
+ SfxPoolItem *pItem = 0;
+ if ( nRef )
+ {
+ pItem = pDefItem->Create(rStream, nVersion);
+
+ if ( !bPersistentRefCounts )
+ // bis <SfxItemPool::LoadCompleted()> festhalten
+ AddRef(*pItem, 1);
+ else
+ {
+ if ( nRef > SFX_ITEMS_OLD_MAXREF )
+ pItem->SetKind( nRef );
+ else
+ AddRef(*pItem, nRef);
+ }
+ }
+
+ pNewArr->C40_INSERT( SfxPoolItem, pItem, j);
+
+ // restliche gespeicherte Laenge skippen (neueres Format)
+ nLastPos = rStream.Tell();
+ }
+
+ aSizeTable >> nAttrSize;
+ SFX_ASSERT( !bKnownItem || ( nPos + nAttrSize) >= nLastPos,
+ nPos,
+ "too many bytes read - version mismatch?" );
+
+ if ( !bKnownItem || ( nLastPos < (nPos + nAttrSize) ) )
+ {
+ nLastPos = nPos + nAttrSize;
+ rStream.Seek( nLastPos );
+ }
+ }
+
+ if ( bKnownItem )
+ {
+ SfxPoolItemArray_Impl *pOldArr = *ppArr;
+ *ppArr = pNewArr;
+
+ // die Items merken, die schon im Pool sind
+ int bEmpty = TRUE;
+ if ( 0 != pOldArr )
+ for ( USHORT n = 0; bEmpty && n < pOldArr->Count(); ++n )
+ bEmpty = pOldArr->GetObject(n) == 0;
+ DBG_ASSERTWARNING( bEmpty, "loading non-empty pool" );
+ if ( !bEmpty )
+ {
+ // f"ur alle alten suchen, ob ein gleiches neues existiert
+ for ( USHORT nOld = 0; nOld < pOldArr->Count(); ++nOld )
+ {
+ SfxPoolItem *pOldItem = (*pOldArr)[nOld];
+ if ( pOldItem )
+ {
+ int bFound = FALSE;
+ for ( USHORT nNew = 0;
+ !bFound && nNew < (*ppArr)->Count();
+ ++nNew )
+ {
+ SfxPoolItem *&rpNewItem =
+ (SfxPoolItem*&)(*ppArr)->GetData()[nNew];
+
+ if ( rpNewItem && *rpNewItem == *pOldItem )
+ {
+ AddRef( *pOldItem, rpNewItem->GetRefCount() );
+ SetRefCount( *rpNewItem, 0 );
+ delete rpNewItem;
+ rpNewItem = pOldItem;
+ bFound = TRUE;
+ SFX_TRACE( "reusing item", pOldItem );
+ }
+ }
+ //! DBG_ASSERT( bFound, "old-item not found in file" );
+ if ( !bFound )
+ {
+ SFX_TRACE( "item not found: ", pOldItem );
+ }
+ }
+ }
+ }
+ delete pOldArr; /* @@@ */
+ }
+ }
+
+ // Pool-Defaults lesen
+ if ( pImp->nMajorVer > 1 || pImp->nMinorVer > 0 )
+ CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_DEFAULTS );
+
+ ULONG nLastPos = rStream.Tell();
+ while ( rStream >> nWhich, nWhich )
+ {
+ // ggf. Which-Id aus alter Version verschieben?
+ if ( pImp->nLoadingVersion != pImp->nVersion )
+ nWhich = GetNewWhich( nWhich );
+
+ rStream >> nSlot;
+ USHORT nMappedWhich = GetWhich(nSlot, FALSE);
+ int bKnownItem = bOwnPool || IsWhich(nMappedWhich);
+
+ ULONG nPos = nLastPos;
+ sal_uInt32 nSize;
+ USHORT nVersion;
+ rStream >> nVersion;
+
+ if ( bKnownItem )
+ {
+ if ( !bOwnPool )
+ nWhich = nMappedWhich;
+ SfxPoolItem *pItem =
+ ( *( ppStaticDefaults + GetIndex_Impl(nWhich) ) )
+ ->Create( rStream, nVersion );
+ pItem->SetKind( SFX_ITEMS_POOLDEFAULT );
+ *( ppPoolDefaults + GetIndex_Impl(nWhich) ) = pItem;
+ }
+
+ nLastPos = rStream.Tell();
+ aSizeTable >> nSize;
+ SFX_ASSERT( ( nPos + nSize) >= nLastPos, nPos,
+ "too many bytes read - version mismatch?" );
+ if ( nLastPos < (nPos + nSize) )
+ rStream.Seek( nPos + nSize );
+ }
+
+ delete[] pBuf;
+ rStream.Seek(nEndOfSizes);
+ CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_ENDPOOL );
+ CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_ENDPOOL );
+
+ if ( pSecondary )
+ {
+ if ( !bSecondaryLoaded )
+ pSecondary->Load1_Impl( rStream );
+ else
+ rStream.Seek( nSecondaryEnd );
+ }
+
+ if ( aExternName != aName )
+ aName.Erase();
+
+ pImp->bStreaming = FALSE;
+ return rStream;
+}
+
+// -----------------------------------------------------------------------
+
+const SfxPoolItem* SfxItemPool::LoadSurrogate
+(
+ SvStream& rStream, // vor einem Surrogat positionierter Stream
+ USHORT& rWhich, // Which-Id des zu ladenden <SfxPoolItem>s
+ USHORT nSlotId, // Slot-Id des zu ladenden <SfxPoolItem>s
+ const SfxItemPool* pRefPool // <SfxItemPool> in dem das Surrogat gilt
+)
+
+/* [Beschreibung]
+
+ L"adt Surrogat aus 'rStream' und liefert das dadurch in 'rRefPool'
+ repr"asentierte SfxPoolItem zu"ruck. Ist das im Stream befindliche
+ Surrogat == SFX_ITEMS_DIRECT (!SFX_ITEM_POOLABLE) wird 0 zur"uckgegeben,
+ das Item ist direkt aus dem Stream zu laden. Bei 0xfff0 (SFX_ITEMS_NULL)
+ wird auch 0 zurueckgegeben und rWhich auf 0 gesetzt, das Item ist nicht
+ verfuegbar.
+
+ Ansonsten wird ber"ucksichtigt, ob der betroffene Pool ohne Ref-Counts
+ geladen wird, ob aus einem neuen Pool nachgeladen wird (&rRefPool != this)
+ oder ob aus einem g"anzlich anders aufgebauten Pool geladen wird.
+
+ Wird aus einem anders aufgebauten Pool geladen und die 'nSlotId' kann
+ nicht in eine Which-Id dieses Pools gemappt werden, wird ebenfalls 0
+ zur"uckgeliefert.
+
+ Preconditions: - Pool mu\s geladen sein
+ - LoadCompleted darf noch nicht gerufen worden sein
+ - 'rStream' steht genau an der Position, an der ein
+ Surrogat f"ur ein Item mit der SlotId 'nSlotId' und
+ der WhichId 'rWhichId' mit StoreSurrogate gepeichert
+ wurde
+
+ Postconditions: - 'rStream' ist so positioniert, wie auch StoreSurrogate
+ sein speichern beendet hatte
+ - konnte ein Item geladen werden, befindet es sich
+ in diesem SfxItemPool
+ - 'rWhichId' enth"alt die ggf. gemappte Which-Id
+ Laufzeit: Tiefe des Ziel Sekund"arpools * 10 + 10
+
+ [Querverweise]
+
+ <SfxItemPool::StoreSurrogate(SvStream&,const SfxPoolItem &)const>
+*/
+
+{
+ // erstmal das Surrogat lesen
+ USHORT nSurrogat;
+ rStream >> nSurrogat;
+
+ // direkt gespeichertes Item?
+ if ( SFX_ITEMS_DIRECT == nSurrogat )
+ return 0;
+
+ // nicht vorhandenes Item?
+ if ( SFX_ITEMS_NULL == nSurrogat )
+ {
+ rWhich = 0;
+ return 0;
+ }
+
+ // Bei einem identisch aufgebauten Pool (im Stream) kann das Surrogat
+ // auf jeden Fall aufgel"ost werden.
+ if ( !pRefPool )
+ pRefPool = this;
+ FASTBOOL bResolvable = pRefPool->GetName().Len() > 0;
+ if ( !bResolvable )
+ {
+ // Bei einem anders aufgebauten Pool im Stream, mu\s die SlotId
+ // aus dem Stream in eine Which-Id gemappt werden k"onnen.
+ USHORT nMappedWhich = nSlotId ? GetWhich(nSlotId, TRUE) : 0;
+ if ( IsWhich(nMappedWhich) )
+ {
+ // gemappte SlotId kann "ubernommen werden
+ rWhich = nMappedWhich;
+ bResolvable = TRUE;
+ }
+ }
+
+ // kann Surrogat aufgel"ost werden?
+ const SfxPoolItem *pItem = 0;
+ if ( bResolvable )
+ {
+ for ( SfxItemPool *pTarget = this; pTarget; pTarget = pTarget->pSecondary )
+ {
+ // richtigen (Folge-) Pool gefunden?
+ if ( pTarget->IsInRange(rWhich) )
+ {
+ // dflt-Attribut?
+ if ( SFX_ITEMS_STATICDEFAULT == nSurrogat )
+ return *(pTarget->ppStaticDefaults +
+ pTarget->GetIndex_Impl(rWhich));
+
+ SfxPoolItemArray_Impl* pItemArr = *(pTarget->pImp->ppPoolItems +
+ pTarget->GetIndex_Impl(rWhich));
+ pItem = pItemArr && nSurrogat < pItemArr->Count()
+ ? (*pItemArr)[nSurrogat]
+ : 0;
+ if ( !pItem )
+ {
+ DBG_ERROR( "can't resolve surrogate" );
+ rWhich = 0; // nur zur Sicherheit fuer richtige Stream-Pos
+ return 0;
+ }
+
+ // Nachladen aus Ref-Pool?
+ if ( pRefPool != pMaster )
+ return &pTarget->Put( *pItem );
+
+ // Referenzen sind NICHT schon mit Pool geladen worden?
+ if ( !pTarget->HasPersistentRefCounts() )
+ AddRef( *pItem, 1 );
+ else
+ return pItem;
+
+ return pItem;
+ }
+ }
+
+ SFX_ASSERT( FALSE, rWhich, "can't resolve Which-Id in LoadSurrogate" );
+ }
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------
+
+
+FASTBOOL SfxItemPool::StoreSurrogate
+(
+ SvStream& rStream,
+ const SfxPoolItem* pItem
+) const
+
+/* [Beschreibung]
+
+ Speichert ein Surrogat f"ur '*pItem' in 'rStream'.
+
+
+ [R"uckgabewert]
+
+ FASTBOOL TRUE
+ es wurde ein echtes Surrogat gespeichert, auch
+ SFX_ITEMS_NULL bei 'pItem==0',
+ SFX_ITEMS_STATICDEFAULT und SFX_ITEMS_POOLDEFAULT
+ gelten als 'echte' Surrogate
+
+ FALSE
+ es wurde ein Dummy-Surrogat (SFX_ITEMS_DIRECT)
+ gespeichert, das eigentliche Item mu\s direkt
+ hinterher selbst gespeichert werden
+*/
+
+{
+ if ( pItem )
+ {
+ FASTBOOL bRealSurrogate = IsItemFlag(*pItem, SFX_ITEM_POOLABLE);
+ rStream << ( bRealSurrogate
+ ? GetSurrogate( pItem )
+ : (UINT16) SFX_ITEMS_DIRECT );
+ return bRealSurrogate;
+ }
+
+ rStream << (UINT16) SFX_ITEMS_NULL;
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SfxItemPool::GetSurrogate(const SfxPoolItem *pItem) const
+{
+ DBG_CHKTHIS(SfxItemPool, 0);
+ DBG_ASSERT( pItem, "no 0-Pointer Surrogate" );
+ DBG_ASSERT( !IsInvalidItem(pItem), "no Invalid-Item Surrogate" );
+ DBG_ASSERT( !IsPoolDefaultItem(pItem), "no Pool-Default-Item Surrogate" );
+
+ if ( !IsInRange(pItem->Which()) )
+ {
+ if ( pSecondary )
+ return pSecondary->GetSurrogate( pItem );
+ SFX_ASSERT( 0, pItem->Which(), "unknown Which-Id - dont ask me for surrogates" );
+ }
+
+ // Pointer auf static- oder pool-dflt-Attribut?
+ if( IsStaticDefaultItem(pItem) || IsPoolDefaultItem(pItem) )
+ return SFX_ITEMS_STATICDEFAULT;
+
+ SfxPoolItemArray_Impl* pItemArr = *(pImp->ppPoolItems + GetIndex_Impl(pItem->Which()));
+ DBG_ASSERT(pItemArr, "ItemArr nicht vorhanden");
+ const USHORT nCount = pItemArr->Count();
+ for ( USHORT i = 0; i < nCount; ++i )
+ {
+ const SfxPoolItem *p = (*pItemArr)[i];
+ if ( p == pItem )
+ return i;
+ }
+ SFX_ASSERT( 0, pItem->Which(), "Item nicht im Pool");
+ return SFX_ITEMS_NULL;
+}
+
+// -----------------------------------------------------------------------
+
+FASTBOOL SfxItemPool::IsInStoringRange( USHORT nWhich ) const
+{
+ return nWhich >= pImp->nStoringStart &&
+ nWhich <= pImp->nStoringEnd;
+}
+
+//------------------------------------------------------------------------
+
+void SfxItemPool::SetStoringRange( USHORT nFrom, USHORT nTo )
+
+/* [Beschreibung]
+
+ Mit dieser Methode kann der Which-Bereich eingeengt werden, der
+ von ItemSets dieses Pool (und dem Pool selbst) gespeichert wird.
+ Die Methode muss dazu vor <SfxItemPool::Store()> gerufen werden
+ und die Werte muessen auch noch gesetzt sein, wenn das eigentliche
+ Dokument (also die ItemSets gespeicher werden).
+
+ Ein Zuruecksetzen ist dann nicht noetig, wenn dieser Range vor
+ JEDEM Speichern richtig gesetzt wird, da er nur beim Speichern
+ beruecksichtigt wird.
+
+ Dieses muss fuer das 3.1-Format gemacht werden, da dort eine
+ Bug in der Pool-Lade-Methode vorliegt.
+*/
+
+{
+ pImp->nStoringStart = nFrom;
+ pImp->nStoringEnd = nTo;
+}
+
+// -----------------------------------------------------------------------
+
+void SfxItemPool::SetVersionMap
+(
+ USHORT nVer, /* neue Versionsnummer */
+ USHORT nOldStart, /* alte erste Which-Id */
+ USHORT nOldEnd, /* alte letzte Which-Id */
+ USHORT* pOldWhichIdTab /* Array mit genau dem Aufbau der Which-Ids
+ der vorhergehenden Version, in denen
+ die jeweils neue Which-Id steht. */
+)
+
+/* [Beschreibung]
+
+ Mit dieser Methode k"onnen neue, inkompatible Which-Id-Folgen oder
+ Verteilungen realisiert werden. Pools, die noch mit alten Versionen
+ gespeichert wurden, werden dann "uber die angegebene Tabelle solange
+ gemappt, bis die aktuelle Version erreicht ist. Neuere Pools k"onnen
+ unter Verlust neuer Attribute geladen werden, da die Map mit dem Pool
+ gespeichert wird.
+
+ Precondition: Pool darf noch nicht geladen sein
+ Postcondition: Which-Ids aus fr"uheren Versionen k"onnen bei Laden auf
+ Version 'nVer' gemappt werden
+ Laufzeit: 1.5 * new + 10
+
+ [Anmerkung]
+
+ F"ur neue Which-Ranges (nStart,nEnd) m"ssen im Vergleich zur Vorg"anger-
+ Version (nOldStart,nOldEnd) immer gelten, da\s (nOldStart,nOldEnd)
+ vollst"andig in (nStart,nEnd) enthalten ist. Es ist also zul"assig, den
+ Which-Range in beide Richtungen zu erweitern, auch durch Einf"ugung
+ von Which-Ids, nicht aber ihn zu beschneiden.
+
+ Diese Methode sollte nur im oder direkt nach Aufruf des Konstruktors
+ gerufen werden.
+
+ Das Array mu\s statisch sein, da es nicht kopiert wird und au\serdem
+ im Copy-Ctor des SfxItemPool wiederverwendet wird.
+
+
+ [Beispiel]
+
+ Urspr"unglich (Version 0) hatte der Pool folgende Which-Ids:
+
+ 1:A, 2:B, 3:C, 4:D
+
+ Nun soll eine neue Version (Version 1) zwei zus"atzliche Ids X und Y
+ zwischen B und C erhalten, also wie folgt aussehen:
+
+ 1:A, 2:B, 3:X, 4:Y, 5:C, 6:D
+
+ Dabei haben sich also die Ids 3 und 4 ge"andert. F"ur die neue Version
+ m"u\ste am Pool folgendes gesetzt werden:
+
+ static USHORT nVersion1Map = { 1, 2, 5, 6 };
+ pPool->SetVersionMap( 1, 1, 4, &nVersion1Map );
+
+
+ [Querverweise]
+
+ <SfxItemPool::IsLoadingVersionCurrent()const>
+ <SfxItemPool::GetNewWhich(USHORT)>
+ <SfxItemPool::GetLoadingVersion()const>
+*/
+
+{
+ // neuen Map-Eintrag erzeugen und einf"ugen
+ const SfxPoolVersion_Impl *pVerMap = new SfxPoolVersion_Impl(
+ nVer, nOldStart, nOldEnd, pOldWhichIdTab );
+ pImp->aVersions.Insert( pVerMap, pImp->aVersions.Count() );
+
+ DBG_ASSERT( nVer > pImp->nVersion, "Versions not sorted" );
+ pImp->nVersion = nVer;
+
+ // Versions-Range anpassen
+ for ( USHORT n = 0; n < nOldEnd-nOldStart+1; ++n )
+ {
+ USHORT nWhich = pOldWhichIdTab[n];
+ if ( nWhich < pImp->nVerStart )
+ {
+ if ( !nWhich )
+ nWhich = 0;
+ pImp->nVerStart = nWhich;
+ }
+ else if ( nWhich > pImp->nVerEnd )
+ pImp->nVerEnd = nWhich;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SfxItemPool::GetNewWhich
+(
+ USHORT nFileWhich // die aus dem Stream geladene Which-Id
+) const
+
+/* [Beschreibung]
+
+ Diese Methoden rechnet Which-Ids aus einem File-Format in die der
+ aktuellen Pool-Version um. Ist das File-Format "alter, werden die vom
+ Pool-Entwickler mit SetVersion() gesetzten Tabellen verwendet,
+ ist das File-Format neuer, dann die aus dem File geladenen Tabellen.
+ Im letzteren Fall kann ggf. nicht jede Which-Id gemappt werden,
+ so da\s 0 zur"uckgeliefert wird.
+
+ Die Berechnung ist nur f"ur Which-Ids definiert, die in der betreffenden
+ File-Version unterst"utzt wurden. Dies ist per Assertion abgesichert.
+
+ Precondition: Pool mu\s geladen sein
+ Postcondition: unver"andert
+ Laufzeit: linear(Anzahl der Sekund"arpools) +
+ linear(Differenz zwischen alter und neuer Version)
+
+
+ [Querverweise]
+
+ <SfxItemPool::IsLoadingVersionCurrent()const>
+ <SfxItemPool::SetVersionMap(USHORT,USHORT,USHORT,USHORT*)>
+ <SfxItemPool::GetLoadingVersion()const>
+*/
+
+{
+ // (Sekund"ar-) Pool bestimmen
+ if ( !IsInVersionsRange(nFileWhich) )
+ {
+ if ( pSecondary )
+ return pSecondary->GetNewWhich( nFileWhich );
+ SFX_ASSERT( 0, nFileWhich, "unknown which in GetNewWhich()" );
+ }
+
+ // Version neuer/gleich/"alter?
+ short nDiff = (short)pImp->nLoadingVersion - (short)pImp->nVersion;
+
+ // Which-Id einer neueren Version?
+ if ( nDiff > 0 )
+ {
+ // von der Top-Version bis runter zur File-Version stufenweise mappen
+ for ( USHORT nMap = pImp->aVersions.Count(); nMap > 0; --nMap )
+ {
+ SfxPoolVersion_Impl *pVerInfo = pImp->aVersions[nMap-1];
+ if ( pVerInfo->_nVer > pImp->nVersion )
+ { USHORT nOfs;
+ USHORT nCount = pVerInfo->_nEnd - pVerInfo->_nStart + 1;
+ for ( nOfs = 0;
+ nOfs <= nCount &&
+ pVerInfo->_pMap[nOfs] != nFileWhich;
+ ++nOfs )
+ continue;
+
+ if ( pVerInfo->_pMap[nOfs] == nFileWhich )
+ nFileWhich = pVerInfo->_nStart + nOfs;
+ else
+ return 0;
+ }
+ else
+ break;
+ }
+ }
+
+ // Which-Id einer neueren Version?
+ else if ( nDiff < 0 )
+ {
+ // von der File-Version bis zur aktuellen Version stufenweise mappen
+ for ( USHORT nMap = 0; nMap < pImp->aVersions.Count(); ++nMap )
+ {
+ SfxPoolVersion_Impl *pVerInfo = pImp->aVersions[nMap];
+ if ( pVerInfo->_nVer > pImp->nLoadingVersion )
+ {
+ DBG_ASSERT( nFileWhich >= pVerInfo->_nStart &&
+ nFileWhich <= pVerInfo->_nEnd,
+ "which-id unknown in version" );
+ nFileWhich = pVerInfo->_pMap[nFileWhich - pVerInfo->_nStart];
+ }
+ }
+ }
+
+ // originale (nDiff==0) bzw. gemappte (nDiff!=0) Id zur"uckliefern
+ return nFileWhich;
+}
+
+// -----------------------------------------------------------------------
+
+
+FASTBOOL SfxItemPool::IsInVersionsRange( USHORT nWhich ) const
+{
+ return nWhich >= pImp->nVerStart && nWhich <= pImp->nVerEnd;
+}
+
+// -----------------------------------------------------------------------
+
+FASTBOOL SfxItemPool::IsCurrentVersionLoading() const
+
+/* [Beschreibung]
+
+ Mit dieser Methode kann festgestellt werden, ob die geladene Pool-Version
+ dem aktuellen Pool-Aufbau entspricht.
+
+ Precondition: Pool mu\s geladen sein
+ Postcondition: unver"andert
+ Laufzeit: linear(Anzahl der Sekund"arpools)
+
+
+ [Querverweise]
+
+ <SfxItemPool::SetVersionMap(USHORT,USHORT,USHORT,USHORT*)>
+ <SfxItemPool::GetNewWhich(USHORT)const>
+ <SfxItemPool::GetLoadingVersion()const>
+*/
+
+{
+ return ( pImp->nVersion == pImp->nLoadingVersion ) &&
+ ( !pSecondary || pSecondary->IsCurrentVersionLoading() );
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SfxItemPool::GetLoadingVersion() const
+
+/* [Beschreibung]
+
+ Diese Methode liefert die Versionsnummer des SfxItemPool-Aufbaus
+ (also des Which-Bereichs), die bei Laden vorgefunden wurde.
+
+ Precondition: Pool mu\s geladen sein
+ Postcondition: unver"andert
+ Laufzeit: 2
+
+
+ [Anmerkung]
+
+ Achtung: Es mu\s ggf. die Versionsnummer von Sekund"arpools
+ ber"ucksichtigt werden.
+
+
+ [Querverweise]
+
+ <SfxItemPool::IsLoadingVersionCurrent()const>
+ <SfxItemPool::SetVersionMap(USHORT,USHORT,USHORT,USHORT*)>
+ <SfxItemPool::GetNewWhich(USHORT)const>
+*/
+
+{
+ return pImp->nLoadingVersion;
+}
+
+//-------------------------------------------------------------------------
+
+FASTBOOL SfxItemPool::IsVer2_Impl() const
+{
+ return pMaster->pImp->nMajorVer >= 2;
+}
+
+//-------------------------------------------------------------------------
+
+
+FASTBOOL SfxItemPool::StoreItem( SvStream &rStream, const SfxPoolItem &rItem,
+ FASTBOOL bDirect ) const
+
+/* [Beschreibung]
+
+ Speichert das <SfxPoolItem> 'rItem' in den <SvStream> 'rStream'
+ entweder als Surrogat ('bDirect == FALSE') oder direkt mit 'rItem.Store()'.
+ Nicht poolable Items werden immer direkt gespeichert. Items ohne Which-Id,
+ also SID-Items, werden nicht gespeichert, ebenso wenn Items, die in der
+ File-Format-Version noch nicht vorhanden waren (return FALSE).
+
+ Das Item wird im Stream wie folgt abgelegt:
+
+ USHORT rItem.Which()
+ USHORT GetSlotId( rItem.Which() ) bzw. 0 falls nicht verf"urbar
+ USHORT GetSurrogate( &rItem ) bzw. SFX_ITEM_DIRECT bei '!SFX_ITEM_POOLBLE'
+
+ optional (falls 'bDirect == TRUE' oder '!rItem.IsPoolable()':
+
+ USHORT rItem.GetVersion()
+ ULONG Size
+ Size rItem.Store()
+
+
+ [Querverweise]
+
+ <SfxItemPool::LoadItem(SvStream&,FASTBOOL)const>
+*/
+
+{
+ DBG_ASSERT( !IsInvalidItem(&rItem), "cannot store invalid items" );
+
+ if ( IsSlot( rItem.Which() ) )
+ return FALSE;
+ const SfxItemPool *pPool = this;
+ while ( !pPool->IsInStoringRange(rItem.Which()) )
+ if ( 0 == ( pPool = pPool->pSecondary ) )
+ return FALSE;
+
+ DBG_ASSERT( !pImp->bInSetItem || !rItem.ISA(SfxSetItem),
+ "SetItem contains ItemSet with SetItem" );
+
+ USHORT nSlotId = pPool->GetSlotId( rItem.Which(), TRUE );
+ USHORT nItemVersion = rItem.GetVersion(_nFileFormatVersion);
+ if ( USHRT_MAX == nItemVersion )
+ return FALSE;
+
+ rStream << rItem.Which() << nSlotId;
+ if ( bDirect || !pPool->StoreSurrogate( rStream, &rItem ) )
+ {
+ rStream << nItemVersion;
+ rStream << (UINT32) 0L; // Platz fuer Laenge in Bytes
+ ULONG nIStart = rStream.Tell();
+ rItem.Store(rStream, nItemVersion);
+ ULONG nIEnd = rStream.Tell();
+ rStream.Seek( nIStart-4 );
+ rStream << (INT32) ( nIEnd-nIStart );
+ rStream.Seek( nIEnd );
+ }
+
+ return TRUE;
+}
+
+//-------------------------------------------------------------------------
+
+
+const SfxPoolItem* SfxItemPool::LoadItem( SvStream &rStream, FASTBOOL bDirect,
+ const SfxItemPool *pRefPool )
+
+// pRefPool==-1 => nicht putten!
+
+{
+ USHORT nWhich, nSlot; // nSurrogate;
+ rStream >> nWhich >> nSlot;
+
+ BOOL bDontPut = (SfxItemPool*)-1 == pRefPool;
+ if ( bDontPut || !pRefPool )
+ pRefPool = this;
+
+ // richtigen Sekund"ar-Pool finden
+ while ( !pRefPool->IsInVersionsRange(nWhich) )
+ {
+ if ( pRefPool->pSecondary )
+ pRefPool = pRefPool->pSecondary;
+ else
+ {
+ // WID in der Version nicht vorhanden => ueberspringen
+ USHORT nSurro, nVersion, nLen;
+ rStream >> nSurro;
+ if ( SFX_ITEMS_DIRECT == nSurro )
+ {
+ rStream >> nVersion >> nLen;
+ rStream.SeekRel( nLen );
+ }
+ return 0;
+ }
+ }
+
+ // wird eine andere Version geladen?
+ FASTBOOL bCurVersion = pRefPool->IsCurrentVersionLoading();
+ if ( !bCurVersion )
+ // Which-Id auf neue Version mappen
+ nWhich = pRefPool->GetNewWhich( nWhich );
+
+ DBG_ASSERT( !nWhich || !pImp->bInSetItem ||
+ !pRefPool->ppStaticDefaults[pRefPool->GetIndex_Impl(nWhich)]->ISA(SfxSetItem),
+ "loading SetItem in ItemSet of SetItem" );
+
+ // soll "uber Surrogat geladen werden?
+ const SfxPoolItem *pItem = 0;
+ if ( !bDirect )
+ {
+ // Which-Id in dieser Version bekannt?
+ if ( nWhich )
+ // Surrogat laden, reagieren falls keins vorhanden
+ pItem = LoadSurrogate( rStream, nWhich, nSlot, pRefPool );
+ else
+ // sonst "uberspringen
+ rStream.SeekRel( sizeof(USHORT) );
+ }
+
+ // wird direkt, also nicht "uber Surrogat geladen?
+ if ( bDirect || ( nWhich && !pItem ) )
+ {
+ // bDirekt bzw. nicht IsPoolable() => Item direkt laden
+ USHORT nVersion;
+ sal_uInt32 nLen;
+ rStream >> nVersion >> nLen;
+ ULONG nIStart = rStream.Tell();
+
+ // Which-Id in dieser Version bekannt?
+ if ( nWhich )
+ {
+ // Item direkt laden
+ SfxPoolItem *pNewItem =
+ pRefPool->GetDefaultItem(nWhich).Create(rStream, nVersion);
+ if ( bDontPut )
+ pItem = pNewItem;
+ else
+ if ( pNewItem )
+ {
+ pItem = &Put(*pNewItem);
+ delete pNewItem;
+ }
+ else
+ pItem = 0;
+ ULONG nIEnd = rStream.Tell();
+ DBG_ASSERT( nIEnd <= (nIStart+nLen), "read past end of item" );
+ if ( (nIStart+nLen) != nIEnd )
+ rStream.Seek( nIStart+nLen );
+ }
+ else
+ // Item "uberspringen
+ rStream.Seek( nIStart+nLen );
+ }
+
+ return pItem;
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_poolitem.cxx b/binfilter/bf_svtools/source/items1/svt_poolitem.cxx
new file mode 100644
index 000000000000..788d770b7e61
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_poolitem.cxx
@@ -0,0 +1,413 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/poolitem.hxx>
+
+#include <tools/stream.hxx>
+
+namespace binfilter
+{
+
+// STATIC DATA -----------------------------------------------------------
+
+DBG_NAME(SfxPoolItem)
+DBG_NAME(SfxVoidItem)
+
+BYTE nSfxFlag8Val[8] =
+{
+ 1, 2, 4, 8, 16, 32, 64, 128
+};
+
+USHORT nSfxFlag16Val[16] =
+{
+ 1, 2, 4, 8, 16, 32, 64, 128, 256, 512,
+ 1024, 2048, 4096, 8192, 16384, 32768
+};
+
+ULONG nSfxFlag32Val[32] =
+{
+ 0x1L, 0x2L, 0x4L, 0x8L,
+ 0x10L, 0x20L, 0x40L, 0x80L,
+ 0x100L, 0x200L, 0x400L, 0x800L,
+ 0x1000L, 0x2000L, 0x40000L, 0x8000L,
+ 0x10000L, 0x20000L, 0x40000L, 0x80000L,
+ 0x100000L, 0x200000L, 0x400000L, 0x800000L,
+ 0x1000000L, 0x2000000L, 0x4000000L, 0x8000000L,
+ 0x10000000L, 0x20000000L, 0x40000000L, 0x80000000L
+};
+
+// RTTI ------------------------------------------------------------------
+
+TYPEINIT0(SfxPoolItem);
+TYPEINIT1(SfxVoidItem, SfxPoolItem);
+// @@@ TYPEINIT1(SfxInvalidItem, SfxPoolItem);
+TYPEINIT1(SfxSetItem, SfxPoolItem);
+// @@@ TYPEINIT1(SfxItemChangedHint, SfxHint);
+
+// ------------------------------------------------------------------------
+#if OSL_DEBUG_LEVEL > 1
+static ULONG nItemCount = 0;
+
+const char* pw1 = "Wow! 10.000 items!";
+const char* pw2 = "Wow! 100.000 items!";
+const char* pw3 = "Wow! 1.000.000 items!";
+const char* pw4 = "Wow! 50.000.000 items!";
+const char* pw5 = "Wow! 10.000.000 items!";
+#endif
+
+IMPL_PTRHINT(SfxPoolItemHint,SfxPoolItem)
+
+// SfxPoolItem -----------------------------------------------------------
+SfxPoolItem::SfxPoolItem( USHORT nW )
+ : nRefCount( 0 ),
+ nWhich( nW )
+ , nKind( 0 )
+{
+ DBG_CTOR(SfxPoolItem, 0);
+ DBG_ASSERT(nW <= SHRT_MAX, "Which Bereich ueberschritten");
+#if OSL_DEBUG_LEVEL > 1
+ ++nItemCount;
+ if ( pw1 && nItemCount>=10000 )
+ {
+ DBG_WARNING( pw1 );
+ pw1 = NULL;
+ }
+ if ( pw2 && nItemCount>=100000 )
+ {
+ DBG_WARNING( pw2 );
+ pw2 = NULL;
+ }
+ if ( pw3 && nItemCount>=1000000 )
+ {
+ DBG_WARNING( pw3 );
+ pw3 = NULL;
+ }
+ if ( pw4 && nItemCount>=5000000 )
+ {
+ DBG_WARNING( pw4 );
+ pw4 = NULL;
+ }
+ if ( pw5 && nItemCount>=10000000 )
+ {
+ DBG_WARNING( pw5 );
+ pw5 = NULL;
+ }
+#endif
+}
+
+// -----------------------------------------------------------------------
+SfxPoolItem::SfxPoolItem( const SfxPoolItem& rCpy )
+ : nRefCount( 0 ), // wird ja ein neues Object!
+ nWhich( rCpy.Which() ) // Funktion rufen wg. ChkThis()
+ , nKind( 0 )
+{
+ DBG_CTOR(SfxPoolItem, 0);
+#if OSL_DEBUG_LEVEL > 1
+ ++nItemCount;
+ if ( pw1 && nItemCount>=10000 )
+ {
+ DBG_WARNING( pw1 );
+ pw1 = NULL;
+ }
+ if ( pw2 && nItemCount>=100000 )
+ {
+ DBG_WARNING( pw2 );
+ pw2 = NULL;
+ }
+ if ( pw3 && nItemCount>=1000000 )
+ {
+ DBG_WARNING( pw3 );
+ pw3 = NULL;
+ }
+ if ( pw4 && nItemCount>=5000000 )
+ {
+ DBG_WARNING( pw4 );
+ pw4 = NULL;
+ }
+ if ( pw5 && nItemCount>=10000000 )
+ {
+ DBG_WARNING( pw5 );
+ pw5 = NULL;
+ }
+#endif
+}
+
+// ------------------------------------------------------------------------
+SfxPoolItem::~SfxPoolItem()
+{
+ DBG_DTOR(SfxPoolItem, 0);
+ DBG_ASSERT(nRefCount == 0 || nRefCount > SFX_ITEMS_MAXREF, "destroying item in use" );
+#if OSL_DEBUG_LEVEL > 1
+ --nItemCount;
+#endif
+}
+
+// ------------------------------------------------------------------------
+int SfxPoolItem::Compare( const SfxPoolItem& ) const
+{
+ return 0;
+}
+
+// ------------------------------------------------------------------------
+int SfxPoolItem::Compare( const SfxPoolItem& rWith, const ::IntlWrapper& ) const
+{
+ return Compare( rWith );
+}
+
+// ------------------------------------------------------------------------
+int SfxPoolItem::operator==( const SfxPoolItem& rCmp ) const
+{
+ DBG_CHKTHIS(SfxPoolItem, 0);
+ return rCmp.Type() == Type();
+}
+
+// -----------------------------------------------------------------------
+#ifndef TF_POOLABLE
+
+int SfxPoolItem::IsPoolable() const
+{
+ DBG_CHKTHIS(SfxPoolItem, 0);
+ return TRUE;
+}
+#endif
+
+// -----------------------------------------------------------------------
+SfxPoolItem* SfxPoolItem::Create(SvStream &, USHORT) const
+{
+ DBG_CHKTHIS(SfxPoolItem, 0);
+ return Clone(0);
+}
+
+// -----------------------------------------------------------------------
+USHORT SfxPoolItem::GetVersion( USHORT ) const
+{
+ DBG_CHKTHIS(SfxPoolItem, 0);
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+SvStream& SfxPoolItem::Store(SvStream &rStream, USHORT ) const
+{
+ DBG_CHKTHIS(SfxPoolItem, 0);
+ return rStream;
+}
+
+//============================================================================
+// static
+bool SfxPoolItem::readByteString(SvStream & rStream, UniString & rString)
+{
+ rStream.ReadByteString(rString);
+ return rStream.GetError() == ERRCODE_NONE;
+}
+
+//============================================================================
+// static
+void SfxPoolItem::writeByteString(SvStream & rStream,
+ UniString const & rString)
+{
+ rStream.WriteByteString(rString);
+}
+
+//============================================================================
+// static
+bool SfxPoolItem::readUnicodeString(SvStream & rStream, UniString & rString,
+ bool bUnicode)
+{
+ rStream.ReadByteString(rString,
+ bUnicode ? RTL_TEXTENCODING_UCS2 :
+ rStream.GetStreamCharSet());
+ return rStream.GetError() == ERRCODE_NONE;
+}
+
+//============================================================================
+// static
+void SfxPoolItem::writeUnicodeString(SvStream & rStream,
+ UniString const & rString)
+{
+ rStream.WriteByteString(rString, RTL_TEXTENCODING_UCS2);
+}
+
+// ------------------------------------------------------------------------
+SfxItemPresentation SfxPoolItem::GetPresentation
+(
+ SfxItemPresentation /*ePresentation*/, // IN: wie formatiert werden soll
+ SfxMapUnit /*eCoreMetric*/, // IN: Ma\seinheit des SfxPoolItems
+ SfxMapUnit /*ePresentationMetric*/, // IN: Wunsch-Ma\einheit der Darstellung
+ XubString& /*rText*/, // OUT: textuelle Darstellung
+ const ::IntlWrapper *
+) const
+
+/* [Beschreibung]
+
+ "Uber diese virtuelle Methode kann von den SfxPoolItem-Subklassen
+ eine textuelle Datstellung des Wertes erhalten werden. Sie sollte
+ von allen UI-relevanten SfxPoolItem-Subklassen "uberladen werden.
+
+ Da die Ma\seinheit des Wertes im SfxItemPool nur "uber
+ <SfxItemPool::GetMetric(USHORT)const> erfragbar ist, und nicht etwa
+ in der SfxPoolItem-Instanz oder -Subklasse verf"ugbar ist, wird die
+ eigene Ma\seinheit als 'eCoreMetric' "ubergeben.
+
+ Die darzustellende Ma\seinheit wird als 'ePresentationMetric'
+ "ubergeben.
+
+
+ [R"uckgabewert]
+
+ SfxItemPresentation SFX_ITEM_PRESENTATION_NONE
+ es konnte keine Text-Darstellung erzeugt werden
+
+ SFX_ITEM_PRESENTATION_NAMELESS
+ es konnte eine Text-Darstellung (ggf. mit
+ Ma\seinheit) erzeugt werden, die jedoch keine
+ semantische Bedeutung enth"alt
+
+ SFX_ITEM_PRESENTATION_COMPLETE
+ es konnte eine komplette Text-Darstellung mit
+ semantischer Bedeutung (und ggf. Ma\seinheit)
+ erzeugt werden
+
+
+ [Beispiele]
+
+ pSvxFontItem->GetPresentation( SFX_PRESENTATION_NAMELESS, ... )
+ "12pt" mit return SFX_ITEM_PRESENTATION_NAMELESS
+
+ pSvxColorItem->GetPresentation( SFX_PRESENTATION_COMPLETE, ... )
+ "rot" mit return SFX_ITEM_PRESENTATION_NAMELESS
+ (das das SvxColorItem nicht wei\s, was f"ur eine Farbe es darstellt,
+ kann es keinen Namen angeben, was durch den Returnwert mitgeteilt wird.
+
+ pSvxBorderItem->GetPresentation( SFX_PRESENTATION_COMPLETE, ... )
+ "1cm oberer Rand, 2cm linker Rand, 0,2cm unterer Rand, ..."
+*/
+
+{
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+// SfxVoidItem ------------------------------------------------------------
+SfxVoidItem::SfxVoidItem( USHORT which ):
+ SfxPoolItem(which)
+{
+ DBG_CTOR(SfxVoidItem, 0);
+}
+
+// SfxVoidItem ------------------------------------------------------------
+SfxVoidItem::SfxVoidItem( const SfxVoidItem& rCopy):
+ SfxPoolItem(rCopy)
+{
+ DBG_CTOR(SfxVoidItem, 0);
+}
+
+// ------------------------------------------------------------------------
+int SfxVoidItem::operator==( const SfxPoolItem&
+#ifdef DBG_UTIL
+rCmp
+#endif
+) const
+{
+ DBG_CHKTHIS(SfxVoidItem, 0);
+ DBG_ASSERT( SfxPoolItem::operator==( rCmp ), "unequal type" );
+ return TRUE;
+}
+
+// ------------------------------------------------------------------------
+SfxItemPresentation SfxVoidItem::GetPresentation
+(
+ SfxItemPresentation /*ePresentation*/,
+ SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/,
+ XubString& rText,
+ const ::IntlWrapper *
+) const
+{
+ DBG_CHKTHIS(SfxVoidItem, 0);
+ rText.AssignAscii(RTL_CONSTASCII_STRINGPARAM("Void"));
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+// ------------------------------------------------------------------------
+SfxPoolItem* SfxVoidItem::Clone(SfxItemPool *) const
+{
+ DBG_CHKTHIS(SfxVoidItem, 0);
+ return new SfxVoidItem(*this);
+}
+
+// ------------------------------------------------------------------------
+int SfxPoolItem::ScaleMetrics( long /*lMult*/, long /*lDiv*/ )
+{
+ return 0;
+}
+
+// ------------------------------------------------------------------------
+int SfxPoolItem::HasMetrics() const
+{
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+#if 0 /* @@@ NOT USED @@@ */
+void SfxPoolItem::GetVersion() const
+{
+ DBG_ERROR( "dummy called" );
+}
+
+// -----------------------------------------------------------------------
+void SfxPoolItem::Store(SvStream &rStream) const
+{
+ DBG_ERROR( "dummy called" );
+}
+#endif /* @@@ NOT USED @@@ */
+
+// -----------------------------------------------------------------------
+
+bool SfxPoolItem::QueryValue( com::sun::star::uno::Any&, BYTE ) const
+{
+ DBG_ERROR("There is no implementation for QueryValue for this item!");
+ return false;
+}
+
+// -----------------------------------------------------------------------
+
+bool SfxPoolItem::PutValue( const com::sun::star::uno::Any&, BYTE )
+{
+ DBG_ERROR("There is no implementation for PutValue for this item!");
+ return false;
+}
+
+SfxVoidItem::~SfxVoidItem()
+{
+ DBG_DTOR(SfxVoidItem, 0);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_sfontitm.cxx b/binfilter/bf_svtools/source/items1/svt_sfontitm.cxx
new file mode 100644
index 000000000000..87c8c52ea8aa
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_sfontitm.cxx
@@ -0,0 +1,148 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/stream.hxx>
+#include <tools/vcompat.hxx>
+
+#include <bf_svtools/sfontitm.hxx>
+
+namespace binfilter
+{
+
+//============================================================================
+//
+// class SfxFontItem
+//
+//============================================================================
+
+TYPEINIT1(SfxFontItem, SfxPoolItem);
+
+//============================================================================
+// virtual
+int SfxFontItem::operator ==(const SfxPoolItem & rItem) const
+{
+ const SfxFontItem * pFontItem = PTR_CAST(SfxFontItem, &rItem);
+ return pFontItem && m_bHasFont == pFontItem->m_bHasFont
+ && m_bHasColor == pFontItem->m_bHasColor
+ && m_bHasFillColor == pFontItem->m_bHasFillColor
+ && (!m_bHasColor || m_aColor == pFontItem->m_aColor)
+ && (!m_bHasFillColor || m_aFillColor == pFontItem->m_aFillColor)
+ && (!m_bHasFont || (m_bKerning == pFontItem->m_bKerning
+ && m_bShadow == pFontItem->m_bShadow
+ && m_bOutline == pFontItem->m_bOutline
+ && m_bWordLine == pFontItem->m_bWordLine
+ && m_nOrientation == pFontItem->m_nOrientation
+ && m_nStrikeout == pFontItem->m_nStrikeout
+ && m_nUnderline == pFontItem->m_nUnderline
+ && m_nItalic == pFontItem->m_nItalic
+ && m_nWidthType == pFontItem->m_nWidthType
+ && m_nWeight == pFontItem->m_nWeight
+ && m_nPitch == pFontItem->m_nPitch
+ && m_nFamily == pFontItem->m_nFamily
+ && m_nLanguage == pFontItem->m_nLanguage
+ && m_nCharSet == pFontItem->m_nCharSet
+ && m_aFillColor == pFontItem->m_aFillColor
+ && m_aColor == pFontItem->m_aColor
+ && m_aSize == pFontItem->m_aSize
+ && m_aStyleName == pFontItem->m_aStyleName
+ && m_aName == pFontItem->m_aName));
+}
+
+//============================================================================
+// virtual
+SfxPoolItem * SfxFontItem::Create(SvStream & rStream, USHORT) const
+{
+ VersionCompat aItemCompat(rStream, STREAM_READ);
+ SfxFontItem * pItem = new SfxFontItem(Which());
+ {
+ VersionCompat aFontCompat(rStream, STREAM_READ);
+ readByteString(rStream, pItem->m_aName);
+ readByteString(rStream, pItem->m_aStyleName);
+ rStream >> pItem->m_aSize;
+ sal_Int16 nCharSet = 0;
+ rStream >> nCharSet;
+ pItem->m_nCharSet = rtl_TextEncoding(nCharSet);
+ rStream >> pItem->m_nFamily >> pItem->m_nPitch >> pItem->m_nWeight
+ >> pItem->m_nUnderline >> pItem->m_nStrikeout
+ >> pItem->m_nItalic;
+ sal_Int16 nLanguage = 0;
+ rStream >> nLanguage;
+ pItem->m_nLanguage = LanguageType(nLanguage);
+ rStream >> pItem->m_nWidthType >> pItem->m_nOrientation;
+ sal_Int8 nWordLine = 0;
+ rStream >> nWordLine;
+ pItem->m_bWordLine = nWordLine != 0;
+ sal_Int8 nOutline = 0;
+ rStream >> nOutline;
+ pItem->m_bOutline = nOutline != 0;
+ sal_Int8 nShadow = 0;
+ rStream >> nShadow;
+ pItem->m_bShadow = nShadow != 0;
+ sal_Int8 nKerning = 0;
+ rStream >> nKerning;
+ pItem->m_bKerning = nKerning != 0;
+ }
+ pItem->m_aColor.Read(rStream, TRUE);
+ pItem->m_aFillColor.Read(rStream, TRUE);
+ sal_Int16 nFlags = 0;
+ rStream >> nFlags;
+ pItem->m_bHasFont = (nFlags & 4) != 0;
+ pItem->m_bHasColor = (nFlags & 1) != 0;
+ pItem->m_bHasFillColor = (nFlags & 2) != 0;
+ return pItem;
+}
+
+//============================================================================
+// virtual
+SvStream & SfxFontItem::Store(SvStream & rStream, USHORT) const
+{
+ VersionCompat aItemCompat(rStream, STREAM_WRITE, 1);
+ {
+ VersionCompat aFontCompat(rStream, STREAM_WRITE, 1);
+ writeByteString(rStream, m_aName);
+ writeByteString(rStream, m_aStyleName);
+ rStream << m_aSize << sal_Int16(m_nCharSet)
+ << m_nFamily << m_nPitch << m_nWeight << m_nUnderline
+ << m_nStrikeout << m_nItalic << sal_Int16(m_nLanguage)
+ << m_nWidthType << m_nOrientation << sal_Int8(m_bWordLine)
+ << sal_Int8(m_bOutline) << sal_Int8(m_bShadow)
+ << sal_Int8(m_bKerning);
+ }
+ SAL_CONST_CAST(Color &, m_aColor).Write(rStream, TRUE);
+ SAL_CONST_CAST(Color &, m_aFillColor).Write(rStream, TRUE);
+ rStream << sal_Int16(m_bHasFont << 2 | m_bHasColor
+ | m_bHasFillColor << 1);
+ return rStream;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_sitem.cxx b/binfilter/bf_svtools/source/items1/svt_sitem.cxx
new file mode 100644
index 000000000000..91f994dae563
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_sitem.cxx
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 ---------------------------------------------------------------
+#include <tools/string.hxx>
+#include <tools/stream.hxx>
+
+#include <bf_svtools/poolitem.hxx>
+#include <bf_svtools/itemset.hxx>
+
+namespace binfilter
+{
+
+// STATIC DATA -----------------------------------------------------------
+
+DBG_NAME(SfxSetItem)
+
+// --------------------------------------------------------------------------
+
+SfxSetItem::SfxSetItem( USHORT which, const SfxItemSet &rSet) :
+ SfxPoolItem(which),
+ pSet(rSet.Clone(TRUE))
+{
+ DBG_CTOR(SfxSetItem, 0);
+}
+
+// --------------------------------------------------------------------------
+
+SfxSetItem::SfxSetItem( USHORT which, SfxItemSet *pS) :
+ SfxPoolItem(which),
+ pSet(pS)
+{
+ DBG_CTOR(SfxSetItem, 0);
+ DBG_ASSERT(pS, "SfxSetItem without set constructed" );
+}
+
+// --------------------------------------------------------------------------
+
+SfxSetItem::SfxSetItem( const SfxSetItem& rCopy, SfxItemPool *pPool ) :
+ SfxPoolItem(rCopy.Which()),
+ pSet(rCopy.pSet->Clone(TRUE, pPool))
+{
+ DBG_CTOR(SfxSetItem, 0);
+}
+
+// --------------------------------------------------------------------------
+
+SfxSetItem::~SfxSetItem()
+{
+ DBG_DTOR(SfxSetItem, 0);
+ delete pSet; pSet = 0;
+}
+
+// --------------------------------------------------------------------------
+
+int SfxSetItem::operator==( const SfxPoolItem& rCmp) const
+{
+ DBG_CHKTHIS(SfxSetItem, 0);
+ DBG_ASSERT( SfxPoolItem::operator==( rCmp ), "unequal type" );
+ return *pSet == *(((const SfxSetItem &)rCmp).pSet);
+}
+
+// --------------------------------------------------------------------------
+
+SfxItemPresentation SfxSetItem::GetPresentation
+(
+ SfxItemPresentation /*ePresentation*/,
+ SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/,
+ XubString& /*rText*/,
+ const ::IntlWrapper *
+) const
+{
+ DBG_CHKTHIS(SfxSetItem, 0);
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+// --------------------------------------------------------------------------
+
+SvStream& SfxSetItem::Store(SvStream& rStream, USHORT) const
+{
+ GetItemSet().Store(rStream);
+ return rStream;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_slstitm.cxx b/binfilter/bf_svtools/source/items1/svt_slstitm.cxx
new file mode 100644
index 000000000000..9a6e34a36c3e
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_slstitm.cxx
@@ -0,0 +1,343 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/slstitm.hxx>
+
+#include <bf_svtools/poolitem.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <tools/stream.hxx>
+
+namespace binfilter
+{
+
+// STATIC DATA -----------------------------------------------------------
+
+DBG_NAME(SfxStringListItem)
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1_AUTOFACTORY(SfxStringListItem, SfxPoolItem);
+
+class SfxImpStringList
+{
+public:
+ USHORT nRefCount;
+ List aList;
+
+ SfxImpStringList() { nRefCount = 1; }
+ ~SfxImpStringList();
+};
+
+//------------------------------------------------------------------------
+
+SfxImpStringList::~SfxImpStringList()
+{
+ DBG_ASSERT(nRefCount!=0xffff,"ImpList already deleted");
+ String* pStr = (String*)aList.First();
+ while( pStr )
+ {
+ delete pStr;
+ pStr = (String*)aList.Next();
+ }
+ nRefCount = 0xffff;
+}
+
+// class SfxStringListItem -----------------------------------------------
+
+SfxStringListItem::SfxStringListItem() :
+ pImp(NULL)
+{
+}
+
+//------------------------------------------------------------------------
+
+SfxStringListItem::SfxStringListItem( USHORT which, SvStream& rStream ) :
+ SfxPoolItem( which ),
+ pImp(NULL)
+{
+ long nEntryCount;
+ rStream >> nEntryCount;
+
+ if( nEntryCount )
+ pImp = new SfxImpStringList;
+
+ long i;
+ String* pStr;
+ for( i=0; i < nEntryCount; i++ )
+ {
+ pStr = new String;
+ readByteString(rStream, *pStr);
+ pImp->aList.Insert( pStr, LIST_APPEND );
+ }
+}
+
+//------------------------------------------------------------------------
+
+SfxStringListItem::SfxStringListItem( const SfxStringListItem& rItem ) :
+ SfxPoolItem( rItem ),
+ pImp(NULL)
+{
+ pImp = rItem.pImp;
+
+ if( pImp )
+ {
+ DBG_ASSERT(pImp->nRefCount!=0xffff,"ImpList not valid");
+ pImp->nRefCount++;
+ }
+}
+
+//------------------------------------------------------------------------
+
+SfxStringListItem::~SfxStringListItem()
+{
+ if( pImp )
+ {
+ DBG_ASSERT(pImp->nRefCount!=0xffff,"ImpList not valid");
+ if( pImp->nRefCount > 1 )
+ pImp->nRefCount--;
+ else
+ delete pImp;
+ }
+}
+
+//------------------------------------------------------------------------
+
+int SfxStringListItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+
+ SfxStringListItem* pItem = (SfxStringListItem*)&rItem;
+
+ if( pImp == pItem->pImp )
+ return TRUE;
+ else
+ return FALSE;
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SfxStringListItem::GetPresentation
+(
+ SfxItemPresentation /*ePresentation*/,
+ SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/,
+ XubString& rText,
+ const ::IntlWrapper *
+) const
+{
+ rText.AssignAscii(RTL_CONSTASCII_STRINGPARAM("(List)"));
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* SfxStringListItem::Clone( SfxItemPool *) const
+{
+ return new SfxStringListItem( *this );
+ /*
+ if( pImp )
+ return new SfxStringListItem( Which(), &(pImp->aList) );
+ else
+ return new SfxStringListItem( Which(), NULL );
+ */
+
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* SfxStringListItem::Create( SvStream & rStream, USHORT ) const
+{
+ return new SfxStringListItem( Which(), rStream );
+}
+
+//------------------------------------------------------------------------
+
+SvStream& SfxStringListItem::Store( SvStream & rStream, USHORT ) const
+{
+ if( !pImp )
+ {
+ rStream << 0L;
+ return rStream;
+ }
+
+ DBG_ASSERT(pImp->nRefCount!=0xffff,"ImpList not valid");
+
+ long nCount = pImp->aList.Count();
+ rStream << nCount;
+
+ long i;
+ String* pStr;
+ for( i=0; i < nCount; i++ )
+ {
+ pStr = (String*)(pImp->aList.GetObject( i ));
+ writeByteString(rStream, *pStr);
+ }
+
+ return rStream;
+}
+
+//------------------------------------------------------------------------
+
+void SfxStringListItem::SetString( const XubString& rStr )
+{
+ DBG_ASSERT(GetRefCount()==0,"SetString:RefCount!=0");
+
+ if ( pImp && (pImp->nRefCount == 1) )
+ delete pImp;
+ else
+ if( pImp )
+ pImp->nRefCount--;
+ pImp = new SfxImpStringList;
+
+ xub_StrLen nStart = 0;
+ xub_StrLen nDelimPos;
+ XubString aStr(rStr);
+ aStr.ConvertLineEnd(LINEEND_CR);
+ do
+ {
+ nDelimPos = aStr.Search( _CR, nStart );
+ xub_StrLen nLen;
+ if ( nDelimPos == STRING_NOTFOUND )
+ nLen = 0xffff;
+ else
+ nLen = nDelimPos - nStart;
+
+ XubString* pStr = new XubString(aStr.Copy(nStart, nLen));
+ // String gehoert der Liste
+ pImp->aList.Insert( pStr, LIST_APPEND );
+
+ nStart += nLen + 1 ; // delimiter ueberspringen
+ } while( nDelimPos != STRING_NOTFOUND );
+
+ // Kein Leerstring am Ende
+ if( pImp->aList.Last() &&
+ !((XubString*)pImp->aList.Last())->Len() )
+ delete (XubString*)pImp->aList.Remove( pImp->aList.Count()-1 );
+}
+
+//------------------------------------------------------------------------
+
+XubString SfxStringListItem::GetString()
+{
+ XubString aStr;
+ if ( pImp )
+ {
+ DBG_ASSERT(pImp->nRefCount!=0xffff,"ImpList not valid");
+ XubString* pStr = (XubString*)(pImp->aList.First());
+ while( pStr )
+ {
+ aStr += *pStr;
+ pStr = (XubString*)(pImp->aList.Next());
+ if ( pStr )
+ aStr += '\r';
+ }
+ }
+ aStr.ConvertLineEnd();
+ return aStr;
+}
+
+//------------------------------------------------------------------------
+
+#ifndef TF_POOLABLE
+
+int SfxStringListItem::IsPoolable() const
+{
+ return FALSE;
+}
+
+#endif
+
+//------------------------------------------------------------------------
+
+void SfxStringListItem::SetStringList( const com::sun::star::uno::Sequence< rtl::OUString >& rList )
+{
+ DBG_ASSERT(GetRefCount()==0,"SetString:RefCount!=0");
+
+ if ( pImp && (pImp->nRefCount == 1) )
+ delete pImp;
+ else
+ if( pImp )
+ pImp->nRefCount--;
+ pImp = new SfxImpStringList;
+
+ for ( sal_Int32 n = 0; n < rList.getLength(); n++ )
+ {
+ XubString* pStr = new XubString( rList[n] );
+ // String gehoert der Liste
+ pImp->aList.Insert( pStr, LIST_APPEND );
+ }
+}
+
+//----------------------------------------------------------------------------
+void SfxStringListItem::GetStringList( com::sun::star::uno::Sequence< rtl::OUString >& rList ) const
+{
+ long nCount = pImp->aList.Count();
+
+ rList.realloc( nCount );
+ for( long i=0; i < nCount; i++ )
+ rList[i] = *(String*)(pImp->aList.GetObject( i ));
+}
+
+//----------------------------------------------------------------------------
+// virtual
+bool SfxStringListItem::PutValue( const com::sun::star::uno::Any& rVal,BYTE )
+{
+ com::sun::star::uno::Sequence< rtl::OUString > aValue;
+ if ( rVal >>= aValue )
+ {
+ SetStringList( aValue );
+ return true;
+ }
+
+ DBG_ERROR( "SfxStringListItem::PutValue - Wrong type!" );
+ return false;
+}
+
+//----------------------------------------------------------------------------
+// virtual
+bool SfxStringListItem::QueryValue( com::sun::star::uno::Any& rVal,BYTE ) const
+{
+ // GetString() is not const!!!
+ SfxStringListItem* pThis = const_cast< SfxStringListItem * >( this );
+
+ com::sun::star::uno::Sequence< rtl::OUString > aStringList;
+ pThis->GetStringList( aStringList );
+ rVal = ::com::sun::star::uno::makeAny( aStringList );
+ return true;
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_stylepool.cxx b/binfilter/bf_svtools/source/items1/svt_stylepool.cxx
new file mode 100644
index 000000000000..83e4ea3c1ae3
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_stylepool.cxx
@@ -0,0 +1,271 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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.
+ *
+ ************************************************************************/
+
+#ifdef _MSC_VER
+#pragma hdrstop
+#endif
+
+#include <vector>
+#include <map>
+
+#include "stylepool.hxx"
+#include <bf_svtools/itemiter.hxx>
+#include <bf_svtools/itempool.hxx>
+
+
+using namespace boost;
+
+namespace binfilter
+{
+ // A "Node" represents a subset of inserted SfxItemSets
+ // The root node represents the empty set
+ // The other nodes contain a SfxPoolItem and represents an item set which contains their
+ // pool item and the pool items of their parents.
+ class Node
+ {
+ std::vector<Node*> mChildren; // child nodes, create by findChildNode(..)
+ std::vector< StylePool::SfxItemSet_Pointer_t > aItemSet; // shared pointer an inserted item set or nul
+ const SfxPoolItem *pItem; // my pool item
+ Node *pUpper; // if I'm a child node that's my parent node
+ public:
+ Node() : pItem( 0 ), pUpper( 0 ) {} // root node Ctor
+ Node( const SfxPoolItem& rItem, Node* pParent ) : // child node Ctor
+ pItem( rItem.Clone() ), pUpper( pParent ){}
+ ~Node();
+ bool hasItemSet() const { return 0 < aItemSet.size(); }
+ const StylePool::SfxItemSet_Pointer_t getItemSet() const { return aItemSet[aItemSet.size()-1]; }
+ void setItemSet( const SfxItemSet& rSet ){ aItemSet.push_back( StylePool::SfxItemSet_Pointer_t( rSet.Clone() ) ); }
+ Node* findChildNode( const SfxPoolItem& rItem );
+ Node* nextItemSet( Node* pLast );
+ const SfxPoolItem& getPoolItem() const { return *pItem; }
+ };
+
+ Node* Node::findChildNode( const SfxPoolItem& rItem )
+ {
+ Node* pNextNode = this;
+ std::vector<Node*>::iterator aIter = mChildren.begin();
+ while( aIter != mChildren.end() )
+ {
+ if( rItem.Which() == (*aIter)->getPoolItem().Which() &&
+ rItem == (*aIter)->getPoolItem() )
+ return *aIter;
+ ++aIter;
+ }
+ pNextNode = new Node( rItem, pNextNode );
+ mChildren.push_back( pNextNode );
+ return pNextNode;
+ }
+
+ /* Find the next node which has a SfxItemSet.
+ The input parameter pLast has a sophisticated meaning:
+ downstairs only:
+ pLast == 0 => scan your children and their children
+ but neither your parents neither your siblings
+ downstairs and upstairs:
+ pLast == this => scan your children, their children,
+ the children of your parent behind you, and so on
+ partial downstairs and upstairs
+ pLast != 0 && pLast != this => scan your children behind the given children,
+ the children of your parent behind you and so on.
+ */
+
+ Node* Node::nextItemSet( Node* pLast )
+ {
+ // Searching downstairs
+ std::vector<Node*>::iterator aIter = mChildren.begin();
+ // For pLast == 0 and pLast == this all children are of interest
+ // for another pLast the search starts behind pLast...
+ if( pLast && pLast != this )
+ {
+ aIter = std::find( mChildren.begin(), mChildren.end(), pLast );
+ if( aIter != mChildren.end() )
+ ++aIter;
+ }
+ Node *pNext = 0;
+ while( aIter != mChildren.end() )
+ {
+ pNext = *aIter;
+ if( pNext->hasItemSet() ) // any child with item set?
+ return pNext;
+ pNext = pNext->nextItemSet( 0 ); // 0 => downstairs only
+ if( pNext )
+ return pNext;
+ ++aIter;
+ }
+ // Searching upstairs
+ if( pLast && pUpper )
+ pNext = pUpper->nextItemSet( this );
+ return pNext;
+ }
+
+ Node::~Node()
+ {
+ std::vector<Node*>::iterator aIter = mChildren.begin();
+ while( aIter != mChildren.end() )
+ {
+ delete *aIter;
+ ++aIter;
+ }
+ delete pItem;
+ }
+
+ class Iterator : public IStylePoolIteratorAccess
+ {
+ std::map< const SfxItemSet*, Node >& rRoot;
+ std::map< const SfxItemSet*, Node >::iterator pCurrNode;
+ Node* pNode;
+ public:
+ Iterator( std::map< const SfxItemSet*, Node >& rR )
+ : rRoot( rR ), pCurrNode( rR.begin() ), pNode(0) {}
+ virtual StylePool::SfxItemSet_Pointer_t getNext();
+ virtual ::rtl::OUString getName();
+ };
+
+ StylePool::SfxItemSet_Pointer_t Iterator::getNext()
+ {
+ StylePool::SfxItemSet_Pointer_t pReturn;
+ while( pNode || pCurrNode != rRoot.end() )
+ {
+ if( !pNode )
+ {
+ pNode = &pCurrNode->second;
+ ++pCurrNode;
+ if( pNode->hasItemSet() )
+ return pNode->getItemSet();
+ }
+ pNode = pNode->nextItemSet( pNode );
+ if( pNode && pNode->hasItemSet() )
+ return pNode->getItemSet();
+ }
+ return pReturn;
+ }
+
+ ::rtl::OUString Iterator::getName()
+ {
+ ::rtl::OUString aString;
+ if( pNode && pNode->hasItemSet() )
+ aString = StylePool::nameOf( pNode->getItemSet() );
+ return aString;
+ }
+
+
+/* This static method creates a unique name from a shared pointer to a SfxItemSet
+ The name is the memory address of the SfxItemSet itself. */
+
+::rtl::OUString StylePool::nameOf( SfxItemSet_Pointer_t pSet )
+{
+ return ::rtl::OUString::valueOf( reinterpret_cast<sal_IntPtr>( pSet.get() ), 16 );
+}
+
+// class StylePoolImpl organized a tree-structure where every node represents a SfxItemSet.
+// The insertItemSet method adds a SfxItemSet into the tree if necessary and returns a shared_ptr
+// to a copy of the SfxItemSet.
+// The aRoot-Node represents an empty SfxItemSet.
+
+class StylePoolImpl
+{
+private:
+ std::map< const SfxItemSet*, Node > aRoot;
+ sal_Int32 nCount;
+public:
+ StylePoolImpl() : nCount(0) {}
+ StylePool::SfxItemSet_Pointer_t insertItemSet( const SfxItemSet& rSet );
+ IStylePoolIteratorAccess* createIterator();
+ sal_Int32 getCount() const { return nCount; }
+};
+
+StylePool::SfxItemSet_Pointer_t StylePoolImpl::insertItemSet( const SfxItemSet& rSet )
+{
+ bool bNonPoolable = false;
+ Node* pCurNode = &aRoot[ rSet.GetParent() ];
+ SfxItemIter aIter( rSet );
+ const SfxPoolItem* pItem = aIter.GetCurItem();
+ // Every SfxPoolItem in the SfxItemSet causes a step deeper into the tree,
+ // a complete empty SfxItemSet would stay at the root node.
+ while( pItem )
+ {
+ if( !rSet.GetPool()->IsItemFlag(pItem->Which(), SFX_ITEM_POOLABLE ) )
+ bNonPoolable = true;
+ pCurNode = pCurNode->findChildNode( *pItem );
+ pItem = aIter.NextItem();
+ }
+ // Every leaf node represents an inserted item set, but "non-leaf" nodes represents subsets
+ // of inserted itemsets.
+ // These nodes could have but does not need to have a shared_ptr to a item set.
+ if( !pCurNode->hasItemSet() )
+ {
+ pCurNode->setItemSet( rSet );
+ bNonPoolable = false; // to avoid a double insertion
+ ++nCount;
+ }
+ // If rSet contains at least one non poolable item, a new itemset has to be inserted
+ if( bNonPoolable )
+ pCurNode->setItemSet( rSet );
+#ifdef DEBUG
+ {
+ sal_Int32 nCheck = -1;
+ sal_Int32 nNo = -1;
+ IStylePoolIteratorAccess* pIter = createIterator();
+ StylePool::SfxItemSet_Pointer_t pTemp;
+ do
+ {
+ ++nCheck;
+ pTemp = pIter->getNext();
+ if( pCurNode->hasItemSet() && pTemp.get() == pCurNode->getItemSet().get() )
+ {
+ ::rtl::OUString aStr = pIter->getName();
+ nNo = nCheck;
+ }
+ } while( pTemp.get() );
+ DBG_ASSERT( nCount == nCheck, "Wrong counting");
+ delete pIter;
+ }
+#endif
+ return pCurNode->getItemSet();
+}
+
+IStylePoolIteratorAccess* StylePoolImpl::createIterator()
+{ return new Iterator( aRoot ); }
+
+// Ctor, Dtor and redirected methods of class StylePool, nearly inline ;-)
+
+StylePool::SfxItemSet_Pointer_t StylePool::insertItemSet( const SfxItemSet& rSet )
+{ return pImpl->insertItemSet( rSet ); }
+
+IStylePoolIteratorAccess* StylePool::createIterator()
+{ return pImpl->createIterator(); }
+
+sal_Int32 StylePool::getCount() const
+{ return pImpl->getCount(); }
+
+StylePool::~StylePool() { delete pImpl; }
+
+// End of class StylePool
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_tfrmitem.cxx b/binfilter/bf_svtools/source/items1/svt_tfrmitem.cxx
new file mode 100644
index 000000000000..0c570e54e31d
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_tfrmitem.cxx
@@ -0,0 +1,166 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <com/sun/star/uno/Any.hxx>
+
+#include <tools/stream.hxx>
+#include <tools/debug.hxx>
+#include <tools/string.hxx>
+
+#include <bf_svtools/tfrmitem.hxx>
+
+namespace binfilter
+{
+
+DBG_NAME( SfxTargetFrameItem )
+TYPEINIT1( SfxTargetFrameItem, SfxPoolItem );
+
+// -----------------------------------------------------------------------
+
+SfxTargetFrameItem::SfxTargetFrameItem( USHORT which ) :
+ SfxPoolItem( which )
+{
+ DBG_CTOR( SfxTargetFrameItem, 0 );
+}
+
+// -----------------------------------------------------------------------
+
+SfxTargetFrameItem::SfxTargetFrameItem( const SfxTargetFrameItem& rItem ) :
+ SfxPoolItem( rItem )
+{
+ DBG_CTOR( SfxTargetFrameItem, 0 );
+ for( USHORT nCur = 0; nCur <= (USHORT)SfxOpenModeLast; nCur++ )
+ _aFrames[nCur] = rItem._aFrames[nCur];
+}
+
+// -----------------------------------------------------------------------
+
+SfxTargetFrameItem::~SfxTargetFrameItem()
+{
+ DBG_DTOR(SfxTargetFrameItem, 0);
+}
+
+// -----------------------------------------------------------------------
+
+int SfxTargetFrameItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_CHKTHIS( SfxTargetFrameItem, 0 );
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+
+ for( USHORT nCur = 0; nCur <= (USHORT)SfxOpenModeLast; nCur++ )
+ {
+ if( _aFrames[nCur] != ((const SfxTargetFrameItem&)rItem)._aFrames[nCur] )
+ return 0;
+ }
+ return 1;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxTargetFrameItem::Create( SvStream& rStream, USHORT ) const
+{
+ DBG_CHKTHIS(SfxTargetFrameItem, 0);
+ SfxTargetFrameItem* pItem = new SfxTargetFrameItem( Which() );
+ USHORT nCount = 0;
+ rStream >> nCount;
+ for(USHORT nCur=0; nCur<= (USHORT)SfxOpenModeLast && nCount; nCur++,nCount--)
+ {
+ readByteString(rStream, pItem->_aFrames[ nCur ]);
+ }
+ // die uebriggebliebenen ueberspringen
+ String aTemp;
+ while( nCount )
+ {
+ readByteString(rStream, aTemp);
+ nCount--;
+ }
+ return pItem;
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SfxTargetFrameItem::Store( SvStream& rStream, USHORT ) const
+{
+ DBG_CHKTHIS( SfxTargetFrameItem, 0 );
+ USHORT nCount = (USHORT)(SfxOpenModeLast+1);
+ rStream << nCount;
+ for( USHORT nCur = 0; nCur <= (USHORT)SfxOpenModeLast; nCur++ )
+ {
+ writeByteString(rStream, _aFrames[ nCur ]);
+ }
+ return rStream;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxTargetFrameItem::Clone( SfxItemPool* ) const
+{
+ DBG_CHKTHIS( SfxTargetFrameItem, 0 );
+ return new SfxTargetFrameItem( *this );
+}
+
+// -----------------------------------------------------------------------
+// virtual
+bool SfxTargetFrameItem::QueryValue( com::sun::star::uno::Any& rVal,BYTE ) const
+{
+ String aVal;
+ for ( int i = 0; i <= SfxOpenModeLast; i++ )
+ {
+ aVal += _aFrames[ i ];
+ aVal += ';' ;
+ }
+
+ rVal <<= rtl::OUString( aVal );
+ return true;
+}
+
+// -----------------------------------------------------------------------
+// virtual
+bool SfxTargetFrameItem::PutValue( const com::sun::star::uno::Any& rVal,BYTE )
+{
+ rtl::OUString aValue;
+ if ( rVal >>= aValue )
+ {
+ const String aVal( aValue );
+
+ for ( USHORT i = 0; i <= SfxOpenModeLast; i++ )
+ _aFrames[ i ] = aVal.GetToken( i );
+
+ return true;
+ }
+
+ DBG_ERROR( "SfxTargetFrameItem::PutValue - Wrong type!" );
+ return false;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_tresitem.cxx b/binfilter/bf_svtools/source/items1/svt_tresitem.cxx
new file mode 100644
index 000000000000..bc59ddf234b7
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_tresitem.cxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/tresitem.hxx>
+
+using namespace com::sun::star;
+
+namespace binfilter
+{
+
+//============================================================================
+//
+// CntTransferResultItem
+//
+//============================================================================
+
+TYPEINIT1_AUTOFACTORY(CntTransferResultItem, SfxPoolItem)
+
+//============================================================================
+// virtual
+int CntTransferResultItem::operator ==(SfxPoolItem const & rItem) const
+{
+ if (CntTransferResultItem * pResultItem = PTR_CAST(CntTransferResultItem,
+ &rItem))
+ return m_aResult.Source == pResultItem->m_aResult.Source
+ && m_aResult.Target == pResultItem->m_aResult.Target
+ && m_aResult.Result == pResultItem->m_aResult.Result;
+ return false;
+}
+
+//============================================================================
+// virtual
+bool CntTransferResultItem::QueryValue(uno::Any & rVal, BYTE) const
+{
+ rVal <<= m_aResult;
+ return true;
+}
+
+//============================================================================
+// virtual
+bool CntTransferResultItem::PutValue(uno::Any const & rVal, BYTE)
+{
+ return rVal >>= m_aResult;
+}
+
+//============================================================================
+// virtual
+SfxPoolItem * CntTransferResultItem::Clone(SfxItemPool *) const
+{
+ return new CntTransferResultItem(*this);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_visitem.cxx b/binfilter/bf_svtools/source/items1/svt_visitem.cxx
new file mode 100644
index 000000000000..5835c45110ed
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_visitem.cxx
@@ -0,0 +1,153 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/visitem.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <tools/stream.hxx>
+
+namespace binfilter
+{
+
+//============================================================================
+//
+// class SfxVisibilityItem
+//
+//============================================================================
+
+DBG_NAME(SfxVisibilityItem)
+
+//============================================================================
+TYPEINIT1_AUTOFACTORY(SfxVisibilityItem, SfxPoolItem);
+
+//============================================================================
+SfxVisibilityItem::SfxVisibilityItem(USHORT which, SvStream & rStream):
+ SfxPoolItem(which)
+{
+ DBG_CTOR(SfxVisibilityItem, 0);
+ sal_Bool bValue = 0;
+ rStream >> bValue;
+ m_nValue.bVisible = bValue;
+}
+
+//============================================================================
+// virtual
+int SfxVisibilityItem::operator ==(const SfxPoolItem & rItem) const
+{
+ DBG_CHKTHIS(SfxVisibilityItem, 0);
+ DBG_ASSERT(SfxPoolItem::operator ==(rItem), "unequal type");
+ return m_nValue.bVisible == SAL_STATIC_CAST(const SfxVisibilityItem *, &rItem)->
+ m_nValue.bVisible;
+}
+
+//============================================================================
+// virtual
+int SfxVisibilityItem::Compare(const SfxPoolItem & rWith) const
+{
+ DBG_ASSERT(rWith.ISA(SfxVisibilityItem), "SfxVisibilityItem::Compare(): Bad type");
+ return m_nValue.bVisible == static_cast< SfxVisibilityItem const * >(&rWith)->m_nValue.bVisible ?
+ 0 : m_nValue.bVisible ? -1 : 1;
+}
+
+//============================================================================
+// virtual
+SfxItemPresentation SfxVisibilityItem::GetPresentation(SfxItemPresentation,
+ SfxMapUnit, SfxMapUnit,
+ XubString & rText,
+ const ::IntlWrapper *) const
+{
+ rText = GetValueTextByVal(m_nValue.bVisible);
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+
+//============================================================================
+// virtual
+bool SfxVisibilityItem::QueryValue(com::sun::star::uno::Any& rVal,BYTE) const
+{
+ rVal <<= m_nValue;
+ return true;
+}
+
+//============================================================================
+// virtual
+bool SfxVisibilityItem::PutValue(const com::sun::star::uno::Any& rVal,BYTE)
+{
+ if (rVal >>= m_nValue)
+ return true;
+
+ DBG_ERROR( "SfxInt16Item::PutValue - Wrong type!" );
+ return false;
+}
+
+//============================================================================
+// virtual
+SfxPoolItem * SfxVisibilityItem::Create(SvStream & rStream, USHORT) const
+{
+ DBG_CHKTHIS(SfxVisibilityItem, 0);
+ return new SfxVisibilityItem(Which(), rStream);
+}
+
+//============================================================================
+// virtual
+SvStream & SfxVisibilityItem::Store(SvStream & rStream, USHORT) const
+{
+ DBG_CHKTHIS(SfxVisibilityItem, 0);
+ rStream << m_nValue.bVisible;
+ return rStream;
+}
+
+//============================================================================
+// virtual
+SfxPoolItem * SfxVisibilityItem::Clone(SfxItemPool *) const
+{
+ DBG_CHKTHIS(SfxVisibilityItem, 0);
+ return new SfxVisibilityItem(*this);
+}
+
+//============================================================================
+// virtual
+USHORT SfxVisibilityItem::GetValueCount() const
+{
+ return 2;
+}
+
+//============================================================================
+// virtual
+UniString SfxVisibilityItem::GetValueTextByVal(BOOL bTheValue) const
+{
+ return
+ bTheValue ?
+ UniString::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("TRUE")) :
+ UniString::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("FALSE"));
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/svt_whiter.cxx b/binfilter/bf_svtools/source/items1/svt_whiter.cxx
new file mode 100644
index 000000000000..bab4be33f6f2
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/svt_whiter.cxx
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 ---------------------------------------------------------------
+#include "whiter.hxx"
+#include <bf_svtools/itemset.hxx>
+
+namespace binfilter
+{
+
+DBG_NAME(SfxWhichIter)
+
+// -----------------------------------------------------------------------
+
+SfxWhichIter::SfxWhichIter( const SfxItemSet& rSet, USHORT nFromWh, USHORT nToWh ):
+ pRanges(rSet.GetRanges()),
+ pStart(rSet.GetRanges()),
+ nOfst(0), nFrom(nFromWh), nTo(nToWh)
+{
+ DBG_CTOR(SfxWhichIter, 0);
+ if ( nFrom > 0 )
+ FirstWhich();
+}
+
+// -----------------------------------------------------------------------
+
+SfxWhichIter::~SfxWhichIter()
+{
+ DBG_DTOR(SfxWhichIter, 0);
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SfxWhichIter::NextWhich()
+{
+ DBG_CHKTHIS(SfxWhichIter, 0);
+ while ( 0 != *pRanges )
+ {
+ const USHORT nLastWhich = *pRanges + nOfst;
+ ++nOfst;
+ if (*(pRanges+1) == nLastWhich)
+ {
+ pRanges += 2;
+ nOfst = 0;
+ }
+ USHORT nWhich = *pRanges + nOfst;
+ if ( 0 == nWhich || ( nWhich >= nFrom && nWhich <= nTo ) )
+ return nWhich;
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SfxWhichIter::FirstWhich()
+{
+ DBG_CHKTHIS(SfxWhichIter, 0);
+ pRanges = pStart;
+ nOfst = 0;
+ if ( *pRanges >= nFrom && *pRanges <= nTo )
+ return *pRanges;
+ return NextWhich();
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/items1/whassert.hxx b/binfilter/bf_svtools/source/items1/whassert.hxx
new file mode 100644
index 000000000000..1942162a7d8d
--- /dev/null
+++ b/binfilter/bf_svtools/source/items1/whassert.hxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 _SFX_WHASSERT_HXX
+#define _SFX_WHASSERT_HXX
+
+#include <tools/debug.hxx>
+#include <tools/string.hxx>
+
+namespace binfilter
+{
+
+//------------------------------------------------------------------------
+
+#ifdef DBG_UTIL
+#define SFX_ASSERT( bCondition, nId, sMessage ) \
+{ \
+ if ( DbgIsAssert() ) \
+ { \
+ if ( !(bCondition) ) \
+ { \
+ ByteString aMsg( sMessage ); \
+ aMsg.Append(RTL_CONSTASCII_STRINGPARAM("\nwith Id/Pos: ")); \
+ aMsg += ByteString::CreateFromInt32( nId ); \
+ DbgOut( aMsg.GetBuffer(), DBG_OUT_ERROR, __FILE__, __LINE__); \
+ } \
+ } \
+}
+#else
+#define SFX_ASSERT( bCondition, nId, sMessage )
+#endif
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/memtools/makefile.mk b/binfilter/bf_svtools/source/memtools/makefile.mk
new file mode 100644
index 000000000000..08ba1d76239c
--- /dev/null
+++ b/binfilter/bf_svtools/source/memtools/makefile.mk
@@ -0,0 +1,46 @@
+#*************************************************************************
+#
+# DO NOT ALTER 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=binfilter
+TARGET=svarray
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=\
+ $(SLO)$/svt_svarray.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/binfilter/bf_svtools/source/memtools/svt_svarray.cxx b/binfilter/bf_svtools/source/memtools/svt_svarray.cxx
new file mode 100644
index 000000000000..86d7885aa0a5
--- /dev/null
+++ b/binfilter/bf_svtools/source/memtools/svt_svarray.cxx
@@ -0,0 +1,372 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+#define _SVARRAY_CXX
+
+#define _SVSTDARR_BOOLS
+#define _SVSTDARR_BYTES
+#define _SVSTDARR_ULONGS
+#define _SVSTDARR_ULONGSSORT
+#define _SVSTDARR_USHORTS
+#define _SVSTDARR_LONGS
+#define _SVSTDARR_LONGSSORT
+#define _SVSTDARR_SHORTS
+#define _SVSTDARR_STRINGS
+#define _SVSTDARR_STRINGSDTOR
+#define _SVSTDARR_STRINGSSORT
+#define _SVSTDARR_STRINGSSORTDTOR
+#define _SVSTDARR_STRINGSISORT
+#define _SVSTDARR_STRINGSISORTDTOR
+#define _SVSTDARR_USHORTSSORT
+
+#define _SVSTDARR_BYTESTRINGS
+#define _SVSTDARR_BYTESTRINGSDTOR
+#define _SVSTDARR_BYTESTRINGSSORT
+#define _SVSTDARR_BYTESTRINGSSORTDTOR
+#define _SVSTDARR_BYTESTRINGSISORT
+#define _SVSTDARR_BYTESTRINGSISORTDTOR
+
+#define _SVSTDARR_XUB_STRLEN
+#define _SVSTDARR_XUB_STRLENSORT
+
+#include <bf_svtools/svstdarr.hxx>
+
+#include <tools/string.hxx>
+
+#include <tools/debug.hxx>
+
+namespace binfilter
+{
+
+SV_IMPL_VARARR(SvPtrarr,VoidPtr)
+
+USHORT SvPtrarr::GetPos( const VoidPtr& aElement ) const
+{ USHORT n;
+ for( n=0; n < nA && *(GetData()+n) != aElement; ) n++;
+ return ( n >= nA ? USHRT_MAX : n );
+}
+
+SV_IMPL_VARARR( SvBools, BOOL )
+SV_IMPL_VARARR( SvBytes, BYTE )
+SV_IMPL_VARARR( SvULongs, ULONG )
+SV_IMPL_VARARR( SvUShorts, USHORT )
+SV_IMPL_VARARR( SvLongs, long)
+SV_IMPL_VARARR( SvShorts, short )
+
+SV_IMPL_VARARR( SvXub_StrLens, xub_StrLen )
+
+SV_IMPL_PTRARR( SvStrings, StringPtr )
+SV_IMPL_PTRARR( SvStringsDtor, StringPtr )
+SV_IMPL_OP_PTRARR_SORT( SvStringsSort, StringPtr )
+SV_IMPL_OP_PTRARR_SORT( SvStringsSortDtor, StringPtr )
+
+SV_IMPL_PTRARR( SvByteStrings, ByteStringPtr )
+SV_IMPL_PTRARR( SvByteStringsDtor, ByteStringPtr )
+SV_IMPL_OP_PTRARR_SORT( SvByteStringsSort, ByteStringPtr )
+SV_IMPL_OP_PTRARR_SORT( SvByteStringsSortDtor, ByteStringPtr )
+
+
+
+// ---------------- strings -------------------------------------
+
+// Array mit anderer Seek-Methode!
+_SV_IMPL_SORTAR_ALG( SvStringsISort, StringPtr )
+void SvStringsISort::DeleteAndDestroy( USHORT nP, USHORT nL )
+{
+ if( nL )
+ {
+ DBG_ASSERT( nP < nA && nP + nL <= nA, "ERR_VAR_DEL" );
+ for( USHORT n=nP; n < nP + nL; n++ )
+ delete *((StringPtr*)pData+n);
+ SvPtrarr::Remove( nP, nL );
+ }
+}
+BOOL SvStringsISort::Seek_Entry( const StringPtr aE, USHORT* pP ) const
+{
+ register USHORT nO = SvStringsISort_SAR::Count(),
+ nM,
+ nU = 0;
+ if( nO > 0 )
+ {
+ nO--;
+ while( nU <= nO )
+ {
+ nM = nU + ( nO - nU ) / 2;
+ StringCompare eCmp = (*((StringPtr*)pData + nM))->
+ CompareIgnoreCaseToAscii( *(aE) );
+ if( COMPARE_EQUAL == eCmp )
+ {
+ if( pP ) *pP = nM;
+ return TRUE;
+ }
+ else if( COMPARE_LESS == eCmp )
+ nU = nM + 1;
+ else if( nM == 0 )
+ {
+ if( pP ) *pP = nU;
+ return FALSE;
+ }
+ else
+ nO = nM - 1;
+ }
+ }
+ if( pP ) *pP = nU;
+ return FALSE;
+}
+
+// ---------------- strings -------------------------------------
+
+// Array mit anderer Seek-Methode!
+_SV_IMPL_SORTAR_ALG( SvStringsISortDtor, StringPtr )
+void SvStringsISortDtor::DeleteAndDestroy( USHORT nP, USHORT nL )
+{
+ if( nL )
+ {
+ DBG_ASSERT( nP < nA && nP + nL <= nA, "ERR_VAR_DEL" );
+ for( USHORT n=nP; n < nP + nL; n++ )
+ delete *((StringPtr*)pData+n);
+ SvPtrarr::Remove( nP, nL );
+ }
+}
+BOOL SvStringsISortDtor::Seek_Entry( const StringPtr aE, USHORT* pP ) const
+{
+ register USHORT nO = SvStringsISortDtor_SAR::Count(),
+ nM,
+ nU = 0;
+ if( nO > 0 )
+ {
+ nO--;
+ while( nU <= nO )
+ {
+ nM = nU + ( nO - nU ) / 2;
+ StringCompare eCmp = (*((StringPtr*)pData + nM))->
+ CompareIgnoreCaseToAscii( *(aE) );
+ if( COMPARE_EQUAL == eCmp )
+ {
+ if( pP ) *pP = nM;
+ return TRUE;
+ }
+ else if( COMPARE_LESS == eCmp )
+ nU = nM + 1;
+ else if( nM == 0 )
+ {
+ if( pP ) *pP = nU;
+ return FALSE;
+ }
+ else
+ nO = nM - 1;
+ }
+ }
+ if( pP ) *pP = nU;
+ return FALSE;
+}
+
+// ---------------- Ushorts -------------------------------------
+
+/* SortArray fuer UShorts */
+BOOL SvUShortsSort::Seek_Entry( const USHORT aE, USHORT* pP ) const
+{
+ register USHORT nO = SvUShorts::Count(),
+ nM,
+ nU = 0;
+ if( nO > 0 )
+ {
+ nO--;
+ while( nU <= nO )
+ {
+ nM = nU + ( nO - nU ) / 2;
+ if( *(pData + nM) == aE )
+ {
+ if( pP ) *pP = nM;
+ return TRUE;
+ }
+ else if( *(pData + nM) < aE )
+ nU = nM + 1;
+ else if( nM == 0 )
+ {
+ if( pP ) *pP = nU;
+ return FALSE;
+ }
+ else
+ nO = nM - 1;
+ }
+ }
+ if( pP ) *pP = nU;
+ return FALSE;
+}
+
+void SvUShortsSort::Insert( const SvUShortsSort * pI, USHORT nS, USHORT nE )
+{
+ if( USHRT_MAX == nE )
+ nE = pI->Count();
+ USHORT nP;
+ const USHORT * pIArr = pI->GetData();
+ for( ; nS < nE; ++nS )
+ {
+ if( ! Seek_Entry( *(pIArr+nS), &nP) )
+ SvUShorts::Insert( *(pIArr+nS), nP );
+ if( ++nP >= Count() )
+ {
+ SvUShorts::Insert( pI, nP, nS+1, nE );
+ nS = nE;
+ }
+ }
+}
+
+BOOL SvUShortsSort::Insert( const USHORT aE )
+{
+ USHORT nP;
+ BOOL bExist = Seek_Entry( aE, &nP );
+ if( !bExist )
+ SvUShorts::Insert( aE, nP );
+ return !bExist;
+}
+
+BOOL SvUShortsSort::Insert( const USHORT aE, USHORT& rP )
+{
+ BOOL bExist = Seek_Entry( aE, &rP );
+ if( !bExist )
+ SvUShorts::Insert( aE, rP );
+ return !bExist;
+}
+
+void SvUShortsSort::Insert( const USHORT* pE, USHORT nL)
+{
+ USHORT nP;
+ for( USHORT n = 0; n < nL; ++n )
+ if( ! Seek_Entry( *(pE+n), &nP ))
+ SvUShorts::Insert( *(pE+n), nP );
+}
+
+// remove ab dem Eintrag
+void SvUShortsSort::Remove( const USHORT aE, USHORT nL )
+{
+ USHORT nP;
+ if( nL && Seek_Entry( aE, &nP ) )
+ SvUShorts::Remove( nP, nL);
+}
+
+// ---------------- bytestrings -------------------------------------
+
+// Array mit anderer Seek-Methode!
+_SV_IMPL_SORTAR_ALG( SvByteStringsISort, ByteStringPtr )
+void SvByteStringsISort::DeleteAndDestroy( USHORT nP, USHORT nL )
+{
+ if( nL )
+ {
+ DBG_ASSERT( nP < nA && nP + nL <= nA, "ERR_VAR_DEL" );
+ for( USHORT n=nP; n < nP + nL; n++ )
+ delete *((ByteStringPtr*)pData+n);
+ SvPtrarr::Remove( nP, nL );
+ }
+}
+BOOL SvByteStringsISort::Seek_Entry( const ByteStringPtr aE, USHORT* pP ) const
+{
+ register USHORT nO = SvByteStringsISort_SAR::Count(),
+ nM,
+ nU = 0;
+ if( nO > 0 )
+ {
+ nO--;
+ while( nU <= nO )
+ {
+ nM = nU + ( nO - nU ) / 2;
+ StringCompare eCmp = (*((ByteStringPtr*)pData + nM))->
+ CompareIgnoreCaseToAscii( *(aE) );
+ if( COMPARE_EQUAL == eCmp )
+ {
+ if( pP ) *pP = nM;
+ return TRUE;
+ }
+ else if( COMPARE_LESS == eCmp )
+ nU = nM + 1;
+ else if( nM == 0 )
+ {
+ if( pP ) *pP = nU;
+ return FALSE;
+ }
+ else
+ nO = nM - 1;
+ }
+ }
+ if( pP ) *pP = nU;
+ return FALSE;
+}
+
+
+// Array mit anderer Seek-Methode!
+_SV_IMPL_SORTAR_ALG( SvByteStringsISortDtor, ByteStringPtr )
+void SvByteStringsISortDtor::DeleteAndDestroy( USHORT nP, USHORT nL )
+{
+ if( nL )
+ {
+ DBG_ASSERT( nP < nA && nP + nL <= nA, "ERR_VAR_DEL" );
+ for( USHORT n=nP; n < nP + nL; n++ )
+ delete *((ByteStringPtr*)pData+n);
+ SvPtrarr::Remove( nP, nL );
+ }
+}
+BOOL SvByteStringsISortDtor::Seek_Entry( const ByteStringPtr aE, USHORT* pP ) const
+{
+ register USHORT nO = SvByteStringsISortDtor_SAR::Count(),
+ nM,
+ nU = 0;
+ if( nO > 0 )
+ {
+ nO--;
+ while( nU <= nO )
+ {
+ nM = nU + ( nO - nU ) / 2;
+ StringCompare eCmp = (*((ByteStringPtr*)pData + nM))->
+ CompareIgnoreCaseToAscii( *(aE) );
+ if( COMPARE_EQUAL == eCmp )
+ {
+ if( pP ) *pP = nM;
+ return TRUE;
+ }
+ else if( COMPARE_LESS == eCmp )
+ nU = nM + 1;
+ else if( nM == 0 )
+ {
+ if( pP ) *pP = nU;
+ return FALSE;
+ }
+ else
+ nO = nM - 1;
+ }
+ }
+ if( pP ) *pP = nU;
+ return FALSE;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc/ctrltool.src b/binfilter/bf_svtools/source/misc/ctrltool.src
new file mode 100644
index 000000000000..604f475a8de0
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc/ctrltool.src
@@ -0,0 +1,144 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/svtools.hrc>
+
+String STR_SVT_STYLE_LIGHT
+{
+ Text [ en-US ] = "Light" ;
+};
+
+String STR_SVT_STYLE_LIGHT_ITALIC
+{
+ Text [ en-US ] = "Light Italic" ;
+};
+
+String STR_SVT_STYLE_NORMAL
+{
+ Text [ en-US ] = "Regular" ;
+};
+
+String STR_SVT_STYLE_NORMAL_ITALIC
+{
+ Text [ en-US ] = "Italic" ;
+};
+
+String STR_SVT_STYLE_BOLD
+{
+ Text [ en-US ] = "Bold" ;
+};
+
+String STR_SVT_STYLE_BOLD_ITALIC
+{
+ Text [ en-US ] = "Bold Italic" ;
+};
+
+String STR_SVT_STYLE_BLACK
+{
+ Text [ en-US ] = "Black" ;
+};
+
+String STR_SVT_STYLE_BLACK_ITALIC
+{
+ Text [ en-US ] = "Black Italic" ;
+};
+
+/*
+Finnische Texte:
+ "Light",
+ "Light Kursivoitu",
+ "Normaali",
+ "Kursivoitu",
+ "Lihavoitu",
+ "Lihavoitu Kursivoitu",
+ "Black",
+ "Black Kursivoitu"
+*/
+
+String STR_SVT_FONTMAP_BOTH
+{
+ Text [ en-US ] = "The same font will be used on both your printer and your screen." ;
+};
+
+String STR_SVT_FONTMAP_PRINTERONLY
+{
+ Text [ en-US ] = "This is a printer font. The screen image may differ." ;
+};
+
+String STR_SVT_FONTMAP_SCREENONLY
+{
+ Text [ en-US ] = "This is a screen font. The printer image may differ." ;
+};
+
+String STR_SVT_FONTMAP_SIZENOTAVAILABLE
+{
+ Text [ en-US ] = "This font size has not been installed. The closest available size will be used.";
+};
+
+String STR_SVT_FONTMAP_STYLENOTAVAILABLE
+{
+ Text [ en-US ] = "This font style will be simulated or the closest matching style will be used.";
+};
+
+String STR_SVT_FONTMAP_NOTAVAILABLE
+{
+ Text [ en-US ] = "This font has not been installed. The closest available font will be used.";
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/binfilter/bf_svtools/source/misc/errtxt.src b/binfilter/bf_svtools/source/misc/errtxt.src
new file mode 100644
index 000000000000..40b9258e3d90
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc/errtxt.src
@@ -0,0 +1,506 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/svtools.hrc>
+#include "sfxecode.hxx"
+
+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 Internet connection to $(ARG1)." ;
+ };
+ String ERRCODE_INET_READ
+ {
+ Text [ en-US ] = "Error reading data from the Internet.\nServer error message: $(ARG1)." ;
+ };
+ String ERRCODE_INET_WRITE
+ {
+ Text [ en-US ] = "Error transferring data to the Internet.\nServer error message: $(ARG1)." ;
+ };
+ String ERRCODE_INET_GENERAL
+ {
+ Text [ en-US ] = "General Internet error has occurred." ;
+ };
+ String ERRCODE_INET_OFFLINE
+ {
+ Text [ en-US ] = "The requested Internet 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_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." ;
+ };
+};
+
+// eof ------------------------------------------------------------------------
+
diff --git a/binfilter/bf_svtools/source/misc/makefile.mk b/binfilter/bf_svtools/source/misc/makefile.mk
new file mode 100644
index 000000000000..460e1dcfe896
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc/makefile.mk
@@ -0,0 +1,64 @@
+#*************************************************************************
+#
+# DO NOT ALTER 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=binfilter
+TARGET=misc
+
+ENABLE_EXCEPTIONS := TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+SRS1NAME=ehdl
+SRC1FILES=\
+ ctrltool.src\
+ errtxt.src
+
+SLOFILES=\
+ $(SLO)$/svt_asynclink.obj \
+ $(SLO)$/svt_ctrltool.obj \
+ $(SLO)$/svt_imageresourceaccess.obj \
+ $(SLO)$/svt_templatefoldercache.obj \
+ $(SLO)$/svt_urihelper.obj \
+ $(SLO)$/svt_ehdl.obj \
+ $(SLO)$/svt_flbytes.obj \
+ $(SLO)$/svt_imap.obj \
+ $(SLO)$/svt_imap2.obj \
+ $(SLO)$/svt_imap3.obj \
+ $(SLO)$/svt_ownlist.obj \
+ $(SLO)$/svt_vcldata.obj \
+ $(SLO)$/svt_restrictedpaths.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/binfilter/bf_svtools/source/misc/svt_asynclink.cxx b/binfilter/bf_svtools/source/misc/svt_asynclink.cxx
new file mode 100644
index 000000000000..884de6c05b97
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc/svt_asynclink.cxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <asynclink.hxx>
+#include <osl/mutex.hxx>
+#include <tools/debug.hxx>
+#include <vcl/timer.hxx>
+#include <vcl/svapp.hxx>
+
+//--------------------------------------------------------------------
+
+namespace binfilter
+{
+
+void AsynchronLink::CreateMutex()
+{
+ if( !_pMutex ) _pMutex = new osl::Mutex;
+}
+
+void AsynchronLink::Call( void* pObj, BOOL
+#ifdef DBG_UTIL
+bAllowDoubles
+#endif
+, BOOL bUseTimer )
+{
+#ifdef DBG_UTIL
+ if ( bUseTimer || !_bInCall )
+ DBG_WARNING( "Recursives Call. Eher ueber Timer. TLX Fragen" );
+#endif
+ if( _aLink.IsSet() )
+ {
+ _pArg = pObj;
+ DBG_ASSERT( bAllowDoubles ||
+ ( !_nEventId && ( !_pTimer || !_pTimer->IsActive() ) ),
+ "Schon ein Call unterwegs" );
+ if( _nEventId )
+ {
+ if( _pMutex ) _pMutex->acquire();
+ Application::RemoveUserEvent( _nEventId );
+ if( _pMutex ) _pMutex->release();
+ }
+ if( _pTimer )_pTimer->Stop();
+ if( bUseTimer )
+ {
+ if( !_pTimer )
+ {
+ _pTimer = new Timer;
+ _pTimer->SetTimeout( 0 );
+ _pTimer->SetTimeoutHdl( STATIC_LINK(
+ this, AsynchronLink, HandleCall) );
+ }
+ _pTimer->Start();
+ }
+ else
+ {
+ if( _pMutex ) _pMutex->acquire();
+ Application::PostUserEvent( _nEventId, STATIC_LINK( this, AsynchronLink, HandleCall), 0 );
+ if( _pMutex ) _pMutex->release();
+ }
+ }
+}
+
+AsynchronLink::~AsynchronLink()
+{
+ if( _nEventId )
+ {
+ Application::RemoveUserEvent( _nEventId );
+ }
+ delete _pTimer;
+ if( _pDeleted ) *_pDeleted = TRUE;
+ delete _pMutex;
+}
+
+IMPL_STATIC_LINK( AsynchronLink, HandleCall, void*, EMPTYARG )
+{
+ if( pThis->_pMutex ) pThis->_pMutex->acquire();
+ pThis->_nEventId = 0;
+ if( pThis->_pMutex ) pThis->_pMutex->release();
+ pThis->Call_Impl( pThis->_pArg );
+ return 0;
+}
+
+void AsynchronLink::ClearPendingCall()
+{
+ if( _pMutex ) _pMutex->acquire();
+ if( _nEventId )
+ {
+ Application::RemoveUserEvent( _nEventId );
+ _nEventId = 0;
+ }
+ if( _pMutex ) _pMutex->release();
+ if( _pTimer ) _pTimer->Stop();
+}
+
+void AsynchronLink::Call_Impl( void* pArg )
+{
+ _bInCall = TRUE;
+ BOOL bDeleted = FALSE;
+ _pDeleted = &bDeleted;
+ _aLink.Call( pArg );
+ if( !bDeleted )
+ {
+ _bInCall = FALSE;
+ _pDeleted = 0;
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc/svt_ctrltool.cxx b/binfilter/bf_svtools/source/misc/svt_ctrltool.cxx
new file mode 100644
index 000000000000..712fee2cbf69
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc/svt_ctrltool.cxx
@@ -0,0 +1,404 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 CTRLTOOL_CXX
+
+#include <string.h>
+#include <tools/debug.hxx>
+#include <i18npool/mslangid.hxx>
+#include <vcl/window.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+#include <svtools.hrc>
+#include <svtdata.hxx>
+#include <ctrltool.hxx>
+
+namespace binfilter
+{
+
+class ImplFontListFontInfo : public FontInfo
+{
+ friend class FontList;
+
+private:
+ OutputDevice* mpDevice;
+ ImplFontListFontInfo* mpNext;
+
+public:
+ ImplFontListFontInfo( const FontInfo& rInfo,
+ OutputDevice* pDev ) :
+ FontInfo( rInfo )
+ {
+ mpDevice = pDev;
+ }
+
+ OutputDevice* GetDevice() const { return mpDevice; }
+};
+
+class ImplFontListNameInfo
+{
+ friend class FontList;
+
+private:
+ XubString maSearchName;
+ ImplFontListFontInfo* mpFirst;
+ USHORT mnType;
+
+ ImplFontListNameInfo( const XubString& rSearchName ) :
+ maSearchName( rSearchName )
+ {}
+
+ const XubString& GetSearchName() const { return maSearchName; }
+};
+
+static StringCompare ImplCompareFontInfo( ImplFontListFontInfo* pInfo1,
+ ImplFontListFontInfo* pInfo2 )
+{
+ if ( pInfo1->GetWeight() < pInfo2->GetWeight() )
+ return COMPARE_LESS;
+ else if ( pInfo1->GetWeight() > pInfo2->GetWeight() )
+ return COMPARE_GREATER;
+
+ if ( pInfo1->GetItalic() < pInfo2->GetItalic() )
+ return COMPARE_LESS;
+ else if ( pInfo1->GetItalic() > pInfo2->GetItalic() )
+ return COMPARE_GREATER;
+
+ return pInfo1->GetStyleName().CompareTo( pInfo2->GetStyleName() );
+}
+
+static void ImplMakeSearchString( XubString& rStr )
+{
+ rStr.ToLowerAscii();
+}
+
+// -----------------------------------------------------------------------
+
+static void ImplMakeSearchStringFromName( XubString& rStr )
+{
+ rStr = rStr.GetToken( 0, ';' );
+ ImplMakeSearchString( rStr );
+}
+
+// -----------------------------------------------------------------------
+
+ImplFontListNameInfo* FontList::ImplFind( const XubString& rSearchName, ULONG* pIndex ) const
+{
+ // Wenn kein Eintrag in der Liste oder der Eintrag groesser ist als
+ // der Letzte, dann hinten dranhaengen. Wir vergleichen erst mit dem
+ // letzten Eintrag, da die Liste von VCL auch sortiert zurueckkommt
+ // und somit die Wahrscheinlichkeit das hinten angehaengt werden muss
+ // sehr gross ist.
+ StringCompare eComp;
+ ULONG nCnt = Count();
+ if ( !nCnt )
+ {
+ if ( pIndex )
+ *pIndex = LIST_APPEND;
+ return NULL;
+ }
+ else
+ {
+ ImplFontListNameInfo* pCmpData = (ImplFontListNameInfo*)List::GetObject( nCnt-1 );
+ eComp = rSearchName.CompareTo( pCmpData->maSearchName );
+ if ( eComp == COMPARE_GREATER )
+ {
+ if ( pIndex )
+ *pIndex = LIST_APPEND;
+ return NULL;
+ }
+ else if ( eComp == COMPARE_EQUAL )
+ return pCmpData;
+ }
+
+ // Fonts in der Liste suchen
+ ImplFontListNameInfo* pCompareData;
+ ImplFontListNameInfo* pFoundData = NULL;
+ ULONG nLow = 0;
+ ULONG nHigh = nCnt-1;
+ ULONG nMid;
+
+ do
+ {
+ nMid = (nLow + nHigh) / 2;
+ pCompareData = (ImplFontListNameInfo*)List::GetObject( nMid );
+ eComp = rSearchName.CompareTo( pCompareData->maSearchName );
+ if ( eComp == COMPARE_LESS )
+ {
+ if ( !nMid )
+ break;
+ nHigh = nMid-1;
+ }
+ else
+ {
+ if ( eComp == COMPARE_GREATER )
+ nLow = nMid + 1;
+ else
+ {
+ pFoundData = pCompareData;
+ break;
+ }
+ }
+ }
+ while ( nLow <= nHigh );
+
+ if ( pIndex )
+ {
+ eComp = rSearchName.CompareTo( pCompareData->maSearchName );
+ if ( eComp == COMPARE_GREATER )
+ *pIndex = (nMid+1);
+ else
+ *pIndex = nMid;
+ }
+
+ return pFoundData;
+}
+
+// -----------------------------------------------------------------------
+
+ImplFontListNameInfo* FontList::ImplFindByName( const XubString& rStr ) const
+{
+ XubString aSearchName = rStr;
+ ImplMakeSearchStringFromName( aSearchName );
+ return ImplFind( aSearchName, NULL );
+}
+
+// -----------------------------------------------------------------------
+
+void FontList::ImplInsertFonts( OutputDevice* pDevice, BOOL bAll,
+ BOOL bInsertData )
+{
+ rtl_TextEncoding eSystemEncoding = gsl_getSystemTextEncoding();
+
+ USHORT nType;
+ if ( pDevice->GetOutDevType() != OUTDEV_PRINTER )
+ nType = FONTLIST_FONTNAMETYPE_SCREEN;
+ else
+ nType = FONTLIST_FONTNAMETYPE_PRINTER;
+
+ // Alle Fonts vom Device abfragen
+ int n = pDevice->GetDevFontCount();
+ USHORT i;
+ for( i = 0; i < n; i++ )
+ {
+ FontInfo aFontInfo = pDevice->GetDevFont( i );
+
+ // Wenn keine Raster-Schriften angezeigt werden sollen,
+ // dann diese ignorieren
+ if ( !bAll && (aFontInfo.GetType() == TYPE_RASTER) )
+ continue;
+
+ XubString aSearchName = aFontInfo.GetName();
+ ImplFontListNameInfo* pData;
+ ULONG nIndex;
+ ImplMakeSearchString( aSearchName );
+ pData = ImplFind( aSearchName, &nIndex );
+
+ if ( !pData )
+ {
+ if ( bInsertData )
+ {
+ ImplFontListFontInfo* pNewInfo = new ImplFontListFontInfo( aFontInfo, pDevice );
+ pData = new ImplFontListNameInfo( aSearchName );
+ pData->mpFirst = pNewInfo;
+ pNewInfo->mpNext = NULL;
+ pData->mnType = 0;
+ Insert( (void*)pData, nIndex );
+ }
+ }
+ else
+ {
+ if ( bInsertData )
+ {
+ BOOL bInsert = TRUE;
+ ImplFontListFontInfo* pPrev = NULL;
+ ImplFontListFontInfo* pTemp = pData->mpFirst;
+ ImplFontListFontInfo* pNewInfo = new ImplFontListFontInfo( aFontInfo, pDevice );
+ while ( pTemp )
+ {
+ StringCompare eComp = ImplCompareFontInfo( pNewInfo, pTemp );
+ if ( (eComp == COMPARE_LESS) || (eComp == COMPARE_EQUAL) )
+ {
+ if ( eComp == COMPARE_EQUAL )
+ {
+ // Overwrite charset, because charset should match
+ // with the system charset
+ if ( (pTemp->GetCharSet() != eSystemEncoding) &&
+ (pNewInfo->GetCharSet() == eSystemEncoding) )
+ {
+ ImplFontListFontInfo* pTemp2 = pTemp->mpNext;
+ *((FontInfo*)pTemp) = *((FontInfo*)pNewInfo);
+ pTemp->mpNext = pTemp2;
+ }
+ delete pNewInfo;
+ bInsert = FALSE;
+ }
+
+ break;
+ }
+
+ pPrev = pTemp;
+ pTemp = pTemp->mpNext;
+ }
+
+ if ( bInsert )
+ {
+ pNewInfo->mpNext = pTemp;
+ if ( pPrev )
+ pPrev->mpNext = pNewInfo;
+ else
+ pData->mpFirst = pNewInfo;
+ }
+ }
+ }
+
+ if ( pData )
+ {
+ pData->mnType |= nType;
+ if ( aFontInfo.GetType() != TYPE_RASTER )
+ pData->mnType |= FONTLIST_FONTNAMETYPE_SCALABLE;
+ }
+ }
+}
+
+// =======================================================================
+
+FontList::FontList( OutputDevice* pDevice, OutputDevice* pDevice2, BOOL bAll ) :
+ List( 4096, sal::static_int_cast< USHORT >(pDevice->GetDevFontCount()), 32 )
+{
+ // Variablen initialisieren
+ mpDev = pDevice;
+ mpDev2 = pDevice2;
+ mpSizeAry = NULL;
+
+ // Stylenamen festlegen
+ maLight = XubString( SvtResId( STR_SVT_STYLE_LIGHT ) );
+ maLightItalic = XubString( SvtResId( STR_SVT_STYLE_LIGHT_ITALIC ) );
+ maNormal = XubString( SvtResId( STR_SVT_STYLE_NORMAL ) );
+ maNormalItalic = XubString( SvtResId( STR_SVT_STYLE_NORMAL_ITALIC ) );
+ maBold = XubString( SvtResId( STR_SVT_STYLE_BOLD ) );
+ maBoldItalic = XubString( SvtResId( STR_SVT_STYLE_BOLD_ITALIC ) );
+ maBlack = XubString( SvtResId( STR_SVT_STYLE_BLACK ) );
+ maBlackItalic = XubString( SvtResId( STR_SVT_STYLE_BLACK_ITALIC ) );
+
+ ImplInsertFonts( pDevice, bAll, TRUE );
+
+ // Gegebenenfalls muessen wir mit den Bildschirmfonts vergleichen,
+ // damit dort die eigentlich doppelten auf Equal mappen koennen
+ BOOL bCompareWindow = FALSE;
+ if ( !pDevice2 && (pDevice->GetOutDevType() == OUTDEV_PRINTER) )
+ {
+ bCompareWindow = TRUE;
+ pDevice2 = Application::GetDefaultDevice();
+ }
+
+ if ( pDevice2 &&
+ (pDevice2->GetOutDevType() != pDevice->GetOutDevType()) )
+ ImplInsertFonts( pDevice2, bAll, !bCompareWindow );
+}
+
+// -----------------------------------------------------------------------
+
+FontList::~FontList()
+{
+ // Gegebenenfalls SizeArray loeschen
+ if ( mpSizeAry )
+ delete[] mpSizeAry;
+
+ // FontInfos loeschen
+ ImplFontListNameInfo* pData = (ImplFontListNameInfo*)First();
+ while ( pData )
+ {
+ ImplFontListFontInfo* pTemp;
+ ImplFontListFontInfo* pInfo = pData->mpFirst;
+ while ( pInfo )
+ {
+ pTemp = pInfo->mpNext;
+ delete pInfo;
+ pInfo = pTemp;
+ }
+ ImplFontListNameInfo* pNext = (ImplFontListNameInfo*)Next();
+ delete pData;
+ pData = pNext;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+FontInfo FontList::Get( const XubString& rName,
+ FontWeight eWeight, FontItalic eItalic ) const
+{
+ ImplFontListNameInfo* pData = ImplFindByName( rName );
+ ImplFontListFontInfo* pFontInfo = NULL;
+ ImplFontListFontInfo* pFontNameInfo = NULL;
+ if ( pData )
+ {
+ ImplFontListFontInfo* pSearchInfo = pData->mpFirst;
+ pFontNameInfo = pSearchInfo;
+ while ( pSearchInfo )
+ {
+ if ( (eWeight == pSearchInfo->GetWeight()) &&
+ (eItalic == pSearchInfo->GetItalic()) )
+ {
+ pFontInfo = pSearchInfo;
+ break;
+ }
+
+ pSearchInfo = pSearchInfo->mpNext;
+ }
+ }
+
+ // Konnten die Daten nicht gefunden werden, dann muessen bestimmte
+ // Attribute nachgebildet werden
+ FontInfo aInfo;
+ if ( !pFontInfo )
+ {
+ // Falls der Fontname stimmt, uebernehmen wir soviel wie moeglich
+ if ( pFontNameInfo )
+ {
+ aInfo = *pFontNameInfo;
+ aInfo.SetStyleName( XubString() );
+ }
+
+ aInfo.SetWeight( eWeight );
+ aInfo.SetItalic( eItalic );
+ }
+ else
+ aInfo = *pFontInfo;
+
+ // set Fontname to keep FontAlias
+ aInfo.SetName( rName );
+
+ return aInfo;
+}
+
+//------------------------------------------------------------------------
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc/svt_ehdl.cxx b/binfilter/bf_svtools/source/misc/svt_ehdl.cxx
new file mode 100644
index 000000000000..beab827e9482
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc/svt_ehdl.cxx
@@ -0,0 +1,471 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <osl/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
+
+#include <bf_svtools/ehdl.hxx>
+#include <bf_svtools/svtdata.hxx>
+#include <bf_svtools/svtools.hrc>
+#include "sfxecode.hxx"
+
+namespace binfilter
+{
+
+//=========================================================================
+
+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
+
+ */
+
+
+{
+ SolarMutexGuard aGuard;
+
+ // 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(String(RTL_CONSTASCII_USTRINGPARAM("$(ACTION)$(ERROR)")));
+ 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
+{
+ ResId aId(RID_ERRHDL, *pMgr);
+ ErrorResource_Impl aEr(aId, (USHORT)lClassId);
+ if(aEr)
+ {
+ rStr=((ResString)aEr).GetString();
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+//-------------------------------------------------------------------------
+
+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
+
+ */
+
+{
+ SolarMutexGuard aGuard;
+
+ BOOL bRet = FALSE;
+ rStr=String(String(RTL_CONSTASCII_USTRINGPARAM("$(CLASS)$(ERROR)")));
+ ResId *pResId = new ResId(nId, *pMgr);
+
+ {
+ ErrorResource_Impl aEr(*pResId, (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);
+ }
+
+ delete pResId;
+ return bRet;
+}
+
+//-------------------------------------------------------------------------
+
+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 )
+ {
+ SolarMutexGuard aGuard;
+
+ 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;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc/svt_flbytes.cxx b/binfilter/bf_svtools/source/misc/svt_flbytes.cxx
new file mode 100644
index 000000000000..3c0d0d3d980d
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc/svt_flbytes.cxx
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <vcl/svapp.hxx>
+
+#include <flbytes.hxx>
+
+#ifndef _SVSTDARR_ULONGS_DECL
+#define _SVSTDARR_ULONGS
+#include <bf_svtools/svstdarr.hxx>
+#undef _SVSTDARR_ULONGS
+#endif
+
+//============================================================================
+namespace binfilter
+{
+
+inline ULONG MyMin( long a, long b )
+{
+ return Max( long( Min( a , b ) ), 0L );
+}
+
+//============================================================================
+SV_DECL_IMPL_REF_LIST( SvLockBytes, SvLockBytes* )
+
+//============================================================================
+//
+// SvSyncLockBytes
+//
+//============================================================================
+
+TYPEINIT1(SvSyncLockBytes, SvOpenLockBytes);
+
+//============================================================================
+// virtual
+ErrCode SvSyncLockBytes::ReadAt(ULONG nPos, void * pBuffer, ULONG nCount,
+ ULONG * pRead) const
+{
+ for (ULONG nReadTotal = 0;;)
+ {
+ ULONG nReadCount = 0;
+ ErrCode nError = m_xAsyncLockBytes->ReadAt(nPos, pBuffer, nCount,
+ &nReadCount);
+ nReadTotal += nReadCount;
+ if (nError != ERRCODE_IO_PENDING || !IsSynchronMode())
+ {
+ if (pRead)
+ *pRead = nReadTotal;
+ return nError;
+ }
+ nPos += nReadCount;
+ pBuffer = static_cast< sal_Char * >(pBuffer) + nReadCount;
+ nCount -= nReadCount;
+ Application::Yield();
+ }
+}
+
+//============================================================================
+// virtual
+ErrCode SvSyncLockBytes::WriteAt(ULONG nPos, const void * pBuffer,
+ ULONG nCount, ULONG * pWritten)
+{
+ for (ULONG nWrittenTotal = 0;;)
+ {
+ ULONG nWrittenCount = 0;
+ ErrCode nError = m_xAsyncLockBytes->WriteAt(nPos, pBuffer, nCount,
+ &nWrittenCount);
+ nWrittenTotal += nWrittenCount;
+ if (nError != ERRCODE_IO_PENDING || !IsSynchronMode())
+ {
+ if (pWritten)
+ *pWritten = nWrittenTotal;
+ return nError;
+ }
+ nPos += nWrittenCount;
+ pBuffer = static_cast< sal_Char const * >(pBuffer) + nWrittenCount;
+ nCount -= nWrittenCount;
+ Application::Yield();
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc/svt_imageresourceaccess.cxx b/binfilter/bf_svtools/source/misc/svt_imageresourceaccess.cxx
new file mode 100644
index 000000000000..91fffc7f02b2
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc/svt_imageresourceaccess.cxx
@@ -0,0 +1,199 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 "imageresourceaccess.hxx"
+
+/** === 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 binfilter
+{
+//........................................................................
+
+ 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();
+ }
+
+ //====================================================================
+ //= ImageResourceAccess
+ //====================================================================
+ //--------------------------------------------------------------------
+ bool ImageResourceAccess::isImageResourceURL( const ::rtl::OUString& _rURL )
+ {
+ ::rtl::OUString sIndicator( RTL_CONSTASCII_USTRINGPARAM( "private:resource/" ) );
+ return _rURL.indexOf( sIndicator ) == 0;
+ }
+
+ //--------------------------------------------------------------------
+ SvStream* ImageResourceAccess::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(), "ImageResourceAccess::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(), "ImageResourceAccess::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, "ImageResourceAccess::getImageStream: caught an exception!" );
+ }
+
+ return pReturn;
+ }
+
+}
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc/svt_imap.cxx b/binfilter/bf_svtools/source/misc/svt_imap.cxx
new file mode 100644
index 000000000000..c47a7045aa65
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc/svt_imap.cxx
@@ -0,0 +1,1119 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/table.hxx>
+#include <string.h>
+#include <math.h>
+#include <tools/urlobj.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/mapmod.hxx>
+#include <vcl/window.hxx>
+
+#include "urihelper.hxx"
+#include <bf_svtools/imap.hxx>
+#include <bf_svtools/imapobj.hxx>
+#include <bf_svtools/imapcirc.hxx>
+#include <bf_svtools/imaprect.hxx>
+#include <bf_svtools/imappoly.hxx>
+
+namespace binfilter
+{
+
+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;
+
+/******************************************************************************/
+
+
+#ifdef WIN
+#pragma optimize ( "", off )
+#endif
+
+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 )
+{
+}
+
+
+/******************************************************************************
+|*
+|* 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(::binfilter::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 = ::binfilter::SmartRel2Abs( INetURLObject(rBaseURL), aURL, ::binfilter::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;
+}
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+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::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;
+}
+
+
+/******************************************************************************/
+/******************************************************************************/
+/******************************************************************************/
+
+/******************************************************************************
+|*
+|* 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;
+ }
+}
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+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 );
+}
+
+
+#ifdef WIN
+#pragma optimize ( "", on )
+#endif
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc/svt_imap2.cxx b/binfilter/bf_svtools/source/misc/svt_imap2.cxx
new file mode 100644
index 000000000000..07881be1e642
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc/svt_imap2.cxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+#ifdef WIN
+#include <sysdep.hxx>
+#endif
+#include <string.h>
+
+#include <vcl/svapp.hxx>
+#include <tools/urlobj.hxx>
+#include <vcl/wrkwin.hxx>
+#include <sot/formats.hxx>
+
+#include "urihelper.hxx"
+#include <bf_svtools/imap.hxx>
+#include <bf_svtools/imap.hxx>
+#include <bf_svtools/imapobj.hxx>
+#include <bf_svtools/imaprect.hxx>
+#include <bf_svtools/imapcirc.hxx>
+#include <bf_svtools/imappoly.hxx>
+
+#define NOTEOL(c) ((c)!='\0')
+
+namespace binfilter
+{
+
+TYPEINIT0_AUTOFACTORY( ImageMap );
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc/svt_imap3.cxx b/binfilter/bf_svtools/source/misc/svt_imap3.cxx
new file mode 100644
index 000000000000..503c0a6c03da
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc/svt_imap3.cxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/imap.hxx>
+
+#include <tools/debug.hxx>
+
+namespace binfilter
+{
+
+
+/******************************************************************************
+|*
+|* 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 );
+ }
+ }
+}
+
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc/svt_inidef.cxx b/binfilter/bf_svtools/source/misc/svt_inidef.cxx
new file mode 100644
index 000000000000..95331c6bd8dd
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc/svt_inidef.cxx
@@ -0,0 +1,274 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/string.hxx>
+#include "inetdef.hxx"
+#include "inidef.hxx"
+
+namespace binfilter
+{
+
+//========================================================================
+
+class SfxStdIniDef_Impl: public SfxIniDefaulter
+{
+public:
+ SfxStdIniDef_Impl( SfxIniDefaultManager *pDefMgr )
+ : SfxIniDefaulter( pDefMgr )
+ {}
+ virtual BOOL QueryDefault( String &rValue, const SfxIniEntry &rEntry );
+};
+
+//-------------------------------------------------------------------------
+
+BOOL SfxStdIniDef_Impl::QueryDefault( String &rValue, const SfxIniEntry &rEntry )
+{
+ switch ( rEntry.GetKey() )
+ {
+ case SFX_KEY_BROWSERRESTORE:
+ {
+ rValue = "1";
+ return TRUE;
+ }
+
+ case SFX_KEY_INET_HOME:
+ {
+ if ( System::GetLanguage() == LANGUAGE_GERMAN )
+ rValue = "http://www.stardivision.de";
+ else
+ rValue = "http://www.stardivision.com";
+ return TRUE;
+ }
+
+ case SFX_KEY_INET_MEMCACHE:
+ rValue = "4";
+ return TRUE;
+
+ case SFX_KEY_INET_DISKCACHE:
+ rValue = "2048";
+ return TRUE;
+
+ case SFX_KEY_INET_CACHEEXPIRATION:
+ rValue = "3";
+ return TRUE;
+
+ case SFX_KEY_INET_MAXHTTPCONS:
+ rValue = "4";
+ return TRUE;
+
+ case SFX_KEY_INET_MAXFTPCONS:
+ rValue = "2";
+ return TRUE;
+
+// case SFX_KEY_INET_JAVAMINHEAP:
+// rValue = "256";
+// return TRUE;
+
+// case SFX_KEY_INET_JAVAMAXHEAP:
+// rValue = "";
+// return TRUE;
+
+ case SFX_KEY_INET_USERAGENT:
+ rValue = INET_DEF_CALLERNAME;
+ return TRUE;
+
+ case SFX_KEY_INET_EXE_JAVASCRIPT:
+#ifdef SOLAR_JAVA
+ rValue = "0"; // noch "0", solange es noch soviel Bugs gibt
+#else
+ rValue = "0"; // immer "0"
+#endif
+ return TRUE;
+
+ case SFX_KEY_INET_EXE_PLUGIN:
+ rValue = "1";
+ return TRUE;
+
+/* case SFX_KEY_INET_JAVA_ENABLE:
+#ifdef SOLAR_JAVA
+ rValue = "1";
+#else
+ rValue = "0";
+#endif
+ return TRUE; */
+
+// case SFX_KEY_INET_NETACCESS:
+// rValue = "2";
+// return TRUE;
+
+ case SFX_KEY_INET_CHANNELS:
+ rValue = "1";
+ return TRUE;
+
+ case SFX_KEY_BASIC_ENABLE:
+ rValue = "1";
+ return TRUE;
+
+ case SFX_KEY_INET_COOKIES:
+ rValue = "1";
+ return TRUE;
+
+ case SFX_KEY_ICONGRID:
+ rValue = "100;70;0";
+ return TRUE;
+
+ case SFX_KEY_METAFILEPRINT:
+ rValue = "1";
+ return TRUE;
+ }
+
+ return SfxIniDefaulter::QueryDefault( rValue, rEntry );
+}
+
+//=========================================================================
+
+SfxIniDefaultManager::SfxIniDefaultManager()
+: _pList( new SfxIniDefaulterList )
+{
+ new SfxStdIniDef_Impl( this );
+}
+
+//-------------------------------------------------------------------------
+
+SfxIniDefaultManager::~SfxIniDefaultManager()
+{
+ if ( _pList )
+ {
+ for ( USHORT n = _pList->Count(); n--; )
+ delete _pList->GetObject(n);
+ delete _pList;
+ }
+}
+
+//-------------------------------------------------------------------------
+
+BOOL SfxIniDefaultManager::QueryDefault
+(
+ String& rValue, /* out: Default-Wert f"ur 'rEntry'
+ (Default ist Leerstring) */
+ const SfxIniEntry& rEntry // in: Beschreibung des Eintrags
+)
+
+/* [Beschreibung]
+
+ "Uber diese interne Methode besorgt sich der <SfxIniManager> den
+ Default f"ur einen in 'rEntry' beschriebenen Eintrag.
+*/
+
+{
+ for ( USHORT n = _pList->Count(); n--; )
+ if ( _pList->GetObject(n)->QueryDefault( rValue, rEntry ) )
+ return TRUE;
+ return FALSE;
+}
+
+//=========================================================================
+
+SfxIniDefaulter::SfxIniDefaulter( SfxIniDefaultManager *pManager )
+
+/* [Beschreibung]
+
+ Der Ctor dieser Klasse meldet die neue Instanz automatisch am
+ <SfxiniDefaultManager> 'pManager' an.
+*/
+
+: _pManager( pManager )
+
+{
+ pManager->Insert( this );
+}
+
+//-------------------------------------------------------------------------
+
+SfxIniDefaulter::~SfxIniDefaulter()
+
+/* [Beschreibung]
+
+ Der Dtor dieser Klasse meldet die neue Instanz automatisch am
+ <SfxiniDefaultManager> ab, der im Ctor angegeben wurde.
+*/
+
+{
+ _pManager->Remove( this );
+}
+
+//-------------------------------------------------------------------------
+
+BOOL SfxIniDefaulter::QueryDefault
+(
+ String& rValue, /* out: Default-Wert f"ur 'rEntry'
+ (Default ist Leerstring) */
+ const SfxIniEntry& rEntry // in: Beschreibung des Eintrags
+)
+
+/* [Beschreibung]
+
+ Diese virtuelle Methode mu\s "uberladen werden. Sie soll dann in
+ 'rValue' einen Default-Wert f"ur den in 'rEntry' beschriebenen
+ ini-Eintrag setzen, falls ihr dieser bekannt ist.
+
+
+ [Returnwert]
+
+ TRUE In 'rValue' befindet sich der Default-Wert.
+
+ FALSE F"ur diesen Eintrag ist kein Default-Wert bekannt.
+
+*/
+
+{
+ return FALSE;
+};
+
+//========================================================================
+
+SfxIniEntry::SfxIniEntry
+(
+ const String& aGroup,
+ const String& aKey,
+ SfxIniGroup eGroup,
+ SfxIniKey eKey,
+ USHORT nIndex
+)
+: _aGroup( aGroup ),
+ _aKey( aKey ),
+ _eGroup( eGroup ),
+ _eKey( eKey ),
+ _nIndex( nIndex )
+{
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc/svt_iniprop.cxx b/binfilter/bf_svtools/source/misc/svt_iniprop.cxx
new file mode 100644
index 000000000000..19db7fd3df19
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc/svt_iniprop.cxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 "iniprop.hxx"
+
+namespace binfilter
+{
+
+//-------------------------------------------------------------------------
+
+TYPEINIT1(SfxAppIniManagerProperty, ApplicationProperty);
+
+//-------------------------------------------------------------------------
+
+SfxAppIniManagerProperty::~SfxAppIniManagerProperty()
+{
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc/svt_ownlist.cxx b/binfilter/bf_svtools/source/misc/svt_ownlist.cxx
new file mode 100644
index 000000000000..bcb6b047371a
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc/svt_ownlist.cxx
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <ctype.h>
+#include <stdio.h>
+#include <tools/string.hxx>
+#include <com/sun/star/beans/PropertyValues.hpp>
+#include <bf_svtools/ownlist.hxx>
+
+using namespace com::sun::star;
+
+namespace binfilter
+{
+
+//=========================================================================
+//============== SvCommandList ============================================
+//=========================================================================
+PRV_SV_IMPL_OWNER_LIST(SvCommandList,SvCommand)
+
+//=========================================================================
+SvCommand & SvCommandList::Append
+(
+ const String & rCommand, /* das Kommando */
+ const String & rArg /* dasArgument des Kommandos */
+)
+/* [Beschreibung]
+
+ Es wird eine Objekt vom Typ SvCommand erzeugt und an die Liste
+ angeh"angt.
+
+ [R"uckgabewert]
+
+ SvCommand & Das erteugte Objekt wird zur"uckgegeben.
+*/
+{
+ SvCommand * pCmd = new SvCommand( rCommand, rArg );
+ aTypes.Insert( pCmd, LIST_APPEND );
+ return *pCmd;
+}
+
+//=========================================================================
+SvStream & operator >>
+(
+ SvStream & rStm, /* Stream aus dem gelesen wird */
+ SvCommandList & rThis /* Die zu f"ullende Liste */
+)
+/* [Beschreibung]
+
+ Die Liste mit ihren Elementen wird gelesen. Das Format ist:
+ 1. Anzahl der Elemente
+ 2. Alle Elemente
+
+ [R"uckgabewert]
+
+ SvStream & Der "ubergebene Stream.
+*/
+{
+ UINT32 nCount = 0;
+ rStm >> nCount;
+ if( !rStm.GetError() )
+ {
+ while( nCount-- )
+ {
+ SvCommand * pCmd = new SvCommand();
+ rStm >> *pCmd;
+ rThis.aTypes.Insert( pCmd, LIST_APPEND );
+ }
+ }
+ return rStm;
+}
+
+//=========================================================================
+SvStream & operator <<
+(
+ SvStream & rStm, /* Stream in den geschrieben wird */
+ const SvCommandList & rThis /* Die zu schreibende Liste */
+)
+/* [Beschreibung]
+
+ Die Liste mit ihren Elementen wir geschrieben. Das Format ist:
+ 1. Anzahl der Elemente
+ 2. Alle Elemente
+
+ [R"uckgabewert]
+
+ SvStream & Der "ubergebene Stream.
+*/
+{
+ UINT32 nCount = rThis.aTypes.Count();
+ rStm << nCount;
+
+ for( UINT32 i = 0; i < nCount; i++ )
+ {
+ SvCommand * pCmd = (SvCommand *)rThis.aTypes.GetObject( i );
+ rStm << *pCmd;
+ }
+ return rStm;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc/svt_restrictedpaths.cxx b/binfilter/bf_svtools/source/misc/svt_restrictedpaths.cxx
new file mode 100644
index 000000000000..718c907b09c8
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc/svt_restrictedpaths.cxx
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/urlobj.hxx>
+#include <algorithm>
+#include <vector>
+#include <osl/process.h>
+#include <tools/urlobj.hxx>
+#include <unotools/localfilehelper.hxx>
+#include <bf_svtools/syslocale.hxx>
+
+namespace binfilter
+{
+ //=====================================================================
+ //= CheckURLAllowed
+ //=====================================================================
+ struct CheckURLAllowed
+ {
+ protected:
+ #ifdef WNT
+ SvtSysLocale m_aSysLocale;
+ #endif
+ String m_sCheckURL; // the URL to check
+ bool m_bAllowParent;
+ public:
+ inline CheckURLAllowed( const String& _rCheckURL, bool bAllowParent = true )
+ :m_sCheckURL( _rCheckURL ), m_bAllowParent( bAllowParent )
+ {
+ #ifdef WNT
+ // on windows, assume that the relevant file systems are case insensitive,
+ // thus normalize the URL
+ m_sCheckURL = m_aSysLocale.GetCharClass().toLower( m_sCheckURL, 0, m_sCheckURL.Len() );
+ #endif
+ }
+
+ bool operator()( const String& _rApprovedURL )
+ {
+ #ifdef WNT
+ // on windows, assume that the relevant file systems are case insensitive,
+ // thus normalize the URL
+ String sApprovedURL( m_aSysLocale.GetCharClass().toLower( _rApprovedURL, 0, _rApprovedURL.Len() ) );
+ #else
+ String sApprovedURL( _rApprovedURL );
+ #endif
+
+ xub_StrLen nLenApproved = sApprovedURL.Len();
+ xub_StrLen nLenChecked = m_sCheckURL.Len();
+
+ if ( nLenApproved > nLenChecked )
+ {
+ if ( m_bAllowParent )
+ {
+ if ( sApprovedURL.Search( m_sCheckURL ) == 0 )
+ {
+ if ( ( m_sCheckURL.GetChar( nLenChecked - 1 ) == '/' )
+ || ( sApprovedURL.GetChar( nLenChecked ) == '/' ) )
+ return true;
+ }
+ }
+ else
+ {
+ // just a difference in final slash?
+ if ( ( nLenApproved == ( nLenChecked + 1 ) ) &&
+ ( sApprovedURL.GetChar( nLenApproved - 1 ) == '/' ) )
+ return true;
+ }
+ return false;
+ }
+ else if ( nLenApproved < nLenChecked )
+ {
+ if ( m_sCheckURL.Search( sApprovedURL ) == 0 )
+ {
+ if ( ( sApprovedURL.GetChar( nLenApproved - 1 ) == '/' )
+ || ( m_sCheckURL.GetChar( nLenApproved ) == '/' ) )
+ return true;
+ }
+ return false;
+ }
+ else
+ {
+ // strings have equal length
+ return ( sApprovedURL == m_sCheckURL );
+ }
+ }
+ };
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc/svt_templatefoldercache.cxx b/binfilter/bf_svtools/source/misc/svt_templatefoldercache.cxx
new file mode 100644
index 000000000000..004788b49f57
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc/svt_templatefoldercache.cxx
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/urlobj.hxx>
+#include <tools/string.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 <rtl/ref.hxx>
+#include <salhelper/simplereferenceobject.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/debug.hxx>
+#include <bf_svtools/pathoptions.hxx>
+#include "comphelper/processfactory.hxx"
+#include <vector>
+#include <list>
+#include <functional>
+#include <algorithm>
+
+//.........................................................................
+namespace binfilter
+{
+//.........................................................................
+
+ 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 );
+ }
+
+ //---------------------------------------------------------------------
+ /// 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 );
+ }
+ };
+//.........................................................................
+} // namespace sfx2
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc/svt_urihelper.cxx b/binfilter/bf_svtools/source/misc/svt_urihelper.cxx
new file mode 100644
index 000000000000..f95bc04ba5f6
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc/svt_urihelper.cxx
@@ -0,0 +1,870 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/urlobj.hxx>
+#include <tools/table.hxx>
+#include <urihelper.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "com/sun/star/lang/WrappedTargetRuntimeException.hpp"
+#include "com/sun/star/lang/XMultiComponentFactory.hpp"
+#include "com/sun/star/ucb/Command.hpp"
+#include <com/sun/star/ucb/FileSystemNotation.hpp>
+#include "com/sun/star/ucb/IllegalIdentifierException.hpp"
+#include "com/sun/star/ucb/UnsupportedCommandException.hpp"
+#include "com/sun/star/ucb/XCommandEnvironment.hpp"
+#include "com/sun/star/ucb/XCommandProcessor.hpp"
+#include "com/sun/star/ucb/XContent.hpp"
+#include "com/sun/star/ucb/XContentIdentifierFactory.hpp"
+#include "com/sun/star/ucb/XContentProvider.hpp"
+#include <com/sun/star/ucb/XContentProviderManager.hpp>
+#include "com/sun/star/uno/Any.hxx"
+#include "com/sun/star/uno/Exception.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "com/sun/star/uno/Sequence.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/uno/XInterface.hpp"
+#include "com/sun/star/uri/UriReferenceFactory.hpp"
+#include "com/sun/star/uri/XUriReference.hpp"
+#include "com/sun/star/uri/XUriReferenceFactory.hpp"
+#include "cppuhelper/exc_hlp.hxx"
+#include "comphelper/processfactory.hxx"
+#include "osl/diagnose.h"
+#include "rtl/ustrbuf.hxx"
+#include "rtl/ustring.h"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+#include <tools/debug.hxx>
+#include <tools/inetmime.hxx>
+#include <ucbhelper/contentbroker.hxx>
+#include <unotools/charclass.hxx>
+#include "rtl/instance.hxx"
+
+namespace css = com::sun::star;
+using namespace com::sun::star;
+
+namespace binfilter
+{
+
+//============================================================================
+//
+// SmartRel2Abs
+//
+//============================================================================
+
+inline UniString toUniString(ByteString const & rString)
+{
+ return UniString(rString, RTL_TEXTENCODING_ISO_8859_1);
+}
+
+inline UniString toUniString(UniString const & rString)
+{
+ return rString;
+}
+
+template< typename Str >
+inline UniString SmartRel2Abs_Impl(INetURLObject const & rTheBaseURIRef,
+ Str const & rTheRelURIRef,
+ Link const & rMaybeFileHdl,
+ bool bCheckFileExists,
+ bool bIgnoreFragment,
+ INetURLObject::EncodeMechanism
+ eEncodeMechanism,
+ INetURLObject::DecodeMechanism
+ eDecodeMechanism,
+ rtl_TextEncoding eCharset,
+ bool bRelativeNonURIs,
+ INetURLObject::FSysStyle eStyle)
+{
+ // Backwards compatibility:
+ if (rTheRelURIRef.Len() != 0 && rTheRelURIRef.GetChar(0) == '#')
+ return toUniString(rTheRelURIRef);
+
+ INetURLObject aAbsURIRef;
+ if (rTheBaseURIRef.HasError())
+ aAbsURIRef.
+ SetSmartURL(rTheRelURIRef, eEncodeMechanism, eCharset, eStyle);
+ else
+ {
+ bool bWasAbsolute;
+ aAbsURIRef = rTheBaseURIRef.smartRel2Abs(rTheRelURIRef,
+ bWasAbsolute,
+ bIgnoreFragment,
+ eEncodeMechanism,
+ eCharset,
+ bRelativeNonURIs,
+ eStyle);
+ if (bCheckFileExists
+ && !bWasAbsolute
+ && (aAbsURIRef.GetProtocol() == INET_PROT_FILE) )
+ {
+ INetURLObject aNonFileURIRef;
+ aNonFileURIRef.SetSmartURL(rTheRelURIRef,
+ eEncodeMechanism,
+ eCharset,
+ eStyle);
+ if (!aNonFileURIRef.HasError()
+ && aNonFileURIRef.GetProtocol() != INET_PROT_FILE)
+ {
+ bool bMaybeFile = false;
+ if (rMaybeFileHdl.IsSet())
+ {
+ UniString aFilePath(toUniString(rTheRelURIRef));
+ bMaybeFile = rMaybeFileHdl.Call(&aFilePath) != 0;
+ }
+ if (!bMaybeFile)
+ aAbsURIRef = aNonFileURIRef;
+ }
+ }
+ }
+ return aAbsURIRef.GetMainURL(eDecodeMechanism, eCharset);
+}
+
+UniString
+SmartRel2Abs(INetURLObject const & rTheBaseURIRef,
+ UniString const & rTheRelURIRef,
+ Link const & rMaybeFileHdl,
+ bool bCheckFileExists,
+ bool bIgnoreFragment,
+ INetURLObject::EncodeMechanism eEncodeMechanism,
+ INetURLObject::DecodeMechanism eDecodeMechanism,
+ rtl_TextEncoding eCharset,
+ bool bRelativeNonURIs,
+ INetURLObject::FSysStyle eStyle)
+{
+ return SmartRel2Abs_Impl(rTheBaseURIRef, rTheRelURIRef, rMaybeFileHdl,
+ bCheckFileExists, bIgnoreFragment,
+ eEncodeMechanism, eDecodeMechanism, eCharset,
+ bRelativeNonURIs, eStyle);
+}
+
+//============================================================================
+//
+// SetMaybeFileHdl
+//
+//============================================================================
+
+}
+
+namespace { struct MaybeFileHdl : public rtl::Static< Link, MaybeFileHdl > {}; }
+
+namespace binfilter
+{
+
+void SetMaybeFileHdl(Link const & rTheMaybeFileHdl)
+{
+ MaybeFileHdl::get() = rTheMaybeFileHdl;
+}
+
+//============================================================================
+//
+// GetMaybeFileHdl
+//
+//============================================================================
+
+Link GetMaybeFileHdl()
+{
+ return MaybeFileHdl::get();
+}
+
+namespace {
+
+bool isAbsoluteHierarchicalUriReference(
+ css::uno::Reference< css::uri::XUriReference > const & uriReference)
+{
+ return uriReference.is() && uriReference->isAbsolute()
+ && uriReference->isHierarchical() && !uriReference->hasRelativePath();
+}
+
+// To improve performance, assume that if for any prefix URL of a given
+// hierarchical URL either a UCB content cannot be created, or the UCB content
+// does not support the getCasePreservingURL command, then this will hold for
+// any other prefix URL of the given URL, too:
+enum Result { Success, GeneralFailure, SpecificFailure };
+
+Result normalizePrefix(
+ css::uno::Reference< css::ucb::XContentProvider > const & broker,
+ rtl::OUString const & uri, rtl::OUString * normalized)
+{
+ OSL_ASSERT(broker.is() && normalized != 0);
+ css::uno::Reference< css::ucb::XContent > content;
+ try {
+ content = broker->queryContent(
+ css::uno::Reference< css::ucb::XContentIdentifierFactory >(
+ broker, css::uno::UNO_QUERY_THROW)->createContentIdentifier(
+ uri));
+ } catch (css::ucb::IllegalIdentifierException &) {}
+ if (!content.is()) {
+ return GeneralFailure;
+ }
+ try {
+ #if OSL_DEBUG_LEVEL > 0
+ bool ok =
+ #endif
+ (css::uno::Reference< css::ucb::XCommandProcessor >(
+ content, css::uno::UNO_QUERY_THROW)->execute(
+ css::ucb::Command(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "getCasePreservingURL")),
+ -1, css::uno::Any()),
+ 0,
+ css::uno::Reference< css::ucb::XCommandEnvironment >())
+ >>= *normalized);
+ OSL_ASSERT(ok);
+ } catch (css::uno::RuntimeException &) {
+ throw;
+ } catch (css::ucb::UnsupportedCommandException &) {
+ return GeneralFailure;
+ } catch (css::uno::Exception &) {
+ return SpecificFailure;
+ }
+ return Success;
+}
+
+rtl::OUString normalize(
+ css::uno::Reference< css::ucb::XContentProvider > const & broker,
+ css::uno::Reference< css::uri::XUriReferenceFactory > const & uriFactory,
+ rtl::OUString const & uriReference)
+{
+ // normalizePrefix can potentially fail (a typically example being a file
+ // URL that denotes a non-existing resource); in such a case, try to
+ // normalize as long a prefix of the given URL as possible (i.e., normalize
+ // all the existing directories within the path):
+ rtl::OUString normalized;
+ sal_Int32 n = uriReference.indexOf('#');
+ normalized = n == -1 ? uriReference : uriReference.copy(0, n);
+ switch (normalizePrefix(broker, normalized, &normalized)) {
+ case Success:
+ return n == -1 ? normalized : normalized + uriReference.copy(n);
+ case GeneralFailure:
+ return uriReference;
+ case SpecificFailure:
+ default:
+ break;
+ }
+ css::uno::Reference< css::uri::XUriReference > ref(
+ uriFactory->parse(uriReference));
+ if (!isAbsoluteHierarchicalUriReference(ref)) {
+ return uriReference;
+ }
+ sal_Int32 count = ref->getPathSegmentCount();
+ if (count < 2) {
+ return uriReference;
+ }
+ rtl::OUStringBuffer head(ref->getScheme());
+ head.append(static_cast< sal_Unicode >(':'));
+ if (ref->hasAuthority()) {
+ head.appendAscii(RTL_CONSTASCII_STRINGPARAM("//"));
+ head.append(ref->getAuthority());
+ }
+ for (sal_Int32 i = count - 1; i > 0; --i) {
+ rtl::OUStringBuffer buf(head);
+ for (sal_Int32 j = 0; j < i; ++j) {
+ buf.append(static_cast< sal_Unicode >('/'));
+ buf.append(ref->getPathSegment(j));
+ }
+ normalized = buf.makeStringAndClear();
+ if (normalizePrefix(broker, normalized, &normalized) != SpecificFailure)
+ {
+ buf.append(normalized);
+ css::uno::Reference< css::uri::XUriReference > preRef(
+ uriFactory->parse(normalized));
+ if (!isAbsoluteHierarchicalUriReference(preRef)) {
+ // This could only happen if something is inconsistent:
+ break;
+ }
+ sal_Int32 preCount = preRef->getPathSegmentCount();
+ // normalizePrefix may have added or removed a final slash:
+ if (preCount != i) {
+ if (preCount == i - 1) {
+ buf.append(static_cast< sal_Unicode >('/'));
+ } else if (preCount - 1 == i && buf.getLength() > 0
+ && buf.charAt(buf.getLength() - 1) == '/')
+ {
+ buf.setLength(buf.getLength() - 1);
+ } else {
+ // This could only happen if something is inconsistent:
+ break;
+ }
+ }
+ for (sal_Int32 j = i; j < count; ++j) {
+ buf.append(static_cast< sal_Unicode >('/'));
+ buf.append(ref->getPathSegment(j));
+ }
+ if (ref->hasQuery()) {
+ buf.append(static_cast< sal_Unicode >('?'));
+ buf.append(ref->getQuery());
+ }
+ if (ref->hasFragment()) {
+ buf.append(static_cast< sal_Unicode >('#'));
+ buf.append(ref->getFragment());
+ }
+ return buf.makeStringAndClear();
+ }
+ }
+ return uriReference;
+}
+
+}
+
+css::uno::Reference< css::uri::XUriReference >
+normalizedMakeRelative(
+ css::uno::Reference< css::uno::XComponentContext > const & context,
+ rtl::OUString const & baseUriReference, rtl::OUString const & uriReference)
+{
+ OSL_ASSERT(context.is());
+ css::uno::Reference< css::lang::XMultiComponentFactory > componentFactory(
+ context->getServiceManager());
+ if (!componentFactory.is()) {
+ throw css::uno::RuntimeException(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "component context has no service manager")),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ css::uno::Sequence< css::uno::Any > args(2);
+ args[0] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local"));
+ args[1] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office"));
+ css::uno::Reference< css::ucb::XContentProvider > broker;
+ try {
+ broker = css::uno::Reference< css::ucb::XContentProvider >(
+ componentFactory->createInstanceWithArgumentsAndContext(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.ucb.UniversalContentBroker")),
+ args, context),
+ css::uno::UNO_QUERY_THROW);
+ } catch (css::uno::RuntimeException &) {
+ throw;
+ } catch (css::uno::Exception &) {
+ css::uno::Any exception(cppu::getCaughtException());
+ throw css::lang::WrappedTargetRuntimeException(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "creating com.sun.star.ucb.UniversalContentBroker failed")),
+ css::uno::Reference< css::uno::XInterface >(),
+ exception);
+ }
+ css::uno::Reference< css::uri::XUriReferenceFactory > uriFactory(
+ css::uri::UriReferenceFactory::create(context));
+ return uriFactory->makeRelative(
+ uriFactory->parse(normalize(broker, uriFactory, baseUriReference)),
+ uriFactory->parse(normalize(broker, uriFactory, uriReference)), true,
+ true, false);
+}
+
+rtl::OUString simpleNormalizedMakeRelative(
+ rtl::OUString const & baseUriReference, rtl::OUString const & uriReference)
+{
+ com::sun::star::uno::Reference< com::sun::star::uri::XUriReference > rel(
+ normalizedMakeRelative(
+ com::sun::star::uno::Reference<
+ com::sun::star::uno::XComponentContext >(
+ (com::sun::star::uno::Reference<
+ com::sun::star::beans::XPropertySet >(
+ comphelper::getProcessServiceFactory(),
+ com::sun::star::uno::UNO_QUERY_THROW)->
+ getPropertyValue(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("DefaultContext")))),
+ com::sun::star::uno::UNO_QUERY_THROW),
+ baseUriReference, uriReference));
+ return rel.is() ? rel->getUriReference() : uriReference;
+}
+
+//============================================================================
+//
+// FindFirstURLInText
+//
+//============================================================================
+
+inline xub_StrLen nextChar(UniString const & rStr, xub_StrLen nPos)
+{
+ return INetMIME::isHighSurrogate(rStr.GetChar(nPos))
+ && rStr.Len() - nPos >= 2
+ && INetMIME::isLowSurrogate(rStr.GetChar(nPos + 1)) ?
+ nPos + 2 : nPos + 1;
+}
+
+bool isBoundary1(CharClass const & rCharClass, UniString const & rStr,
+ xub_StrLen nPos, xub_StrLen nEnd)
+{
+ if (nPos == nEnd)
+ return true;
+ if (rCharClass.isLetterNumeric(rStr, nPos))
+ return false;
+ switch (rStr.GetChar(nPos))
+ {
+ case '$':
+ case '%':
+ case '&':
+ case '-':
+ case '/':
+ case '@':
+ case '\\':
+ return false;
+ default:
+ return true;
+ }
+}
+
+bool isBoundary2(CharClass const & rCharClass, UniString const & rStr,
+ xub_StrLen nPos, xub_StrLen nEnd)
+{
+ if (nPos == nEnd)
+ return true;
+ if (rCharClass.isLetterNumeric(rStr, nPos))
+ return false;
+ switch (rStr.GetChar(nPos))
+ {
+ case '!':
+ case '#':
+ case '$':
+ case '%':
+ case '&':
+ case '\'':
+ case '*':
+ case '+':
+ case '-':
+ case '/':
+ case '=':
+ case '?':
+ case '@':
+ case '^':
+ case '_':
+ case '`':
+ case '{':
+ case '|':
+ case '}':
+ case '~':
+ return false;
+ default:
+ return true;
+ }
+}
+
+bool checkWChar(CharClass const & rCharClass, UniString const & rStr,
+ xub_StrLen * pPos, xub_StrLen * pEnd, bool bBackslash = false,
+ bool bPipe = false)
+{
+ sal_Unicode c = rStr.GetChar(*pPos);
+ if (INetMIME::isUSASCII(c))
+ {
+ static sal_uInt8 const aMap[128]
+ = { 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 1, 0, 0, 4, 4, 4, 1, // !"#$%&'
+ 1, 1, 1, 1, 1, 4, 1, 4, // ()*+,-./
+ 4, 4, 4, 4, 4, 4, 4, 4, // 01234567
+ 4, 4, 1, 1, 0, 1, 0, 1, // 89:;<=>?
+ 4, 4, 4, 4, 4, 4, 4, 4, // @ABCDEFG
+ 4, 4, 4, 4, 4, 4, 4, 4, // HIJKLMNO
+ 4, 4, 4, 4, 4, 4, 4, 4, // PQRSTUVW
+ 4, 4, 4, 1, 2, 1, 0, 1, // XYZ[\]^_
+ 0, 4, 4, 4, 4, 4, 4, 4, // `abcdefg
+ 4, 4, 4, 4, 4, 4, 4, 4, // hijklmno
+ 4, 4, 4, 4, 4, 4, 4, 4, // pqrstuvw
+ 4, 4, 4, 0, 3, 0, 1, 0 }; // xyz{|}~
+ switch (aMap[c])
+ {
+ default: // not uric
+ return false;
+
+ case 1: // uric
+ ++(*pPos);
+ return true;
+
+ case 2: // "\"
+ if (bBackslash)
+ {
+ *pEnd = ++(*pPos);
+ return true;
+ }
+ else
+ return false;
+
+ case 3: // "|"
+ if (bPipe)
+ {
+ *pEnd = ++(*pPos);
+ return true;
+ }
+ else
+ return false;
+
+ case 4: // alpha, digit, "$", "%", "&", "-", "/", "@" (see
+ // isBoundary1)
+ *pEnd = ++(*pPos);
+ return true;
+ }
+ }
+ else if (rCharClass.isLetterNumeric(rStr, *pPos))
+ {
+ *pEnd = *pPos = nextChar(rStr, *pPos);
+ return true;
+ }
+ else
+ return false;
+}
+
+sal_uInt32 scanDomain(UniString const & rStr, xub_StrLen * pPos,
+ xub_StrLen nEnd)
+{
+ sal_Unicode const * pBuffer = rStr.GetBuffer();
+ sal_Unicode const * p = pBuffer + *pPos;
+ sal_uInt32 nLabels = INetURLObject::scanDomain(p, pBuffer + nEnd, false);
+ *pPos = sal::static_int_cast< xub_StrLen >(p - pBuffer);
+ return nLabels;
+}
+
+UniString
+FindFirstURLInText(UniString const & rText,
+ xub_StrLen & rBegin,
+ xub_StrLen & rEnd,
+ CharClass const & rCharClass,
+ INetURLObject::EncodeMechanism eMechanism,
+ rtl_TextEncoding eCharset,
+ INetURLObject::FSysStyle eStyle)
+{
+ if (!(rBegin <= rEnd && rEnd <= rText.Len()))
+ return UniString();
+
+ // Search for the first substring of [rBegin..rEnd[ that matches any of the
+ // following productions (for which the appropriate style bit is set in
+ // eStyle, if applicable).
+ //
+ // 1st Production (known scheme):
+ // \B1 <one of the known schemes, except file> ":" 1*wchar ["#" 1*wchar]
+ // \B1
+ //
+ // 2nd Production (file):
+ // \B1 "FILE:" 1*(wchar / "\" / "|") ["#" 1*wchar] \B1
+ //
+ // 3rd Production (ftp):
+ // \B1 "FTP" 2*("." label) ["/" *wchar] ["#" 1*wchar] \B1
+ //
+ // 4th Production (http):
+ // \B1 "WWW" 2*("." label) ["/" *wchar] ["#" 1*wchar] \B1
+ //
+ // 5th Production (mailto):
+ // \B2 local-part "@" domain \B1
+ //
+ // 6th Production (UNC file):
+ // \B1 "\\" domain "\" *(wchar / "\") \B1
+ //
+ // 7th Production (DOS file):
+ // \B1 ALPHA ":\" *(wchar / "\") \B1
+ //
+ // 8th Production (Unix-like DOS file):
+ // \B1 ALPHA ":/" *(wchar / "\") \B1
+ //
+ // The productions use the following auxiliary rules.
+ //
+ // local-part = atom *("." atom)
+ // atom = 1*(alphanum / "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+"
+ // / "-" / "/" / "=" / "?" / "^" / "_" / "`" / "{" / "|" / "}"
+ // / "~")
+ // domain = label *("." label)
+ // label = alphanum [*(alphanum / "-") alphanum]
+ // alphanum = ALPHA / DIGIT
+ // wchar = <any uric character (ignoring the escaped rule), or "%", or
+ // a letter or digit (according to rCharClass)>
+ //
+ // "\B1" (boundary 1) stands for the beginning or end of the block of text,
+ // or a character that is neither (a) a letter or digit (according to
+ // rCharClass), nor (b) any of "$", "%", "&", "-", "/", "@", or "\".
+ // (FIXME: What was the rationale for this set of punctuation characters?)
+ //
+ // "\B2" (boundary 2) stands for the beginning or end of the block of text,
+ // or a character that is neither (a) a letter or digit (according to
+ // rCharClass), nor (b) any of "!", "#", "$", "%", "&", "'", "*", "+", "-",
+ // "/", "=", "?", "@", "^", "_", "`", "{", "|", "}", or "~" (i.e., an RFC
+ // 822 <atom> character, or "@" from \B1's set above).
+ //
+ // Productions 1--4, and 6--8 try to find a maximum-length match, but they
+ // stop at the first <wchar> character that is a "\B1" character which is
+ // only followed by "\B1" characters (taking "\" and "|" characters into
+ // account appropriately). Production 5 simply tries to find a maximum-
+ // length match.
+ //
+ // Productions 1--4 use the given eMechanism and eCharset. Productions 5--9
+ // use ENCODE_ALL.
+ //
+ // Productions 6--9 are only applicable if the FSYS_DOS bit is set in
+ // eStyle.
+
+ bool bBoundary1 = true;
+ bool bBoundary2 = true;
+ for (xub_StrLen nPos = rBegin; nPos != rEnd; nPos = nextChar(rText, nPos))
+ {
+ sal_Unicode c = rText.GetChar(nPos);
+ if (bBoundary1)
+ {
+ if (INetMIME::isAlpha(c))
+ {
+ xub_StrLen i = nPos;
+ INetProtocol eScheme
+ = INetURLObject::CompareProtocolScheme(UniString(rText, i,
+ rEnd));
+ if (eScheme == INET_PROT_FILE) // 2nd
+ {
+ while (rText.GetChar(i++) != ':') ;
+ xub_StrLen nPrefixEnd = i;
+ xub_StrLen nUriEnd = i;
+ while (i != rEnd
+ && checkWChar(rCharClass, rText, &i, &nUriEnd, true,
+ true)) ;
+ if (i != nPrefixEnd && rText.GetChar(i) == '#')
+ {
+ ++i;
+ while (i != rEnd
+ && checkWChar(rCharClass, rText, &i, &nUriEnd)) ;
+ }
+ if (nUriEnd != nPrefixEnd
+ && isBoundary1(rCharClass, rText, nUriEnd, rEnd))
+ {
+ INetURLObject aUri(UniString(rText, nPos,
+ nUriEnd - nPos),
+ INET_PROT_FILE, eMechanism, eCharset,
+ eStyle);
+ if (!aUri.HasError())
+ {
+ rBegin = nPos;
+ rEnd = nUriEnd;
+ return
+ aUri.GetMainURL(INetURLObject::DECODE_TO_IURI);
+ }
+ }
+ }
+ else if (eScheme != INET_PROT_NOT_VALID) // 1st
+ {
+ while (rText.GetChar(i++) != ':') ;
+ xub_StrLen nPrefixEnd = i;
+ xub_StrLen nUriEnd = i;
+ while (i != rEnd
+ && checkWChar(rCharClass, rText, &i, &nUriEnd)) ;
+ if (i != nPrefixEnd && rText.GetChar(i) == '#')
+ {
+ ++i;
+ while (i != rEnd
+ && checkWChar(rCharClass, rText, &i, &nUriEnd)) ;
+ }
+ if (nUriEnd != nPrefixEnd
+ && (isBoundary1(rCharClass, rText, nUriEnd, rEnd)
+ || rText.GetChar(nUriEnd) == '\\'))
+ {
+ INetURLObject aUri(UniString(rText, nPos,
+ nUriEnd - nPos),
+ INET_PROT_HTTP, eMechanism,
+ eCharset);
+ if (!aUri.HasError())
+ {
+ rBegin = nPos;
+ rEnd = nUriEnd;
+ return
+ aUri.GetMainURL(INetURLObject::DECODE_TO_IURI);
+ }
+ }
+ }
+
+ // 3rd, 4th:
+ i = nPos;
+ sal_uInt32 nLabels = scanDomain(rText, &i, rEnd);
+ if (nLabels >= 3
+ && rText.GetChar(nPos + 3) == '.'
+ && (((rText.GetChar(nPos) == 'w'
+ || rText.GetChar(nPos) == 'W')
+ && (rText.GetChar(nPos + 1) == 'w'
+ || rText.GetChar(nPos + 1) == 'W')
+ && (rText.GetChar(nPos + 2) == 'w'
+ || rText.GetChar(nPos + 2) == 'W'))
+ || ((rText.GetChar(nPos) == 'f'
+ || rText.GetChar(nPos) == 'F')
+ && (rText.GetChar(nPos + 1) == 't'
+ || rText.GetChar(nPos + 1) == 'T')
+ && (rText.GetChar(nPos + 2) == 'p'
+ || rText.GetChar(nPos + 2) == 'P'))))
+ // (note that rText.GetChar(nPos + 3) is guaranteed to be
+ // valid)
+ {
+ xub_StrLen nUriEnd = i;
+ if (i != rEnd && rText.GetChar(i) == '/')
+ {
+ nUriEnd = ++i;
+ while (i != rEnd
+ && checkWChar(rCharClass, rText, &i, &nUriEnd)) ;
+ }
+ if (i != rEnd && rText.GetChar(i) == '#')
+ {
+ ++i;
+ while (i != rEnd
+ && checkWChar(rCharClass, rText, &i, &nUriEnd)) ;
+ }
+ if (isBoundary1(rCharClass, rText, nUriEnd, rEnd)
+ || rText.GetChar(nUriEnd) == '\\')
+ {
+ INetURLObject aUri(UniString(rText, nPos,
+ nUriEnd - nPos),
+ INET_PROT_HTTP, eMechanism,
+ eCharset);
+ if (!aUri.HasError())
+ {
+ rBegin = nPos;
+ rEnd = nUriEnd;
+ return
+ aUri.GetMainURL(INetURLObject::DECODE_TO_IURI);
+ }
+ }
+ }
+
+ if ((eStyle & INetURLObject::FSYS_DOS) != 0 && rEnd - nPos >= 3
+ && rText.GetChar(nPos + 1) == ':'
+ && (rText.GetChar(nPos + 2) == '/'
+ || rText.GetChar(nPos + 2) == '\\')) // 7th, 8th
+ {
+ i = nPos + 3;
+ xub_StrLen nUriEnd = i;
+ while (i != rEnd
+ && checkWChar(rCharClass, rText, &i, &nUriEnd)) ;
+ if (isBoundary1(rCharClass, rText, nUriEnd, rEnd))
+ {
+ INetURLObject aUri(UniString(rText, nPos,
+ nUriEnd - nPos),
+ INET_PROT_FILE,
+ INetURLObject::ENCODE_ALL,
+ RTL_TEXTENCODING_UTF8,
+ INetURLObject::FSYS_DOS);
+ if (!aUri.HasError())
+ {
+ rBegin = nPos;
+ rEnd = nUriEnd;
+ return
+ aUri.GetMainURL(INetURLObject::DECODE_TO_IURI);
+ }
+ }
+ }
+ }
+ else if ((eStyle & INetURLObject::FSYS_DOS) != 0 && rEnd - nPos >= 2
+ && rText.GetChar(nPos) == '\\'
+ && rText.GetChar(nPos + 1) == '\\') // 6th
+ {
+ xub_StrLen i = nPos + 2;
+ sal_uInt32 nLabels = scanDomain(rText, &i, rEnd);
+ if (nLabels >= 1 && i != rEnd && rText.GetChar(i) == '\\')
+ {
+ xub_StrLen nUriEnd = ++i;
+ while (i != rEnd
+ && checkWChar(rCharClass, rText, &i, &nUriEnd,
+ true)) ;
+ if (isBoundary1(rCharClass, rText, nUriEnd, rEnd))
+ {
+ INetURLObject aUri(UniString(rText, nPos,
+ nUriEnd - nPos),
+ INET_PROT_FILE,
+ INetURLObject::ENCODE_ALL,
+ RTL_TEXTENCODING_UTF8,
+ INetURLObject::FSYS_DOS);
+ if (!aUri.HasError())
+ {
+ rBegin = nPos;
+ rEnd = nUriEnd;
+ return
+ aUri.GetMainURL(INetURLObject::DECODE_TO_IURI);
+ }
+ }
+ }
+ }
+ }
+ if (bBoundary2 && INetMIME::isAtomChar(c)) // 5th
+ {
+ bool bDot = false;
+ for (xub_StrLen i = nPos + 1; i != rEnd; ++i)
+ {
+ sal_Unicode c2 = rText.GetChar(i);
+ if (INetMIME::isAtomChar(c2))
+ bDot = false;
+ else if (bDot)
+ break;
+ else if (c2 == '.')
+ bDot = true;
+ else
+ {
+ if (c2 == '@')
+ {
+ ++i;
+ sal_uInt32 nLabels = scanDomain(rText, &i, rEnd);
+ if (nLabels >= 1
+ && isBoundary1(rCharClass, rText, i, rEnd))
+ {
+ INetURLObject aUri(UniString(rText, nPos, i - nPos),
+ INET_PROT_MAILTO,
+ INetURLObject::ENCODE_ALL);
+ if (!aUri.HasError())
+ {
+ rBegin = nPos;
+ rEnd = i;
+ return aUri.GetMainURL(
+ INetURLObject::DECODE_TO_IURI);
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+ bBoundary1 = isBoundary1(rCharClass, rText, nPos, rEnd);
+ bBoundary2 = isBoundary2(rCharClass, rText, nPos, rEnd);
+ }
+ rBegin = rEnd;
+ return UniString();
+}
+
+//============================================================================
+//
+// removePassword
+//
+//============================================================================
+
+UniString
+removePassword(UniString const & rURI,
+ INetURLObject::EncodeMechanism eEncodeMechanism,
+ INetURLObject::DecodeMechanism eDecodeMechanism,
+ rtl_TextEncoding eCharset)
+{
+ INetURLObject aObj(rURI, eEncodeMechanism, eCharset);
+ return aObj.HasError() ?
+ rURI :
+ String(aObj.GetURLNoPass(eDecodeMechanism, eCharset));
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc/svt_vcldata.cxx b/binfilter/bf_svtools/source/misc/svt_vcldata.cxx
new file mode 100644
index 000000000000..72a8d7b82fee
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc/svt_vcldata.cxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+
+#include <bf_svtools/svtdata.hxx>
+
+namespace binfilter
+{
+
+//============================================================================
+//
+// class ImpSvtData
+//
+//============================================================================
+
+ResMgr * ImpSvtData::GetResMgr()
+{
+ return GetResMgr(Application::GetSettings().GetUILocale());
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc1/makefile.mk b/binfilter/bf_svtools/source/misc1/makefile.mk
new file mode 100644
index 000000000000..1e17d8eac717
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc1/makefile.mk
@@ -0,0 +1,62 @@
+#*************************************************************************
+#
+# DO NOT ALTER 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.
+#
+#*************************************************************************
+
+EXTERNAL_WARNINGS_NOT_ERRORS := TRUE
+
+PRJ=..$/..$/..
+
+PRJNAME=binfilter
+TARGET=misc1
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+EXCEPTIONSFILES=\
+ $(SLO)$/svt_fstathelper.obj \
+ $(SLO)$/svt_strmadpt.obj \
+ $(SLO)$/svt_svtdata.obj
+
+SLOFILES=\
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/svt_adrparse.obj \
+ $(SLO)$/svt_docpasswdrequest.obj \
+ $(SLO)$/svt_inethist.obj \
+ $(SLO)$/svt_inettype.obj \
+ $(SLO)$/svt_loginerr.obj \
+ $(SLO)$/svt_PasswordHelper.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
+
+
diff --git a/binfilter/bf_svtools/source/misc1/svt_PasswordHelper.cxx b/binfilter/bf_svtools/source/misc1/svt_PasswordHelper.cxx
new file mode 100644
index 000000000000..4b4702ea2f00
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc1/svt_PasswordHelper.cxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 "PasswordHelper.hxx"
+
+#include <rtl/digest.h>
+#include <tools/string.hxx>
+
+using namespace com::sun::star;
+
+namespace binfilter
+{
+
+void SvPasswordHelper::GetHashPassword(uno::Sequence<sal_Int8>& rPassHash, const sal_Char* pPass, sal_uInt32 nLen)
+{
+ rPassHash.realloc(RTL_DIGEST_LENGTH_SHA1);
+
+ rtlDigestError aError = rtl_digest_SHA1 (pPass, nLen, reinterpret_cast<sal_uInt8*>(rPassHash.getArray()), rPassHash.getLength());
+ if (aError != rtl_Digest_E_None)
+ {
+ rPassHash.realloc(0);
+ }
+}
+
+void SvPasswordHelper::GetHashPasswordLittleEndian(uno::Sequence<sal_Int8>& rPassHash, const String& sPass)
+{
+ xub_StrLen nSize(sPass.Len());
+ sal_Char* pCharBuffer = new sal_Char[nSize * sizeof(sal_Unicode)];
+
+ for (xub_StrLen i = 0; i < nSize; ++i)
+ {
+ sal_Unicode ch(sPass.GetChar(i));
+ pCharBuffer[2 * i] = static_cast< sal_Char >(ch & 0xFF);
+ pCharBuffer[2 * i + 1] = static_cast< sal_Char >(ch >> 8);
+ }
+
+ GetHashPassword(rPassHash, pCharBuffer, nSize * sizeof(sal_Unicode));
+
+ delete[] pCharBuffer;
+}
+
+void SvPasswordHelper::GetHashPasswordBigEndian(uno::Sequence<sal_Int8>& rPassHash, const String& sPass)
+{
+ xub_StrLen nSize(sPass.Len());
+ sal_Char* pCharBuffer = new sal_Char[nSize * sizeof(sal_Unicode)];
+
+ for (xub_StrLen i = 0; i < nSize; ++i)
+ {
+ sal_Unicode ch(sPass.GetChar(i));
+ pCharBuffer[2 * i] = static_cast< sal_Char >(ch >> 8);
+ pCharBuffer[2 * i + 1] = static_cast< sal_Char >(ch & 0xFF);
+ }
+
+ GetHashPassword(rPassHash, pCharBuffer, nSize * sizeof(sal_Unicode));
+
+ delete[] pCharBuffer;
+}
+
+void SvPasswordHelper::GetHashPassword(uno::Sequence<sal_Int8>& rPassHash, const String& sPass)
+{
+ GetHashPasswordLittleEndian(rPassHash, sPass);
+}
+
+bool SvPasswordHelper::CompareHashPassword(const uno::Sequence<sal_Int8>& rOldPassHash, const String& sNewPass)
+{
+ bool bResult = false;
+
+ uno::Sequence<sal_Int8> aNewPass(RTL_DIGEST_LENGTH_SHA1);
+ GetHashPasswordLittleEndian(aNewPass, sNewPass);
+ if (aNewPass == rOldPassHash)
+ bResult = true;
+ else
+ {
+ GetHashPasswordBigEndian(aNewPass, sNewPass);
+ bResult = (aNewPass == rOldPassHash);
+ }
+
+ return bResult;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc1/svt_adrparse.cxx b/binfilter/bf_svtools/source/misc1/svt_adrparse.cxx
new file mode 100644
index 000000000000..8d91c8d279a3
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc1/svt_adrparse.cxx
@@ -0,0 +1,774 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/inetmime.hxx>
+
+#include <adrparse.hxx>
+
+
+//============================================================================
+namespace binfilter
+{
+
+enum ElementType { ELEMENT_START, ELEMENT_DELIM, ELEMENT_ITEM, ELEMENT_END };
+
+//============================================================================
+struct ParsedAddrSpec
+{
+ sal_Unicode const * m_pBegin;
+ sal_Unicode const * m_pEnd;
+ ElementType m_eLastElem;
+ bool m_bAtFound;
+ bool m_bReparse;
+
+ ParsedAddrSpec() { reset(); }
+
+ bool isPoorlyValid() const { return m_eLastElem >= ELEMENT_ITEM; }
+
+ bool isValid() const { return isPoorlyValid() && m_bAtFound; }
+
+ inline void reset();
+
+ inline void finish();
+};
+
+inline void ParsedAddrSpec::reset()
+{
+ m_pBegin = 0;
+ m_pEnd = 0;
+ m_eLastElem = ELEMENT_START;
+ m_bAtFound = false;
+ m_bReparse = false;
+}
+
+inline void ParsedAddrSpec::finish()
+{
+ if (isPoorlyValid())
+ m_eLastElem = ELEMENT_END;
+ else
+ reset();
+}
+
+//============================================================================
+class SvAddressParser_Impl
+{
+ enum State { BEFORE_COLON, BEFORE_LESS, AFTER_LESS, AFTER_GREATER };
+
+ enum TokenType { TOKEN_QUOTED = 0x80000000, TOKEN_DOMAIN, TOKEN_COMMENT,
+ TOKEN_ATOM };
+
+ sal_Unicode const * m_pInputPos;
+ sal_Unicode const * m_pInputEnd;
+ sal_uInt32 m_nCurToken;
+ sal_Unicode const * m_pCurTokenBegin;
+ sal_Unicode const * m_pCurTokenEnd;
+ sal_Unicode const * m_pCurTokenContentBegin;
+ sal_Unicode const * m_pCurTokenContentEnd;
+ bool m_bCurTokenReparse;
+ ParsedAddrSpec m_aOuterAddrSpec;
+ ParsedAddrSpec m_aInnerAddrSpec;
+ ParsedAddrSpec * m_pAddrSpec;
+ sal_Unicode const * m_pRealNameBegin;
+ sal_Unicode const * m_pRealNameEnd;
+ sal_Unicode const * m_pRealNameContentBegin;
+ sal_Unicode const * m_pRealNameContentEnd;
+ bool m_bRealNameReparse;
+ bool m_bRealNameFinished;
+ sal_Unicode const * m_pFirstCommentBegin;
+ sal_Unicode const * m_pFirstCommentEnd;
+ bool m_bFirstCommentReparse;
+ State m_eState;
+ TokenType m_eType;
+
+ inline void resetRealNameAndFirstComment();
+
+ inline void reset();
+
+ inline void addTokenToAddrSpec(ElementType eTokenElem);
+
+ inline void addTokenToRealName();
+
+ bool readToken();
+
+ static UniString reparse(sal_Unicode const * pBegin,
+ sal_Unicode const * pEnd, bool bAddrSpec);
+
+ static UniString reparseComment(sal_Unicode const * pBegin,
+ sal_Unicode const * pEnd);
+
+public:
+ SvAddressParser_Impl(SvAddressParser * pParser, UniString const & rInput);
+};
+
+inline void SvAddressParser_Impl::resetRealNameAndFirstComment()
+{
+ m_pRealNameBegin = 0;
+ m_pRealNameEnd = 0;
+ m_pRealNameContentBegin = 0;
+ m_pRealNameContentEnd = 0;
+ m_bRealNameReparse = false;
+ m_bRealNameFinished = false;
+ m_pFirstCommentBegin = 0;
+ m_pFirstCommentEnd = 0;
+ m_bFirstCommentReparse = false;
+}
+
+inline void SvAddressParser_Impl::reset()
+{
+ m_aOuterAddrSpec.reset();
+ m_aInnerAddrSpec.reset();
+ m_pAddrSpec = &m_aOuterAddrSpec;
+ resetRealNameAndFirstComment();
+ m_eState = BEFORE_COLON;
+ m_eType = TOKEN_ATOM;
+}
+
+inline void SvAddressParser_Impl::addTokenToAddrSpec(ElementType eTokenElem)
+{
+ if (!m_pAddrSpec->m_pBegin)
+ m_pAddrSpec->m_pBegin = m_pCurTokenBegin;
+ else if (m_pAddrSpec->m_pEnd < m_pCurTokenBegin)
+ m_pAddrSpec->m_bReparse = true;
+ m_pAddrSpec->m_pEnd = m_pCurTokenEnd;
+ m_pAddrSpec->m_eLastElem = eTokenElem;
+}
+
+inline void SvAddressParser_Impl::addTokenToRealName()
+{
+ if (!m_bRealNameFinished && m_eState != AFTER_LESS)
+ {
+ if (!m_pRealNameBegin)
+ m_pRealNameBegin = m_pRealNameContentBegin = m_pCurTokenBegin;
+ else if (m_pRealNameEnd < m_pCurTokenBegin - 1
+ || m_pRealNameEnd == m_pCurTokenBegin - 1
+ && *m_pRealNameEnd != ' ')
+ m_bRealNameReparse = true;
+ m_pRealNameEnd = m_pRealNameContentEnd = m_pCurTokenEnd;
+ }
+}
+
+//============================================================================
+//
+// SvAddressParser_Impl
+//
+//============================================================================
+
+bool SvAddressParser_Impl::readToken()
+{
+ m_nCurToken = m_eType;
+ m_bCurTokenReparse = false;
+ switch (m_eType)
+ {
+ case TOKEN_QUOTED:
+ {
+ m_pCurTokenBegin = m_pInputPos - 1;
+ m_pCurTokenContentBegin = m_pInputPos;
+ bool bEscaped = false;
+ for (;;)
+ {
+ if (m_pInputPos >= m_pInputEnd)
+ return false;
+ sal_Unicode cChar = *m_pInputPos++;
+ if (bEscaped)
+ {
+ m_bCurTokenReparse = true;
+ bEscaped = false;
+ }
+ else if (cChar == '"')
+ {
+ m_pCurTokenEnd = m_pInputPos;
+ m_pCurTokenContentEnd = m_pInputPos - 1;
+ return true;
+ }
+ else if (cChar == '\\')
+ bEscaped = true;
+ }
+ }
+
+ case TOKEN_DOMAIN:
+ {
+ m_pCurTokenBegin = m_pInputPos - 1;
+ m_pCurTokenContentBegin = m_pInputPos;
+ bool bEscaped = false;
+ for (;;)
+ {
+ if (m_pInputPos >= m_pInputEnd)
+ return false;
+ sal_Unicode cChar = *m_pInputPos++;
+ if (bEscaped)
+ bEscaped = false;
+ else if (cChar == ']')
+ {
+ m_pCurTokenEnd = m_pInputPos;
+ return true;
+ }
+ else if (cChar == '\\')
+ bEscaped = true;
+ }
+ }
+
+ case TOKEN_COMMENT:
+ {
+ m_pCurTokenBegin = m_pInputPos - 1;
+ m_pCurTokenContentBegin = 0;
+ m_pCurTokenContentEnd = 0;
+ bool bEscaped = false;
+ xub_StrLen nLevel = 0;
+ for (;;)
+ {
+ if (m_pInputPos >= m_pInputEnd)
+ return false;
+ sal_Unicode cChar = *m_pInputPos++;
+ if (bEscaped)
+ {
+ m_bCurTokenReparse = true;
+ m_pCurTokenContentEnd = m_pInputPos;
+ bEscaped = false;
+ }
+ else if (cChar == '(')
+ {
+ if (!m_pCurTokenContentBegin)
+ m_pCurTokenContentBegin = m_pInputPos - 1;
+ m_pCurTokenContentEnd = m_pInputPos;
+ ++nLevel;
+ }
+ else if (cChar == ')')
+ if (nLevel)
+ {
+ m_pCurTokenContentEnd = m_pInputPos;
+ --nLevel;
+ }
+ else
+ return true;
+ else if (cChar == '\\')
+ {
+ if (!m_pCurTokenContentBegin)
+ m_pCurTokenContentBegin = m_pInputPos - 1;
+ bEscaped = true;
+ }
+ else if (cChar > ' ' && cChar != 0x7F) // DEL
+ {
+ if (!m_pCurTokenContentBegin)
+ m_pCurTokenContentBegin = m_pInputPos - 1;
+ m_pCurTokenContentEnd = m_pInputPos;
+ }
+ }
+ }
+
+ default:
+ {
+ sal_Unicode cChar;
+ for (;;)
+ {
+ if (m_pInputPos >= m_pInputEnd)
+ return false;
+ cChar = *m_pInputPos++;
+ if (cChar > ' ' && cChar != 0x7F) // DEL
+ break;
+ }
+ m_pCurTokenBegin = m_pInputPos - 1;
+ if (cChar == '"' || cChar == '(' || cChar == ')' || cChar == ','
+ || cChar == '.' || cChar == ':' || cChar == ';'
+ || cChar == '<' || cChar == '>' || cChar == '@'
+ || cChar == '[' || cChar == '\\' || cChar == ']')
+ {
+ m_nCurToken = cChar;
+ m_pCurTokenEnd = m_pInputPos;
+ return true;
+ }
+ else
+ for (;;)
+ {
+ if (m_pInputPos >= m_pInputEnd)
+ {
+ m_pCurTokenEnd = m_pInputPos;
+ return true;
+ }
+ cChar = *m_pInputPos++;
+ if (cChar <= ' ' || cChar == '"' || cChar == '('
+ || cChar == ')' || cChar == ',' || cChar == '.'
+ || cChar == ':' || cChar == ';' || cChar == '<'
+ || cChar == '>' || cChar == '@' || cChar == '['
+ || cChar == '\\' || cChar == ']'
+ || cChar == 0x7F) // DEL
+ {
+ m_pCurTokenEnd = --m_pInputPos;
+ return true;
+ }
+ }
+ }
+ }
+}
+
+//============================================================================
+// static
+UniString SvAddressParser_Impl::reparse(sal_Unicode const * pBegin,
+ sal_Unicode const * pEnd,
+ bool bAddrSpec)
+{
+ UniString aResult;
+ TokenType eMode = TOKEN_ATOM;
+ bool bEscaped = false;
+ bool bEndsWithSpace = false;
+ xub_StrLen nLevel = 0;
+ while (pBegin < pEnd)
+ {
+ sal_Unicode cChar = *pBegin++;
+ switch (eMode)
+ {
+ case TOKEN_QUOTED:
+ if (bEscaped)
+ {
+ aResult += cChar;
+ bEscaped = false;
+ }
+ else if (cChar == '"')
+ {
+ if (bAddrSpec)
+ aResult += cChar;
+ eMode = TOKEN_ATOM;
+ }
+ else if (cChar == '\\')
+ {
+ if (bAddrSpec)
+ aResult += cChar;
+ bEscaped = true;
+ }
+ else
+ aResult += cChar;
+ break;
+
+ case TOKEN_DOMAIN:
+ if (bEscaped)
+ {
+ aResult += cChar;
+ bEscaped = false;
+ }
+ else if (cChar == ']')
+ {
+ aResult += cChar;
+ eMode = TOKEN_ATOM;
+ }
+ else if (cChar == '\\')
+ {
+ if (bAddrSpec)
+ aResult += cChar;
+ bEscaped = true;
+ }
+ else
+ aResult += cChar;
+ break;
+
+ case TOKEN_COMMENT:
+ if (bEscaped)
+ bEscaped = false;
+ else if (cChar == '(')
+ ++nLevel;
+ else if (cChar == ')')
+ if (nLevel)
+ --nLevel;
+ else
+ eMode = TOKEN_ATOM;
+ else if (cChar == '\\')
+ bEscaped = true;
+ break;
+
+ case TOKEN_ATOM:
+ if (cChar <= ' ' || cChar == 0x7F) // DEL
+ {
+ if (!bAddrSpec && !bEndsWithSpace)
+ {
+ aResult += ' ';
+ bEndsWithSpace = true;
+ }
+ }
+ else if (cChar == '(')
+ {
+ if (!bAddrSpec && !bEndsWithSpace)
+ {
+ aResult += ' ';
+ bEndsWithSpace = true;
+ }
+ eMode = TOKEN_COMMENT;
+ }
+ else
+ {
+ bEndsWithSpace = false;
+ if (cChar == '"')
+ {
+ if (bAddrSpec)
+ aResult += cChar;
+ eMode = TOKEN_QUOTED;
+ }
+ else if (cChar == '[')
+ {
+ aResult += cChar;
+ eMode = TOKEN_QUOTED;
+ }
+ else
+ aResult += cChar;
+ }
+ break;
+ }
+ }
+ return aResult;
+}
+
+//============================================================================
+// static
+UniString SvAddressParser_Impl::reparseComment(sal_Unicode const * pBegin,
+ sal_Unicode const * pEnd)
+{
+ UniString aResult;
+ while (pBegin < pEnd)
+ {
+ sal_Unicode cChar = *pBegin++;
+ if (cChar == '\\')
+ cChar = *pBegin++;
+ aResult += cChar;
+ }
+ return aResult;
+}
+
+//============================================================================
+SvAddressParser_Impl::SvAddressParser_Impl(SvAddressParser * pParser,
+ UniString const & rInput)
+{
+ m_pInputPos = rInput.GetBuffer();
+ m_pInputEnd = m_pInputPos + rInput.Len();
+
+ reset();
+ bool bDone = false;
+ for (;;)
+ {
+ if (!readToken())
+ {
+ m_bRealNameFinished = true;
+ if (m_eState == AFTER_LESS)
+ m_nCurToken = '>';
+ else
+ {
+ m_nCurToken = ',';
+ bDone = true;
+ }
+ }
+ switch (m_nCurToken)
+ {
+ case TOKEN_QUOTED:
+ if (m_pAddrSpec->m_eLastElem != ELEMENT_END)
+ {
+ if (m_pAddrSpec->m_bAtFound
+ || m_pAddrSpec->m_eLastElem <= ELEMENT_DELIM)
+ m_pAddrSpec->reset();
+ addTokenToAddrSpec(ELEMENT_ITEM);
+ }
+ if (!m_bRealNameFinished && m_eState != AFTER_LESS)
+ if (m_bCurTokenReparse)
+ {
+ if (!m_pRealNameBegin)
+ m_pRealNameBegin = m_pCurTokenBegin;
+ m_pRealNameEnd = m_pCurTokenEnd;
+ m_bRealNameReparse = true;
+ }
+ else if (m_bRealNameReparse)
+ m_pRealNameEnd = m_pCurTokenEnd;
+ else if (!m_pRealNameBegin)
+ {
+ m_pRealNameBegin = m_pCurTokenBegin;
+ m_pRealNameContentBegin = m_pCurTokenContentBegin;
+ m_pRealNameEnd = m_pRealNameContentEnd
+ = m_pCurTokenContentEnd;
+ }
+ else
+ {
+ m_pRealNameEnd = m_pCurTokenEnd;
+ m_bRealNameReparse = true;
+ }
+ m_eType = TOKEN_ATOM;
+ break;
+
+ case TOKEN_DOMAIN:
+ if (m_pAddrSpec->m_eLastElem != ELEMENT_END)
+ if (m_pAddrSpec->m_bAtFound
+ && m_pAddrSpec->m_eLastElem == ELEMENT_DELIM)
+ addTokenToAddrSpec(ELEMENT_ITEM);
+ else
+ m_pAddrSpec->reset();
+ addTokenToRealName();
+ m_eType = TOKEN_ATOM;
+ break;
+
+ case TOKEN_COMMENT:
+ if (!m_bRealNameFinished && m_eState != AFTER_LESS
+ && !m_pFirstCommentBegin && m_pCurTokenContentBegin)
+ {
+ m_pFirstCommentBegin = m_pCurTokenContentBegin;
+ m_pFirstCommentEnd = m_pCurTokenContentEnd;
+ m_bFirstCommentReparse = m_bCurTokenReparse;
+ }
+ m_eType = TOKEN_ATOM;
+ break;
+
+ case TOKEN_ATOM:
+ if (m_pAddrSpec->m_eLastElem != ELEMENT_END)
+ {
+ if (m_pAddrSpec->m_eLastElem != ELEMENT_DELIM)
+ m_pAddrSpec->reset();
+ addTokenToAddrSpec(ELEMENT_ITEM);
+ }
+ addTokenToRealName();
+ break;
+
+ case '(':
+ m_eType = TOKEN_COMMENT;
+ break;
+
+ case ')':
+ case '\\':
+ case ']':
+ m_pAddrSpec->finish();
+ addTokenToRealName();
+ break;
+
+ case '<':
+ switch (m_eState)
+ {
+ case BEFORE_COLON:
+ case BEFORE_LESS:
+ m_aOuterAddrSpec.finish();
+ if (m_pRealNameBegin)
+ m_bRealNameFinished = true;
+ m_pAddrSpec = &m_aInnerAddrSpec;
+ m_eState = AFTER_LESS;
+ break;
+
+ case AFTER_LESS:
+ m_aInnerAddrSpec.finish();
+ break;
+
+ case AFTER_GREATER:
+ m_aOuterAddrSpec.finish();
+ addTokenToRealName();
+ break;
+ }
+ break;
+
+ case '>':
+ if (m_eState == AFTER_LESS)
+ {
+ m_aInnerAddrSpec.finish();
+ if (m_aInnerAddrSpec.isValid())
+ m_aOuterAddrSpec.m_eLastElem = ELEMENT_END;
+ m_pAddrSpec = &m_aOuterAddrSpec;
+ m_eState = AFTER_GREATER;
+ }
+ else
+ {
+ m_aOuterAddrSpec.finish();
+ addTokenToRealName();
+ }
+ break;
+
+ case '@':
+ if (m_pAddrSpec->m_eLastElem != ELEMENT_END)
+ if (!m_pAddrSpec->m_bAtFound
+ && m_pAddrSpec->m_eLastElem == ELEMENT_ITEM)
+ {
+ addTokenToAddrSpec(ELEMENT_DELIM);
+ m_pAddrSpec->m_bAtFound = true;
+ }
+ else
+ m_pAddrSpec->reset();
+ addTokenToRealName();
+ break;
+
+ case ',':
+ case ';':
+ if (m_eState == AFTER_LESS)
+ if (m_nCurToken == ',')
+ {
+ if (m_aInnerAddrSpec.m_eLastElem
+ != ELEMENT_END)
+ m_aInnerAddrSpec.reset();
+ }
+ else
+ m_aInnerAddrSpec.finish();
+ else
+ {
+ m_pAddrSpec = m_aInnerAddrSpec.isValid()
+ || !m_aOuterAddrSpec.isValid()
+ && m_aInnerAddrSpec.isPoorlyValid() ?
+ &m_aInnerAddrSpec :
+ m_aOuterAddrSpec.isPoorlyValid() ?
+ &m_aOuterAddrSpec : 0;
+ if (m_pAddrSpec)
+ {
+ UniString aTheAddrSpec;
+ if (m_pAddrSpec->m_bReparse)
+ aTheAddrSpec = reparse(m_pAddrSpec->m_pBegin,
+ m_pAddrSpec->m_pEnd, true);
+ else
+ {
+ xub_StrLen nLen =
+ sal::static_int_cast< xub_StrLen >(
+ m_pAddrSpec->m_pEnd
+ - m_pAddrSpec->m_pBegin);
+ if (nLen == rInput.Len())
+ aTheAddrSpec = rInput;
+ else
+ aTheAddrSpec
+ = rInput.Copy(
+ sal::static_int_cast< xub_StrLen >(
+ m_pAddrSpec->m_pBegin
+ - rInput.GetBuffer()),
+ nLen);
+ }
+ UniString aTheRealName;
+ if (!m_pRealNameBegin
+ || m_pAddrSpec == &m_aOuterAddrSpec
+ && m_pRealNameBegin
+ == m_aOuterAddrSpec.m_pBegin
+ && m_pRealNameEnd == m_aOuterAddrSpec.m_pEnd
+ && m_pFirstCommentBegin)
+ if (!m_pFirstCommentBegin)
+ aTheRealName = aTheAddrSpec;
+ else if (m_bFirstCommentReparse)
+ aTheRealName
+ = reparseComment(m_pFirstCommentBegin,
+ m_pFirstCommentEnd);
+ else
+ aTheRealName
+ = rInput.Copy(
+ sal::static_int_cast< xub_StrLen >(
+ m_pFirstCommentBegin
+ - rInput.GetBuffer()),
+ sal::static_int_cast< xub_StrLen >(
+ m_pFirstCommentEnd
+ - m_pFirstCommentBegin));
+ else if (m_bRealNameReparse)
+ aTheRealName = reparse(m_pRealNameBegin,
+ m_pRealNameEnd, false);
+ else
+ {
+ xub_StrLen nLen =
+ sal::static_int_cast< xub_StrLen >(
+ m_pRealNameContentEnd
+ - m_pRealNameContentBegin);
+ if (nLen == rInput.Len())
+ aTheRealName = rInput;
+ else
+ aTheRealName
+ = rInput.Copy(
+ sal::static_int_cast< xub_StrLen >(
+ m_pRealNameContentBegin
+ - rInput.GetBuffer()),
+ nLen);
+ }
+ if (pParser->m_bHasFirst)
+ pParser->m_aRest.Insert(new SvAddressEntry_Impl(
+ aTheAddrSpec,
+ aTheRealName),
+ LIST_APPEND);
+ else
+ {
+ pParser->m_bHasFirst = true;
+ pParser->m_aFirst.m_aAddrSpec = aTheAddrSpec;
+ pParser->m_aFirst.m_aRealName = aTheRealName;
+ }
+ }
+ if (bDone)
+ return;
+ reset();
+ }
+ break;
+
+ case ':':
+ switch (m_eState)
+ {
+ case BEFORE_COLON:
+ m_aOuterAddrSpec.reset();
+ resetRealNameAndFirstComment();
+ m_eState = BEFORE_LESS;
+ break;
+
+ case BEFORE_LESS:
+ case AFTER_GREATER:
+ m_aOuterAddrSpec.finish();
+ addTokenToRealName();
+ break;
+
+ case AFTER_LESS:
+ m_aInnerAddrSpec.reset();
+ break;
+ }
+ break;
+
+ case '"':
+ m_eType = TOKEN_QUOTED;
+ break;
+
+ case '.':
+ if (m_pAddrSpec->m_eLastElem != ELEMENT_END)
+ if (m_pAddrSpec->m_eLastElem != ELEMENT_DELIM)
+ addTokenToAddrSpec(ELEMENT_DELIM);
+ else
+ m_pAddrSpec->reset();
+ addTokenToRealName();
+ break;
+
+ case '[':
+ m_eType = TOKEN_DOMAIN;
+ break;
+ }
+ }
+}
+
+//============================================================================
+//
+// SvAddressParser
+//
+//============================================================================
+
+SvAddressParser::SvAddressParser(UniString const & rInput): m_bHasFirst(false)
+{
+ SvAddressParser_Impl(this, rInput);
+}
+
+//============================================================================
+SvAddressParser::~SvAddressParser()
+{
+ for (ULONG i = m_aRest.Count(); i != 0;)
+ delete m_aRest.Remove(--i);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc1/svt_docpasswdrequest.cxx b/binfilter/bf_svtools/source/misc1/svt_docpasswdrequest.cxx
new file mode 100644
index 000000000000..36bdcb4a2c3c
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc1/svt_docpasswdrequest.cxx
@@ -0,0 +1,141 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 "docpasswdrequest.hxx"
+
+#include <com/sun/star/task/XInteractionAbort.hpp>
+#include <com/sun/star/task/XInteractionPassword.hpp>
+
+namespace binfilter
+{
+
+//==========================================================================
+
+class AbortContinuation : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionAbort >
+{
+ sal_Bool mbSelected;
+
+public:
+ AbortContinuation() : mbSelected( sal_False ) {}
+
+ sal_Bool isSelected() { return mbSelected; }
+
+ void reset() { mbSelected = sal_False; }
+
+ virtual void SAL_CALL select() throw(::com::sun::star::uno::RuntimeException) { mbSelected = sal_True; }
+};
+
+//==========================================================================
+
+class PasswordContinuation : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionPassword >
+{
+ sal_Bool mbSelected;
+ ::rtl::OUString maPassword;
+
+public:
+ PasswordContinuation() : mbSelected( sal_False ) {}
+
+ sal_Bool isSelected() { return mbSelected; }
+
+ void reset() { mbSelected = sal_False; }
+
+ virtual void SAL_CALL select() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPassword( const ::rtl::OUString& aPass ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getPassword( ) throw (::com::sun::star::uno::RuntimeException);
+};
+
+void SAL_CALL PasswordContinuation::select()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ mbSelected = sal_True;
+}
+
+void SAL_CALL PasswordContinuation::setPassword( const ::rtl::OUString& aPass )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ maPassword = aPass;
+}
+
+::rtl::OUString SAL_CALL PasswordContinuation::getPassword()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return maPassword;
+}
+
+//==========================================================================
+
+RequestDocumentPassword::RequestDocumentPassword( ::com::sun::star::task::PasswordRequestMode nMode, ::rtl::OUString aName )
+{
+ ::rtl::OUString temp;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > temp2;
+ ::com::sun::star::task::DocumentPasswordRequest
+ aDocumentPasswordRequest( temp,
+ temp2,
+ ::com::sun::star::task::InteractionClassification_QUERY,
+ nMode,
+ aName );
+
+ m_aRequest <<= aDocumentPasswordRequest;
+
+ m_pAbort = new AbortContinuation;
+ m_pPassword = new PasswordContinuation;
+
+ m_lContinuations.realloc( 2 );
+ m_lContinuations[0] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pAbort );
+ m_lContinuations[1] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pPassword );
+}
+
+sal_Bool RequestDocumentPassword::isPassword()
+{
+ return m_pPassword->isSelected();
+}
+
+::rtl::OUString RequestDocumentPassword::getPassword()
+{
+ return m_pPassword->getPassword();
+}
+
+::com::sun::star::uno::Any SAL_CALL RequestDocumentPassword::getRequest()
+ throw( ::com::sun::star::uno::RuntimeException )
+{
+ return m_aRequest;
+}
+
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >
+ SAL_CALL RequestDocumentPassword::getContinuations()
+ throw( ::com::sun::star::uno::RuntimeException )
+{
+ return m_lContinuations;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc1/svt_fstathelper.cxx b/binfilter/bf_svtools/source/misc1/svt_fstathelper.cxx
new file mode 100644
index 000000000000..772478309349
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc1/svt_fstathelper.cxx
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/date.hxx>
+#include <tools/time.hxx>
+#include <tools/string.hxx>
+#include <ucbhelper/content.hxx>
+#include <com/sun/star/util/DateTime.hpp>
+
+#include <fstathelper.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ucb;
+using namespace ::rtl;
+
+namespace binfilter
+{
+
+
+sal_Bool GetModifiedDateTimeOfFile( const UniString& rURL,
+ Date* pDate, Time* pTime )
+{
+ sal_Bool bRet = FALSE;
+ try
+ {
+ ::ucbhelper::Content aTestContent( rURL,
+ uno::Reference< XCommandEnvironment > ());
+ uno::Any aAny = aTestContent.getPropertyValue(
+ OUString::createFromAscii( "DateModified" ) );
+ if( aAny.hasValue() )
+ {
+ bRet = sal_True;
+ const util::DateTime* pDT = (util::DateTime*)aAny.getValue();
+ if( pDate )
+ *pDate = Date( pDT->Day, pDT->Month, pDT->Year );
+ if( pTime )
+ *pTime = Time( pDT->Hours, pDT->Minutes,
+ pDT->Seconds, pDT->HundredthSeconds );
+ }
+ }
+ catch(...)
+ {
+ }
+
+ return bRet;
+}
+
+sal_Bool IsDocument( const UniString& rURL )
+{
+ BOOL bExist = FALSE;
+ try
+ {
+ ::ucbhelper::Content aTestContent( rURL,
+ uno::Reference< XCommandEnvironment > ());
+ bExist = aTestContent.isDocument();
+ }
+ catch(...)
+ {
+ }
+ return bExist;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc1/svt_inethist.cxx b/binfilter/bf_svtools/source/misc1/svt_inethist.cxx
new file mode 100644
index 000000000000..c3f1b554e328
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc1/svt_inethist.cxx
@@ -0,0 +1,517 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/inethist.hxx>
+
+#ifndef INCLUDED_ALGORITHM
+#include <algorithm>
+#define INCLUDED_ALGORITHM
+#endif
+
+#include "rtl/instance.hxx"
+
+#include "rtl/crc.h"
+
+#include "rtl/memory.h"
+
+#include <tools/solar.h>
+
+#include <tools/debug.hxx>
+
+#include <tools/string.hxx>
+
+#include <tools/urlobj.hxx>
+
+namespace binfilter
+{
+
+/*========================================================================
+ *
+ * INetURLHistory internals.
+ *
+ *======================================================================*/
+#define INETHIST_DEF_FTP_PORT 21
+#define INETHIST_DEF_HTTP_PORT 80
+#define INETHIST_DEF_HTTPS_PORT 443
+
+#define INETHIST_SIZE_LIMIT 1024
+#define INETHIST_MAGIC_HEAD 0x484D4849UL
+
+/*
+ * INetURLHistoryHint implementation.
+ */
+IMPL_PTRHINT (INetURLHistoryHint, const INetURLObject);
+
+/*========================================================================
+ *
+ * INetURLHistory_Impl interface.
+ *
+ *======================================================================*/
+class INetURLHistory_Impl
+{
+ /** head_entry.
+ */
+ struct head_entry
+ {
+ /** Representation.
+ */
+ UINT32 m_nMagic;
+ UINT16 m_nNext;
+ UINT16 m_nMBZ;
+
+ /** Initialization.
+ */
+ void initialize (void)
+ {
+ m_nMagic = INETHIST_MAGIC_HEAD;
+ m_nNext = 0;
+ m_nMBZ = 0;
+ }
+ };
+
+ /** hash_entry.
+ */
+ struct hash_entry
+ {
+ /** Representation.
+ */
+ UINT32 m_nHash;
+ UINT16 m_nLru;
+ UINT16 m_nMBZ;
+
+ /** Initialization.
+ */
+ void initialize (UINT16 nLru, UINT32 nHash = 0)
+ {
+ m_nHash = nHash;
+ m_nLru = nLru;
+ m_nMBZ = 0;
+ }
+
+ /** Comparison.
+ */
+ BOOL operator== (const hash_entry &rOther) const
+ {
+ return (m_nHash == rOther.m_nHash);
+ }
+ BOOL operator< (const hash_entry &rOther) const
+ {
+ return (m_nHash < rOther.m_nHash);
+ }
+
+ BOOL operator== (UINT32 nHash) const
+ {
+ return (m_nHash == nHash);
+ }
+ BOOL operator< (UINT32 nHash) const
+ {
+ return (m_nHash < nHash);
+ }
+ };
+
+ /** lru_entry.
+ */
+ struct lru_entry
+ {
+ /** Representation.
+ */
+ UINT32 m_nHash;
+ UINT16 m_nNext;
+ UINT16 m_nPrev;
+
+ /** Initialization.
+ */
+ void initialize (UINT16 nThis, UINT32 nHash = 0)
+ {
+ m_nHash = nHash;
+ m_nNext = nThis;
+ m_nPrev = nThis;
+ }
+ };
+
+ /** Representation.
+ */
+ head_entry m_aHead;
+ hash_entry m_pHash[INETHIST_SIZE_LIMIT];
+ lru_entry m_pList[INETHIST_SIZE_LIMIT];
+
+ /** Initialization.
+ */
+ void initialize (void);
+
+ /** capacity.
+ */
+ UINT16 capacity (void) const
+ {
+ return (UINT16)(INETHIST_SIZE_LIMIT);
+ }
+
+ /** crc32.
+ */
+ UINT32 crc32 (UniString const & rData) const
+ {
+ return rtl_crc32 (0, rData.GetBuffer(), rData.Len() * sizeof(sal_Unicode));
+ }
+
+ /** find.
+ */
+ UINT16 find (UINT32 nHash) const;
+
+ /** move.
+ */
+ void move (UINT16 nSI, UINT16 nDI);
+
+ /** backlink.
+ */
+ void backlink (UINT16 nThis, UINT16 nTail)
+ {
+ register lru_entry &rThis = m_pList[nThis];
+ register lru_entry &rTail = m_pList[nTail];
+
+ rTail.m_nNext = nThis;
+ rTail.m_nPrev = rThis.m_nPrev;
+ rThis.m_nPrev = nTail;
+ m_pList[rTail.m_nPrev].m_nNext = nTail;
+ }
+
+ /** unlink.
+ */
+ void unlink (UINT16 nThis)
+ {
+ register lru_entry &rThis = m_pList[nThis];
+
+ m_pList[rThis.m_nPrev].m_nNext = rThis.m_nNext;
+ m_pList[rThis.m_nNext].m_nPrev = rThis.m_nPrev;
+ rThis.m_nNext = nThis;
+ rThis.m_nPrev = nThis;
+ }
+
+ /** Not implemented.
+ */
+ INetURLHistory_Impl (const INetURLHistory_Impl&);
+ INetURLHistory_Impl& operator= (const INetURLHistory_Impl&);
+
+public:
+ INetURLHistory_Impl (void);
+ ~INetURLHistory_Impl (void);
+
+ /** putUrl/queryUrl.
+ */
+ void putUrl (const String &rUrl);
+ BOOL queryUrl (const String &rUrl);
+};
+
+/*========================================================================
+ *
+ * INetURLHistory_Impl implementation.
+ *
+ *======================================================================*/
+/*
+ * INetURLHistory_Impl.
+ */
+INetURLHistory_Impl::INetURLHistory_Impl (void)
+{
+ initialize();
+}
+
+/*
+ * ~INetURLHistory_Impl.
+ */
+INetURLHistory_Impl::~INetURLHistory_Impl (void)
+{
+}
+
+/*
+ * initialize.
+ */
+void INetURLHistory_Impl::initialize (void)
+{
+ m_aHead.initialize();
+
+ USHORT i, n = capacity();
+ for (i = 0; i < n; i++)
+ m_pHash[i].initialize(i);
+ for (i = 0; i < n; i++)
+ m_pList[i].initialize(i);
+ for (i = 1; i < n; i++)
+ backlink (m_aHead.m_nNext, i);
+}
+
+/*
+ * find.
+ */
+UINT16 INetURLHistory_Impl::find (UINT32 nHash) const
+{
+ UINT16 l = 0;
+ UINT16 r = capacity() - 1;
+ UINT16 c = capacity();
+
+ while ((l < r) && (r < c))
+ {
+ UINT16 m = (l + r) / 2;
+ if (m_pHash[m] == nHash)
+ return m;
+
+ if (m_pHash[m] < nHash)
+ l = m + 1;
+ else
+ r = m - 1;
+ }
+ return l;
+}
+
+/*
+ * move.
+ */
+void INetURLHistory_Impl::move (UINT16 nSI, UINT16 nDI)
+{
+ hash_entry e = m_pHash[nSI];
+ if (nSI < nDI)
+ {
+ // shift left.
+ rtl_moveMemory (
+ &m_pHash[nSI ],
+ &m_pHash[nSI + 1],
+ (nDI - nSI) * sizeof(hash_entry));
+ }
+ if (nSI > nDI)
+ {
+ // shift right.
+ rtl_moveMemory (
+ &m_pHash[nDI + 1],
+ &m_pHash[nDI ],
+ (nSI - nDI) * sizeof(hash_entry));
+ }
+ m_pHash[nDI] = e;
+}
+
+/*
+ * putUrl.
+ */
+void INetURLHistory_Impl::putUrl (const String &rUrl)
+{
+ UINT32 h = crc32 (rUrl);
+ UINT16 k = find (h);
+ if ((k < capacity()) && (m_pHash[k] == h))
+ {
+ // Cache hit.
+ UINT16 nMRU = m_pHash[k].m_nLru;
+ if (nMRU != m_aHead.m_nNext)
+ {
+ // Update LRU chain.
+ unlink (nMRU);
+ backlink (m_aHead.m_nNext, nMRU);
+
+ // Rotate LRU chain.
+ m_aHead.m_nNext = m_pList[m_aHead.m_nNext].m_nPrev;
+ }
+ }
+ else
+ {
+ // Cache miss. Obtain least recently used.
+ UINT16 nLRU = m_pList[m_aHead.m_nNext].m_nPrev;
+
+ UINT16 nSI = find (m_pList[nLRU].m_nHash);
+ if (!(nLRU == m_pHash[nSI].m_nLru))
+ {
+ // Update LRU chain.
+ nLRU = m_pHash[nSI].m_nLru;
+ unlink (nLRU);
+ backlink (m_aHead.m_nNext, nLRU);
+ }
+
+ // Rotate LRU chain.
+ m_aHead.m_nNext = m_pList[m_aHead.m_nNext].m_nPrev;
+
+ // Check source and destination.
+ UINT16 nDI = std::min (k, UINT16(capacity() - 1));
+ if (nSI < nDI)
+ {
+ if (!(m_pHash[nDI] < h))
+ nDI -= 1;
+ }
+ if (nDI < nSI)
+ {
+ if (m_pHash[nDI] < h)
+ nDI += 1;
+ }
+
+ // Assign data.
+ m_pList[m_aHead.m_nNext].m_nHash = m_pHash[nSI].m_nHash = h;
+ move (nSI, nDI);
+ }
+}
+
+/*
+ * queryUrl.
+ */
+BOOL INetURLHistory_Impl::queryUrl (const String &rUrl)
+{
+ UINT32 h = crc32 (rUrl);
+ UINT16 k = find (h);
+ if ((k < capacity()) && (m_pHash[k] == h))
+ {
+ // Cache hit.
+ return TRUE;
+ }
+ else
+ {
+ // Cache miss.
+ return FALSE;
+ }
+}
+
+/*========================================================================
+ *
+ * INetURLHistory::StaticInstance implementation.
+ *
+ *======================================================================*/
+INetURLHistory * INetURLHistory::StaticInstance::operator ()()
+{
+ static INetURLHistory g_aInstance;
+ return &g_aInstance;
+}
+
+/*========================================================================
+ *
+ * INetURLHistory implementation.
+ *
+ *======================================================================*/
+/*
+ * INetURLHistory.
+ */
+INetURLHistory::INetURLHistory() : m_pImpl (new INetURLHistory_Impl())
+{
+}
+
+/*
+ * ~INetURLHistory.
+ */
+INetURLHistory::~INetURLHistory()
+{
+ DELETEZ (m_pImpl);
+}
+
+/*
+ * GetOrCreate.
+ */
+INetURLHistory* INetURLHistory::GetOrCreate()
+{
+ return rtl_Instance<
+ INetURLHistory, StaticInstance,
+ osl::MutexGuard, osl::GetGlobalMutex >::create (
+ StaticInstance(), osl::GetGlobalMutex());
+}
+
+/*
+ * NormalizeUrl_Impl.
+ */
+void INetURLHistory::NormalizeUrl_Impl (INetURLObject &rUrl)
+{
+ switch (rUrl.GetProtocol())
+ {
+ case INET_PROT_FILE:
+ if (!rUrl.IsCaseSensitive())
+ {
+ String aPath (rUrl.GetURLPath(INetURLObject::NO_DECODE));
+ aPath.ToLowerAscii();
+ rUrl.SetURLPath (aPath, INetURLObject::NOT_CANONIC);
+ }
+ break;
+
+ case INET_PROT_FTP:
+ if (!rUrl.HasPort())
+ rUrl.SetPort (INETHIST_DEF_FTP_PORT);
+ break;
+
+ case INET_PROT_HTTP:
+ if (!rUrl.HasPort())
+ rUrl.SetPort (INETHIST_DEF_HTTP_PORT);
+ if (!rUrl.HasURLPath())
+ rUrl.SetURLPath ("/");
+ break;
+
+ case INET_PROT_HTTPS:
+ if (!rUrl.HasPort())
+ rUrl.SetPort (INETHIST_DEF_HTTPS_PORT);
+ if (!rUrl.HasURLPath())
+ rUrl.SetURLPath ("/");
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*
+ * PutUrl_Impl.
+ */
+void INetURLHistory::PutUrl_Impl (const INetURLObject &rUrl)
+{
+ DBG_ASSERT (m_pImpl, "PutUrl_Impl(): no Implementation");
+ if (m_pImpl)
+ {
+ INetURLObject aHistUrl (rUrl);
+ NormalizeUrl_Impl (aHistUrl);
+
+ m_pImpl->putUrl (aHistUrl.GetMainURL(INetURLObject::NO_DECODE));
+ Broadcast (INetURLHistoryHint (&rUrl));
+
+ if (aHistUrl.HasMark())
+ {
+ aHistUrl.SetURL (aHistUrl.GetURLNoMark(INetURLObject::NO_DECODE),
+ INetURLObject::NOT_CANONIC);
+
+ m_pImpl->putUrl (aHistUrl.GetMainURL(INetURLObject::NO_DECODE));
+ Broadcast (INetURLHistoryHint (&aHistUrl));
+ }
+ }
+}
+
+/*
+ * QueryUrl_Impl.
+ */
+BOOL INetURLHistory::QueryUrl_Impl (const INetURLObject &rUrl)
+{
+ DBG_ASSERT (m_pImpl, "QueryUrl_Impl(): no Implementation");
+ if (m_pImpl)
+ {
+ INetURLObject aHistUrl (rUrl);
+ NormalizeUrl_Impl (aHistUrl);
+
+ return m_pImpl->queryUrl (aHistUrl.GetMainURL(INetURLObject::NO_DECODE));
+ }
+ return FALSE;
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc1/svt_inettype.cxx b/binfilter/bf_svtools/source/misc1/svt_inettype.cxx
new file mode 100644
index 000000000000..472b3c154ee3
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc1/svt_inettype.cxx
@@ -0,0 +1,865 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/table.hxx>
+#include <tools/wldcrd.hxx>
+
+#include <bf_svtools/inettype.hxx>
+#include <bf_svtools/svtdata.hxx>
+#include <bf_svtools/svtools.hrc>
+
+#ifndef _SVSTDARR_STRINGSSORT_DECL
+#define _SVSTDARR_STRINGSSORT
+#include <bf_svtools/svstdarr.hxx>
+#undef _SVSTDARR_STRINGSSORT
+#endif
+
+//============================================================================
+namespace binfilter
+{
+
+//============================================================================
+struct MediaTypeEntry
+{
+ sal_Char const * m_pTypeName;
+ INetContentType m_eTypeID;
+ sal_Char const * m_pExtension;
+};
+
+//============================================================================
+struct TypeIDMapEntry
+{
+ UniString m_aTypeName;
+ UniString m_aPresentation;
+ UniString m_aSystemFileType;
+};
+
+//============================================================================
+struct TypeNameMapEntry: public UniString
+{
+ UniString m_aExtension;
+ INetContentType m_eTypeID;
+
+ TypeNameMapEntry(const UniString & rType):
+ UniString(rType), m_eTypeID(CONTENT_TYPE_UNKNOWN) {}
+};
+
+//============================================================================
+struct ExtensionMapEntry: public UniString
+{
+ INetContentType m_eTypeID;
+
+ ExtensionMapEntry(const UniString & rExt):
+ UniString(rExt), m_eTypeID(CONTENT_TYPE_UNKNOWN) {}
+};
+
+//============================================================================
+class Registration
+{
+ static Registration * m_pRegistration;
+
+ Table m_aTypeIDMap; // map TypeID to TypeName, Presentation
+ SvStringsSort m_aTypeNameMap; // map TypeName to TypeID, Extension
+ SvStringsSort m_aExtensionMap; // map Extension to TypeID
+ sal_uInt32 m_nNextDynamicID;
+
+public:
+ Registration(): m_nNextDynamicID(CONTENT_TYPE_LAST + 1) {}
+
+ ~Registration();
+
+ static inline void deinitialize();
+
+ static inline TypeIDMapEntry * getEntry(INetContentType eTypeID);
+
+ static TypeNameMapEntry * getExtensionEntry(UniString const & rTypeName);
+
+ static INetContentType RegisterContentType(UniString const & rTypeName,
+ UniString const &
+ rPresentation,
+ UniString const * pExtension,
+ UniString const *
+ pSystemFileType);
+
+ static INetContentType GetContentType(UniString const & rTypeName);
+
+ static UniString GetContentType(INetContentType eTypeID);
+
+ static INetContentType GetContentType4Extension(UniString const &
+ rExtension);
+
+};
+
+// static
+inline void Registration::deinitialize()
+{
+ delete m_pRegistration;
+ m_pRegistration = 0;
+}
+
+// static
+inline TypeIDMapEntry * Registration::getEntry(INetContentType eTypeID)
+{
+ return
+ m_pRegistration ?
+ static_cast< TypeIDMapEntry * >(m_pRegistration->
+ m_aTypeIDMap.Get(eTypeID)) :
+ 0;
+}
+
+//============================================================================
+MediaTypeEntry const * seekEntry(UniString const & rTypeName,
+ MediaTypeEntry const * pMap, sal_Size nSize);
+
+//============================================================================
+/** A mapping from type names to type ids and extensions. Sorted by type
+ name.
+ */
+MediaTypeEntry const aStaticTypeNameMap[CONTENT_TYPE_LAST + 1]
+ = { { " ", CONTENT_TYPE_UNKNOWN, "" },
+ { CONTENT_TYPE_STR_X_CNT_DOCUMENT, CONTENT_TYPE_X_CNT_DOCUMENT,
+ "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_FSYSBOX, CONTENT_TYPE_X_CNT_FSYSBOX, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_CDROM_VOLUME,
+ CONTENT_TYPE_X_CNT_CDROM_VOLUME, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_DISK_35, CONTENT_TYPE_X_CNT_DISK_35, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_DISK_525, CONTENT_TYPE_X_CNT_DISK_525,
+ "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_FSYSFILE, CONTENT_TYPE_X_CNT_FSYSFILE,
+ "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_FIXED_VOLUME,
+ CONTENT_TYPE_X_CNT_FIXED_VOLUME, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_FSYSFOLDER, CONTENT_TYPE_X_CNT_FSYSFOLDER,
+ "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_RAM_VOLUME, CONTENT_TYPE_X_CNT_RAM_VOLUME,
+ "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_REMOTE_VOLUME,
+ CONTENT_TYPE_X_CNT_REMOTE_VOLUME, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_REMOVEABLE_VOLUME,
+ CONTENT_TYPE_X_CNT_REMOVEABLE_VOLUME, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_FSYSSPECIALFILE,
+ CONTENT_TYPE_X_CNT_FSYSSPECIALFILE, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_FSYSSPECIALFOLDER,
+ CONTENT_TYPE_X_CNT_FSYSSPECIALFOLDER, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_TAPEDRIVE, CONTENT_TYPE_X_CNT_TAPEDRIVE,
+ "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_FSYSURLFILE, CONTENT_TYPE_X_CNT_FSYSURLFILE,
+ "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_FTPBOX, CONTENT_TYPE_X_CNT_FTPBOX, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_FTPFILE, CONTENT_TYPE_X_CNT_FTPFILE, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_FTPFOLDER, CONTENT_TYPE_X_CNT_FTPFOLDER,
+ "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_FTPLINK, CONTENT_TYPE_X_CNT_FTPLINK, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_HTTPBOX, CONTENT_TYPE_X_CNT_HTTPBOX, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_HTTPFILE, CONTENT_TYPE_X_CNT_HTTPFILE,
+ "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_IMAPBOX, CONTENT_TYPE_X_CNT_IMAPBOX, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_IMAPFOLDER, CONTENT_TYPE_X_CNT_IMAPFOLDER,
+ "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_MESSAGE, CONTENT_TYPE_X_CNT_MESSAGE, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_NEWSBOX, CONTENT_TYPE_X_CNT_NEWSBOX, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_NEWSGROUP, CONTENT_TYPE_X_CNT_NEWSGROUP,
+ "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_OUTBOX, CONTENT_TYPE_X_CNT_OUTBOX, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_POP3BOX, CONTENT_TYPE_X_CNT_POP3BOX, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_PUBLISHBOX, CONTENT_TYPE_X_CNT_PUBLISHBOX,
+ "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_SEARCHBOX, CONTENT_TYPE_X_CNT_SEARCHBOX,
+ "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_SEPARATOR, CONTENT_TYPE_X_CNT_SEPARATOR,
+ "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_BOOKMARK, CONTENT_TYPE_X_CNT_BOOKMARK,
+ "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_SUBSCRIBEBOX,
+ CONTENT_TYPE_X_CNT_SUBSCRIBEBOX, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_CDF, CONTENT_TYPE_X_CNT_CDF, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_CDFITEM, CONTENT_TYPE_X_CNT_CDFITEM, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_CDFSUB, CONTENT_TYPE_X_CNT_CDFSUB, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_STARCHANNEL, CONTENT_TYPE_X_CNT_STARCHANNEL,
+ "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_TRASHBOX, CONTENT_TYPE_X_CNT_TRASHBOX,
+ "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_TRASH, CONTENT_TYPE_X_CNT_TRASH, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_VIMBBOARD, CONTENT_TYPE_X_CNT_VIMBBOARD,
+ "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_VIMBBOARDBOX,
+ CONTENT_TYPE_X_CNT_VIMBBOARDBOX, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_VIMBOX, CONTENT_TYPE_X_CNT_VIMBOX, "tmp" },
+ { CONTENT_TYPE_STR_X_CNT_VIMINBOX, CONTENT_TYPE_X_CNT_VIMINBOX,
+ "tmp" },
+ { CONTENT_TYPE_STR_APP_OCTSTREAM, CONTENT_TYPE_APP_OCTSTREAM, "tmp" },
+ { CONTENT_TYPE_STR_APP_PDF, CONTENT_TYPE_APP_PDF, "pdf" },
+ { CONTENT_TYPE_STR_APP_RTF, CONTENT_TYPE_APP_RTF, "rtf" },
+ { CONTENT_TYPE_STR_APP_VND_CALC, CONTENT_TYPE_APP_VND_CALC, "sdc" },
+ { CONTENT_TYPE_STR_APP_VND_CHART, CONTENT_TYPE_APP_VND_CHART, "sds" },
+ { CONTENT_TYPE_STR_APP_VND_DRAW, CONTENT_TYPE_APP_VND_DRAW, "sda" },
+ { CONTENT_TYPE_STR_APP_VND_IMAGE, CONTENT_TYPE_APP_VND_IMAGE, "sim" },
+ { CONTENT_TYPE_STR_APP_VND_IMPRESS, CONTENT_TYPE_APP_VND_IMPRESS,
+ "sdd" },
+ { CONTENT_TYPE_STR_APP_VND_IMPRESSPACKED,
+ CONTENT_TYPE_APP_VND_IMPRESSPACKED, "sdp" },
+ { CONTENT_TYPE_STR_APP_VND_MAIL, CONTENT_TYPE_APP_VND_MAIL, "sdm" },
+ { CONTENT_TYPE_STR_APP_VND_MATH, CONTENT_TYPE_APP_VND_MATH, "smf" },
+ { CONTENT_TYPE_STR_APP_VND_NEWS, CONTENT_TYPE_APP_VND_NEWS, "sdm" },
+ { CONTENT_TYPE_STR_APP_VND_OUTTRAY, CONTENT_TYPE_APP_VND_OUTTRAY,
+ "sdm" },
+ { CONTENT_TYPE_STR_APP_VND_TEMPLATE, CONTENT_TYPE_APP_VND_TEMPLATE,
+ "vor" },
+ { CONTENT_TYPE_STR_APP_VND_WRITER, CONTENT_TYPE_APP_VND_WRITER,
+ "sdw" },
+ { CONTENT_TYPE_STR_APP_VND_WRITER_GLOBAL,
+ CONTENT_TYPE_APP_VND_WRITER_GLOBAL, "sgl" },
+ { CONTENT_TYPE_STR_APP_VND_WRITER_WEB,
+ CONTENT_TYPE_APP_VND_WRITER_WEB, "htm" },
+ { CONTENT_TYPE_STR_APP_VND_SUN_XML_CALC, CONTENT_TYPE_APP_VND_SUN_XML_CALC, "sxc" },
+ { CONTENT_TYPE_STR_APP_VND_SUN_XML_CHART, CONTENT_TYPE_APP_VND_SUN_XML_CHART, "sxs" },
+ { CONTENT_TYPE_STR_APP_VND_SUN_XML_DRAW, CONTENT_TYPE_APP_VND_SUN_XML_DRAW, "sxd" },
+ { CONTENT_TYPE_STR_APP_VND_SUN_XML_IMPRESS, CONTENT_TYPE_APP_VND_SUN_XML_IMPRESS, "sxi" },
+ { CONTENT_TYPE_STR_APP_VND_SUN_XML_IMPRESSPACKED, CONTENT_TYPE_APP_VND_SUN_XML_IMPRESSPACKED, "sxp" },
+ { CONTENT_TYPE_STR_APP_VND_SUN_XML_MATH, CONTENT_TYPE_APP_VND_SUN_XML_MATH, "sxm" },
+ { CONTENT_TYPE_STR_APP_VND_SUN_XML_WRITER, CONTENT_TYPE_APP_VND_SUN_XML_WRITER, "sxw" },
+ { CONTENT_TYPE_STR_APP_VND_SUN_XML_WRITER_GLOBAL, CONTENT_TYPE_APP_VND_SUN_XML_WRITER_GLOBAL, "sxg" },
+ { CONTENT_TYPE_STR_APP_FRAMESET, CONTENT_TYPE_APP_FRAMESET, "sfs" },
+ { CONTENT_TYPE_STR_APP_GALLERY, CONTENT_TYPE_APP_GALLERY, "gal" },
+ { CONTENT_TYPE_STR_APP_GALLERY_THEME, CONTENT_TYPE_APP_GALLERY_THEME,
+ "thm" },
+ { CONTENT_TYPE_STR_APP_JAR, CONTENT_TYPE_APP_JAR, "jar" },
+ { CONTENT_TYPE_STR_APP_MACRO, CONTENT_TYPE_APP_MACRO, "tmp" },
+ { CONTENT_TYPE_STR_APP_MSEXCEL, CONTENT_TYPE_APP_MSEXCEL, "xls" },
+ { CONTENT_TYPE_STR_APP_MSEXCEL_TEMPL, CONTENT_TYPE_APP_MSEXCEL_TEMPL,
+ "xlt" },
+ { CONTENT_TYPE_STR_APP_MSPPOINT, CONTENT_TYPE_APP_MSPPOINT, "ppt" },
+ { CONTENT_TYPE_STR_APP_MSPPOINT_TEMPL,
+ CONTENT_TYPE_APP_MSPPOINT_TEMPL, "pot" },
+ { CONTENT_TYPE_STR_APP_MSWORD, CONTENT_TYPE_APP_MSWORD, "doc" },
+ { CONTENT_TYPE_STR_APP_MSWORD_TEMPL, CONTENT_TYPE_APP_MSWORD_TEMPL,
+ "dot" },
+ { CONTENT_TYPE_STR_APP_SCHEDULE_CMB, CONTENT_TYPE_APP_SCHEDULE,
+ "tmp" },
+ { CONTENT_TYPE_STR_APP_SCHEDULE_EVT, CONTENT_TYPE_APP_SCHEDULE_EVT,
+ "tmp" },
+ { CONTENT_TYPE_STR_APP_SCHEDULE_FEVT,
+ CONTENT_TYPE_APP_SCHEDULE_FORM_EVT, "tmp" },
+ { CONTENT_TYPE_STR_APP_SCHEDULE_FTASK,
+ CONTENT_TYPE_APP_SCHEDULE_FORM_TASK, "tmp" },
+ { CONTENT_TYPE_STR_APP_SCHEDULE_TASK, CONTENT_TYPE_APP_SCHEDULE_TASK,
+ "tmp" },
+ { CONTENT_TYPE_STR_APP_STARCALC, CONTENT_TYPE_APP_STARCALC, "sdc" },
+ { CONTENT_TYPE_STR_APP_STARCHART, CONTENT_TYPE_APP_STARCHART, "sds" },
+ { CONTENT_TYPE_STR_APP_STARDRAW, CONTENT_TYPE_APP_STARDRAW, "sda" },
+ { CONTENT_TYPE_STR_APP_STARHELP, CONTENT_TYPE_APP_STARHELP, "svh" },
+ { CONTENT_TYPE_STR_APP_STARIMAGE, CONTENT_TYPE_APP_STARIMAGE, "sim" },
+ { CONTENT_TYPE_STR_APP_STARIMPRESS, CONTENT_TYPE_APP_STARIMPRESS,
+ "sdd" },
+ { CONTENT_TYPE_STR_APP_STARMAIL_SDM, CONTENT_TYPE_APP_STARMAIL_SDM,
+ "sdm" },
+ { CONTENT_TYPE_STR_APP_STARMAIL_SMD, CONTENT_TYPE_APP_STARMAIL_SMD,
+ "smd" },
+ { CONTENT_TYPE_STR_APP_STARMATH, CONTENT_TYPE_APP_STARMATH, "smf" },
+ { CONTENT_TYPE_STR_APP_STARWRITER, CONTENT_TYPE_APP_STARWRITER,
+ "sdw" },
+ { CONTENT_TYPE_STR_APP_STARWRITER_GLOB,
+ CONTENT_TYPE_APP_STARWRITER_GLOB, "sgl" },
+ { CONTENT_TYPE_STR_APP_CDE_CALENDAR_APP,
+ CONTENT_TYPE_APP_CDE_CALENDAR_APP, "appt" },
+ { CONTENT_TYPE_STR_APP_ZIP, CONTENT_TYPE_APP_ZIP, "zip" },
+ { CONTENT_TYPE_STR_AUDIO_AIFF, CONTENT_TYPE_AUDIO_AIFF, "aif" },
+ { CONTENT_TYPE_STR_AUDIO_BASIC, CONTENT_TYPE_AUDIO_BASIC, "au" },
+ { CONTENT_TYPE_STR_AUDIO_MIDI, CONTENT_TYPE_AUDIO_MIDI, "mid" },
+ { CONTENT_TYPE_STR_AUDIO_WAV, CONTENT_TYPE_AUDIO_WAV, "wav" },
+ { CONTENT_TYPE_STR_IMAGE_GENERIC, CONTENT_TYPE_IMAGE_GENERIC, "tmp" },
+ { CONTENT_TYPE_STR_IMAGE_GIF, CONTENT_TYPE_IMAGE_GIF, "gif" },
+ { CONTENT_TYPE_STR_IMAGE_JPEG, CONTENT_TYPE_IMAGE_JPEG, "jpg" },
+ { CONTENT_TYPE_STR_IMAGE_PCX, CONTENT_TYPE_IMAGE_PCX, "pcx" },
+ { CONTENT_TYPE_STR_IMAGE_PNG, CONTENT_TYPE_IMAGE_PNG, "png" },
+ { CONTENT_TYPE_STR_IMAGE_TIFF, CONTENT_TYPE_IMAGE_TIFF, "tif" },
+ { CONTENT_TYPE_STR_IMAGE_BMP, CONTENT_TYPE_IMAGE_BMP, "bmp" },
+ { CONTENT_TYPE_STR_INET_MSG_RFC822, CONTENT_TYPE_INET_MESSAGE_RFC822,
+ "tmp" },
+ { CONTENT_TYPE_STR_INET_MULTI_ALTERNATIVE,
+ CONTENT_TYPE_INET_MULTIPART_ALTERNATIVE, "tmp" },
+ { CONTENT_TYPE_STR_INET_MULTI_DIGEST,
+ CONTENT_TYPE_INET_MULTIPART_DIGEST, "tmp" },
+ { CONTENT_TYPE_STR_INET_MULTI_MIXED,
+ CONTENT_TYPE_INET_MULTIPART_MIXED, "tmp" },
+ { CONTENT_TYPE_STR_INET_MULTI_PARALLEL,
+ CONTENT_TYPE_INET_MULTIPART_PARALLEL, "tmp" },
+ { CONTENT_TYPE_STR_INET_MULTI_RELATED,
+ CONTENT_TYPE_INET_MULTIPART_RELATED, "tmp" },
+ { CONTENT_TYPE_STR_TEXT_ICALENDAR, CONTENT_TYPE_TEXT_ICALENDAR,
+ "ics" },
+ { CONTENT_TYPE_STR_TEXT_HTML, CONTENT_TYPE_TEXT_HTML, "htm" },
+ { CONTENT_TYPE_STR_TEXT_PLAIN, CONTENT_TYPE_TEXT_PLAIN, "txt" },
+ { CONTENT_TYPE_STR_TEXT_XMLICALENDAR, CONTENT_TYPE_TEXT_XMLICALENDAR,
+ "xcs" },
+ { CONTENT_TYPE_STR_TEXT_URL, CONTENT_TYPE_TEXT_URL, "url" },
+ { CONTENT_TYPE_STR_TEXT_VCALENDAR, CONTENT_TYPE_TEXT_VCALENDAR,
+ "vcs" },
+ { CONTENT_TYPE_STR_TEXT_VCARD, CONTENT_TYPE_TEXT_VCARD, "vcf" },
+ { CONTENT_TYPE_STR_VIDEO_VDO, CONTENT_TYPE_VIDEO_VDO, "vdo" },
+ { CONTENT_TYPE_STR_VIDEO_MSVIDEO, CONTENT_TYPE_VIDEO_MSVIDEO, "avi" },
+ { CONTENT_TYPE_STR_X_STARMAIL, CONTENT_TYPE_X_STARMAIL, "smd" },
+ { CONTENT_TYPE_STR_X_VRML, CONTENT_TYPE_X_VRML, "wrl" }
+};
+
+//============================================================================
+/** A mapping from extensions to type IDs. Sorted by extension.
+ */
+MediaTypeEntry const aStaticExtensionMap[]
+ = { { "aif", CONTENT_TYPE_AUDIO_AIFF, "" },
+ { "aiff", CONTENT_TYPE_AUDIO_AIFF, "" },
+ { "appt", CONTENT_TYPE_APP_CDE_CALENDAR_APP, "" },
+ { "au", CONTENT_TYPE_AUDIO_BASIC, "" },
+ { "avi", CONTENT_TYPE_VIDEO_MSVIDEO, "" },
+ { "bmp", CONTENT_TYPE_IMAGE_BMP, "" },
+ { "cgm", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "doc", CONTENT_TYPE_APP_MSWORD, "" },
+ { "dot", CONTENT_TYPE_APP_MSWORD_TEMPL, "" },
+ { "dxf", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "eps", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "gal", CONTENT_TYPE_APP_GALLERY, "" },
+ { "gif", CONTENT_TYPE_IMAGE_GIF, "" },
+ { "htm", CONTENT_TYPE_TEXT_HTML, "" },
+ { "html", CONTENT_TYPE_TEXT_HTML, "" },
+ { "ics", CONTENT_TYPE_TEXT_ICALENDAR, "" },
+ { "jar", CONTENT_TYPE_APP_JAR, "" },
+ { "jpeg", CONTENT_TYPE_IMAGE_JPEG, "" },
+ { "jpg", CONTENT_TYPE_IMAGE_JPEG, "" },
+ { "met", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "mid", CONTENT_TYPE_AUDIO_MIDI, "" },
+ { "midi", CONTENT_TYPE_AUDIO_MIDI, "" },
+ { "pbm", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "pcd", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "pct", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "pcx", CONTENT_TYPE_IMAGE_PCX, "" },
+ { "pdf", CONTENT_TYPE_APP_PDF, "" },
+ { "pgm", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "png", CONTENT_TYPE_IMAGE_PNG, "" },
+ { "pot", CONTENT_TYPE_APP_MSPPOINT_TEMPL, "" },
+ { "ppm", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "ppt", CONTENT_TYPE_APP_MSPPOINT, "" },
+ { "psd", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "ras", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "rtf", CONTENT_TYPE_APP_RTF, "" },
+ { "sda", CONTENT_TYPE_APP_VND_DRAW, "" },
+ { "sdc", CONTENT_TYPE_APP_VND_CALC, "" },
+ { "sdd", CONTENT_TYPE_APP_VND_IMPRESS, "" },
+ { "sdm", CONTENT_TYPE_APP_VND_MAIL, "" },
+ { "sdp", CONTENT_TYPE_APP_VND_IMPRESSPACKED, "" },
+ { "sds", CONTENT_TYPE_APP_VND_CHART, "" },
+ { "sdw", CONTENT_TYPE_APP_VND_WRITER, "" },
+ { "sd~", CONTENT_TYPE_X_STARMAIL, "" },
+ { "sfs", CONTENT_TYPE_APP_FRAMESET , "" },
+ { "sgl", CONTENT_TYPE_APP_VND_WRITER_GLOBAL , "" },
+ { "sim", CONTENT_TYPE_APP_VND_IMAGE, "" },
+ { "smd", CONTENT_TYPE_APP_STARMAIL_SMD, "" }, //CONTENT_TYPE_X_STARMAIL
+ { "smf", CONTENT_TYPE_APP_VND_MATH, "" },
+ { "svh", CONTENT_TYPE_APP_STARHELP, "" },
+ { "svm", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "sxc", CONTENT_TYPE_APP_VND_SUN_XML_CALC, "" },
+ { "sxd", CONTENT_TYPE_APP_VND_SUN_XML_DRAW, "" },
+ { "sxg", CONTENT_TYPE_APP_VND_SUN_XML_WRITER_GLOBAL, "" },
+ { "sxi", CONTENT_TYPE_APP_VND_SUN_XML_IMPRESS, "" },
+ { "sxm", CONTENT_TYPE_APP_VND_SUN_XML_MATH, "" },
+ { "sxp", CONTENT_TYPE_APP_VND_SUN_XML_IMPRESSPACKED, "" },
+ { "sxs", CONTENT_TYPE_APP_VND_SUN_XML_CHART, "" },
+ { "sxw", CONTENT_TYPE_APP_VND_SUN_XML_WRITER, "" },
+ { "tga", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "thm", CONTENT_TYPE_APP_GALLERY_THEME, "" },
+ { "tif", CONTENT_TYPE_IMAGE_TIFF, "" },
+ { "tiff", CONTENT_TYPE_IMAGE_TIFF, "" },
+ { "txt", CONTENT_TYPE_TEXT_PLAIN, "" },
+ { "url", CONTENT_TYPE_TEXT_URL, "" },
+ { "vcf", CONTENT_TYPE_TEXT_VCARD, "" },
+ { "vcs", CONTENT_TYPE_TEXT_VCALENDAR, "" },
+ { "vdo", CONTENT_TYPE_VIDEO_VDO, "" },
+ { "vor", CONTENT_TYPE_APP_VND_TEMPLATE, "" },
+ { "wav", CONTENT_TYPE_AUDIO_WAV, "" },
+ { "wmf", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "wrl", CONTENT_TYPE_X_VRML, "" },
+ { "xbm", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "xcs", CONTENT_TYPE_TEXT_XMLICALENDAR, "" },
+ { "xls", CONTENT_TYPE_APP_MSEXCEL, "" },
+ { "xlt", CONTENT_TYPE_APP_MSEXCEL_TEMPL, "" },
+ { "xlw", CONTENT_TYPE_APP_MSEXCEL, "" },
+ { "xpm", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "zip", CONTENT_TYPE_APP_ZIP, "" } };
+
+//============================================================================
+/** A mapping from presentations to type IDs. Sorted by presentations.
+ */
+MediaTypeEntry const aStaticPresentationMap[]
+ = { { "Binary Data", CONTENT_TYPE_APP_OCTSTREAM, "" },
+ { "Bitmap", CONTENT_TYPE_IMAGE_BMP, "" },
+ { "DOS Command File", CONTENT_TYPE_APP_OCTSTREAM, "" },
+ { "Digital Video", CONTENT_TYPE_VIDEO_MSVIDEO, "" },
+ { "Executable", CONTENT_TYPE_APP_OCTSTREAM, "" },
+ { "Grafik", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "HTM", CONTENT_TYPE_TEXT_HTML, "" },
+ { "HTML", CONTENT_TYPE_TEXT_HTML, "" },
+ { "Hypertext", CONTENT_TYPE_TEXT_HTML, "" },
+ { "Icon", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "Image File", CONTENT_TYPE_IMAGE_GENERIC, "" },
+ { "MIDI", CONTENT_TYPE_AUDIO_MIDI, "" },
+ { "Master Document", CONTENT_TYPE_APP_VND_WRITER_GLOBAL, "" },
+ { "Plain Text", CONTENT_TYPE_TEXT_PLAIN, "" },
+ { "StarCalc", CONTENT_TYPE_APP_VND_CALC, "" },
+ { "StarCalc 3.0", CONTENT_TYPE_APP_VND_CALC, "" },
+ { "StarCalc 4.0", CONTENT_TYPE_APP_VND_CALC, "" },
+ { "StarCalc 5.0", CONTENT_TYPE_APP_VND_CALC, "" },
+ { "StarCalc Datei", CONTENT_TYPE_APP_VND_CALC, "" },
+ { "StarCalc Document", CONTENT_TYPE_APP_VND_CALC, "" },
+ { "StarCalc File", CONTENT_TYPE_APP_VND_CALC, "" },
+ { "StarChart 3.0", CONTENT_TYPE_APP_VND_CHART, "" },
+ { "StarChart 4.0", CONTENT_TYPE_APP_VND_CHART, "" },
+ { "StarChart 5.0", CONTENT_TYPE_APP_VND_CHART, "" },
+ { "StarChart Document", CONTENT_TYPE_APP_VND_CHART, "" },
+ { "StarDraw 3.0", CONTENT_TYPE_APP_VND_DRAW, "" },
+ { "StarDraw 5.0", CONTENT_TYPE_APP_VND_DRAW, "" },
+ { "StarDraw", CONTENT_TYPE_APP_VND_DRAW, "" },
+ { "StarDraw Document", CONTENT_TYPE_APP_VND_DRAW, "" },
+ { "StarImpress 4.0", CONTENT_TYPE_APP_VND_IMPRESS, "" },
+ { "StarImpress 5.0 (packed)", CONTENT_TYPE_APP_VND_IMPRESSPACKED, "" },
+ { "StarImpress 5.0", CONTENT_TYPE_APP_VND_IMPRESS, "" },
+ { "StarImpress Document", CONTENT_TYPE_APP_VND_IMPRESS, "" },
+ { "StarMath 3.0", CONTENT_TYPE_APP_VND_MATH, "" },
+ { "StarMath 4.0", CONTENT_TYPE_APP_VND_MATH, "" },
+ { "StarMath 5.0", CONTENT_TYPE_APP_VND_MATH, "" },
+ { "StarMath Document", CONTENT_TYPE_APP_VND_MATH, "" },
+ { "StarMessage5", CONTENT_TYPE_APP_VND_MAIL, "" },
+ { "StarOffice XML (Calc)", CONTENT_TYPE_APP_VND_SUN_XML_CALC, "" },
+ { "StarOffice XML (Impress)", CONTENT_TYPE_APP_VND_SUN_XML_IMPRESS, "" },
+ { "StarOffice XML (Draw)", CONTENT_TYPE_APP_VND_SUN_XML_DRAW, "" },
+ { "StarOffice XML (Chart)", CONTENT_TYPE_APP_VND_SUN_XML_CHART, "" },
+ { "StarOffice XML (Writer)", CONTENT_TYPE_APP_VND_SUN_XML_WRITER, "" },
+ { "StarWriter", CONTENT_TYPE_APP_VND_WRITER, "" },
+ { "StarWriter 3.0", CONTENT_TYPE_APP_VND_WRITER, "" },
+ { "StarWriter 4.0", CONTENT_TYPE_APP_VND_WRITER, "" },
+ { "StarWriter 5.0", CONTENT_TYPE_APP_VND_WRITER, "" },
+ { "StarWriter Document", CONTENT_TYPE_APP_VND_WRITER, "" },
+ { "StarWriter/Global 5.0", CONTENT_TYPE_APP_VND_WRITER_GLOBAL, "" },
+ { "StarWriter/Global Document", CONTENT_TYPE_APP_VND_WRITER_GLOBAL, "" },
+ { "StarWriter/Web 5.0", CONTENT_TYPE_APP_VND_WRITER_WEB, "" },
+ { "StarWriterGlobal Document", CONTENT_TYPE_APP_VND_WRITER_GLOBAL, "" },
+ { "StarWriterHtml Document", CONTENT_TYPE_APP_VND_WRITER_WEB, "" },
+ { "UniformResourceLocator", CONTENT_TYPE_TEXT_URL, "" },
+ { "text/html", CONTENT_TYPE_TEXT_HTML, "" } };
+
+//============================================================================
+//
+// Registration
+//
+//============================================================================
+
+// static
+Registration * Registration::m_pRegistration = 0;
+
+//============================================================================
+Registration::~Registration()
+{
+ {for (ULONG i = 0; i < m_aTypeIDMap.Count(); ++i)
+ delete static_cast< TypeIDMapEntry * >(m_aTypeIDMap.GetObject(i));
+ }
+ m_aTypeIDMap.Clear();
+ {for (USHORT i = 0; i < m_aTypeNameMap.Count(); ++i)
+ delete static_cast< TypeNameMapEntry * >(m_aTypeNameMap.GetObject(i));
+ }
+ m_aTypeNameMap.Remove(USHORT(0), m_aTypeNameMap.Count());
+ {for (USHORT i = 0; i < m_aExtensionMap.Count(); ++i)
+ delete
+ static_cast< ExtensionMapEntry * >(m_aExtensionMap.GetObject(i));
+ }
+ m_aExtensionMap.Remove(USHORT(0), m_aExtensionMap.Count());
+}
+
+//============================================================================
+// static
+TypeNameMapEntry * Registration::getExtensionEntry(UniString const &
+ rTypeName)
+{
+ if (m_pRegistration)
+ {
+ UniString aTheTypeName = rTypeName;
+ aTheTypeName.ToLowerAscii();
+ USHORT nPos;
+ if (m_pRegistration->m_aTypeNameMap.Seek_Entry(&aTheTypeName, &nPos))
+ return static_cast< TypeNameMapEntry * >(m_pRegistration->
+ m_aTypeNameMap.
+ GetObject(nPos));
+ }
+ return 0;
+}
+
+//============================================================================
+// static
+INetContentType Registration::RegisterContentType(UniString const & rTypeName,
+ UniString const &
+ rPresentation,
+ UniString const *
+ pExtension,
+ UniString const *
+ pSystemFileType)
+{
+ if (!m_pRegistration)
+ m_pRegistration = new Registration;
+
+ DBG_ASSERT(GetContentType(rTypeName) == CONTENT_TYPE_UNKNOWN,
+ "Registration::RegisterContentType(): Already registered");
+
+ INetContentType eTypeID
+ = INetContentType(m_pRegistration->m_nNextDynamicID++);
+ UniString aTheTypeName = rTypeName;
+ aTheTypeName.ToLowerAscii();
+
+ TypeIDMapEntry * pTypeIDMapEntry = new TypeIDMapEntry;
+ pTypeIDMapEntry->m_aTypeName = aTheTypeName;
+ pTypeIDMapEntry->m_aPresentation = rPresentation;
+ if (pSystemFileType)
+ pTypeIDMapEntry->m_aSystemFileType = *pSystemFileType;
+ m_pRegistration->m_aTypeIDMap.Insert(eTypeID, pTypeIDMapEntry);
+
+ TypeNameMapEntry * pTypeNameMapEntry = new TypeNameMapEntry(aTheTypeName);
+ if (pExtension)
+ pTypeNameMapEntry->m_aExtension = *pExtension;
+ pTypeNameMapEntry->m_eTypeID = eTypeID;
+ m_pRegistration->m_aTypeNameMap.Insert(pTypeNameMapEntry);
+
+ if (pExtension)
+ {
+ ExtensionMapEntry * pExtensionMapEntry
+ = new ExtensionMapEntry(*pExtension);
+ pExtensionMapEntry->m_eTypeID = eTypeID;
+ m_pRegistration->m_aExtensionMap.Insert(pExtensionMapEntry);
+ }
+
+ return eTypeID;
+}
+
+//============================================================================
+// static
+INetContentType Registration::GetContentType(UniString const & rTypeName)
+{
+ if (!m_pRegistration)
+ m_pRegistration = new Registration;
+
+ UniString aTheTypeName = rTypeName;
+ aTheTypeName.ToLowerAscii();
+ USHORT nPos;
+ return m_pRegistration->m_aTypeNameMap.Seek_Entry(&aTheTypeName, &nPos) ?
+ static_cast< TypeNameMapEntry * >(m_pRegistration->
+ m_aTypeNameMap.
+ GetObject(nPos))->
+ m_eTypeID :
+ CONTENT_TYPE_UNKNOWN;
+}
+
+//============================================================================
+// static
+UniString Registration::GetContentType(INetContentType eTypeID)
+{
+ if (!m_pRegistration)
+ m_pRegistration = new Registration;
+
+ TypeIDMapEntry * pEntry
+ = static_cast< TypeIDMapEntry * >(m_pRegistration->
+ m_aTypeIDMap.Get(eTypeID));
+ return pEntry ? pEntry->m_aTypeName : UniString();
+}
+
+//============================================================================
+// static
+INetContentType Registration::GetContentType4Extension(UniString const &
+ rExtension)
+{
+ if (!m_pRegistration)
+ m_pRegistration = new Registration;
+
+ USHORT nPos;
+ return m_pRegistration->
+ m_aExtensionMap.
+ Seek_Entry(const_cast< UniString * >(&rExtension),
+ &nPos) ?
+ static_cast< ExtensionMapEntry * >(m_pRegistration->
+ m_aExtensionMap.
+ GetObject(nPos))->
+ m_eTypeID :
+ CONTENT_TYPE_UNKNOWN;
+}
+
+//============================================================================
+//
+// seekEntry
+//
+//============================================================================
+
+MediaTypeEntry const * seekEntry(UniString const & rTypeName,
+ MediaTypeEntry const * pMap, sal_Size nSize)
+{
+#if defined DBG_UTIL || defined INETTYPE_DEBUG
+ static bool bChecked = false;
+ if (!bChecked)
+ {
+ for (sal_Size i = 0; i < nSize - 1; ++i)
+ DBG_ASSERT(pMap[i].m_pTypeName < pMap[i + 1].m_pTypeName,
+ "seekEntry(): Bad map");
+ bChecked = true;
+ }
+#endif // DBG_UTIL, INETTYPE_DEBUG
+
+ sal_Size nLow = 0;
+ sal_Size nHigh = nSize;
+ while (nLow != nHigh)
+ {
+ sal_Size nMiddle = (nLow + nHigh) / 2;
+ MediaTypeEntry const * pEntry = pMap + nMiddle;
+ switch (rTypeName.CompareIgnoreCaseToAscii(pEntry->m_pTypeName))
+ {
+ case COMPARE_LESS:
+ nHigh = nMiddle;
+ break;
+
+ case COMPARE_EQUAL:
+ return pEntry;
+
+ case COMPARE_GREATER:
+ nLow = nMiddle + 1;
+ break;
+ }
+ }
+ return 0;
+}
+
+//============================================================================
+//static
+INetContentType INetContentTypes::RegisterContentType(UniString const &
+ rTypeName,
+ UniString const &
+ rPresentation,
+ UniString const *
+ pExtension,
+ UniString const *
+ pSystemFileType)
+{
+ INetContentType eTypeID = GetContentType(rTypeName);
+ if (eTypeID == CONTENT_TYPE_UNKNOWN)
+ eTypeID = Registration::RegisterContentType(rTypeName, rPresentation,
+ pExtension,
+ pSystemFileType);
+ else if (eTypeID > CONTENT_TYPE_LAST)
+ {
+ TypeIDMapEntry * pTypeEntry = Registration::getEntry(eTypeID);
+ if (pTypeEntry)
+ {
+ if (rPresentation.Len() != 0)
+ pTypeEntry->m_aPresentation = rPresentation;
+ if (pSystemFileType)
+ pTypeEntry->m_aSystemFileType = *pSystemFileType;
+ }
+ if (pExtension)
+ {
+ TypeNameMapEntry * pEntry
+ = Registration::getExtensionEntry(rTypeName);
+ if (pEntry)
+ pEntry->m_aExtension = *pExtension;
+ }
+ }
+ return eTypeID;
+}
+
+//============================================================================
+// static
+INetContentType INetContentTypes::GetContentType(UniString const & rTypeName)
+{
+ UniString aType;
+ UniString aSubType;
+ if (parse(rTypeName, aType, aSubType))
+ {
+ aType += '/';
+ aType += aSubType;
+ MediaTypeEntry const * pEntry = seekEntry(aType, aStaticTypeNameMap,
+ CONTENT_TYPE_LAST + 1);
+ return pEntry ? pEntry->m_eTypeID :
+ Registration::GetContentType(aType);
+ }
+ else
+ return
+ rTypeName.EqualsIgnoreCaseAscii(CONTENT_TYPE_STR_X_STARMAIL) ?
+ CONTENT_TYPE_X_STARMAIL : CONTENT_TYPE_UNKNOWN;
+ // the content type "x-starmail" has no sub type
+}
+
+//============================================================================
+//static
+UniString INetContentTypes::GetContentType(INetContentType eTypeID)
+{
+ static sal_Char const * aMap[CONTENT_TYPE_LAST + 1];
+ static bool bInitialized = false;
+ if (!bInitialized)
+ {
+ for (sal_Size i = 0; i <= CONTENT_TYPE_LAST; ++i)
+ aMap[aStaticTypeNameMap[i].m_eTypeID]
+ = aStaticTypeNameMap[i].m_pTypeName;
+ aMap[CONTENT_TYPE_UNKNOWN] = CONTENT_TYPE_STR_APP_OCTSTREAM;
+ aMap[CONTENT_TYPE_TEXT_PLAIN] = CONTENT_TYPE_STR_TEXT_PLAIN
+ "; charset=iso-8859-1";
+ bInitialized = true;
+ }
+
+ UniString aTypeName = eTypeID <= CONTENT_TYPE_LAST ?
+ UniString::CreateFromAscii(aMap[eTypeID]) :
+ Registration::GetContentType(eTypeID);
+ if (aTypeName.Len() == 0)
+ {
+ DBG_ERROR("INetContentTypes::GetContentType(): Bad ID");
+ return
+ UniString::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(
+ CONTENT_TYPE_STR_APP_OCTSTREAM));
+ }
+ return aTypeName;
+}
+
+//============================================================================
+//static
+UniString INetContentTypes::GetPresentation(INetContentType, const ::com::sun::star::lang::Locale& )
+{
+ UniString aPresentation;
+ return aPresentation;
+}
+
+//============================================================================
+//static
+INetContentType INetContentTypes::GetContentType4Extension(UniString const &
+ rExtension)
+{
+ MediaTypeEntry const * pEntry = seekEntry(rExtension, aStaticExtensionMap,
+ sizeof aStaticExtensionMap
+ / sizeof (MediaTypeEntry));
+ if (pEntry)
+ return pEntry->m_eTypeID;
+ INetContentType eTypeID
+ = Registration::GetContentType4Extension(rExtension);
+ return eTypeID == CONTENT_TYPE_UNKNOWN ? CONTENT_TYPE_APP_OCTSTREAM :
+ eTypeID;
+}
+
+//============================================================================
+// static
+bool INetContentTypes::parse(ByteString const & rMediaType,
+ ByteString & rType, ByteString & rSubType,
+ INetContentTypeParameterList * pParameters)
+{
+ sal_Char const * p = rMediaType.GetBuffer();
+ sal_Char const * pEnd = p + rMediaType.Len();
+
+ p = INetMIME::skipLinearWhiteSpaceComment(p, pEnd);
+ sal_Char const * pToken = p;
+ bool bDowncase = false;
+ while (p != pEnd && INetMIME::isTokenChar(*p))
+ {
+ bDowncase = bDowncase || INetMIME::isUpperCase(*p);
+ ++p;
+ }
+ if (p == pToken)
+ return false;
+ rType = ByteString(pToken, sal::static_int_cast< xub_StrLen >(p - pToken));
+ if (bDowncase)
+ rType.ToLowerAscii();
+
+ p = INetMIME::skipLinearWhiteSpaceComment(p, pEnd);
+ if (p == pEnd || *p++ != '/')
+ return false;
+
+ p = INetMIME::skipLinearWhiteSpaceComment(p, pEnd);
+ pToken = p;
+ bDowncase = false;
+ while (p != pEnd && INetMIME::isTokenChar(*p))
+ {
+ bDowncase = bDowncase || INetMIME::isUpperCase(*p);
+ ++p;
+ }
+ if (p == pToken)
+ return false;
+ rSubType = ByteString(
+ pToken, sal::static_int_cast< xub_StrLen >(p - pToken));
+ if (bDowncase)
+ rSubType.ToLowerAscii();
+
+ return INetMIME::scanParameters(p, pEnd, pParameters) == pEnd;
+}
+
+//============================================================================
+// static
+bool INetContentTypes::parse(UniString const & rMediaType,
+ UniString & rType, UniString & rSubType,
+ INetContentTypeParameterList * pParameters)
+{
+ sal_Unicode const * p = rMediaType.GetBuffer();
+ sal_Unicode const * pEnd = p + rMediaType.Len();
+
+ p = INetMIME::skipLinearWhiteSpaceComment(p, pEnd);
+ sal_Unicode const * pToken = p;
+ bool bDowncase = false;
+ while (p != pEnd && INetMIME::isTokenChar(*p))
+ {
+ bDowncase = bDowncase || INetMIME::isUpperCase(*p);
+ ++p;
+ }
+ if (p == pToken)
+ return false;
+ rType = UniString(pToken, sal::static_int_cast< xub_StrLen >(p - pToken));
+ if (bDowncase)
+ rType.ToLowerAscii();
+
+ p = INetMIME::skipLinearWhiteSpaceComment(p, pEnd);
+ if (p == pEnd || *p++ != '/')
+ return false;
+
+ p = INetMIME::skipLinearWhiteSpaceComment(p, pEnd);
+ pToken = p;
+ bDowncase = false;
+ while (p != pEnd && INetMIME::isTokenChar(*p))
+ {
+ bDowncase = bDowncase || INetMIME::isUpperCase(*p);
+ ++p;
+ }
+ if (p == pToken)
+ return false;
+ rSubType = UniString(
+ pToken, sal::static_int_cast< xub_StrLen >(p - pToken));
+ if (bDowncase)
+ rSubType.ToLowerAscii();
+
+ return INetMIME::scanParameters(p, pEnd, pParameters) == pEnd;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc1/svt_loginerr.cxx b/binfilter/bf_svtools/source/misc1/svt_loginerr.cxx
new file mode 100644
index 000000000000..3b7fa0e89cec
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc1/svt_loginerr.cxx
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/loginerr.hxx>
+
+namespace binfilter
+{
+
+//============================================================================
+//
+// CntLoginErrorHint Implementation.
+//
+//============================================================================
+
+TYPEINIT1( CntLoginErrorHint, SfxHint );
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc1/svt_strmadpt.cxx b/binfilter/bf_svtools/source/misc1/svt_strmadpt.cxx
new file mode 100644
index 000000000000..c6256ecfbdb6
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc1/svt_strmadpt.cxx
@@ -0,0 +1,920 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <functional> // needed under Solaris when including <algorithm>...
+
+#include <algorithm>
+#include <limits>
+#include <set>
+
+#include <rtl/alloc.h>
+#include <rtl/memory.h>
+
+#include <instrm.hxx>
+#include <outstrm.hxx>
+#include <strmadpt.hxx>
+
+using namespace com::sun::star;
+
+namespace binfilter
+{
+
+//============================================================================
+class SvDataPipe_Impl
+{
+public:
+ enum SeekResult { SEEK_BEFORE_MARKED, SEEK_OK, SEEK_PAST_END };
+
+private:
+ struct Page
+ {
+ Page * m_pPrev;
+ Page * m_pNext;
+ sal_Int8 * m_pStart;
+ sal_Int8 * m_pRead;
+ sal_Int8 * m_pEnd;
+ sal_uInt32 m_nOffset;
+ sal_Int8 m_aBuffer[1];
+ };
+
+ std::multiset< sal_uInt32 > m_aMarks;
+ Page * m_pFirstPage;
+ Page * m_pReadPage;
+ Page * m_pWritePage;
+ sal_Int8 * m_pReadBuffer;
+ sal_uInt32 m_nReadBufferSize;
+ sal_uInt32 m_nReadBufferFilled;
+ sal_uInt32 m_nPageSize;
+ sal_uInt32 m_nMinPages;
+ sal_uInt32 m_nMaxPages;
+ sal_uInt32 m_nPages;
+ bool m_bEOF;
+
+ bool remove(Page * pPage);
+
+public:
+ inline SvDataPipe_Impl(sal_uInt32 nThePageSize = 1000,
+ sal_uInt32 nTheMinPages = 100,
+ sal_uInt32 nTheMaxPages
+ = std::numeric_limits< sal_uInt32 >::max());
+
+ ~SvDataPipe_Impl();
+
+ inline void setReadBuffer(sal_Int8 * pBuffer, sal_uInt32 nSize);
+
+ sal_uInt32 read();
+
+ void clearReadBuffer() { m_pReadBuffer = 0; }
+
+ sal_uInt32 write(sal_Int8 const * pBuffer, sal_uInt32 nSize);
+
+ void setEOF() { m_bEOF = true; }
+
+ inline bool isEOF() const;
+
+ bool addMark(sal_uInt32 nPosition);
+
+ bool removeMark(sal_uInt32 nPosition);
+
+ inline sal_uInt32 getReadPosition() const;
+
+ SeekResult setReadPosition(sal_uInt32 nPosition);
+};
+
+SvDataPipe_Impl::SvDataPipe_Impl(sal_uInt32 nThePageSize,
+ sal_uInt32 nTheMinPages,
+ sal_uInt32 nTheMaxPages):
+ m_pFirstPage(0),
+ m_pReadPage(0),
+ m_pWritePage(0),
+ m_pReadBuffer(0),
+ m_nPageSize(std::min< sal_uInt32 >(
+ std::max< sal_uInt32 >(nThePageSize, sal_uInt32(1)),
+ sal_uInt32(std::numeric_limits< sal_uInt32 >::max()
+ - sizeof (Page) + 1))),
+ m_nMinPages(std::max< sal_uInt32 >(nTheMinPages, sal_uInt32(1))),
+ m_nMaxPages(std::max< sal_uInt32 >(nTheMaxPages, sal_uInt32(1))),
+ m_nPages(0),
+ m_bEOF(false)
+{}
+
+inline void SvDataPipe_Impl::setReadBuffer(sal_Int8 * pBuffer,
+ sal_uInt32 nSize)
+{
+ m_pReadBuffer = pBuffer;
+ m_nReadBufferSize = nSize;
+ m_nReadBufferFilled = 0;
+}
+
+inline bool SvDataPipe_Impl::isEOF() const
+{
+ return m_bEOF && m_pReadPage == m_pWritePage
+ && (!m_pReadPage || m_pReadPage->m_pRead == m_pReadPage->m_pEnd);
+}
+
+inline sal_uInt32 SvDataPipe_Impl::getReadPosition() const
+{
+ return m_pReadPage == 0 ? 0 :
+ m_pReadPage->m_nOffset
+ + (m_pReadPage->m_pRead
+ - m_pReadPage->m_aBuffer);
+}
+
+//============================================================================
+//
+// SvOutputStreamOpenLockBytes
+//
+//============================================================================
+
+TYPEINIT1(SvOutputStreamOpenLockBytes, SvOpenLockBytes)
+
+//============================================================================
+// virtual
+ErrCode SvOutputStreamOpenLockBytes::ReadAt(ULONG, void *, ULONG, ULONG *)
+ const
+{
+ return ERRCODE_IO_CANTREAD;
+}
+
+//============================================================================
+// virtual
+ErrCode SvOutputStreamOpenLockBytes::WriteAt(ULONG nPos, void const * pBuffer,
+ ULONG nCount, ULONG * pWritten)
+{
+ if (nPos != m_nPosition)
+ return ERRCODE_IO_CANTWRITE;
+ return FillAppend(pBuffer, nCount, pWritten);
+}
+
+//============================================================================
+// virtual
+ErrCode SvOutputStreamOpenLockBytes::Flush() const
+{
+ if (!m_xOutputStream.is())
+ return ERRCODE_IO_CANTWRITE;
+ try
+ {
+ m_xOutputStream->flush();
+ }
+ catch (io::IOException)
+ {
+ return ERRCODE_IO_CANTWRITE;
+ }
+ return ERRCODE_NONE;
+}
+
+//============================================================================
+// virtual
+ErrCode SvOutputStreamOpenLockBytes::SetSize(ULONG)
+{
+ return ERRCODE_IO_NOTSUPPORTED;
+}
+
+//============================================================================
+// virtual
+ErrCode SvOutputStreamOpenLockBytes::Stat(SvLockBytesStat * pStat,
+ SvLockBytesStatFlag) const
+{
+ if (pStat)
+ pStat->nSize = m_nPosition;
+ return ERRCODE_NONE;
+}
+
+//============================================================================
+// virtual
+ErrCode SvOutputStreamOpenLockBytes::FillAppend(void const * pBuffer,
+ ULONG nCount,
+ ULONG * pWritten)
+{
+ if (!m_xOutputStream.is())
+ return ERRCODE_IO_CANTWRITE;
+ if (nCount > 0
+ && nCount > std::numeric_limits< ULONG >::max() - m_nPosition)
+ {
+ nCount = std::numeric_limits< ULONG >::max() - m_nPosition;
+ if (nCount == 0)
+ return ERRCODE_IO_CANTWRITE;
+ }
+ try
+ {
+ m_xOutputStream->
+ writeBytes(uno::Sequence< sal_Int8 >(
+ static_cast< sal_Int8 const * >(pBuffer), nCount));
+ }
+ catch (io::IOException)
+ {
+ return ERRCODE_IO_CANTWRITE;
+ }
+ m_nPosition += nCount;
+ if (pWritten)
+ *pWritten = nCount;
+ return ERRCODE_NONE;
+}
+
+//============================================================================
+// virtual
+ULONG SvOutputStreamOpenLockBytes::Tell() const
+{
+ return m_nPosition;
+}
+
+//============================================================================
+// virtual
+ULONG SvOutputStreamOpenLockBytes::Seek(ULONG)
+{
+ return m_nPosition;
+}
+
+//============================================================================
+// virtual
+void SvOutputStreamOpenLockBytes::Terminate()
+{
+ if (m_xOutputStream.is())
+ try
+ {
+ m_xOutputStream->closeOutput();
+ }
+ catch (io::IOException) {}
+}
+
+//============================================================================
+//
+// SvLockBytesInputStream
+//
+//============================================================================
+
+// virtual
+uno::Any SAL_CALL SvLockBytesInputStream::queryInterface(uno::Type const &
+ rType)
+ throw (uno::RuntimeException)
+{
+ uno::Any
+ aReturn(cppu::queryInterface(rType,
+ static_cast< io::XInputStream * >(this),
+ static_cast< io::XSeekable * >(this)));
+ return aReturn.hasValue() ? aReturn : OWeakObject::queryInterface(rType);
+}
+
+//============================================================================
+// virtual
+void SAL_CALL SvLockBytesInputStream::acquire() throw ()
+{
+ OWeakObject::acquire();
+}
+
+//============================================================================
+// virtual
+void SAL_CALL SvLockBytesInputStream::release() throw ()
+{
+ OWeakObject::release();
+}
+
+//============================================================================
+// virtual
+sal_Int32 SAL_CALL
+SvLockBytesInputStream::readBytes(uno::Sequence< sal_Int8 > & rData,
+ sal_Int32 nBytesToRead)
+ throw (io::IOException, uno::RuntimeException)
+{
+ if (!m_xLockBytes.Is())
+ throw io::NotConnectedException();
+ if (nBytesToRead < 0
+ || m_nPosition > std::numeric_limits< ULONG >::max()
+ && nBytesToRead > 0)
+ throw io::IOException();
+ rData.realloc(nBytesToRead);
+ sal_Int32 nSize = 0;
+ while (nSize < nBytesToRead)
+ {
+ ULONG nCount;
+ ErrCode nError = m_xLockBytes->ReadAt(ULONG(m_nPosition),
+ rData.getArray() + nSize,
+ nBytesToRead - nSize, &nCount);
+ if (nError != ERRCODE_NONE && nError != ERRCODE_IO_PENDING)
+ throw io::IOException();
+ m_nPosition += nCount;
+ nSize += nCount;
+ if (nError == ERRCODE_NONE && nCount == 0)
+ break;
+ }
+ rData.realloc(nSize);
+ return nSize;
+}
+
+//============================================================================
+// virtual
+sal_Int32 SAL_CALL
+SvLockBytesInputStream::readSomeBytes(uno::Sequence< sal_Int8 > & rData,
+ sal_Int32 nMaxBytesToRead)
+ throw (io::IOException, uno::RuntimeException)
+{
+ if (!m_xLockBytes.Is())
+ throw io::NotConnectedException();
+ if (m_nPosition > std::numeric_limits< ULONG >::max()
+ && nMaxBytesToRead > 0)
+ throw io::IOException();
+ rData.realloc(nMaxBytesToRead);
+ ULONG nCount = 0;
+ if (nMaxBytesToRead > 0)
+ {
+ ErrCode nError;
+ do
+ {
+ nError = m_xLockBytes->ReadAt(ULONG(m_nPosition),
+ rData.getArray(),
+ nMaxBytesToRead < 0 ?
+ 0 : nMaxBytesToRead,
+ &nCount);
+ if (nError != ERRCODE_NONE && nError != ERRCODE_IO_PENDING)
+ throw io::IOException();
+ m_nPosition += nCount;
+ }
+ while (nCount == 0 && nError == ERRCODE_IO_PENDING);
+ }
+ rData.realloc(sal_Int32(nCount));
+ return sal_Int32(nCount);
+}
+
+//============================================================================
+// virtual
+void SAL_CALL SvLockBytesInputStream::skipBytes(sal_Int32 nBytesToSkip)
+ throw (io::IOException, uno::RuntimeException)
+{
+ if (!m_xLockBytes.Is())
+ throw io::NotConnectedException();
+ if (nBytesToSkip < 0)
+ throw io::IOException();
+ if (m_nPosition + nBytesToSkip < 0)
+ throw io::BufferSizeExceededException();
+ m_nPosition += nBytesToSkip;
+}
+
+//============================================================================
+// virtual
+sal_Int32 SAL_CALL SvLockBytesInputStream::available()
+ throw (io::IOException, uno::RuntimeException)
+{
+ if (!m_xLockBytes.Is())
+ throw io::NotConnectedException();
+ SvLockBytesStat aStat;
+ if (m_xLockBytes->Stat(&aStat, SVSTATFLAG_DEFAULT) != ERRCODE_NONE)
+ throw io::IOException();
+ return aStat.nSize <= m_nPosition ?
+ 0 :
+ std::min< sal_uInt32 >(
+ sal_uInt32(aStat.nSize - m_nPosition),
+ sal_uInt32(std::numeric_limits< sal_Int32 >::max()));
+}
+
+//============================================================================
+// virtual
+void SAL_CALL SvLockBytesInputStream::closeInput()
+ throw (io::IOException, uno::RuntimeException)
+{
+ if (!m_xLockBytes.Is())
+ throw io::NotConnectedException();
+ m_xLockBytes = 0;
+}
+
+//============================================================================
+// virtual
+void SAL_CALL SvLockBytesInputStream::seek(sal_Int64 nLocation)
+ throw (lang::IllegalArgumentException, io::IOException,
+ uno::RuntimeException)
+{
+ if (nLocation < 0)
+ throw lang::IllegalArgumentException();
+ if (!m_xLockBytes.Is())
+ throw io::NotConnectedException();
+ m_nPosition = nLocation;
+}
+
+//============================================================================
+// virtual
+sal_Int64 SAL_CALL SvLockBytesInputStream::getPosition()
+ throw (io::IOException, uno::RuntimeException)
+{
+ if (!m_xLockBytes.Is())
+ throw io::NotConnectedException();
+ return m_nPosition;
+}
+
+//============================================================================
+// virtual
+sal_Int64 SAL_CALL SvLockBytesInputStream::getLength()
+ throw (io::IOException, uno::RuntimeException)
+{
+ if (!m_xLockBytes.Is())
+ throw io::NotConnectedException();
+ SvLockBytesStat aStat;
+ if (m_xLockBytes->Stat(&aStat, SVSTATFLAG_DEFAULT) != ERRCODE_NONE)
+ throw io::IOException();
+ return aStat.nSize;
+}
+
+//============================================================================
+//
+// SvInputStream
+//
+//============================================================================
+
+bool SvInputStream::open()
+{
+ if (GetError() != ERRCODE_NONE)
+ return false;
+ if (!(m_xSeekable.is() || m_pPipe))
+ {
+ if (!m_xStream.is())
+ {
+ SetError(ERRCODE_IO_INVALIDDEVICE);
+ return false;
+ }
+ m_xSeekable
+ = uno::Reference< io::XSeekable >(m_xStream, uno::UNO_QUERY);
+ if (!m_xSeekable.is())
+ m_pPipe = new SvDataPipe_Impl;
+ }
+ return true;
+}
+
+//============================================================================
+// virtual
+ULONG SvInputStream::GetData(void * pData, ULONG nSize)
+{
+ if (!open())
+ {
+ SetError(ERRCODE_IO_CANTREAD);
+ return 0;
+ }
+ sal_uInt32 nRead = 0;
+ if (m_xSeekable.is())
+ {
+ if (m_nSeekedFrom != STREAM_SEEK_TO_END)
+ {
+ try
+ {
+ m_xSeekable->seek(m_nSeekedFrom);
+ }
+ catch (io::IOException)
+ {
+ SetError(ERRCODE_IO_CANTREAD);
+ return 0;
+ }
+ m_nSeekedFrom = STREAM_SEEK_TO_END;
+ }
+ for (;;)
+ {
+ sal_Int32 nRemain
+ = sal_Int32(
+ std::min(ULONG(nSize - nRead),
+ ULONG(std::numeric_limits< sal_Int32 >::max())));
+ if (nRemain == 0)
+ break;
+ uno::Sequence< sal_Int8 > aBuffer;
+ sal_Int32 nCount;
+ try
+ {
+ nCount = m_xStream->readBytes(aBuffer, nRemain);
+ }
+ catch (io::IOException)
+ {
+ SetError(ERRCODE_IO_CANTREAD);
+ return nRead;
+ }
+ rtl_copyMemory(static_cast< sal_Int8 * >(pData) + nRead,
+ aBuffer.getConstArray(), sal_uInt32(nCount));
+ nRead += nCount;
+ if (nCount < nRemain)
+ break;
+ }
+ }
+ else
+ {
+ if (m_nSeekedFrom != STREAM_SEEK_TO_END)
+ {
+ SetError(ERRCODE_IO_CANTREAD);
+ return 0;
+ }
+ m_pPipe->setReadBuffer(static_cast< sal_Int8 * >(pData), nSize);
+ nRead = m_pPipe->read();
+ if (nRead < nSize && !m_pPipe->isEOF())
+ for (;;)
+ {
+ sal_Int32 nRemain
+ = sal_Int32(
+ std::min(
+ ULONG(nSize - nRead),
+ ULONG(std::numeric_limits< sal_Int32 >::max())));
+ if (nRemain == 0)
+ break;
+ uno::Sequence< sal_Int8 > aBuffer;
+ sal_Int32 nCount;
+ try
+ {
+ nCount = m_xStream->readBytes(aBuffer, nRemain);
+ }
+ catch (io::IOException)
+ {
+ SetError(ERRCODE_IO_CANTREAD);
+ break;
+ }
+ m_pPipe->write(aBuffer.getConstArray(), sal_uInt32(nCount));
+ nRead += m_pPipe->read();
+ if (nCount < nRemain)
+ {
+ m_xStream->closeInput();
+ m_pPipe->setEOF();
+ break;
+ }
+ }
+ m_pPipe->clearReadBuffer();
+ }
+ return nRead;
+}
+
+//============================================================================
+// virtual
+ULONG SvInputStream::PutData(void const *, ULONG)
+{
+ SetError(ERRCODE_IO_NOTSUPPORTED);
+ return 0;
+}
+
+//============================================================================
+// virtual
+void SvInputStream::FlushData()
+{}
+
+//============================================================================
+// virtual
+ULONG SvInputStream::SeekPos(ULONG nPos)
+{
+ if (open())
+ if (nPos == STREAM_SEEK_TO_END)
+ if (m_nSeekedFrom == STREAM_SEEK_TO_END)
+ {
+ if (m_xSeekable.is())
+ try
+ {
+ sal_Int64 nLength = m_xSeekable->getLength();
+ if (nLength < STREAM_SEEK_TO_END)
+ {
+ m_nSeekedFrom = Tell();
+ return ULONG(nLength);
+ }
+ }
+ catch (io::IOException) {}
+ else
+ return Tell(); //@@@
+ }
+ else
+ return Tell();
+ else if (nPos == m_nSeekedFrom)
+ {
+ m_nSeekedFrom = STREAM_SEEK_TO_END;
+ return nPos;
+ }
+ else if (m_xSeekable.is())
+ try
+ {
+ m_xSeekable->seek(nPos);
+ m_nSeekedFrom = STREAM_SEEK_TO_END;
+ return nPos;
+ }
+ catch (io::IOException) {}
+ else if (m_pPipe->setReadPosition(nPos) == SvDataPipe_Impl::SEEK_OK)
+ {
+ m_nSeekedFrom = STREAM_SEEK_TO_END;
+ return nPos;
+ }
+ SetError(ERRCODE_IO_CANTSEEK);
+ return Tell();
+}
+
+//============================================================================
+// virtual
+void SvInputStream::SetSize(ULONG)
+{
+ SetError(ERRCODE_IO_NOTSUPPORTED);
+}
+
+//============================================================================
+SvInputStream::SvInputStream(
+ com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
+ const &
+ rTheStream):
+ m_xStream(rTheStream),
+ m_pPipe(0),
+ m_nSeekedFrom(STREAM_SEEK_TO_END)
+{
+ SetBufferSize(0);
+}
+
+//============================================================================
+// virtual
+SvInputStream::~SvInputStream()
+{
+ if (m_xStream.is())
+ try
+ {
+ m_xStream->closeInput();
+ }
+ catch (io::IOException) {}
+ delete m_pPipe;
+}
+
+//============================================================================
+// virtual
+USHORT SvInputStream::IsA() const
+{
+ return 0;
+}
+
+//============================================================================
+// virtual
+void SvInputStream::AddMark(ULONG nPos)
+{
+ if (open() && m_pPipe)
+ m_pPipe->addMark(nPos);
+}
+
+//============================================================================
+// virtual
+void SvInputStream::RemoveMark(ULONG nPos)
+{
+ if (open() && m_pPipe)
+ m_pPipe->removeMark(nPos);
+}
+
+//============================================================================
+//
+// SvDataPipe_Impl
+//
+//============================================================================
+
+bool SvDataPipe_Impl::remove(Page * pPage)
+{
+ if (pPage != m_pFirstPage || m_pReadPage == m_pFirstPage
+ || !m_aMarks.empty()
+ && *m_aMarks.begin() < m_pFirstPage->m_nOffset + m_nPageSize)
+ return false;
+
+ m_pFirstPage = m_pFirstPage->m_pNext;
+
+ if (m_nPages <= m_nMinPages)
+ return true;
+
+ pPage->m_pPrev->m_pNext = pPage->m_pNext;
+ pPage->m_pNext->m_pPrev = pPage->m_pPrev;
+ rtl_freeMemory(pPage);
+ --m_nPages;
+
+ return true;
+}
+
+//============================================================================
+SvDataPipe_Impl::~SvDataPipe_Impl()
+{
+ if (m_pFirstPage != 0)
+ for (Page * pPage = m_pFirstPage;;)
+ {
+ Page * pNext = pPage->m_pNext;
+ rtl_freeMemory(pPage);
+ if (pNext == m_pFirstPage)
+ break;
+ pPage = pNext;
+ }
+}
+
+//============================================================================
+sal_uInt32 SvDataPipe_Impl::read()
+{
+ if (m_pReadBuffer == 0 || m_nReadBufferSize == 0 || m_pReadPage == 0)
+ return 0;
+
+ sal_uInt32 nSize = m_nReadBufferSize;
+ sal_uInt32 nRemain = m_nReadBufferSize - m_nReadBufferFilled;
+
+ m_pReadBuffer += m_nReadBufferFilled;
+ m_nReadBufferSize -= m_nReadBufferFilled;
+ m_nReadBufferFilled = 0;
+
+ while (nRemain > 0)
+ {
+ sal_uInt32 nBlock = std::min(sal_uInt32(m_pReadPage->m_pEnd
+ - m_pReadPage->m_pRead),
+ nRemain);
+ rtl_copyMemory(m_pReadBuffer, m_pReadPage->m_pRead, nBlock);
+ m_pReadPage->m_pRead += nBlock;
+ m_pReadBuffer += nBlock;
+ m_nReadBufferSize -= nBlock;
+ m_nReadBufferFilled = 0;
+ nRemain -= nBlock;
+
+ if (m_pReadPage == m_pWritePage)
+ break;
+
+ if (m_pReadPage->m_pRead == m_pReadPage->m_pEnd)
+ {
+ Page * pRemove = m_pReadPage;
+ m_pReadPage = pRemove->m_pNext;
+ remove(pRemove);
+ }
+ }
+
+ return nSize - nRemain;
+}
+
+//============================================================================
+sal_uInt32 SvDataPipe_Impl::write(sal_Int8 const * pBuffer, sal_uInt32 nSize)
+{
+ if (nSize == 0)
+ return 0;
+
+ if (m_pWritePage == 0)
+ {
+ m_pFirstPage
+ = static_cast< Page * >(rtl_allocateMemory(sizeof (Page)
+ + m_nPageSize
+ - 1));
+ m_pFirstPage->m_pPrev = m_pFirstPage;
+ m_pFirstPage->m_pNext = m_pFirstPage;
+ m_pFirstPage->m_pStart = m_pFirstPage->m_aBuffer;
+ m_pFirstPage->m_pRead = m_pFirstPage->m_aBuffer;
+ m_pFirstPage->m_pEnd = m_pFirstPage->m_aBuffer;
+ m_pFirstPage->m_nOffset = 0;
+ m_pReadPage = m_pFirstPage;
+ m_pWritePage = m_pFirstPage;
+ ++m_nPages;
+ }
+
+ sal_uInt32 nRemain = nSize;
+
+ if (m_pReadBuffer != 0 && m_pReadPage == m_pWritePage
+ && m_pReadPage->m_pRead == m_pWritePage->m_pEnd)
+ {
+ sal_uInt32 nBlock = std::min(nRemain,
+ sal_uInt32(m_nReadBufferSize
+ - m_nReadBufferFilled));
+ sal_uInt32 nPosition = m_pWritePage->m_nOffset
+ + (m_pWritePage->m_pEnd
+ - m_pWritePage->m_aBuffer);
+ if (!m_aMarks.empty())
+ nBlock = *m_aMarks.begin() > nPosition ?
+ std::min(nBlock, sal_uInt32(*m_aMarks.begin()
+ - nPosition)) :
+ 0;
+
+ if (nBlock > 0)
+ {
+ rtl_copyMemory(m_pReadBuffer + m_nReadBufferFilled, pBuffer,
+ nBlock);
+ m_nReadBufferFilled += nBlock;
+ nRemain -= nBlock;
+
+ nPosition += nBlock;
+ m_pWritePage->m_nOffset = (nPosition / m_nPageSize) * m_nPageSize;
+ m_pWritePage->m_pStart = m_pWritePage->m_aBuffer
+ + nPosition % m_nPageSize;
+ m_pWritePage->m_pRead = m_pWritePage->m_pStart;
+ m_pWritePage->m_pEnd = m_pWritePage->m_pStart;
+ }
+ }
+
+ if (nRemain > 0)
+ for (;;)
+ {
+ sal_uInt32 nBlock
+ = std::min(sal_uInt32(m_pWritePage->m_aBuffer + m_nPageSize
+ - m_pWritePage->m_pEnd),
+ nRemain);
+ rtl_copyMemory(m_pWritePage->m_pEnd, pBuffer, nBlock);
+ m_pWritePage->m_pEnd += nBlock;
+ pBuffer += nBlock;
+ nRemain -= nBlock;
+
+ if (nRemain == 0)
+ break;
+
+ if (m_pWritePage->m_pNext == m_pFirstPage)
+ {
+ if (m_nPages == m_nMaxPages)
+ break;
+
+ Page * pNew
+ = static_cast< Page * >(rtl_allocateMemory(
+ sizeof (Page) + m_nPageSize
+ - 1));
+ pNew->m_pPrev = m_pWritePage;
+ pNew->m_pNext = m_pWritePage->m_pNext;
+
+ m_pWritePage->m_pNext->m_pPrev = pNew;
+ m_pWritePage->m_pNext = pNew;
+ ++m_nPages;
+ }
+
+ m_pWritePage->m_pNext->m_nOffset = m_pWritePage->m_nOffset
+ + m_nPageSize;
+ m_pWritePage = m_pWritePage->m_pNext;
+ m_pWritePage->m_pStart = m_pWritePage->m_aBuffer;
+ m_pWritePage->m_pRead = m_pWritePage->m_aBuffer;
+ m_pWritePage->m_pEnd = m_pWritePage->m_aBuffer;
+ }
+
+ return nSize - nRemain;
+}
+
+//============================================================================
+bool SvDataPipe_Impl::addMark(sal_uInt32 nPosition)
+{
+ if (m_pFirstPage != 0 && m_pFirstPage->m_nOffset > nPosition)
+ return false;
+ m_aMarks.insert(nPosition);
+ return true;
+}
+
+//============================================================================
+bool SvDataPipe_Impl::removeMark(sal_uInt32 nPosition)
+{
+ std::multiset< sal_uInt32 >::iterator t = m_aMarks.find(nPosition);
+ if (t == m_aMarks.end())
+ return false;
+ m_aMarks.erase(t);
+ while (remove(m_pFirstPage));
+ return true;
+}
+
+//============================================================================
+SvDataPipe_Impl::SeekResult SvDataPipe_Impl::setReadPosition(sal_uInt32
+ nPosition)
+{
+ if (m_pFirstPage == 0)
+ return nPosition == 0 ? SEEK_OK : SEEK_PAST_END;
+
+ if (nPosition
+ <= m_pReadPage->m_nOffset
+ + (m_pReadPage->m_pRead - m_pReadPage->m_aBuffer))
+ {
+ if (nPosition
+ < m_pFirstPage->m_nOffset
+ + (m_pFirstPage->m_pStart - m_pFirstPage->m_aBuffer))
+ return SEEK_BEFORE_MARKED;
+
+ while (nPosition < m_pReadPage->m_nOffset)
+ {
+ m_pReadPage->m_pRead = m_pReadPage->m_pStart;
+ m_pReadPage = m_pReadPage->m_pPrev;
+ }
+ }
+ else
+ {
+ if (nPosition
+ > m_pWritePage->m_nOffset
+ + (m_pWritePage->m_pEnd - m_pWritePage->m_aBuffer))
+ return SEEK_PAST_END;
+
+ while (m_pReadPage != m_pWritePage
+ && nPosition >= m_pReadPage->m_nOffset + m_nPageSize)
+ {
+ Page * pRemove = m_pReadPage;
+ m_pReadPage = pRemove->m_pNext;
+ remove(pRemove);
+ }
+ }
+
+ m_pReadPage->m_pRead = m_pReadPage->m_aBuffer
+ + (nPosition - m_pReadPage->m_nOffset);
+ return SEEK_OK;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/misc1/svt_svtdata.cxx b/binfilter/bf_svtools/source/misc1/svt_svtdata.cxx
new file mode 100644
index 000000000000..752fc0972cdc
--- /dev/null
+++ b/binfilter/bf_svtools/source/misc1/svt_svtdata.cxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <map>
+
+#include <tools/resmgr.hxx>
+#include <tools/shl.hxx>
+
+#include <bf_svtools/svtdata.hxx>
+
+namespace binfilter
+{
+
+ImpSvtData::~ImpSvtData()
+{
+ delete pResMgr;
+}
+
+ResMgr * ImpSvtData::GetResMgr(const ::com::sun::star::lang::Locale aLocale)
+{
+ if (!pResMgr)
+ pResMgr = ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(bf_svt), aLocale );
+ return pResMgr;
+}
+
+ImpSvtData & ImpSvtData::GetSvtData()
+{
+ void ** pAppData = GetAppData(BF_SHL_SVT);
+ if (!*pAppData)
+ *pAppData= new ImpSvtData;
+ return *static_cast<ImpSvtData *>(*pAppData);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/notify/listenerbase.hxx b/binfilter/bf_svtools/source/notify/listenerbase.hxx
new file mode 100644
index 000000000000..a1375ac0742e
--- /dev/null
+++ b/binfilter/bf_svtools/source/notify/listenerbase.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 _SVT_LISTENERBASE_HXX
+#define _SVT_LISTENERBASE_HXX
+
+namespace binfilter
+{
+
+class SvtBroadcaster;
+class SvtListener;
+
+class SvtListenerBase
+{
+ SvtListenerBase *pNext;
+ SvtListenerBase *pLeft, *pRight;
+ SvtBroadcaster *pBroadcaster;
+ SvtListener *pListener;
+
+public:
+
+ SvtListenerBase( SvtListener& rLst, SvtBroadcaster& rBroadcaster );
+ ~SvtListenerBase();
+
+ SvtListenerBase* GetNext() const { return pNext; }
+ void SetNext( SvtListenerBase* p ) { pNext = p; }
+
+ SvtBroadcaster* GetBroadcaster() const { return pBroadcaster; }
+ SvtListener* GetListener() const { return pListener; }
+
+ SvtListenerBase* GetLeft() const { return pLeft; }
+ SvtListenerBase* GetRight() const { return pRight; }
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/notify/makefile.mk b/binfilter/bf_svtools/source/notify/makefile.mk
new file mode 100644
index 000000000000..8564bd14cec5
--- /dev/null
+++ b/binfilter/bf_svtools/source/notify/makefile.mk
@@ -0,0 +1,55 @@
+#*************************************************************************
+#
+# DO NOT ALTER 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=binfilter
+TARGET=notify
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/svt_smplhint.obj \
+ $(SLO)$/svt_hint.obj \
+ $(SLO)$/svt_lstner.obj \
+ $(SLO)$/svt_isethint.obj \
+ $(SLO)$/svt_cancel.obj \
+ $(SLO)$/svt_brdcst.obj \
+ $(SLO)$/svt_listener.obj \
+ $(SLO)$/svt_listenerbase.obj \
+ $(SLO)$/svt_listeneriter.obj \
+ $(SLO)$/svt_broadcast.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/binfilter/bf_svtools/source/notify/svt_brdcst.cxx b/binfilter/bf_svtools/source/notify/svt_brdcst.cxx
new file mode 100644
index 000000000000..ebef9be2994b
--- /dev/null
+++ b/binfilter/bf_svtools/source/notify/svt_brdcst.cxx
@@ -0,0 +1,203 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/debug.hxx>
+
+#include <bf_svtools/hint.hxx>
+#include <bf_svtools/smplhint.hxx>
+#include <bf_svtools/lstner.hxx>
+
+#define _SFX_BRDCST_CXX
+#include <bf_svtools/brdcst.hxx>
+
+namespace binfilter
+{
+
+//====================================================================
+DBG_NAME(SfxBroadcaster)
+TYPEINIT0(SfxBroadcaster);
+
+//====================================================================
+
+//====================================================================
+// broadcast immediately
+
+
+void SfxBroadcaster::Broadcast( const SfxHint &rHint )
+{
+ DBG_CHKTHIS(SfxBroadcaster, 0);
+
+ // is anybody to notify?
+ if ( aListeners.Count() /*! || aGlobListeners.Count() */ )
+ {
+ #if 0
+ // determine the type only once, because of its expensiveness
+ const TypeId& rBCType = Type();
+ const TypeId& rHintType = rHint.Type();
+ #endif
+
+ // notify all registered listeners exactly once
+ for ( USHORT n = 0; n < aListeners.Count(); ++n )
+ {
+ SfxListener* pListener = aListeners[n];
+ if ( pListener )
+ #if 0
+ pListener->SFX_NOTIFY( *this, rBCType, rHint, rHintType );
+ #else
+ pListener->Notify( *this, rHint );
+ #endif
+ }
+ }
+}
+
+//--------------------------------------------------------------------
+
+// unregister all listeners
+
+SfxBroadcaster::~SfxBroadcaster()
+{
+ DBG_DTOR(SfxBroadcaster, 0);
+
+ Broadcast( SfxSimpleHint(SFX_HINT_DYING) );
+
+ // remove all still registered listeners
+ for ( USHORT nPos = 0; nPos < aListeners.Count(); ++nPos )
+ {
+ SfxListener *pListener = aListeners[nPos];
+ if ( pListener )
+ pListener->RemoveBroadcaster_Impl(*this);
+ }
+}
+
+//--------------------------------------------------------------------
+
+// simple ctor of class SfxBroadcaster
+
+SfxBroadcaster::SfxBroadcaster()
+{
+ DBG_CTOR(SfxBroadcaster, 0);
+}
+
+//--------------------------------------------------------------------
+
+// copy ctor of class SfxBroadcaster
+
+
+SfxBroadcaster::SfxBroadcaster( const SfxBroadcaster &rBC )
+{
+ DBG_CTOR(SfxBroadcaster, 0);
+
+ for ( USHORT n = 0; n < rBC.aListeners.Count(); ++n )
+ {
+ SfxListener *pListener = rBC.aListeners[n];
+ if ( pListener )
+ pListener->StartListening( *this );
+ }
+}
+
+//--------------------------------------------------------------------
+
+// add a new SfxListener to the list
+
+BOOL SfxBroadcaster::AddListener( SfxListener& rListener )
+{
+ DBG_CHKTHIS(SfxBroadcaster, 0);
+ const SfxListener *pListener = &rListener;
+ const SfxListener *pNull = 0;
+ USHORT nFreePos = aListeners.GetPos( pNull );
+ if ( nFreePos < aListeners.Count() )
+ aListeners.GetData()[nFreePos] = pListener;
+ else if ( aListeners.Count() < (USHRT_MAX-1) )
+ aListeners.Insert( pListener, aListeners.Count() );
+ else
+ {
+ DBG_ERROR( "array overflow" );
+ return FALSE;
+ }
+
+ DBG_ASSERT( USHRT_MAX != aListeners.GetPos(pListener),
+ "AddListener failed" );
+ return TRUE;
+}
+
+//--------------------------------------------------------------------
+
+// called, if no more listeners exists
+
+void SfxBroadcaster::ListenersGone()
+{
+ DBG_CHKTHIS(SfxBroadcaster,0);
+}
+
+//--------------------------------------------------------------------
+
+// forward a notification to all registered listeners
+
+void SfxBroadcaster::SFX_FORWARD(SfxBroadcaster& rBC, const TypeId& rBCType,
+ const SfxHint& rHint, const TypeId& rHintType)
+{
+ const USHORT nCount = aListeners.Count();
+ for ( USHORT i = 0; i < nCount; ++i )
+ {
+ SfxListener *pListener = aListeners[i];
+ if ( pListener )
+ pListener->SFX_NOTIFY( rBC, rBCType, rHint, rHintType);
+ }
+}
+
+//--------------------------------------------------------------------
+
+// remove one SfxListener from the list
+
+void SfxBroadcaster::RemoveListener( SfxListener& rListener )
+{
+ {DBG_CHKTHIS(SfxBroadcaster, 0);}
+ const SfxListener *pListener = &rListener;
+ USHORT nPos = aListeners.GetPos(pListener);
+ DBG_ASSERT( nPos != USHRT_MAX, "RemoveListener: Listener unknown" );
+ aListeners.GetData()[nPos] = 0;
+ if ( !HasListeners() )
+ ListenersGone();
+}
+
+//--------------------------------------------------------------------
+
+BOOL SfxBroadcaster::HasListeners() const
+{
+ for ( USHORT n = 0; n < aListeners.Count(); ++n )
+ if ( aListeners.GetObject(n) != 0 )
+ return TRUE;
+ return FALSE;
+}
+
+//--------------------------------------------------------------------
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/notify/svt_broadcast.cxx b/binfilter/bf_svtools/source/notify/svt_broadcast.cxx
new file mode 100644
index 000000000000..832b23f4f5bc
--- /dev/null
+++ b/binfilter/bf_svtools/source/notify/svt_broadcast.cxx
@@ -0,0 +1,123 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/debug.hxx>
+
+#include "listener.hxx"
+#include "listeneriter.hxx"
+#include "broadcast.hxx"
+#include <bf_svtools/smplhint.hxx>
+
+namespace binfilter
+{
+
+//====================================================================
+TYPEINIT0(SvtBroadcaster);
+
+//====================================================================
+
+// simple ctor of class SvtBroadcaster
+
+SvtBroadcaster::SvtBroadcaster()
+ : pRoot( 0 )
+{
+}
+
+//--------------------------------------------------------------------
+
+// copy ctor of class SvtBroadcaster
+
+SvtBroadcaster::SvtBroadcaster( const SvtBroadcaster &rBC )
+ : pRoot( 0 )
+{
+ SvtListenerIter aIter( (SvtBroadcaster&)rBC );
+ SvtListener* pLast = aIter.GoStart();
+ if( pLast )
+ do {
+ pLast->StartListening( *this );
+ } while( 0 != ( pLast = aIter.GoNext() ));
+}
+
+//--------------------------------------------------------------------
+
+// unregister all listeners
+
+SvtBroadcaster::~SvtBroadcaster()
+{
+ Broadcast( SfxSimpleHint(SFX_HINT_DYING) );
+
+ SvtListenerIter aIter( *this );
+ SvtListener* pLast = aIter.GoStart();
+ if( pLast )
+ do {
+ pLast->EndListening( *this );
+ if( !HasListeners() ) // all gone ??
+ break;
+ } while( 0 != ( pLast = aIter.GoNext() ));
+}
+
+//--------------------------------------------------------------------
+
+// broadcast immedeately
+
+void SvtBroadcaster::Broadcast( const SfxHint &rHint )
+{
+ // is anybody to notify?
+ if( HasListeners() /* && !IsModifyLocked()*/ )
+ {
+// LockModify();
+// bInModify = TRUE;
+
+ SvtListenerIter aIter( *this );
+ SvtListener* pLast = aIter.GoStart();
+ if( pLast )
+ do {
+ pLast->Notify( *this, rHint );
+ if( !HasListeners() ) // all gone ??
+ break;
+ } while( 0 != ( pLast = aIter.GoNext() ));
+
+// bInModify = FALSE;
+// UnlockModify();
+ }
+}
+
+//--------------------------------------------------------------------
+
+
+// called, if no more listeners exists
+
+void SvtBroadcaster::ListenersGone()
+{
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/notify/svt_cancel.cxx b/binfilter/bf_svtools/source/notify/svt_cancel.cxx
new file mode 100644
index 000000000000..6fded87fb87f
--- /dev/null
+++ b/binfilter/bf_svtools/source/notify/svt_cancel.cxx
@@ -0,0 +1,209 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+#define _SFX_CANCEL_CXX
+#include <bf_svtools/cancel.hxx>
+
+#include <osl/mutex.hxx>
+#include <tools/debug.hxx>
+
+#include <bf_svtools/smplhint.hxx>
+#include <bf_svtools/cnclhint.hxx>
+
+#include <rtl/instance.hxx>
+
+namespace { struct lclMutex : public rtl::Static< ::osl::Mutex, lclMutex >{}; }
+
+namespace binfilter
+{
+
+//=========================================================================
+
+SfxCancelManager::SfxCancelManager( SfxCancelManager *pParent )
+: _pParent( pParent )
+{
+}
+
+//-------------------------------------------------------------------------
+
+SfxCancelManager::~SfxCancelManager()
+{
+ DBG_ASSERT( _pParent || !_aJobs.Count(), "deleting SfxCancelManager in use" );
+ for ( USHORT n = _aJobs.Count(); n--; )
+ _aJobs.GetObject(n)->SetManager( _pParent );
+}
+
+//-------------------------------------------------------------------------
+
+BOOL SfxCancelManager::CanCancel() const
+
+/* [Beschreibung]
+
+ Liefert TRUE wenn an diesem CancelManager oder an einem Parent
+ ein Job l"auft.
+*/
+
+{
+ ::osl::MutexGuard aGuard( lclMutex::get() );
+ return _aJobs.Count() > 0 || ( _pParent && _pParent->CanCancel() );
+}
+
+//-------------------------------------------------------------------------
+
+void SfxCancelManager::Cancel( BOOL bDeep )
+
+/* [Beschreibung]
+
+ Diese Methode markiert alle angemeldeten <SfxCancellable>-Instanzen
+ als suspendiert.
+*/
+
+{
+ ::osl::MutexGuard aGuard( lclMutex::get() );
+ SfxCancelManagerWeak xWeak( this );
+ for ( USHORT n = _aJobs.Count(); n-- && xWeak.Is(); )
+ if ( n < _aJobs.Count() )
+ _aJobs.GetObject(n)->Cancel();
+ if ( xWeak.Is() && _pParent )
+ _pParent->Cancel( bDeep );
+}
+
+//-------------------------------------------------------------------------
+
+void SfxCancelManager::InsertCancellable( SfxCancellable *pJob )
+
+/* [Beschreibung]
+
+ Diese interne Methode tr"agt 'pJob' in die Liste der unterbrechbaren
+ Jobs ein und Broadcastet dies. Jeder <SfxCancellable> darf nur
+ maximal einmal angemeldet sein, dies geschiet in seinem Ctor.
+*/
+
+{
+#ifdef GPF_ON_EMPTY_TITLE
+ if ( !pJob->GetTitle() )
+ {
+ DBG_ERROR( "SfxCancellable: empty titles not allowed (Vermummungsverbot)" )
+ *(int*)0 = 0;
+ }
+#endif
+
+ ::osl::ClearableMutexGuard aGuard( lclMutex::get() );
+ _aJobs.C40_INSERT( SfxCancellable, pJob, _aJobs.Count() );
+
+ aGuard.clear();
+ Broadcast( SfxSimpleHint( SFX_HINT_CANCELLABLE ) );
+}
+
+//-------------------------------------------------------------------------
+
+
+void SfxCancelManager::RemoveCancellable( SfxCancellable *pJob )
+
+/* [Beschreibung]
+
+ Diese interne Methode tr"agt 'pJob' aus die Liste der unterbrechbaren
+ Jobs aus und Broadcastet dies. Dieser Aufruf mu\s paarig nach einem
+ <InsertCancellable> erfolgen und wird im Dtor des <SfxCancellable>
+ ausgel"ost.
+*/
+
+{
+ ::osl::ClearableMutexGuard aGuard( lclMutex::get() );
+ const SfxCancellable *pTmp = pJob;
+ USHORT nPos = _aJobs.GetPos( pTmp );
+ if ( nPos != 0xFFFF )
+ {
+ _aJobs.Remove( nPos , 1 );
+ aGuard.clear();
+ Broadcast( SfxSimpleHint( SFX_HINT_CANCELLABLE ) );
+ Broadcast( SfxCancelHint( pJob, SFXCANCELHINT_REMOVED ) );
+ }
+}
+
+//-------------------------------------------------------------------------
+
+SfxCancellable::~SfxCancellable()
+{
+ SfxCancelManager* pMgr = _pMgr;
+ if ( pMgr )
+ pMgr->RemoveCancellable( this );
+}
+
+//-------------------------------------------------------------------------
+
+void SfxCancellable::Cancel()
+
+/* [Description]
+
+ This virtual function is called when the user hits the cancel-button.
+ If you overload it, you can stop your activities. Please always call
+ 'SfxCancellable::Cancel()'.
+*/
+
+{
+#ifdef GFP_ON_NO_CANCEL
+ if ( _bCancelled < 5 )
+ ++_bCancelled;
+ else
+ {
+ delete this;
+ }
+#else
+ _bCancelled = TRUE;
+#endif
+}
+
+//-------------------------------------------------------------------------
+
+void SfxCancellable::SetManager( SfxCancelManager *pMgr )
+{
+ SfxCancelManager* pTmp = _pMgr;
+ if ( pTmp )
+ pTmp->RemoveCancellable( this );
+ _pMgr = pMgr;
+ if ( pMgr )
+ pMgr->InsertCancellable( this );
+}
+
+//-------------------------------------------------------------------------
+
+TYPEINIT1(SfxCancelHint, SfxHint);
+
+SfxCancelHint::SfxCancelHint( SfxCancellable* pJob, USHORT _nAction )
+{
+ pCancellable = pJob;
+ nAction = _nAction;
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/notify/svt_hint.cxx b/binfilter/bf_svtools/source/notify/svt_hint.cxx
new file mode 100644
index 000000000000..de312a318de0
--- /dev/null
+++ b/binfilter/bf_svtools/source/notify/svt_hint.cxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/hint.hxx>
+
+namespace binfilter
+{
+
+//====================================================================
+
+TYPEINIT0(SfxHint);
+
+//====================================================================
+// virtual dtor for the typical base-class Hint
+
+SfxHint::~SfxHint()
+{
+}
+
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/notify/svt_isethint.cxx b/binfilter/bf_svtools/source/notify/svt_isethint.cxx
new file mode 100644
index 000000000000..7462866baa4c
--- /dev/null
+++ b/binfilter/bf_svtools/source/notify/svt_isethint.cxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/isethint.hxx>
+#include <bf_svtools/itemset.hxx>
+
+namespace binfilter
+{
+
+//====================================================================
+
+TYPEINIT1(SfxItemSetHint, SfxHint);
+
+//====================================================================
+
+SfxItemSetHint::~SfxItemSetHint()
+{
+ delete _pItemSet;
+}
+
+//--------------------------------------------------------------------
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/notify/svt_listener.cxx b/binfilter/bf_svtools/source/notify/svt_listener.cxx
new file mode 100644
index 000000000000..49e9ff8eeab3
--- /dev/null
+++ b/binfilter/bf_svtools/source/notify/svt_listener.cxx
@@ -0,0 +1,169 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/debug.hxx>
+
+#include "broadcast.hxx"
+#include "listener.hxx"
+#include "listenerbase.hxx"
+#include "listeneriter.hxx"
+
+namespace binfilter
+{
+
+//====================================================================
+TYPEINIT0(SvtListener);
+
+//====================================================================
+// simple ctor of class SvtListener
+
+SvtListener::SvtListener()
+ : pBrdCastLst( 0 )
+{
+}
+//--------------------------------------------------------------------
+
+// copy ctor of class SvtListener
+
+SvtListener::SvtListener( const SvtListener &rListener )
+ : pBrdCastLst( 0 )
+{
+ SvtListenerBase* pLst = rListener.pBrdCastLst;
+ while( pLst )
+ {
+ new SvtListenerBase( *this, *pLst->GetBroadcaster() );
+ pLst = pLst->GetNext();
+ }
+}
+//--------------------------------------------------------------------
+
+// unregisteres the SvtListener from its SvtBroadcasters
+
+SvtListener::~SvtListener()
+{
+ EndListeningAll();
+}
+
+//--------------------------------------------------------------------
+
+// registeres at a specific SvtBroadcaster
+
+BOOL SvtListener::StartListening( SvtBroadcaster& rBroadcaster )
+{
+ const SvtListenerBase* pLst = pBrdCastLst;
+ while( pLst )
+ {
+ if( &rBroadcaster == pLst->GetBroadcaster() )
+ {
+ // double, than return
+ return FALSE;
+ }
+ pLst = pLst->GetNext();
+ }
+ new SvtListenerBase( *this, rBroadcaster );
+ return TRUE;
+}
+
+//--------------------------------------------------------------------
+
+// unregisteres at a specific SvtBroadcaster
+
+BOOL SvtListener::EndListening( SvtBroadcaster& rBroadcaster )
+{
+ SvtListenerBase *pLst = pBrdCastLst, *pPrev = pLst;
+ while( pLst )
+ {
+ if( &rBroadcaster == pLst->GetBroadcaster() )
+ {
+ if( pBrdCastLst == pLst )
+ pBrdCastLst = pLst->GetNext();
+ else
+ pPrev->SetNext( pLst->GetNext() );
+
+ delete pLst;
+ return TRUE;
+ }
+ pPrev = pLst;
+ pLst = pLst->GetNext();
+ }
+ return FALSE;
+}
+
+//--------------------------------------------------------------------
+
+// unregisteres all Broadcasters
+
+void SvtListener::EndListeningAll()
+{
+ SvtListenerBase *pLst = pBrdCastLst;
+ while( pLst )
+ {
+ SvtListenerBase *pDel = pLst;
+ pLst = pLst->GetNext();
+
+ delete pDel;
+ }
+ pBrdCastLst = 0;
+}
+
+#ifdef DBG_UTIL
+
+BOOL SvtListener::IsListening( SvtBroadcaster& rBroadcaster ) const
+{
+ const SvtListenerBase *pLst = pBrdCastLst;
+ while( pLst )
+ {
+ if( &rBroadcaster == pLst->GetBroadcaster() )
+ break;
+ pLst = pLst->GetNext();
+ }
+ return 0 != pLst;
+}
+
+#endif
+
+//--------------------------------------------------------------------
+
+// base implementation of notification handler
+
+void SvtListener::Notify( SvtBroadcaster&
+#ifdef DBG_UTIL
+rBC
+#endif
+, const SfxHint& )
+{
+ DBG_ASSERT( IsListening( rBC ),
+ "notification from unregistered broadcaster" );
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/notify/svt_listenerbase.cxx b/binfilter/bf_svtools/source/notify/svt_listenerbase.cxx
new file mode 100644
index 000000000000..1c49d4777fa3
--- /dev/null
+++ b/binfilter/bf_svtools/source/notify/svt_listenerbase.cxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/debug.hxx>
+
+#include "listenerbase.hxx"
+#include "listeneriter.hxx"
+#include "listener.hxx"
+#include "broadcast.hxx"
+
+namespace binfilter
+{
+
+
+SvtListenerBase::SvtListenerBase( SvtListener& rLst,
+ SvtBroadcaster& rBroadcaster )
+ : pLeft( 0 ), pRight( 0 ),
+ pBroadcaster( &rBroadcaster ), pListener( &rLst )
+{
+ pNext = rLst.pBrdCastLst;
+ rLst.pBrdCastLst = this;
+
+ if( pBroadcaster->pRoot )
+ {
+ // set ever behind the root
+ pRight = pBroadcaster->pRoot->pRight;
+ pBroadcaster->pRoot->pRight = this;
+ this->pLeft = pBroadcaster->pRoot;
+ if( pRight )
+ pRight->pLeft = this;
+ }
+ else
+ pBroadcaster->pRoot = this;
+}
+
+SvtListenerBase::~SvtListenerBase()
+{
+ SvtListenerBase *pR = pRight, *pL = pLeft;
+ if( pBroadcaster->pRoot )
+ pBroadcaster->pRoot = pL ? pL : pR;
+
+ if( pL )
+ pL->pRight = pR;
+ if( pR )
+ pR->pLeft = pL;
+
+ SvtListenerIter::RemoveListener( *this, pR );
+
+ if( !pBroadcaster->pRoot )
+ pBroadcaster->ListenersGone();
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/notify/svt_listeneriter.cxx b/binfilter/bf_svtools/source/notify/svt_listeneriter.cxx
new file mode 100644
index 000000000000..473e24628da7
--- /dev/null
+++ b/binfilter/bf_svtools/source/notify/svt_listeneriter.cxx
@@ -0,0 +1,118 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/debug.hxx>
+
+#include "listenerbase.hxx"
+#include "listeneriter.hxx"
+#include "broadcast.hxx"
+#include "listener.hxx"
+
+namespace binfilter
+{
+
+SvtListenerIter* SvtListenerIter::pListenerIters = 0;
+
+SvtListenerIter::SvtListenerIter( SvtBroadcaster& rBrdcst )
+ : rRoot( rBrdcst )
+{
+ // hinten einketten!
+ pNxtIter = 0;
+ if( pListenerIters )
+ {
+ SvtListenerIter* pTmp = pListenerIters;
+ while( pTmp->pNxtIter )
+ pTmp = pTmp->pNxtIter;
+ pTmp->pNxtIter = this;
+ }
+ else
+ pListenerIters = this;
+
+ pAkt = rRoot.pRoot;
+ pDelNext = pAkt;
+}
+
+
+
+SvtListenerIter::~SvtListenerIter()
+{
+ if( pListenerIters )
+ {
+ if( pListenerIters == this )
+ pListenerIters = pNxtIter;
+ else
+ {
+ SvtListenerIter* pTmp = pListenerIters;
+ while( pTmp->pNxtIter != this )
+ if( 0 == ( pTmp = pTmp->pNxtIter ) )
+ return ;
+ pTmp->pNxtIter = pNxtIter;
+ }
+ }
+}
+
+void SvtListenerIter::RemoveListener( SvtListenerBase& rDel,
+ SvtListenerBase* pNext )
+{
+ // Update the ListenerIter
+ SvtListenerIter* pTmp = pListenerIters;
+ while( pTmp )
+ {
+ if( pTmp->pAkt == &rDel || pTmp->pDelNext == &rDel )
+ pTmp->pDelNext = pNext;
+ pTmp = pTmp->pNxtIter;
+ }
+}
+
+SvtListener* SvtListenerIter::GoNext()
+{
+ if( pDelNext == pAkt )
+ {
+ pAkt = pAkt->GetRight();
+ pDelNext = pAkt;
+ }
+ else
+ pAkt = pDelNext;
+ return pAkt ? pAkt->GetListener() : 0;
+}
+
+SvtListener* SvtListenerIter::GoStart() // zum Anfang des Baums
+{
+ pAkt = rRoot.pRoot;
+ if( pAkt )
+ while( pAkt->GetLeft() )
+ pAkt = pAkt->GetLeft();
+ pDelNext = pAkt;
+ return pAkt ? pAkt->GetListener() : 0;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/notify/svt_lstner.cxx b/binfilter/bf_svtools/source/notify/svt_lstner.cxx
new file mode 100644
index 000000000000..241fbb5ad7b1
--- /dev/null
+++ b/binfilter/bf_svtools/source/notify/svt_lstner.cxx
@@ -0,0 +1,182 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/debug.hxx>
+
+#include <bf_svtools/hint.hxx>
+#include <bf_svtools/brdcst.hxx>
+
+#define _SFX_LSTNER_CXX
+#include <bf_svtools/lstner.hxx>
+
+namespace binfilter
+{
+
+//====================================================================
+DBG_NAME(SfxListener)
+TYPEINIT0(SfxListener);
+
+//====================================================================
+// simple ctor of class SfxListener
+
+SfxListener::SfxListener()
+{
+ DBG_CTOR(SfxListener, 0);
+}
+//--------------------------------------------------------------------
+
+// copy ctor of class SfxListener
+
+SfxListener::SfxListener( const SfxListener &rListener )
+{
+ DBG_CTOR(SfxListener, 0);
+
+ for ( USHORT n = 0; n < rListener.aBCs.Count(); ++n )
+ StartListening( *rListener.aBCs[n] );
+}
+//--------------------------------------------------------------------
+
+// unregisteres the SfxListener from its SfxBroadcasters
+
+SfxListener::~SfxListener()
+{
+ DBG_DTOR(SfxListener, 0);
+
+ // unregister at all remainding broadcasters
+ for ( USHORT nPos = 0; nPos < aBCs.Count(); ++nPos )
+ {
+ SfxBroadcaster *pBC = aBCs[nPos];
+ pBC->RemoveListener(*this);
+ }
+}
+
+//--------------------------------------------------------------------
+
+// unregisteres at a specific SfxBroadcaster
+
+void SfxListener::RemoveBroadcaster_Impl( SfxBroadcaster& rBC )
+{
+ DBG_CHKTHIS(SfxListener, 0);
+
+ const SfxBroadcaster *pBC = &rBC;
+ aBCs.Remove( aBCs.GetPos(pBC), 1 );
+}
+
+//--------------------------------------------------------------------
+
+// registeres at a specific SfxBroadcaster
+
+BOOL SfxListener::StartListening( SfxBroadcaster& rBroadcaster, BOOL bPreventDups )
+{
+ DBG_CHKTHIS(SfxListener, 0);
+
+ if ( !bPreventDups || !IsListening( rBroadcaster ) )
+ {
+ if ( rBroadcaster.AddListener(*this) )
+ {
+ const SfxBroadcaster *pBC = &rBroadcaster;
+ aBCs.Insert( pBC, aBCs.Count() );
+
+ DBG_ASSERT( IsListening(rBroadcaster), "StartListening failed" );
+ return TRUE;
+ }
+
+ }
+ return FALSE;
+}
+
+//--------------------------------------------------------------------
+
+// unregisteres at a specific SfxBroadcaster
+
+BOOL SfxListener::EndListening( SfxBroadcaster& rBroadcaster, BOOL bAllDups )
+{
+ DBG_CHKTHIS(SfxListener, 0);
+
+ if ( !IsListening( rBroadcaster ) )
+ return FALSE;
+
+ do
+ {
+ rBroadcaster.RemoveListener(*this);
+ const SfxBroadcaster *pBC = &rBroadcaster;
+ aBCs.Remove( aBCs.GetPos(pBC), 1 );
+ }
+ while ( bAllDups && IsListening( rBroadcaster ) );
+ return TRUE;
+}
+
+//--------------------------------------------------------------------
+
+// unregisteres all Broadcasters
+
+void SfxListener::EndListeningAll()
+{
+ DBG_CHKTHIS(SfxListener, 0);
+
+ // MI: bei Optimierung beachten: Seiteneffekte von RemoveListener beachten!
+ while ( aBCs.Count() )
+ {
+ SfxBroadcaster *pBC = aBCs.GetObject(0);
+ pBC->RemoveListener(*this);
+ aBCs.Remove( 0, 1 );
+ }
+}
+
+//--------------------------------------------------------------------
+
+BOOL SfxListener::IsListening( SfxBroadcaster& rBroadcaster ) const
+{
+ const SfxBroadcaster *pBC = &rBroadcaster;
+ return USHRT_MAX != aBCs.GetPos( pBC );
+}
+
+//--------------------------------------------------------------------
+
+// base implementation of notification handler
+
+#ifdef DBG_UTIL
+void SfxListener::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
+ const SfxHint&, const TypeId& rHintType )
+#else
+void SfxListener::SFX_NOTIFY( SfxBroadcaster&, const TypeId&,
+ const SfxHint&, const TypeId& )
+#endif
+{
+ #ifdef DBG_UTIL
+ const SfxBroadcaster *pBC = &rBC;
+ DBG_ASSERT( USHRT_MAX != aBCs.GetPos(pBC),
+ "notification from unregistered broadcaster" );
+ #endif
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/notify/svt_smplhint.cxx b/binfilter/bf_svtools/source/notify/svt_smplhint.cxx
new file mode 100644
index 000000000000..eaa2e2036b00
--- /dev/null
+++ b/binfilter/bf_svtools/source/notify/svt_smplhint.cxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/smplhint.hxx>
+
+namespace binfilter
+{
+
+//====================================================================
+
+TYPEINIT1(SfxSimpleHint, SfxHint);
+
+//====================================================================
+// creates a SimpleHint with the type nId
+
+SfxSimpleHint::SfxSimpleHint( ULONG nIdP )
+{
+ nId = nIdP;
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/numbers/makefile.mk b/binfilter/bf_svtools/source/numbers/makefile.mk
new file mode 100644
index 000000000000..7198a7d51c44
--- /dev/null
+++ b/binfilter/bf_svtools/source/numbers/makefile.mk
@@ -0,0 +1,71 @@
+#*************************************************************************
+#
+# DO NOT ALTER 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=binfilter
+TARGET=numbers
+LIBTARGET=NO
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+EXCEPTIONSFILES= \
+ $(SLO)$/svt_numuno.obj \
+ $(SLO)$/svt_numfmuno.obj \
+ $(SLO)$/svt_supservs.obj
+
+SLOFILES = \
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/svt_zforfind.obj \
+ $(SLO)$/svt_zforlist.obj \
+ $(SLO)$/svt_zformat.obj \
+ $(SLO)$/svt_zforscan.obj \
+ $(SLO)$/svt_numhead.obj
+
+LIB1TARGET= $(SLB)$/$(TARGET).uno.lib
+LIB1OBJFILES= \
+ $(SLO)$/svt_numfmuno.obj \
+ $(SLO)$/svt_supservs.obj
+
+LIB2TARGET= $(SLB)$/$(TARGET).lib
+LIB2OBJFILES= \
+ $(SLO)$/svt_zforfind.obj \
+ $(SLO)$/svt_zforlist.obj \
+ $(SLO)$/svt_zformat.obj \
+ $(SLO)$/svt_zforscan.obj \
+ $(SLO)$/svt_numuno.obj \
+ $(SLO)$/svt_numhead.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/binfilter/bf_svtools/source/numbers/numfmuno.hxx b/binfilter/bf_svtools/source/numbers/numfmuno.hxx
new file mode 100644
index 000000000000..51a423a71a2f
--- /dev/null
+++ b/binfilter/bf_svtools/source/numbers/numfmuno.hxx
@@ -0,0 +1,320 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 _NUMFMUNO_HXX
+#define _NUMFMUNO_HXX
+
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/util/XNumberFormatPreviewer.hpp>
+#include <com/sun/star/util/XNumberFormats.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/beans/XPropertyAccess.hpp>
+
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/implbase3.hxx>
+
+namespace binfilter
+{
+
+class SvNumberformat;
+class SvNumberFormatter;
+class SvNumberFormatsSupplierObj;
+
+
+// SvNumberFormatterServiceObj wird global als Service angemeldet
+
+class SvNumberFormatterServiceObj : public cppu::WeakImplHelper3<
+ com::sun::star::util::XNumberFormatter,
+ com::sun::star::util::XNumberFormatPreviewer,
+ com::sun::star::lang::XServiceInfo>
+{
+private:
+ SvNumberFormatsSupplierObj* pSupplier;
+
+public:
+ SvNumberFormatterServiceObj();
+ virtual ~SvNumberFormatterServiceObj();
+
+ // XNumberFormatter
+ virtual void SAL_CALL attachNumberFormatsSupplier(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::util::XNumberFormatsSupplier >& xSupplier )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >
+ SAL_CALL getNumberFormatsSupplier()
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL detectNumberFormat( sal_Int32 nKey, const ::rtl::OUString& aString )
+ throw(::com::sun::star::util::NotNumericException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL convertStringToNumber( sal_Int32 nKey, const ::rtl::OUString& aString )
+ throw(::com::sun::star::util::NotNumericException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL convertNumberToString( sal_Int32 nKey, double fValue )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Color SAL_CALL queryColorForNumber( sal_Int32 nKey,
+ double fValue, ::com::sun::star::util::Color aDefaultColor )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL formatString( sal_Int32 nKey, const ::rtl::OUString& aString )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Color SAL_CALL queryColorForString( sal_Int32 nKey,
+ const ::rtl::OUString& aString,
+ ::com::sun::star::util::Color aDefaultColor )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getInputString( sal_Int32 nKey, double fValue )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ // XNumberFormatPreviewer
+ virtual ::rtl::OUString SAL_CALL convertNumberToPreviewString(
+ const ::rtl::OUString& aFormat, double fValue,
+ const ::com::sun::star::lang::Locale& nLocale, sal_Bool bAllowEnglish )
+ throw(::com::sun::star::util::MalformedNumberFormatException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Color SAL_CALL queryPreviewColorForNumber(
+ const ::rtl::OUString& aFormat, double fValue,
+ const ::com::sun::star::lang::Locale& nLocale, sal_Bool bAllowEnglish,
+ ::com::sun::star::util::Color aDefaultColor )
+ throw(::com::sun::star::util::MalformedNumberFormatException,
+ ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException);
+};
+
+
+class SvNumberFormatsObj : public cppu::WeakImplHelper3<
+ com::sun::star::util::XNumberFormats,
+ com::sun::star::util::XNumberFormatTypes,
+ com::sun::star::lang::XServiceInfo>
+{
+private:
+ SvNumberFormatsSupplierObj* pSupplier;
+
+public:
+ SvNumberFormatsObj();
+ SvNumberFormatsObj(SvNumberFormatsSupplierObj* pParent);
+ virtual ~SvNumberFormatsObj();
+
+
+ // XNumberFormats
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
+ getByKey( sal_Int32 nKey ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL queryKeys( sal_Int16 nType,
+ const ::com::sun::star::lang::Locale& nLocale, sal_Bool bCreate )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL queryKey( const ::rtl::OUString& aFormat,
+ const ::com::sun::star::lang::Locale& nLocale, sal_Bool bScan )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL addNew( const ::rtl::OUString& aFormat,
+ const ::com::sun::star::lang::Locale& nLocale )
+ throw(::com::sun::star::util::MalformedNumberFormatException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL addNewConverted( const ::rtl::OUString& aFormat,
+ const ::com::sun::star::lang::Locale& nLocale,
+ const ::com::sun::star::lang::Locale& nNewLocale )
+ throw(::com::sun::star::util::MalformedNumberFormatException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeByKey( sal_Int32 nKey ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL generateFormat( sal_Int32 nBaseKey,
+ const ::com::sun::star::lang::Locale& nLocale, sal_Bool bThousands,
+ sal_Bool bRed, sal_Int16 nDecimals, sal_Int16 nLeading )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ // XNumberFormatTypes
+ virtual sal_Int32 SAL_CALL getStandardIndex( const ::com::sun::star::lang::Locale& nLocale )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getStandardFormat( sal_Int16 nType,
+ const ::com::sun::star::lang::Locale& nLocale )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getFormatIndex( sal_Int16 nIndex,
+ const ::com::sun::star::lang::Locale& nLocale )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isTypeCompatible( sal_Int16 nOldType, sal_Int16 nNewType )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getFormatForLocale( sal_Int32 nKey,
+ const ::com::sun::star::lang::Locale& nLocale )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException);
+};
+
+
+class SvNumberFormatObj : public cppu::WeakImplHelper3<
+ com::sun::star::beans::XPropertySet,
+ com::sun::star::beans::XPropertyAccess,
+ com::sun::star::lang::XServiceInfo>
+{
+private:
+ SvNumberFormatsSupplierObj* pSupplier;
+ ULONG nKey;
+
+public:
+ SvNumberFormatObj(SvNumberFormatsSupplierObj* pParent, ULONG nK);
+ virtual ~SvNumberFormatObj();
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
+ SAL_CALL getPropertySetInfo( )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
+ const ::com::sun::star::uno::Any& aValue )
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::beans::PropertyVetoException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
+ const ::rtl::OUString& PropertyName )
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertyChangeListener >& xListener )
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertyChangeListener >& aListener )
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XVetoableChangeListener >& aListener )
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XVetoableChangeListener >& aListener )
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+
+ // XPropertyAccess
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL
+ getPropertyValues() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::beans::PropertyValue >& aProps )
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::beans::PropertyVetoException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException);
+};
+
+
+class SvNumberFormatSettingsObj : public cppu::WeakImplHelper2<
+ com::sun::star::beans::XPropertySet,
+ com::sun::star::lang::XServiceInfo>
+{
+private:
+ SvNumberFormatsSupplierObj* pSupplier;
+
+public:
+ SvNumberFormatSettingsObj(SvNumberFormatsSupplierObj* pParent);
+ virtual ~SvNumberFormatSettingsObj();
+
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
+ SAL_CALL getPropertySetInfo( )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
+ const ::com::sun::star::uno::Any& aValue )
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::beans::PropertyVetoException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
+ const ::rtl::OUString& PropertyName )
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertyChangeListener >& xListener )
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertyChangeListener >& aListener )
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XVetoableChangeListener >& aListener )
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XVetoableChangeListener >& aListener )
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException);
+};
+
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/numbers/numhead.hxx b/binfilter/bf_svtools/source/numbers/numhead.hxx
new file mode 100644
index 000000000000..9c63adab4d62
--- /dev/null
+++ b/binfilter/bf_svtools/source/numbers/numhead.hxx
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 NF_NUMHEAD_HXX
+#define NF_NUMHEAD_HXX
+
+#include <tools/stream.hxx>
+
+namespace binfilter
+{
+
+// -----------------------------------------------------------------------
+
+ // "Automatischer" Record-Header mit Groessenangabe
+
+/* wird fuer SvNumberFormatter nicht gebraucht
+class SvNumReadHeader
+{
+private:
+ SvStream& rStream;
+ ULONG nDataEnd;
+
+public:
+ SvNumReadHeader(SvStream& rNewStream);
+ ~SvNumReadHeader();
+
+ ULONG BytesLeft() const;
+};
+
+class SvNumWriteHeader
+{
+private:
+ SvStream& rStream;
+ ULONG nDataPos;
+ ULONG nDataSize;
+
+public:
+ SvNumWriteHeader(SvStream& rNewStream, ULONG nDefault = 0);
+ ~SvNumWriteHeader();
+};
+
+*/
+
+ // Header mit Groessenangaben fuer mehrere Objekte
+
+class ImpSvNumMultipleReadHeader
+{
+private:
+ SvStream& rStream;
+ char* pBuf;
+ SvMemoryStream* pMemStream;
+ ULONG nEndPos;
+ ULONG nEntryEnd;
+
+public:
+ ImpSvNumMultipleReadHeader(SvStream& rNewStream);
+ ~ImpSvNumMultipleReadHeader();
+
+ void StartEntry();
+ void EndEntry();
+ ULONG BytesLeft() const;
+
+ static void Skip( SvStream& ); // komplett ueberspringen
+};
+
+class ImpSvNumMultipleWriteHeader
+{
+private:
+ SvStream& rStream;
+ SvMemoryStream aMemStream;
+ ULONG nDataPos;
+ sal_uInt32 nDataSize;
+ ULONG nEntryStart;
+
+public:
+ ImpSvNumMultipleWriteHeader(SvStream& rNewStream, ULONG nDefault = 0);
+ ~ImpSvNumMultipleWriteHeader();
+
+ void StartEntry();
+ void EndEntry();
+};
+
+}
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/numbers/supservs.hxx b/binfilter/bf_svtools/source/numbers/supservs.hxx
new file mode 100644
index 000000000000..26a97d65ee59
--- /dev/null
+++ b/binfilter/bf_svtools/source/numbers/supservs.hxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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_NUMBERS_SUPPLIERSERVICE_HXX_
+#define _SVTOOLS_NUMBERS_SUPPLIERSERVICE_HXX_
+
+#include "numuno.hxx"
+#include <bf_svtools/zforlist.hxx>
+
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/io/XPersistObject.hpp>
+
+namespace binfilter
+{
+
+//=========================================================================
+//= SvNumberFormatsSupplierServiceObject - a number formats supplier which
+//= - can be instantiated as an service
+//= - supports the ::com::sun::star::io::XPersistObject interface
+//= - works with it's own SvNumberFormatter instance
+//= - can be initialized (::com::sun::star::lang::XInitialization)
+//= with a specific language (i.e. ::com::sun::star::lang::Locale)
+//=========================================================================
+class SvNumberFormatsSupplierServiceObject
+ :protected SvNumberFormatsSupplierObj
+ ,public ::com::sun::star::lang::XInitialization
+ ,public ::com::sun::star::io::XPersistObject
+ ,public ::com::sun::star::lang::XServiceInfo
+{ // don't want the Set-/GetNumberFormatter to be accessable from outside
+
+ friend ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL SvNumberFormatsSupplierServiceObject_CreateInstance(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
+
+protected:
+ SvNumberFormatter* m_pOwnFormatter;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+
+public:
+ SvNumberFormatsSupplierServiceObject(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+ ~SvNumberFormatsSupplierServiceObject();
+
+ // XInterface
+ virtual void SAL_CALL acquire() throw() { SvNumberFormatsSupplierObj::acquire(); }
+ virtual void SAL_CALL release() throw() { SvNumberFormatsSupplierObj::release(); }
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException)
+ { return SvNumberFormatsSupplierObj::queryInterface(_rType); }
+
+ // XAggregation
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL write( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream >& OutStream ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL read( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream >& InStream ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+
+ // XNumberFormatsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
+ getNumberFormatSettings() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats > SAL_CALL
+ getNumberFormats() throw(::com::sun::star::uno::RuntimeException);
+
+ // XUnoTunnler
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ void implEnsureFormatter();
+};
+
+}
+
+#endif // _SVTOOLS_NUMBERS_SUPPLIERSERVICE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/numbers/svt_nbdll.cxx b/binfilter/bf_svtools/source/numbers/svt_nbdll.cxx
new file mode 100644
index 000000000000..d7255f17eed0
--- /dev/null
+++ b/binfilter/bf_svtools/source/numbers/svt_nbdll.cxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+#ifdef WIN
+
+#include <svwin.h>
+
+#include <sysdep.hxx>
+
+namespace binfilter
+{
+
+
+// Statische DLL-Verwaltungs-Variablen
+static HINSTANCE hDLLInst = 0; // HANDLE der DLL
+
+
+/***************************************************************************
+|*
+|* LibMain()
+|*
+|* Beschreibung Initialisierungsfunktion der DLL
+|* Ersterstellung TH 05.05.93
+|* Letzte Aenderung TH 05.05.93
+|*
+***************************************************************************/
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+/***************************************************************************
+|*
+|* WEP()
+|*
+|* Beschreibung DLL-Deinitialisierung
+|* Ersterstellung TH 05.05.93
+|* Letzte Aenderung TH 05.05.93
+|*
+***************************************************************************/
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/numbers/svt_numfmuno.cxx b/binfilter/bf_svtools/source/numbers/svt_numfmuno.cxx
new file mode 100644
index 000000000000..0e4cd2083386
--- /dev/null
+++ b/binfilter/bf_svtools/source/numbers/svt_numfmuno.cxx
@@ -0,0 +1,1145 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <vcl/svapp.hxx>
+#include <tools/color.hxx>
+#include <tools/debug.hxx>
+#include <i18npool/mslangid.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/ustring.hxx>
+
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+#include "numfmuno.hxx"
+#include "numuno.hxx"
+#include <bf_svtools/zforlist.hxx>
+#include <bf_svtools/zformat.hxx>
+#include <bf_svtools/itemprop.hxx>
+
+using namespace com::sun::star;
+
+namespace binfilter
+{
+
+//------------------------------------------------------------------------
+
+#define SERVICENAME_NUMBERFORMATTER "com.sun.star.util.NumberFormatter"
+#define SERVICENAME_NUMBERSETTINGS "com.sun.star.util.NumberFormatSettings"
+#define SERVICENAME_NUMBERFORMATS "com.sun.star.util.NumberFormats"
+#define SERVICENAME_NUMBERFORMAT "com.sun.star.util.NumberFormatProperties"
+
+//------------------------------------------------------------------------
+
+#define PROPERTYNAME_FMTSTR "FormatString"
+#define PROPERTYNAME_LOCALE "Locale"
+#define PROPERTYNAME_TYPE "Type"
+#define PROPERTYNAME_COMMENT "Comment"
+#define PROPERTYNAME_CURREXT "CurrencyExtension"
+#define PROPERTYNAME_CURRSYM "CurrencySymbol"
+#define PROPERTYNAME_CURRABB "CurrencyAbbreviation"
+#define PROPERTYNAME_DECIMALS "Decimals"
+#define PROPERTYNAME_LEADING "LeadingZeros"
+#define PROPERTYNAME_NEGRED "NegativeRed"
+#define PROPERTYNAME_STDFORM "StandardFormat"
+#define PROPERTYNAME_THOUS "ThousandsSeparator"
+#define PROPERTYNAME_USERDEF "UserDefined"
+
+#define PROPERTYNAME_NOZERO "NoZero"
+#define PROPERTYNAME_NULLDATE "NullDate"
+#define PROPERTYNAME_STDDEC "StandardDecimals"
+#define PROPERTYNAME_TWODIGIT "TwoDigitDateStart"
+
+//------------------------------------------------------------------------
+
+// alles ohne Which-ID, Map nur fuer PropertySetInfo
+
+const SfxItemPropertyMap* lcl_GetNumberFormatPropertyMap()
+{
+ static SfxItemPropertyMap aNumberFormatPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(PROPERTYNAME_FMTSTR), 0, &getCppuType((rtl::OUString*)0),beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(PROPERTYNAME_LOCALE), 0, &getCppuType((lang::Locale*)0),beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(PROPERTYNAME_TYPE), 0, &getCppuType((sal_Int16*)0), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(PROPERTYNAME_COMMENT), 0, &getCppuType((rtl::OUString*)0),beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(PROPERTYNAME_CURREXT), 0, &getCppuType((rtl::OUString*)0),beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(PROPERTYNAME_CURRSYM), 0, &getCppuType((rtl::OUString*)0),beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(PROPERTYNAME_DECIMALS), 0, &getCppuType((sal_Int16*)0), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(PROPERTYNAME_LEADING), 0, &getCppuType((sal_Int16*)0), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(PROPERTYNAME_NEGRED), 0, &getBooleanCppuType(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(PROPERTYNAME_STDFORM), 0, &getBooleanCppuType(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(PROPERTYNAME_THOUS), 0, &getBooleanCppuType(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(PROPERTYNAME_USERDEF), 0, &getBooleanCppuType(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(PROPERTYNAME_CURRABB), 0, &getCppuType((rtl::OUString*)0),beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0},
+ {0,0,0,0,0,0}
+ };
+ return aNumberFormatPropertyMap_Impl;
+}
+
+const SfxItemPropertyMap* lcl_GetNumberSettingsPropertyMap()
+{
+ static SfxItemPropertyMap aNumberSettingsPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(PROPERTYNAME_NOZERO), 0, &getBooleanCppuType(), beans::PropertyAttribute::BOUND, 0},
+ {MAP_CHAR_LEN(PROPERTYNAME_NULLDATE), 0, &getCppuType((util::Date*)0), beans::PropertyAttribute::BOUND, 0},
+ {MAP_CHAR_LEN(PROPERTYNAME_STDDEC), 0, &getCppuType((sal_Int16*)0), beans::PropertyAttribute::BOUND, 0},
+ {MAP_CHAR_LEN(PROPERTYNAME_TWODIGIT), 0, &getCppuType((sal_Int16*)0), beans::PropertyAttribute::BOUND, 0},
+ {0,0,0,0,0,0}
+ };
+ return aNumberSettingsPropertyMap_Impl;
+}
+
+//----------------------------------------------------------------------------------------
+
+LanguageType lcl_GetLanguage( const lang::Locale& rLocale )
+{
+ // empty language -> LANGUAGE_SYSTEM
+ if ( rLocale.Language.getLength() == 0 )
+ return LANGUAGE_SYSTEM;
+
+ LanguageType eRet = MsLangId::convertLocaleToLanguage( rLocale );
+ if ( eRet == LANGUAGE_NONE )
+ eRet = LANGUAGE_SYSTEM; //! or throw an exception?
+
+ return eRet;
+}
+
+//----------------------------------------------------------------------------------------
+
+SvNumberFormatterServiceObj::SvNumberFormatterServiceObj() :
+ pSupplier(NULL)
+{
+}
+
+SvNumberFormatterServiceObj::~SvNumberFormatterServiceObj()
+{
+ if (pSupplier)
+ pSupplier->release();
+}
+
+com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvNumberFormatterServiceObj_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& )
+{
+ return ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface >( ( ::cppu::OWeakObject* ) new SvNumberFormatterServiceObj );
+}
+
+// XNumberFormatter
+
+void SAL_CALL SvNumberFormatterServiceObj::attachNumberFormatsSupplier(
+ const uno::Reference<util::XNumberFormatsSupplier>& xSupplier )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ SvNumberFormatsSupplierObj* pNew = SvNumberFormatsSupplierObj::getImplementation( xSupplier );
+ if (!pNew)
+ throw uno::RuntimeException(); // wrong object
+
+ if (pNew)
+ pNew->acquire();
+ if (pSupplier)
+ pSupplier->release();
+ pSupplier = pNew;
+}
+
+uno::Reference<util::XNumberFormatsSupplier> SAL_CALL
+ SvNumberFormatterServiceObj::getNumberFormatsSupplier()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return pSupplier;
+}
+
+sal_Int32 SAL_CALL SvNumberFormatterServiceObj::detectNumberFormat(
+ sal_Int32 nKey, const rtl::OUString& aString )
+ throw(util::NotNumericException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ INT32 nRet = 0;
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ {
+ String aTemp = aString;
+ sal_uInt32 nUKey = nKey;
+ double fValue = 0.0;
+ if ( pFormatter->IsNumberFormat(aTemp, nUKey, fValue) )
+ nRet = nUKey;
+ else
+ throw util::NotNumericException();
+ }
+ else
+ throw uno::RuntimeException();
+
+ return nRet;
+}
+
+double SAL_CALL SvNumberFormatterServiceObj::convertStringToNumber(
+ sal_Int32 nKey, const rtl::OUString& aString )
+ throw(util::NotNumericException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ double fRet = 0.0;
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ {
+ String aTemp = aString;
+ sal_uInt32 nUKey = nKey;
+ double fValue = 0.0;
+ if ( pFormatter->IsNumberFormat(aTemp, nUKey, fValue) )
+ fRet = fValue;
+ else
+ throw util::NotNumericException();
+ }
+ else
+ throw uno::RuntimeException();
+
+ return fRet;
+}
+
+rtl::OUString SAL_CALL SvNumberFormatterServiceObj::convertNumberToString(
+ sal_Int32 nKey, double fValue ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ String aRet;
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ {
+ Color* pColor = NULL;
+ pFormatter->GetOutputString(fValue, nKey, aRet, &pColor);
+ }
+ else
+ throw uno::RuntimeException();
+
+ return aRet;
+}
+
+util::Color SAL_CALL SvNumberFormatterServiceObj::queryColorForNumber( sal_Int32 nKey,
+ double fValue, util::Color aDefaultColor )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ util::Color nRet = aDefaultColor; // color = INT32
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ {
+ String aStr;
+ Color* pColor = NULL;
+ pFormatter->GetOutputString(fValue, nKey, aStr, &pColor);
+ if (pColor)
+ nRet = pColor->GetColor();
+ // sonst Default behalten
+ }
+ else
+ throw uno::RuntimeException();
+
+ return nRet;
+}
+
+rtl::OUString SAL_CALL SvNumberFormatterServiceObj::formatString( sal_Int32 nKey,
+ const rtl::OUString& aString ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ String aRet;
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ {
+ String aTemp = aString;
+ Color* pColor = NULL;
+ pFormatter->GetOutputString(aTemp, nKey, aRet, &pColor);
+ }
+ else
+ throw uno::RuntimeException();
+
+ return aRet;
+}
+
+util::Color SAL_CALL SvNumberFormatterServiceObj::queryColorForString( sal_Int32 nKey,
+ const rtl::OUString& aString,util::Color aDefaultColor )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ util::Color nRet = aDefaultColor; // color = INT32
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ {
+ String aTemp = aString;
+ String aStr;
+ Color* pColor = NULL;
+ pFormatter->GetOutputString(aTemp, nKey, aStr, &pColor);
+ if (pColor)
+ nRet = pColor->GetColor();
+ // sonst Default behalten
+ }
+ else
+ throw uno::RuntimeException();
+
+ return nRet;
+}
+
+rtl::OUString SAL_CALL SvNumberFormatterServiceObj::getInputString( sal_Int32 nKey, double fValue )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ String aRet;
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ pFormatter->GetInputLineString(fValue, nKey, aRet);
+ else
+ throw uno::RuntimeException();
+
+ return aRet;
+}
+
+// XNumberFormatPreviewer
+
+rtl::OUString SAL_CALL SvNumberFormatterServiceObj::convertNumberToPreviewString(
+ const rtl::OUString& aFormat, double fValue,
+ const lang::Locale& nLocale, sal_Bool bAllowEnglish )
+ throw(util::MalformedNumberFormatException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ String aRet;
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ {
+ String aOutString;
+ String aFormString = aFormat;
+ LanguageType eLang = lcl_GetLanguage( nLocale );
+ Color* pColor = NULL;
+
+ BOOL bOk;
+ if ( bAllowEnglish )
+ bOk = pFormatter->GetPreviewStringGuess(
+ aFormString, fValue, aOutString, &pColor, eLang );
+ else
+ bOk = pFormatter->GetPreviewString(
+ aFormString, fValue, aOutString, &pColor, eLang );
+
+ if (bOk)
+ aRet = aOutString;
+ else
+ throw util::MalformedNumberFormatException();
+ }
+ else
+ throw uno::RuntimeException();
+
+ return aRet;
+}
+
+util::Color SAL_CALL SvNumberFormatterServiceObj::queryPreviewColorForNumber(
+ const rtl::OUString& aFormat, double fValue,
+ const lang::Locale& nLocale, sal_Bool bAllowEnglish,
+ util::Color aDefaultColor )
+ throw(util::MalformedNumberFormatException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ util::Color nRet = aDefaultColor; // color = INT32
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ {
+ String aOutString;
+ String aFormString = aFormat;
+ LanguageType eLang = lcl_GetLanguage( nLocale );
+ Color* pColor = NULL;
+
+ BOOL bOk;
+ if ( bAllowEnglish )
+ bOk = pFormatter->GetPreviewStringGuess(
+ aFormString, fValue, aOutString, &pColor, eLang );
+ else
+ bOk = pFormatter->GetPreviewString(
+ aFormString, fValue, aOutString, &pColor, eLang );
+
+ if (bOk)
+ {
+ if (pColor)
+ nRet = pColor->GetColor();
+ // sonst Default behalten
+ }
+ else
+ throw util::MalformedNumberFormatException();
+ }
+ else
+ throw uno::RuntimeException();
+
+ return nRet;
+}
+
+// XServiceInfo
+
+rtl::OUString SAL_CALL SvNumberFormatterServiceObj::getImplementationName()
+ throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.uno.util.numbers.SvNumberFormatterServiceObject");
+}
+
+sal_Bool SAL_CALL SvNumberFormatterServiceObj::supportsService( const rtl::OUString& ServiceName )
+ throw(uno::RuntimeException)
+{
+ return ( ServiceName.compareToAscii(SERVICENAME_NUMBERFORMATTER) == 0 );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL SvNumberFormatterServiceObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii(SERVICENAME_NUMBERFORMATTER);
+ return aRet;
+}
+
+//------------------------------------------------------------------------
+
+SvNumberFormatsObj::SvNumberFormatsObj(SvNumberFormatsSupplierObj* pParent) :
+ pSupplier(pParent)
+{
+ if (pSupplier)
+ pSupplier->acquire();
+}
+
+SvNumberFormatsObj::~SvNumberFormatsObj()
+{
+ if (pSupplier)
+ pSupplier->release();
+}
+
+// XNumberFormats
+
+uno::Reference<beans::XPropertySet> SAL_CALL SvNumberFormatsObj::getByKey( sal_Int32 nKey )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ const SvNumberformat* pFormat = pFormatter ? pFormatter->GetEntry(nKey) : NULL;
+ if (pFormat)
+ return new SvNumberFormatObj( pSupplier, nKey );
+ else
+ throw uno::RuntimeException();
+}
+
+uno::Sequence<sal_Int32> SAL_CALL SvNumberFormatsObj::queryKeys( sal_Int16 nType,
+ const lang::Locale& nLocale, sal_Bool bCreate )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if ( pFormatter )
+ {
+ sal_uInt32 nIndex = 0;
+ LanguageType eLang = lcl_GetLanguage( nLocale );
+ SvNumberFormatTable& rTable = bCreate ?
+ pFormatter->ChangeCL( nType, nIndex, eLang ) :
+ pFormatter->GetEntryTable( nType, nIndex, eLang );
+ sal_uInt32 nCount = rTable.Count();
+ uno::Sequence<sal_Int32> aSeq(nCount);
+ sal_Int32* pAry = aSeq.getArray();
+ for (sal_uInt32 i=0; i<nCount; i++)
+ pAry[i] = rTable.GetObjectKey( i );
+
+ return aSeq;
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+sal_Int32 SAL_CALL SvNumberFormatsObj::queryKey( const rtl::OUString& aFormat,
+ const lang::Locale& nLocale, sal_Bool bScan )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ INT32 nRet = 0;
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ {
+ String aFormStr = aFormat;
+ LanguageType eLang = lcl_GetLanguage( nLocale );
+ if (bScan)
+ {
+ //! irgendwas muss hier noch passieren...
+ }
+ nRet = pFormatter->GetEntryKey( aFormat, eLang );
+ }
+ else
+ throw uno::RuntimeException();
+
+ return nRet;
+}
+
+sal_Int32 SAL_CALL SvNumberFormatsObj::addNew( const rtl::OUString& aFormat,
+ const lang::Locale& nLocale )
+ throw(util::MalformedNumberFormatException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ INT32 nRet = 0;
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ {
+ String aFormStr = aFormat;
+ LanguageType eLang = lcl_GetLanguage( nLocale );
+ sal_uInt32 nKey = 0;
+ xub_StrLen nCheckPos = 0;
+ short nType = 0;
+ BOOL bOk = pFormatter->PutEntry( aFormStr, nCheckPos, nType, nKey, eLang );
+ if (bOk)
+ nRet = nKey;
+ else if (nCheckPos)
+ {
+ throw util::MalformedNumberFormatException(); // ungueltiges Format
+ }
+ else
+ throw uno::RuntimeException(); // anderer Fehler (z.B. schon vorhanden)
+ }
+ else
+ throw uno::RuntimeException();
+
+ return nRet;
+}
+
+sal_Int32 SAL_CALL SvNumberFormatsObj::addNewConverted( const rtl::OUString& aFormat,
+ const lang::Locale& nLocale, const lang::Locale& nNewLocale )
+ throw(util::MalformedNumberFormatException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ INT32 nRet = 0;
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ {
+ String aFormStr = aFormat;
+ LanguageType eLang = lcl_GetLanguage( nLocale );
+ LanguageType eNewLang = lcl_GetLanguage( nNewLocale );
+ sal_uInt32 nKey = 0;
+ xub_StrLen nCheckPos = 0;
+ short nType = 0;
+ BOOL bOk = pFormatter->PutandConvertEntry( aFormStr, nCheckPos, nType, nKey, eLang, eNewLang );
+ if (bOk || nKey > 0)
+ nRet = nKey;
+ else if (nCheckPos)
+ {
+ throw util::MalformedNumberFormatException(); // ungueltiges Format
+ }
+ else
+ throw uno::RuntimeException(); // anderer Fehler (z.B. schon vorhanden)
+ }
+ else
+ throw uno::RuntimeException();
+
+ return nRet;
+}
+
+void SAL_CALL SvNumberFormatsObj::removeByKey( sal_Int32 nKey ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+
+ if (pFormatter)
+ {
+ pFormatter->DeleteEntry(nKey);
+ pSupplier->NumberFormatDeleted(nKey); // Benachrichtigung fuers Dokument
+ }
+}
+
+rtl::OUString SAL_CALL SvNumberFormatsObj::generateFormat( sal_Int32 nBaseKey,
+ const lang::Locale& nLocale, sal_Bool bThousands,
+ sal_Bool bRed, sal_Int16 nDecimals, sal_Int16 nLeading )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ String aRet;
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ {
+ LanguageType eLang = lcl_GetLanguage( nLocale );
+ pFormatter->GenerateFormat( aRet, nBaseKey, eLang, bThousands, bRed, nDecimals, nLeading );
+ }
+ else
+ throw uno::RuntimeException();
+
+ return aRet;
+}
+
+// XNumberFormatTypes
+
+sal_Int32 SAL_CALL SvNumberFormatsObj::getStandardIndex( const lang::Locale& nLocale )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ INT32 nRet = 0;
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ {
+ LanguageType eLang = lcl_GetLanguage( nLocale );
+ nRet = pFormatter->GetStandardIndex(eLang);
+ }
+ else
+ throw uno::RuntimeException();
+
+ return nRet;
+}
+
+sal_Int32 SAL_CALL SvNumberFormatsObj::getStandardFormat( sal_Int16 nType, const lang::Locale& nLocale )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ INT32 nRet = 0;
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ {
+ LanguageType eLang = lcl_GetLanguage( nLocale );
+ // mask out "defined" bit, so type from an existing number format
+ // can directly be used for getStandardFormat
+ nType &= ~NUMBERFORMAT_DEFINED;
+ nRet = pFormatter->GetStandardFormat(nType, eLang);
+ }
+ else
+ throw uno::RuntimeException();
+
+ return nRet;
+}
+
+sal_Int32 SAL_CALL SvNumberFormatsObj::getFormatIndex( sal_Int16 nIndex, const lang::Locale& nLocale )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ INT32 nRet = 0;
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ {
+ LanguageType eLang = lcl_GetLanguage( nLocale );
+ nRet = pFormatter->GetFormatIndex( (NfIndexTableOffset)nIndex, eLang );
+ }
+ else
+ throw uno::RuntimeException();
+
+ return nRet;
+}
+
+sal_Bool SAL_CALL SvNumberFormatsObj::isTypeCompatible( sal_Int16 nOldType, sal_Int16 nNewType )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ BOOL bRet = FALSE;
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ bRet = pFormatter->IsCompatible( nOldType, nNewType );
+ else
+ throw uno::RuntimeException();
+
+ return bRet;
+}
+
+sal_Int32 SAL_CALL SvNumberFormatsObj::getFormatForLocale( sal_Int32 nKey, const lang::Locale& nLocale )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ INT32 nRet = 0;
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ {
+ LanguageType eLang = lcl_GetLanguage( nLocale );
+ nRet = pFormatter->GetFormatForLanguageIfBuiltIn(nKey, eLang);
+ }
+ else
+ throw uno::RuntimeException();
+
+ return nRet;
+}
+
+// XServiceInfo
+
+rtl::OUString SAL_CALL SvNumberFormatsObj::getImplementationName()
+ throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii("SvNumberFormatsObj");
+}
+
+sal_Bool SAL_CALL SvNumberFormatsObj::supportsService( const rtl::OUString& ServiceName )
+ throw(uno::RuntimeException)
+{
+ return ( ServiceName.compareToAscii(SERVICENAME_NUMBERFORMATS) == 0 );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL SvNumberFormatsObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii(SERVICENAME_NUMBERFORMATS);
+ return aRet;
+}
+
+//------------------------------------------------------------------------
+
+SvNumberFormatObj::SvNumberFormatObj(SvNumberFormatsSupplierObj* pParent, ULONG nK) :
+ pSupplier(pParent),
+ nKey(nK)
+{
+ if (pSupplier)
+ pSupplier->acquire();
+}
+
+SvNumberFormatObj::~SvNumberFormatObj()
+{
+ if (pSupplier)
+ pSupplier->release();
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL SvNumberFormatObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef =
+ new SfxItemPropertySetInfo( lcl_GetNumberFormatPropertyMap() );
+ return aRef;
+}
+
+void SAL_CALL SvNumberFormatObj::setPropertyValue( const rtl::OUString&,
+ const uno::Any& )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ throw beans::UnknownPropertyException(); // everything is read-only
+}
+
+uno::Any SAL_CALL SvNumberFormatObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Any aRet;
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ const SvNumberformat* pFormat = pFormatter ? pFormatter->GetEntry(nKey) : NULL;
+ if (pFormat)
+ {
+ BOOL bThousand, bRed;
+ USHORT nDecimals, nLeading;
+
+ String aString = aPropertyName;
+ if (aString.EqualsAscii( PROPERTYNAME_FMTSTR ))
+ {
+ aRet <<= rtl::OUString( pFormat->GetFormatstring() );
+ }
+ else if (aString.EqualsAscii( PROPERTYNAME_LOCALE ))
+ {
+ lang::Locale aLocale( MsLangId::convertLanguageToLocale(
+ pFormat->GetLanguage()));
+ aRet <<= aLocale;
+ }
+ else if (aString.EqualsAscii( PROPERTYNAME_TYPE ))
+ {
+ aRet <<= (sal_Int16)( pFormat->GetType() );
+ }
+ else if (aString.EqualsAscii( PROPERTYNAME_COMMENT ))
+ {
+ aRet <<= rtl::OUString( pFormat->GetComment() );
+ }
+ else if (aString.EqualsAscii( PROPERTYNAME_STDFORM ))
+ {
+ //! SvNumberformat Member bStandard rausreichen?
+ BOOL bStandard = ( ( nKey % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 );
+ aRet.setValue( &bStandard, getBooleanCppuType() );
+ }
+ else if (aString.EqualsAscii( PROPERTYNAME_USERDEF ))
+ {
+ BOOL bUserDef = ( ( pFormat->GetType() & NUMBERFORMAT_DEFINED ) != 0 );
+ aRet.setValue( &bUserDef, getBooleanCppuType() );
+ }
+ else if (aString.EqualsAscii( PROPERTYNAME_DECIMALS ))
+ {
+ pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
+ aRet <<= (sal_Int16)( nDecimals );
+ }
+ else if (aString.EqualsAscii( PROPERTYNAME_LEADING ))
+ {
+ pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
+ aRet <<= (sal_Int16)( nLeading );
+ }
+ else if (aString.EqualsAscii( PROPERTYNAME_NEGRED ))
+ {
+ pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
+ aRet.setValue( &bRed, getBooleanCppuType() );
+ }
+ else if (aString.EqualsAscii( PROPERTYNAME_THOUS ))
+ {
+ pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
+ aRet.setValue( &bThousand, getBooleanCppuType() );
+ }
+ else if (aString.EqualsAscii( PROPERTYNAME_CURRSYM ))
+ {
+ String aSymbol, aExt;
+ pFormat->GetNewCurrencySymbol( aSymbol, aExt );
+ aRet <<= rtl::OUString( aSymbol );
+ }
+ else if (aString.EqualsAscii( PROPERTYNAME_CURREXT ))
+ {
+ String aSymbol, aExt;
+ pFormat->GetNewCurrencySymbol( aSymbol, aExt );
+ aRet <<= rtl::OUString( aExt );
+ }
+ else if (aString.EqualsAscii( PROPERTYNAME_CURRABB ))
+ {
+ String aSymbol, aExt;
+ BOOL bBank = FALSE;
+ pFormat->GetNewCurrencySymbol( aSymbol, aExt );
+ const NfCurrencyEntry* pCurr = pFormatter->GetCurrencyEntry( bBank,
+ aSymbol, aExt, pFormat->GetLanguage() );
+ if ( pCurr )
+ aRet <<= rtl::OUString( pCurr->GetBankSymbol() );
+ else
+ aRet <<= rtl::OUString();
+ }
+ else
+ throw beans::UnknownPropertyException();
+ }
+ else
+ throw uno::RuntimeException();
+
+ return aRet;
+}
+
+void SAL_CALL SvNumberFormatObj::addPropertyChangeListener( const rtl::OUString&,
+ const uno::Reference<beans::XPropertyChangeListener>&)
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+}
+
+void SAL_CALL SvNumberFormatObj::removePropertyChangeListener( const rtl::OUString&,
+ const uno::Reference<beans::XPropertyChangeListener>&)
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+}
+
+void SAL_CALL SvNumberFormatObj::addVetoableChangeListener( const rtl::OUString&,
+ const uno::Reference<beans::XVetoableChangeListener>&)
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+}
+
+void SAL_CALL SvNumberFormatObj::removeVetoableChangeListener( const rtl::OUString&,
+ const uno::Reference<beans::XVetoableChangeListener>&)
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+}
+
+// XPropertyAccess
+
+uno::Sequence<beans::PropertyValue> SAL_CALL SvNumberFormatObj::getPropertyValues()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ const SvNumberformat* pFormat = pFormatter ? pFormatter->GetEntry(nKey) : NULL;
+ if (pFormat)
+ {
+ String aSymbol, aExt, aAbb;
+ BOOL bBank = FALSE;
+ pFormat->GetNewCurrencySymbol( aSymbol, aExt );
+ const NfCurrencyEntry* pCurr = pFormatter->GetCurrencyEntry( bBank,
+ aSymbol, aExt, pFormat->GetLanguage() );
+ if ( pCurr )
+ aAbb = pCurr->GetBankSymbol();
+
+ String aFmtStr = pFormat->GetFormatstring();
+ String aComment = pFormat->GetComment();
+ BOOL bStandard = ( ( nKey % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 );
+ //! SvNumberformat Member bStandard rausreichen?
+ BOOL bUserDef = ( ( pFormat->GetType() & NUMBERFORMAT_DEFINED ) != 0 );
+ BOOL bThousand, bRed;
+ USHORT nDecimals, nLeading;
+ pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading );
+ lang::Locale aLocale( MsLangId::convertLanguageToLocale(
+ pFormat->GetLanguage()));
+
+ uno::Sequence<beans::PropertyValue> aSeq(13);
+ beans::PropertyValue* pArray = aSeq.getArray();
+
+ pArray[0].Name = rtl::OUString::createFromAscii( PROPERTYNAME_FMTSTR );
+ pArray[0].Value <<= rtl::OUString( aFmtStr );
+ pArray[1].Name = rtl::OUString::createFromAscii( PROPERTYNAME_LOCALE );
+ pArray[1].Value <<= aLocale;
+ pArray[2].Name = rtl::OUString::createFromAscii( PROPERTYNAME_TYPE );
+ pArray[2].Value <<= (sal_Int16)( pFormat->GetType() );
+ pArray[3].Name = rtl::OUString::createFromAscii( PROPERTYNAME_COMMENT );
+ pArray[3].Value <<= rtl::OUString( aComment );
+ pArray[4].Name = rtl::OUString::createFromAscii( PROPERTYNAME_STDFORM );
+ pArray[4].Value.setValue( &bStandard, getBooleanCppuType() );
+ pArray[5].Name = rtl::OUString::createFromAscii( PROPERTYNAME_USERDEF );
+ pArray[5].Value.setValue( &bUserDef, getBooleanCppuType() );
+ pArray[6].Name = rtl::OUString::createFromAscii( PROPERTYNAME_DECIMALS );
+ pArray[6].Value <<= (sal_Int16)( nDecimals );
+ pArray[7].Name = rtl::OUString::createFromAscii( PROPERTYNAME_LEADING );
+ pArray[7].Value <<= (sal_Int16)( nLeading );
+ pArray[8].Name = rtl::OUString::createFromAscii( PROPERTYNAME_NEGRED );
+ pArray[8].Value.setValue( &bRed, getBooleanCppuType() );
+ pArray[9].Name = rtl::OUString::createFromAscii( PROPERTYNAME_THOUS );
+ pArray[9].Value.setValue( &bThousand, getBooleanCppuType() );
+ pArray[10].Name = rtl::OUString::createFromAscii( PROPERTYNAME_CURRSYM );
+ pArray[10].Value <<= rtl::OUString( aSymbol );
+ pArray[11].Name = rtl::OUString::createFromAscii( PROPERTYNAME_CURREXT );
+ pArray[11].Value <<= rtl::OUString( aExt );
+ pArray[12].Name = rtl::OUString::createFromAscii( PROPERTYNAME_CURRABB );
+ pArray[12].Value <<= rtl::OUString( aAbb );
+
+ return aSeq;
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+void SAL_CALL SvNumberFormatObj::setPropertyValues( const uno::Sequence<beans::PropertyValue>& )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ throw beans::UnknownPropertyException(); // everything is read-only
+}
+
+// XServiceInfo
+
+rtl::OUString SAL_CALL SvNumberFormatObj::getImplementationName()
+ throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii("SvNumberFormatObj");
+}
+
+sal_Bool SAL_CALL SvNumberFormatObj::supportsService( const rtl::OUString& ServiceName )
+ throw(uno::RuntimeException)
+{
+ return ( ServiceName.compareToAscii(SERVICENAME_NUMBERFORMAT) == 0 );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL SvNumberFormatObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii(SERVICENAME_NUMBERFORMAT);
+ return aRet;
+}
+
+//------------------------------------------------------------------------
+
+SvNumberFormatSettingsObj::SvNumberFormatSettingsObj(SvNumberFormatsSupplierObj* pParent) :
+ pSupplier(pParent)
+{
+ if (pSupplier)
+ pSupplier->acquire();
+}
+
+SvNumberFormatSettingsObj::~SvNumberFormatSettingsObj()
+{
+ if (pSupplier)
+ pSupplier->release();
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL SvNumberFormatSettingsObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef =
+ new SfxItemPropertySetInfo( lcl_GetNumberSettingsPropertyMap() );
+ return aRef;
+}
+
+void SAL_CALL SvNumberFormatSettingsObj::setPropertyValue( const rtl::OUString& aPropertyName,
+ const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ {
+ String aString = aPropertyName;
+ if (aString.EqualsAscii( PROPERTYNAME_NOZERO ))
+ {
+ // operator >>= shouldn't be used for bool (?)
+ if ( aValue.getValueTypeClass() == uno::TypeClass_BOOLEAN )
+ pFormatter->SetNoZero( *(sal_Bool*)aValue.getValue() );
+ }
+ else if (aString.EqualsAscii( PROPERTYNAME_NULLDATE ))
+ {
+ util::Date aDate;
+ if ( aValue >>= aDate )
+ pFormatter->ChangeNullDate( aDate.Day, aDate.Month, aDate.Year );
+ }
+ else if (aString.EqualsAscii( PROPERTYNAME_STDDEC ))
+ {
+ sal_Int16 nInt16 = sal_Int16();
+ if ( aValue >>= nInt16 )
+ pFormatter->ChangeStandardPrec( nInt16 );
+ }
+ else if (aString.EqualsAscii( PROPERTYNAME_TWODIGIT ))
+ {
+ sal_Int16 nInt16 = sal_Int16();
+ if ( aValue >>= nInt16 )
+ pFormatter->SetYear2000( nInt16 );
+ }
+ else
+ throw beans::UnknownPropertyException();
+
+ pSupplier->SettingsChanged();
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+uno::Any SAL_CALL SvNumberFormatSettingsObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Any aRet;
+ SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL;
+ if (pFormatter)
+ {
+ String aString = aPropertyName;
+ if (aString.EqualsAscii( PROPERTYNAME_NOZERO ))
+ {
+ BOOL bNoZero = pFormatter->GetNoZero();
+ aRet.setValue( &bNoZero, getBooleanCppuType() );
+ }
+ else if (aString.EqualsAscii( PROPERTYNAME_NULLDATE ))
+ {
+ Date* pDate = pFormatter->GetNullDate();
+ if (pDate)
+ {
+ util::Date aUnoDate( pDate->GetDay(), pDate->GetMonth(), pDate->GetYear() );
+ aRet <<= aUnoDate;
+ }
+ }
+ else if (aString.EqualsAscii( PROPERTYNAME_STDDEC ))
+ aRet <<= (sal_Int16)( pFormatter->GetStandardPrec() );
+ else if (aString.EqualsAscii( PROPERTYNAME_TWODIGIT ))
+ aRet <<= (sal_Int16)( pFormatter->GetYear2000() );
+ else
+ throw beans::UnknownPropertyException();
+ }
+ else
+ throw uno::RuntimeException();
+
+ return aRet;
+}
+
+void SAL_CALL SvNumberFormatSettingsObj::addPropertyChangeListener( const rtl::OUString&,
+ const uno::Reference<beans::XPropertyChangeListener>&)
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+}
+
+void SAL_CALL SvNumberFormatSettingsObj::removePropertyChangeListener( const rtl::OUString&,
+ const uno::Reference<beans::XPropertyChangeListener>&)
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+}
+
+void SAL_CALL SvNumberFormatSettingsObj::addVetoableChangeListener( const rtl::OUString&,
+ const uno::Reference<beans::XVetoableChangeListener>&)
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+}
+
+void SAL_CALL SvNumberFormatSettingsObj::removeVetoableChangeListener( const rtl::OUString&,
+ const uno::Reference<beans::XVetoableChangeListener>&)
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+}
+
+// XServiceInfo
+
+rtl::OUString SAL_CALL SvNumberFormatSettingsObj::getImplementationName()
+ throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii("SvNumberFormatSettingsObj");
+}
+
+sal_Bool SAL_CALL SvNumberFormatSettingsObj::supportsService( const rtl::OUString& ServiceName )
+ throw(uno::RuntimeException)
+{
+ return ( ServiceName.compareToAscii(SERVICENAME_NUMBERSETTINGS) == 0 );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL SvNumberFormatSettingsObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii(SERVICENAME_NUMBERSETTINGS);
+ return aRet;
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/numbers/svt_numhead.cxx b/binfilter/bf_svtools/source/numbers/svt_numhead.cxx
new file mode 100644
index 000000000000..e984c09a9b76
--- /dev/null
+++ b/binfilter/bf_svtools/source/numbers/svt_numhead.cxx
@@ -0,0 +1,254 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/debug.hxx>
+
+#include "numhead.hxx"
+
+// ID's fuer Dateien:
+#define SV_NUMID_SIZES 0x4200
+
+namespace binfilter
+{
+
+// STATIC DATA -----------------------------------------------------------
+
+//SEG_EOFGLOBALS()
+
+// =======================================================================
+/* wird fuer SvNumberformatter nicht gebraucht
+//#pragma SEG_FUNCDEF(numhead_01)
+
+SvNumReadHeader::SvNumReadHeader(SvStream& rNewStream) :
+ rStream( rNewStream )
+{
+ ULONG nDataSize;
+ rStream >> nDataSize;
+ nDataEnd = rStream.Tell() + nDataSize;
+}
+
+//#pragma SEG_FUNCDEF(numhead_02)
+
+SvNumReadHeader::~SvNumReadHeader()
+{
+ ULONG nReadEnd = rStream.Tell();
+ DBG_ASSERT( nReadEnd <= nDataEnd, "zuviele Bytes gelesen" );
+ if ( nReadEnd != nDataEnd )
+ rStream.Seek(nDataEnd); // Rest ueberspringen
+}
+
+//#pragma SEG_FUNCDEF(numhead_03)
+
+ULONG SvNumReadHeader::BytesLeft() const
+{
+ ULONG nReadEnd = rStream.Tell();
+ if (nReadEnd <= nDataEnd)
+ return nDataEnd-nReadEnd;
+
+ DBG_ERROR("Fehler bei SvNumReadHeader::BytesLeft");
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+//#pragma SEG_FUNCDEF(numhead_04)
+
+SvNumWriteHeader::SvNumWriteHeader(SvStream& rNewStream, ULONG nDefault) :
+ rStream( rNewStream )
+{
+ nDataSize = nDefault;
+ rStream << nDataSize;
+ nDataPos = rStream.Tell();
+}
+
+//#pragma SEG_FUNCDEF(numhead_05)
+
+SvNumWriteHeader::~SvNumWriteHeader()
+{
+ ULONG nPos = rStream.Tell();
+
+ if ( nPos - nDataPos != nDataSize ) // Default getroffen?
+ {
+ nDataSize = nPos - nDataPos;
+ rStream.Seek(nDataPos - sizeof(sal_uInt32));
+ rStream << nDataSize; // Groesse am Anfang eintragen
+ rStream.Seek(nPos);
+ }
+}
+*/
+
+// =======================================================================
+
+//#pragma SEG_FUNCDEF(numhead_06)
+
+//! mit Skip() synchron
+ImpSvNumMultipleReadHeader::ImpSvNumMultipleReadHeader(SvStream& rNewStream) :
+ rStream( rNewStream )
+{
+ sal_uInt32 nDataSize;
+ rStream >> nDataSize;
+ ULONG nDataPos = rStream.Tell();
+ nEntryEnd = nDataPos;
+
+ rStream.SeekRel(nDataSize);
+ USHORT nID;
+ rStream >> nID;
+ if (nID != SV_NUMID_SIZES)
+ {
+ DBG_ERROR("SV_NUMID_SIZES nicht gefunden");
+ }
+ sal_uInt32 nSizeTableLen;
+ rStream >> nSizeTableLen;
+ pBuf = new char[nSizeTableLen];
+ rStream.Read( pBuf, nSizeTableLen );
+ pMemStream = new SvMemoryStream( pBuf, nSizeTableLen, STREAM_READ );
+
+ nEndPos = rStream.Tell();
+ rStream.Seek( nDataPos );
+}
+
+//#pragma SEG_FUNCDEF(numhead_07)
+
+ImpSvNumMultipleReadHeader::~ImpSvNumMultipleReadHeader()
+{
+ DBG_ASSERT( pMemStream->Tell() == pMemStream->GetEndOfData(),
+ "Sizes nicht vollstaendig gelesen" );
+ delete pMemStream;
+ delete [] pBuf;
+
+ rStream.Seek(nEndPos);
+}
+
+//! mit ctor synchron
+// static
+void ImpSvNumMultipleReadHeader::Skip( SvStream& rStream )
+{
+ sal_uInt32 nDataSize;
+ rStream >> nDataSize;
+ rStream.SeekRel( nDataSize );
+ USHORT nID;
+ rStream >> nID;
+ if ( nID != SV_NUMID_SIZES )
+ {
+ DBG_ERROR("SV_NUMID_SIZES nicht gefunden");
+ }
+ sal_uInt32 nSizeTableLen;
+ rStream >> nSizeTableLen;
+ rStream.SeekRel( nSizeTableLen );
+}
+
+//#pragma SEG_FUNCDEF(numhead_08)
+
+void ImpSvNumMultipleReadHeader::EndEntry()
+{
+ ULONG nPos = rStream.Tell();
+ DBG_ASSERT( nPos <= nEntryEnd, "zuviel gelesen" );
+ if ( nPos != nEntryEnd )
+ rStream.Seek( nEntryEnd ); // Rest ueberspringen
+}
+
+//#pragma SEG_FUNCDEF(numhead_0d)
+
+void ImpSvNumMultipleReadHeader::StartEntry()
+{
+ ULONG nPos = rStream.Tell();
+ sal_uInt32 nEntrySize;
+ (*pMemStream) >> nEntrySize;
+
+ nEntryEnd = nPos + nEntrySize;
+}
+
+//#pragma SEG_FUNCDEF(numhead_09)
+
+ULONG ImpSvNumMultipleReadHeader::BytesLeft() const
+{
+ ULONG nReadEnd = rStream.Tell();
+ if (nReadEnd <= nEntryEnd)
+ return nEntryEnd-nReadEnd;
+
+ DBG_ERROR("Fehler bei ImpSvNumMultipleReadHeader::BytesLeft");
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+//#pragma SEG_FUNCDEF(numhead_0a)
+
+ImpSvNumMultipleWriteHeader::ImpSvNumMultipleWriteHeader(SvStream& rNewStream,
+ ULONG nDefault) :
+ rStream( rNewStream ),
+ aMemStream( 4096, 4096 )
+{
+ nDataSize = nDefault;
+ rStream << nDataSize;
+
+ nDataPos = rStream.Tell();
+ nEntryStart = nDataPos;
+}
+
+//#pragma SEG_FUNCDEF(numhead_0b)
+
+ImpSvNumMultipleWriteHeader::~ImpSvNumMultipleWriteHeader()
+{
+ ULONG nDataEnd = rStream.Tell();
+
+ rStream << (USHORT) SV_NUMID_SIZES;
+ rStream << static_cast<sal_uInt32>(aMemStream.Tell());
+ rStream.Write( aMemStream.GetData(), aMemStream.Tell() );
+
+ if ( nDataEnd - nDataPos != nDataSize ) // Default getroffen?
+ {
+ nDataSize = nDataEnd - nDataPos;
+ ULONG nPos = rStream.Tell();
+ rStream.Seek(nDataPos-sizeof(sal_uInt32));
+ rStream << nDataSize; // Groesse am Anfang eintragen
+ rStream.Seek(nPos);
+ }
+}
+
+//#pragma SEG_FUNCDEF(numhead_0c)
+
+void ImpSvNumMultipleWriteHeader::EndEntry()
+{
+ ULONG nPos = rStream.Tell();
+ aMemStream << static_cast<sal_uInt32>(nPos - nEntryStart);
+}
+
+//#pragma SEG_FUNCDEF(numhead_0e)
+
+void ImpSvNumMultipleWriteHeader::StartEntry()
+{
+ ULONG nPos = rStream.Tell();
+ nEntryStart = nPos;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/numbers/svt_numuno.cxx b/binfilter/bf_svtools/source/numbers/svt_numuno.cxx
new file mode 100644
index 000000000000..a33676c02e6e
--- /dev/null
+++ b/binfilter/bf_svtools/source/numbers/svt_numuno.cxx
@@ -0,0 +1,166 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+#define _ZFORLIST_DECLARE_TABLE
+
+#include <vcl/svapp.hxx>
+#include <tools/color.hxx>
+#include <tools/debug.hxx>
+#include <osl/mutex.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/uuid.h>
+
+#include "numuno.hxx"
+#include "numfmuno.hxx"
+#include <bf_svtools/zforlist.hxx>
+
+using namespace com::sun::star;
+
+namespace binfilter
+{
+
+//------------------------------------------------------------------------
+
+class SvNumFmtSuppl_Impl
+{
+public:
+ SvNumberFormatter* pFormatter;
+
+ SvNumFmtSuppl_Impl(SvNumberFormatter* p) :
+ pFormatter(p) {}
+};
+
+//------------------------------------------------------------------------
+
+// Default-ctor fuer getReflection
+SvNumberFormatsSupplierObj::SvNumberFormatsSupplierObj()
+{
+ pImpl = new SvNumFmtSuppl_Impl(NULL);
+}
+
+SvNumberFormatsSupplierObj::SvNumberFormatsSupplierObj(SvNumberFormatter* pForm)
+{
+ pImpl = new SvNumFmtSuppl_Impl(pForm);
+}
+
+SvNumberFormatsSupplierObj::~SvNumberFormatsSupplierObj()
+{
+ delete pImpl;
+}
+
+SvNumberFormatter* SvNumberFormatsSupplierObj::GetNumberFormatter() const
+{
+ return pImpl->pFormatter;
+}
+
+void SvNumberFormatsSupplierObj::SetNumberFormatter(SvNumberFormatter* pNew)
+{
+ // der alte Numberformatter ist ungueltig geworden, nicht mehr darauf zugreifen!
+ pImpl->pFormatter = pNew;
+}
+
+void SvNumberFormatsSupplierObj::NumberFormatDeleted(sal_uInt32)
+{
+ // Basis-Implementierung tut nix...
+}
+
+void SvNumberFormatsSupplierObj::SettingsChanged()
+{
+ // Basis-Implementierung tut nix...
+}
+
+// XNumberFormatsSupplier
+
+uno::Reference<beans::XPropertySet> SAL_CALL SvNumberFormatsSupplierObj::getNumberFormatSettings()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ return new SvNumberFormatSettingsObj( this );
+}
+
+uno::Reference<util::XNumberFormats> SAL_CALL SvNumberFormatsSupplierObj::getNumberFormats()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ return new SvNumberFormatsObj( this );
+}
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL SvNumberFormatsSupplierObj::getSomething(
+ const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+ return 0;
+}
+
+// static
+const uno::Sequence<sal_Int8>& SvNumberFormatsSupplierObj::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;
+}
+
+// static
+SvNumberFormatsSupplierObj* SvNumberFormatsSupplierObj::getImplementation(
+ const uno::Reference<util::XNumberFormatsSupplier> xObj )
+{
+ SvNumberFormatsSupplierObj* pRet = NULL;
+ uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<SvNumberFormatsSupplierObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething( getUnoTunnelId() )));
+ return pRet;
+}
+
+
+//------------------------------------------------------------------------
+
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/numbers/svt_supservs.cxx b/binfilter/bf_svtools/source/numbers/svt_supservs.cxx
new file mode 100644
index 000000000000..4416954a34c0
--- /dev/null
+++ b/binfilter/bf_svtools/source/numbers/svt_supservs.cxx
@@ -0,0 +1,234 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/stream.hxx>
+#include "supservs.hxx"
+#include <com/sun/star/lang/Locale.hpp>
+#include <i18npool/mslangid.hxx>
+#include <tools/debug.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <strmadpt.hxx>
+#include "instrm.hxx"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+using namespace ::utl;
+
+namespace binfilter
+{
+
+#define PERSISTENT_SERVICE_NAME ::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatsSupplier");
+
+//-------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL SvNumberFormatsSupplierServiceObject_CreateInstance(const Reference< XMultiServiceFactory >& _rxFactory)
+{
+ return static_cast< ::cppu::OWeakObject* >(new SvNumberFormatsSupplierServiceObject(_rxFactory));
+}
+
+//-------------------------------------------------------------------------
+SvNumberFormatsSupplierServiceObject::SvNumberFormatsSupplierServiceObject(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB)
+ :m_pOwnFormatter(NULL)
+ ,m_xORB(_rxORB)
+{
+}
+
+//-------------------------------------------------------------------------
+SvNumberFormatsSupplierServiceObject::~SvNumberFormatsSupplierServiceObject()
+{
+ if (m_pOwnFormatter)
+ {
+ delete m_pOwnFormatter;
+ m_pOwnFormatter = NULL;
+ }
+}
+
+//-------------------------------------------------------------------------
+Any SAL_CALL SvNumberFormatsSupplierServiceObject::queryAggregation( const Type& _rType ) throw (RuntimeException)
+{
+ Any aReturn = ::cppu::queryInterface(_rType,
+ static_cast< XInitialization* >(this),
+ static_cast< XPersistObject* >(this),
+ static_cast< XServiceInfo* >(this)
+ );
+
+ if (!aReturn.hasValue())
+ aReturn = SvNumberFormatsSupplierObj::queryAggregation(_rType);
+
+ return aReturn;
+}
+
+//-------------------------------------------------------------------------
+void SAL_CALL SvNumberFormatsSupplierServiceObject::initialize( const Sequence< Any >& _rArguments ) throw(Exception, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ // the mutex of the base class .... hope we have a real (i.e. own) mutex sometimes
+
+ DBG_ASSERT(m_pOwnFormatter == NULL,
+ "SvNumberFormatsSupplierServiceObject::initialize : already initialized !");
+ // maybe you already called a method which needed the formatter
+ // you should use XMultiServiceFactory::createInstanceWithArguments to avoid that
+ if (m_pOwnFormatter)
+ { // !!! this is only a emergency handling, normally this should not occur !!!
+ delete m_pOwnFormatter;
+ m_pOwnFormatter = NULL;
+ SetNumberFormatter(m_pOwnFormatter);
+ }
+
+ Type aExpectedArgType = ::getCppuType(static_cast<Locale*>(NULL));
+ LanguageType eNewFormatterLanguage = LANGUAGE_ENGLISH_US;
+ // the default
+
+ const Any* pArgs = _rArguments.getConstArray();
+ for (sal_Int32 i=0; i<_rArguments.getLength(); ++i, ++pArgs)
+ {
+ if (pArgs->getValueType().equals(aExpectedArgType))
+ {
+ Locale aLocale;
+ *pArgs >>= aLocale;
+ eNewFormatterLanguage = MsLangId::convertLocaleToLanguage( aLocale);
+ }
+#ifdef DBG_UTIL
+ else
+ {
+ DBG_ERROR("SvNumberFormatsSupplierServiceObject::initialize : unknown argument !");
+ }
+#endif
+ }
+
+ m_pOwnFormatter = new SvNumberFormatter(m_xORB, eNewFormatterLanguage);
+ m_pOwnFormatter->SetEvalDateFormat( NF_EVALDATEFORMAT_FORMAT_INTL );
+ SetNumberFormatter(m_pOwnFormatter);
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString SAL_CALL SvNumberFormatsSupplierServiceObject::getImplementationName( ) throw(RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.uno.util.numbers.SvNumberFormatsSupplierServiceObject");
+}
+
+//-------------------------------------------------------------------------
+sal_Bool SAL_CALL SvNumberFormatsSupplierServiceObject::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aServices = getSupportedServiceNames();
+ const ::rtl::OUString* pServices = aServices.getConstArray();
+ for (sal_Int32 i=0; i<aServices.getLength(); ++i, ++pServices)
+ if (pServices->equals(_rServiceName))
+ return sal_True;
+
+ return sal_False;
+}
+
+//-------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL SvNumberFormatsSupplierServiceObject::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported.getArray()[0] = PERSISTENT_SERVICE_NAME;
+ return aSupported;
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString SAL_CALL SvNumberFormatsSupplierServiceObject::getServiceName( ) throw(RuntimeException)
+{
+ return PERSISTENT_SERVICE_NAME;
+}
+
+//-------------------------------------------------------------------------
+void SAL_CALL SvNumberFormatsSupplierServiceObject::write( const Reference< XObjectOutputStream >& _rxOutStream ) throw(IOException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ implEnsureFormatter();
+
+ Reference< XOutputStream > xStream(_rxOutStream.get());
+ SvLockBytesRef aLockBytes = new SvOutputStreamOpenLockBytes(xStream);
+ SvStream aSvOutputSteam(aLockBytes);
+
+ m_pOwnFormatter->Save(aSvOutputSteam);
+}
+
+//-------------------------------------------------------------------------
+void SAL_CALL SvNumberFormatsSupplierServiceObject::read( const Reference< XObjectInputStream >& _rxInStream ) throw(IOException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ implEnsureFormatter();
+
+ Reference< XInputStream > xStream(_rxInStream.get());
+ SvInputStream aSvInputSteam(xStream);
+
+ m_pOwnFormatter->Load(aSvInputSteam);
+}
+
+//-------------------------------------------------------------------------
+Reference< XPropertySet > SAL_CALL SvNumberFormatsSupplierServiceObject::getNumberFormatSettings() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ implEnsureFormatter();
+ return SvNumberFormatsSupplierObj::getNumberFormatSettings();
+}
+
+//-------------------------------------------------------------------------
+Reference< XNumberFormats > SAL_CALL SvNumberFormatsSupplierServiceObject::getNumberFormats() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ implEnsureFormatter();
+ return SvNumberFormatsSupplierObj::getNumberFormats();
+}
+
+//-------------------------------------------------------------------------
+sal_Int64 SAL_CALL SvNumberFormatsSupplierServiceObject::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw (RuntimeException)
+{
+ sal_Int64 nReturn = SvNumberFormatsSupplierObj::getSomething( aIdentifier );
+ if ( nReturn )
+ // if somebody accesses internals then we should have the formatter
+ implEnsureFormatter();
+ return nReturn;
+}
+
+//-------------------------------------------------------------------------
+void SvNumberFormatsSupplierServiceObject::implEnsureFormatter()
+{
+ if (!m_pOwnFormatter)
+ {
+ // get the office's UI locale
+ SvtSysLocale aSysLocale;
+ Locale aOfficeLocale = aSysLocale.GetLocaleData().getLocale();
+
+ // initi with this locale
+ Sequence< Any > aFakedInitProps( 1 );
+ aFakedInitProps[0] <<= aOfficeLocale;
+
+ initialize( aFakedInitProps );
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/numbers/svt_zforfind.cxx b/binfilter/bf_svtools/source/numbers/svt_zforfind.cxx
new file mode 100644
index 000000000000..eb283aba196d
--- /dev/null
+++ b/binfilter/bf_svtools/source/numbers/svt_zforfind.cxx
@@ -0,0 +1,2794 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <ctype.h>
+#include <stdlib.h>
+#include <float.h>
+#include <errno.h>
+
+#include <tools/date.hxx>
+#include <tools/debug.hxx>
+#include <rtl/math.hxx>
+#include <unotools/charclass.hxx>
+#include <unotools/calendarwrapper.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <com/sun/star/i18n/CalendarFieldIndex.hpp>
+
+#include <bf_svtools/zforlist.hxx> // NUMBERFORMAT_XXX
+#include "zforscan.hxx"
+#include <bf_svtools/zformat.hxx>
+
+#define _ZFORFIND_CXX
+#include "zforfind.hxx"
+#undef _ZFORFIND_CXX
+
+
+#ifndef DBG_UTIL
+#define NF_TEST_CALENDAR 0
+#else
+#define NF_TEST_CALENDAR 0
+#endif
+#if NF_TEST_CALENDAR
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/i18n/XExtendedCalendar.hpp>
+#endif
+
+namespace binfilter
+{
+
+
+const BYTE ImpSvNumberInputScan::nMatchedEndString = 0x01;
+const BYTE ImpSvNumberInputScan::nMatchedMidString = 0x02;
+const BYTE ImpSvNumberInputScan::nMatchedStartString = 0x04;
+const BYTE ImpSvNumberInputScan::nMatchedVirgin = 0x08;
+const BYTE ImpSvNumberInputScan::nMatchedUsedAsReturn = 0x10;
+
+/* It is not clear how we want timezones to be handled. Convert them to local
+ * time isn't wanted, as it isn't done in any other place and timezone
+ * information isn't stored anywhere. Ignoring them and pretending local time
+ * may be wrong too and might not be what the user expects. Keep the input as
+ * string so that no information is lost.
+ * Anyway, defining NF_RECOGNIZE_ISO8601_TIMEZONES to 1 would be the way how it
+ * would work, together with the nTimezonePos handling in GetTimeRef(). */
+#define NF_RECOGNIZE_ISO8601_TIMEZONES 0
+
+//---------------------------------------------------------------------------
+// Konstruktor
+
+ImpSvNumberInputScan::ImpSvNumberInputScan( SvNumberFormatter* pFormatterP )
+ :
+ pUpperMonthText( NULL ),
+ pUpperAbbrevMonthText( NULL ),
+ pUpperDayText( NULL ),
+ pUpperAbbrevDayText( NULL )
+{
+ pFormatter = pFormatterP;
+ pNullDate = new Date(30,12,1899);
+ nYear2000 = SvNumberFormatter::GetYear2000Default();
+ Reset();
+ ChangeIntl();
+}
+
+
+//---------------------------------------------------------------------------
+// Destruktor
+
+ImpSvNumberInputScan::~ImpSvNumberInputScan()
+{
+ Reset();
+ delete pNullDate;
+ delete [] pUpperMonthText;
+ delete [] pUpperAbbrevMonthText;
+ delete [] pUpperDayText;
+ delete [] pUpperAbbrevDayText;
+}
+
+
+//---------------------------------------------------------------------------
+// Reset
+
+void ImpSvNumberInputScan::Reset()
+{
+#if 0
+// ER 16.06.97 18:56 Vorbelegung erfolgt jetzt in NumberStringDivision,
+// wozu immer alles loeschen wenn einiges wieder benutzt oder gar nicht
+// gebraucht wird..
+ for (USHORT i = 0; i < SV_MAX_ANZ_INPUT_STRINGS; i++)
+ {
+ sStrArray[i].Erase();
+ nNums[i] = SV_MAX_ANZ_INPUT_STRINGS-1;
+ IsNum[i] = FALSE;
+ }
+#endif
+ nMonth = 0;
+ nMonthPos = 0;
+ nTimePos = 0;
+ nSign = 0;
+ nESign = 0;
+ nDecPos = 0;
+ nNegCheck = 0;
+ nAnzStrings = 0;
+ nAnzNums = 0;
+ nThousand = 0;
+ eScannedType = NUMBERFORMAT_UNDEFINED;
+ nAmPm = 0;
+ nPosThousandString = 0;
+ nLogical = 0;
+ nStringScanNumFor = 0;
+ nStringScanSign = 0;
+ nMatchedAllStrings = nMatchedVirgin;
+ nMayBeIso8601 = 0;
+ nTimezonePos = 0;
+}
+
+
+//---------------------------------------------------------------------------
+//
+// static
+inline BOOL ImpSvNumberInputScan::MyIsdigit( sal_Unicode c )
+{
+ // If the input string wouldn't be converted using TransformInput() we'd
+ // to use something similar to the following and to adapt many places.
+#if 0
+ // use faster isdigit() if possible
+ if ( c < 128 )
+ return isdigit( (unsigned char) c ) != 0;
+ if ( c < 256 )
+ return FALSE;
+ String aTmp( c );
+ return pFormatter->GetCharClass()->isDigit( aTmp, 0 );
+#else
+ return c < 128 && isdigit( (unsigned char) c );
+#endif
+}
+
+
+//---------------------------------------------------------------------------
+//
+void ImpSvNumberInputScan::TransformInput( String& rStr )
+{
+ xub_StrLen nPos, nLen;
+ for ( nPos = 0, nLen = rStr.Len(); nPos < nLen; ++nPos )
+ {
+ if ( 256 <= rStr.GetChar( nPos ) &&
+ pFormatter->GetCharClass()->isDigit( rStr, nPos ) )
+ break;
+ }
+ if ( nPos < nLen )
+ rStr = pFormatter->GetNatNum()->getNativeNumberString( rStr,
+ pFormatter->GetLocale(), 0 );
+}
+
+
+//---------------------------------------------------------------------------
+// StringToDouble
+//
+// Only simple unsigned floating point values without any error detection,
+// decimal separator has to be '.'
+
+double ImpSvNumberInputScan::StringToDouble( const String& rStr, BOOL bForceFraction )
+{
+ double fNum = 0.0;
+ double fFrac = 0.0;
+ int nExp = 0;
+ xub_StrLen nPos = 0;
+ xub_StrLen nLen = rStr.Len();
+ BOOL bPreSep = !bForceFraction;
+
+ while (nPos < nLen)
+ {
+ if (rStr.GetChar(nPos) == '.')
+ bPreSep = FALSE;
+ else if (bPreSep)
+ fNum = fNum * 10.0 + (double) (rStr.GetChar(nPos) - '0');
+ else
+ {
+ fFrac = fFrac * 10.0 + (double) (rStr.GetChar(nPos) - '0');
+ --nExp;
+ }
+ nPos++;
+ }
+ if ( fFrac )
+ return fNum + ::rtl::math::pow10Exp( fFrac, nExp );
+ return fNum;
+}
+
+
+//---------------------------------------------------------------------------
+// NextNumberStringSymbol
+//
+// Zerlegt die Eingabe in Zahlen und Strings fuer die weitere
+// Verarbeitung (Turing-Maschine).
+//---------------------------------------------------------------------------
+// Ausgangs Zustand = GetChar
+//---------------+-------------------+-----------------------+---------------
+// Alter Zustand | gelesenes Zeichen | Aktion | Neuer Zustand
+//---------------+-------------------+-----------------------+---------------
+// GetChar | Ziffer | Symbol=Zeichen | GetValue
+// | Sonst | Symbol=Zeichen | GetString
+//---------------|-------------------+-----------------------+---------------
+// GetValue | Ziffer | Symbol=Symbol+Zeichen | GetValue
+// | Sonst | Dec(CharPos) | Stop
+//---------------+-------------------+-----------------------+---------------
+// GetString | Ziffer | Dec(CharPos) | Stop
+// | Sonst | Symbol=Symbol+Zeichen | GetString
+//---------------+-------------------+-----------------------+---------------
+
+enum ScanState // States der Turing-Maschine
+{
+ SsStop = 0,
+ SsStart = 1,
+ SsGetValue = 2,
+ SsGetString = 3
+};
+
+BOOL ImpSvNumberInputScan::NextNumberStringSymbol(
+ const sal_Unicode*& pStr,
+ String& rSymbol )
+{
+ BOOL isNumber = FALSE;
+ sal_Unicode cToken;
+ ScanState eState = SsStart;
+ register const sal_Unicode* pHere = pStr;
+ register xub_StrLen nChars = 0;
+
+ while ( ((cToken = *pHere) != 0) && eState != SsStop)
+ {
+ pHere++;
+ switch (eState)
+ {
+ case SsStart:
+ if ( MyIsdigit( cToken ) )
+ {
+ eState = SsGetValue;
+ isNumber = TRUE;
+ }
+ else
+ eState = SsGetString;
+ nChars++;
+ break;
+ case SsGetValue:
+ if ( MyIsdigit( cToken ) )
+ nChars++;
+ else
+ {
+ eState = SsStop;
+ pHere--;
+ }
+ break;
+ case SsGetString:
+ if ( !MyIsdigit( cToken ) )
+ nChars++;
+ else
+ {
+ eState = SsStop;
+ pHere--;
+ }
+ break;
+ default:
+ break;
+ } // switch
+ } // while
+
+ if ( nChars )
+ rSymbol.Assign( pStr, nChars );
+ else
+ rSymbol.Erase();
+
+ pStr = pHere;
+
+ return isNumber;
+}
+
+
+//---------------------------------------------------------------------------
+// SkipThousands
+
+BOOL ImpSvNumberInputScan::SkipThousands(
+ const sal_Unicode*& pStr,
+ String& rSymbol )
+{
+ BOOL res = FALSE;
+ sal_Unicode cToken;
+ const String& rThSep = pFormatter->GetNumThousandSep();
+ register const sal_Unicode* pHere = pStr;
+ ScanState eState = SsStart;
+ xub_StrLen nCounter = 0; // counts 3 digits
+
+ while ( ((cToken = *pHere) != 0) && eState != SsStop)
+ {
+ pHere++;
+ switch (eState)
+ {
+ case SsStart:
+ if ( StringPtrContains( rThSep, pHere-1, 0 ) )
+ {
+ nCounter = 0;
+ eState = SsGetValue;
+ pHere += rThSep.Len()-1;
+ }
+ else
+ {
+ eState = SsStop;
+ pHere--;
+ }
+ break;
+ case SsGetValue:
+ if ( MyIsdigit( cToken ) )
+ {
+ rSymbol += cToken;
+ nCounter++;
+ if (nCounter == 3)
+ {
+ eState = SsStart;
+ res = TRUE; // .000 combination found
+ }
+ }
+ else
+ {
+ eState = SsStop;
+ pHere--;
+ }
+ break;
+ default:
+ break;
+ } // switch
+ } // while
+
+ if (eState == SsGetValue) // break witth less than 3 digits
+ {
+ if ( nCounter )
+ rSymbol.Erase( rSymbol.Len() - nCounter, nCounter );
+ pHere -= nCounter + rThSep.Len(); // put back ThSep also
+ }
+ pStr = pHere;
+
+ return res;
+}
+
+
+//---------------------------------------------------------------------------
+// NumberStringDivision
+
+void ImpSvNumberInputScan::NumberStringDivision( const String& rString )
+{
+ const sal_Unicode* pStr = rString.GetBuffer();
+ const sal_Unicode* const pEnd = pStr + rString.Len();
+ while ( pStr < pEnd && nAnzStrings < SV_MAX_ANZ_INPUT_STRINGS )
+ {
+ if ( NextNumberStringSymbol( pStr, sStrArray[nAnzStrings] ) )
+ { // Zahl
+ IsNum[nAnzStrings] = TRUE;
+ nNums[nAnzNums] = nAnzStrings;
+ nAnzNums++;
+ if (nAnzStrings >= SV_MAX_ANZ_INPUT_STRINGS - 7 &&
+ nPosThousandString == 0) // nur einmal
+ if ( SkipThousands( pStr, sStrArray[nAnzStrings] ) )
+ nPosThousandString = nAnzStrings;
+ }
+ else
+ {
+ IsNum[nAnzStrings] = FALSE;
+ }
+ nAnzStrings++;
+ }
+}
+
+
+//---------------------------------------------------------------------------
+// Whether rString contains rWhat at nPos
+
+BOOL ImpSvNumberInputScan::StringContainsImpl( const String& rWhat,
+ const String& rString, xub_StrLen nPos )
+{
+ if ( nPos + rWhat.Len() <= rString.Len() )
+ return StringPtrContainsImpl( rWhat, rString.GetBuffer(), nPos );
+ return FALSE;
+}
+
+
+//---------------------------------------------------------------------------
+// Whether pString contains rWhat at nPos
+
+BOOL ImpSvNumberInputScan::StringPtrContainsImpl( const String& rWhat,
+ const sal_Unicode* pString, xub_StrLen nPos )
+{
+ if ( rWhat.Len() == 0 )
+ return FALSE;
+ register const sal_Unicode* pWhat = rWhat.GetBuffer();
+ register const sal_Unicode* const pEnd = pWhat + rWhat.Len();
+ register const sal_Unicode* pStr = pString + nPos;
+ while ( pWhat < pEnd )
+ {
+ if ( *pWhat != *pStr )
+ return FALSE;
+ pWhat++;
+ pStr++;
+ }
+ return TRUE;
+}
+
+
+//---------------------------------------------------------------------------
+// SkipChar
+//
+// ueberspringt genau das angegebene Zeichen
+
+inline BOOL ImpSvNumberInputScan::SkipChar( sal_Unicode c, const String& rString,
+ xub_StrLen& nPos )
+{
+ if ((nPos < rString.Len()) && (rString.GetChar(nPos) == c))
+ {
+ nPos++;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+//---------------------------------------------------------------------------
+// SkipBlanks
+//
+// Ueberspringt Leerzeichen
+
+inline void ImpSvNumberInputScan::SkipBlanks( const String& rString,
+ xub_StrLen& nPos )
+{
+ if ( nPos < rString.Len() )
+ {
+ register const sal_Unicode* p = rString.GetBuffer() + nPos;
+ while ( *p == ' ' )
+ {
+ nPos++;
+ p++;
+ }
+ }
+}
+
+
+//---------------------------------------------------------------------------
+// SkipString
+//
+// jump over rWhat in rString at nPos
+
+inline BOOL ImpSvNumberInputScan::SkipString( const String& rWhat,
+ const String& rString, xub_StrLen& nPos )
+{
+ if ( StringContains( rWhat, rString, nPos ) )
+ {
+ nPos = nPos + rWhat.Len();
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+//---------------------------------------------------------------------------
+// GetThousandSep
+//
+// erkennt genau .111 als Tausenderpunkt
+
+inline BOOL ImpSvNumberInputScan::GetThousandSep(
+ const String& rString,
+ xub_StrLen& nPos,
+ USHORT nStringPos )
+{
+ const String& rSep = pFormatter->GetNumThousandSep();
+ // Is it an ordinary space instead of a non-breaking space?
+ bool bSpaceBreak = rSep.GetChar(0) == 0xa0 && rString.GetChar(0) == 0x20 &&
+ rSep.Len() == 1 && rString.Len() == 1;
+ if ( (rString == rSep || bSpaceBreak) // nothing else
+ && nStringPos < nAnzStrings - 1 // safety first!
+ && IsNum[nStringPos+1] // number follows
+ && ( sStrArray[nStringPos+1].Len() == 3 // with 3 digits
+ || nPosThousandString == nStringPos+1 ) ) // or concatenated
+ {
+ nPos = nPos + rSep.Len();
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+//---------------------------------------------------------------------------
+// GetLogical
+//
+// Umwandlung Text in logischen Wert
+// "TRUE" => 1:
+// "FALSE"=> -1:
+// sonst => 0:
+
+short ImpSvNumberInputScan::GetLogical( const String& rString )
+{
+ short res;
+
+ if (rString.Len() < 4) // kein Platz fuer mind 4 Buch.
+ res = 0;
+ else
+ {
+ const ImpSvNumberformatScan* pFS = pFormatter->GetFormatScanner();
+ if ( rString == pFS->GetTrueString() )
+ res = 1;
+ else if ( rString == pFS->GetFalseString() )
+ res = -1;
+ else
+ res = 0;
+ }
+
+ return res;
+}
+
+
+//---------------------------------------------------------------------------
+// GetMonth
+//
+// Converts a string containing a month name (JAN, January) at nPos into the
+// month number (negative if abbreviated), returns 0 if nothing found
+
+short ImpSvNumberInputScan::GetMonth( const String& rString, xub_StrLen& nPos )
+{
+ // #102136# The correct English form of month September abbreviated is
+ // SEPT, but almost every data contains SEP instead.
+ static const String aSeptCorrect( RTL_CONSTASCII_USTRINGPARAM( "SEPT" ) );
+ static const String aSepShortened( RTL_CONSTASCII_USTRINGPARAM( "SEP" ) );
+
+ short res = 0; // no month found
+
+ if (rString.Len() > nPos) // only if needed
+ {
+ if ( !bTextInitialized )
+ InitText();
+ sal_Int16 nMonths = pFormatter->GetCalendar()->getNumberOfMonthsInYear();
+ for ( sal_Int16 i = 0; i < nMonths; i++ )
+ {
+ if ( StringContains( pUpperMonthText[i], rString, nPos ) )
+ { // full names first
+ nPos = nPos + pUpperMonthText[i].Len();
+ res = i+1;
+ break; // for
+ }
+ else if ( StringContains( pUpperAbbrevMonthText[i], rString, nPos ) )
+ { // abbreviated
+ nPos = nPos + pUpperAbbrevMonthText[i].Len();
+ res = sal::static_int_cast< short >(-(i+1)); // negative
+ break; // for
+ }
+ else if ( i == 8 && pUpperAbbrevMonthText[i] == aSeptCorrect &&
+ StringContains( aSepShortened, rString, nPos ) )
+ { // #102136# SEPT/SEP
+ nPos = nPos + aSepShortened.Len();
+ res = sal::static_int_cast< short >(-(i+1)); // negative
+ break; // for
+ }
+ }
+ }
+
+ return res;
+}
+
+
+//---------------------------------------------------------------------------
+// GetDayOfWeek
+//
+// Converts a string containing a DayOfWeek name (Mon, Monday) at nPos into the
+// DayOfWeek number + 1 (negative if abbreviated), returns 0 if nothing found
+
+int ImpSvNumberInputScan::GetDayOfWeek( const String& rString, xub_StrLen& nPos )
+{
+ int res = 0; // no day found
+
+ if (rString.Len() > nPos) // only if needed
+ {
+ if ( !bTextInitialized )
+ InitText();
+ sal_Int16 nDays = pFormatter->GetCalendar()->getNumberOfDaysInWeek();
+ for ( sal_Int16 i = 0; i < nDays; i++ )
+ {
+ if ( StringContains( pUpperDayText[i], rString, nPos ) )
+ { // full names first
+ nPos = nPos + pUpperDayText[i].Len();
+ res = i + 1;
+ break; // for
+ }
+ if ( StringContains( pUpperAbbrevDayText[i], rString, nPos ) )
+ { // abbreviated
+ nPos = nPos + pUpperAbbrevDayText[i].Len();
+ res = -(i + 1); // negative
+ break; // for
+ }
+ }
+ }
+
+ return res;
+}
+
+
+//---------------------------------------------------------------------------
+// GetCurrency
+//
+// Lesen eines Waehrungssysmbols
+// '$' => TRUE
+// sonst => FALSE
+
+BOOL ImpSvNumberInputScan::GetCurrency( const String& rString, xub_StrLen& nPos,
+ const SvNumberformat* pFormat )
+{
+ if ( rString.Len() > nPos )
+ {
+ if ( !aUpperCurrSymbol.Len() )
+ { // if no format specified the currency of the initialized formatter
+ LanguageType eLang = (pFormat ? pFormat->GetLanguage() :
+ pFormatter->GetLanguage());
+ aUpperCurrSymbol = pFormatter->GetCharClass()->upper(
+ SvNumberFormatter::GetCurrencyEntry( eLang ).GetSymbol() );
+ }
+ if ( StringContains( aUpperCurrSymbol, rString, nPos ) )
+ {
+ nPos = nPos + aUpperCurrSymbol.Len();
+ return TRUE;
+ }
+ if ( pFormat )
+ {
+ String aSymbol, aExtension;
+ if ( pFormat->GetNewCurrencySymbol( aSymbol, aExtension ) )
+ {
+ if ( aSymbol.Len() <= rString.Len() - nPos )
+ {
+ pFormatter->GetCharClass()->toUpper( aSymbol );
+ if ( StringContains( aSymbol, rString, nPos ) )
+ {
+ nPos = nPos + aSymbol.Len();
+ return TRUE;
+ }
+ }
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+
+//---------------------------------------------------------------------------
+// GetTimeAmPm
+//
+// Lesen des Zeitsymbols (AM od. PM) f. kurze Zeitangabe
+//
+// Rueckgabe:
+// "AM" od. "PM" => TRUE
+// sonst => FALSE
+//
+// nAmPos:
+// "AM" => 1
+// "PM" => -1
+// sonst => 0
+
+BOOL ImpSvNumberInputScan::GetTimeAmPm( const String& rString, xub_StrLen& nPos )
+{
+
+ if ( rString.Len() > nPos )
+ {
+ const CharClass* pChr = pFormatter->GetCharClass();
+ const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData();
+ if ( StringContains( pChr->upper( pLoc->getTimeAM() ), rString, nPos ) )
+ {
+ nAmPm = 1;
+ nPos = nPos + pLoc->getTimeAM().Len();
+ return TRUE;
+ }
+ else if ( StringContains( pChr->upper( pLoc->getTimePM() ), rString, nPos ) )
+ {
+ nAmPm = -1;
+ nPos = nPos + pLoc->getTimePM().Len();
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+
+//---------------------------------------------------------------------------
+// GetDecSep
+//
+// Lesen eines Dezimaltrenners (',')
+// ',' => TRUE
+// sonst => FALSE
+
+inline BOOL ImpSvNumberInputScan::GetDecSep( const String& rString, xub_StrLen& nPos )
+{
+ if ( rString.Len() > nPos )
+ {
+ const String& rSep = pFormatter->GetNumDecimalSep();
+ if ( rString.Equals( rSep, nPos, rSep.Len() ) )
+ {
+ nPos = nPos + rSep.Len();
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+//---------------------------------------------------------------------------
+// read a hundredth seconds separator
+
+inline BOOL ImpSvNumberInputScan::GetTime100SecSep( const String& rString, xub_StrLen& nPos )
+{
+ if ( rString.Len() > nPos )
+ {
+ const String& rSep = pFormatter->GetLocaleData()->getTime100SecSep();
+ if ( rString.Equals( rSep, nPos, rSep.Len() ) )
+ {
+ nPos = nPos + rSep.Len();
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+//---------------------------------------------------------------------------
+// GetSign
+//
+// Lesen eines Vorzeichens, auch Klammer !?!
+// '+' => 1
+// '-' => -1
+// '(' => -1, nNegCheck = 1
+// sonst => 0
+
+int ImpSvNumberInputScan::GetSign( const String& rString, xub_StrLen& nPos )
+{
+ if (rString.Len() > nPos)
+ switch (rString.GetChar(nPos))
+ {
+ case '+':
+ nPos++;
+ return 1;
+ case '(': // '(' aehnlich wie '-' ?!?
+ nNegCheck = 1;
+ //! fallthru
+ case '-':
+ nPos++;
+ return -1;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+
+//---------------------------------------------------------------------------
+// GetESign
+//
+// Lesen eines Vorzeichens, gedacht fuer Exponent ?!?
+// '+' => 1
+// '-' => -1
+// sonst => 0
+
+short ImpSvNumberInputScan::GetESign( const String& rString, xub_StrLen& nPos )
+{
+ if (rString.Len() > nPos)
+ switch (rString.GetChar(nPos))
+ {
+ case '+':
+ nPos++;
+ return 1;
+ case '-':
+ nPos++;
+ return -1;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+
+//---------------------------------------------------------------------------
+// GetNextNumber
+//
+// i counts string portions, j counts numbers thereof.
+// It should had been called SkipNumber instead.
+
+inline BOOL ImpSvNumberInputScan::GetNextNumber( USHORT& i, USHORT& j )
+{
+ if ( i < nAnzStrings && IsNum[i] )
+ {
+ j++;
+ i++;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+//---------------------------------------------------------------------------
+// GetTimeRef
+
+void ImpSvNumberInputScan::GetTimeRef(
+ double& fOutNumber,
+ USHORT nIndex, // j-value of the first numeric time part of input, default 0
+ USHORT nAnz ) // count of numeric time parts
+{
+ USHORT nHour;
+ USHORT nMinute = 0;
+ USHORT nSecond = 0;
+ double fSecond100 = 0.0;
+ USHORT nStartIndex = nIndex;
+
+ if (nTimezonePos)
+ {
+ // find first timezone number index and adjust count
+ for (USHORT j=0; j<nAnzNums; ++j)
+ {
+ if (nNums[j] == nTimezonePos)
+ {
+ // nAnz is not total count, but count of time relevant strings.
+ if (nStartIndex < j && j - nStartIndex < nAnz)
+ nAnz = j - nStartIndex;
+ break; // for
+ }
+ }
+ }
+
+ if (nDecPos == 2 && (nAnz == 3 || nAnz == 2)) // 20:45.5 or 45.5
+ nHour = 0;
+ else if (nIndex - nStartIndex < nAnz)
+ nHour = (USHORT) sStrArray[nNums[nIndex++]].ToInt32();
+ else
+ {
+ nHour = 0;
+ DBG_ERRORFILE( "ImpSvNumberInputScan::GetTimeRef: bad number index");
+ }
+ if (nDecPos == 2 && nAnz == 2) // 45.5
+ nMinute = 0;
+ else if (nIndex - nStartIndex < nAnz)
+ nMinute = (USHORT) sStrArray[nNums[nIndex++]].ToInt32();
+ if (nIndex - nStartIndex < nAnz)
+ nSecond = (USHORT) sStrArray[nNums[nIndex++]].ToInt32();
+ if (nIndex - nStartIndex < nAnz)
+ fSecond100 = StringToDouble( sStrArray[nNums[nIndex]], TRUE );
+ if (nAmPm == -1 && nHour != 12) // PM
+ nHour += 12;
+ else if (nAmPm == 1 && nHour == 12) // 12 AM
+ nHour = 0;
+
+ fOutNumber = ((double)nHour*3600 +
+ (double)nMinute*60 +
+ (double)nSecond +
+ fSecond100)/86400.0;
+}
+
+
+//---------------------------------------------------------------------------
+// ImplGetDay
+
+USHORT ImpSvNumberInputScan::ImplGetDay( USHORT nIndex )
+{
+ USHORT nRes = 0;
+
+ if (sStrArray[nNums[nIndex]].Len() <= 2)
+ {
+ USHORT nNum = (USHORT) sStrArray[nNums[nIndex]].ToInt32();
+ if (nNum <= 31)
+ nRes = nNum;
+ }
+
+ return nRes;
+}
+
+
+//---------------------------------------------------------------------------
+// ImplGetMonth
+
+USHORT ImpSvNumberInputScan::ImplGetMonth( USHORT nIndex )
+{
+ // preset invalid month number
+ USHORT nRes = pFormatter->GetCalendar()->getNumberOfMonthsInYear();
+
+ if (sStrArray[nNums[nIndex]].Len() <= 2)
+ {
+ USHORT nNum = (USHORT) sStrArray[nNums[nIndex]].ToInt32();
+ if ( 0 < nNum && nNum <= nRes )
+ nRes = nNum - 1; // zero based for CalendarFieldIndex::MONTH
+ }
+
+ return nRes;
+}
+
+
+//---------------------------------------------------------------------------
+// ImplGetYear
+//
+// 30 -> 1930, 29 -> 2029, oder 56 -> 1756, 55 -> 1855, ...
+
+USHORT ImpSvNumberInputScan::ImplGetYear( USHORT nIndex )
+{
+ USHORT nYear = 0;
+
+ if (sStrArray[nNums[nIndex]].Len() <= 4)
+ {
+ nYear = (USHORT) sStrArray[nNums[nIndex]].ToInt32();
+ nYear = SvNumberFormatter::ExpandTwoDigitYear( nYear, nYear2000 );
+ }
+
+ return nYear;
+}
+
+//---------------------------------------------------------------------------
+
+bool ImpSvNumberInputScan::MayBeIso8601()
+{
+ if (nMayBeIso8601 == 0)
+ {
+ if (nAnzNums >= 3 && nNums[0] < nAnzStrings &&
+ sStrArray[nNums[0]].ToInt32() > 31)
+ nMayBeIso8601 = 1;
+ else
+ nMayBeIso8601 = 2;
+ }
+ return nMayBeIso8601 == 1;
+}
+
+//---------------------------------------------------------------------------
+// GetDateRef
+
+BOOL ImpSvNumberInputScan::GetDateRef( double& fDays, USHORT& nCounter,
+ const SvNumberformat* pFormat )
+{
+ using namespace ::com::sun::star::i18n;
+ NfEvalDateFormat eEDF;
+ int nFormatOrder;
+ if ( pFormat && ((pFormat->GetType() & NUMBERFORMAT_DATE) == NUMBERFORMAT_DATE) )
+ {
+ eEDF = pFormatter->GetEvalDateFormat();
+ switch ( eEDF )
+ {
+ case NF_EVALDATEFORMAT_INTL :
+ case NF_EVALDATEFORMAT_FORMAT :
+ nFormatOrder = 1; // only one loop
+ break;
+ default:
+ nFormatOrder = 2;
+ if ( nMatchedAllStrings )
+ eEDF = NF_EVALDATEFORMAT_FORMAT_INTL;
+ // we have a complete match, use it
+ }
+ }
+ else
+ {
+ eEDF = NF_EVALDATEFORMAT_INTL;
+ nFormatOrder = 1;
+ }
+ BOOL res = TRUE;
+
+ const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData();
+ CalendarWrapper* pCal = pFormatter->GetCalendar();
+ for ( int nTryOrder = 1; nTryOrder <= nFormatOrder; nTryOrder++ )
+ {
+ pCal->setGregorianDateTime( Date() ); // today
+ String aOrgCalendar; // empty => not changed yet
+ DateFormat DateFmt;
+ BOOL bFormatTurn;
+ switch ( eEDF )
+ {
+ case NF_EVALDATEFORMAT_INTL :
+ bFormatTurn = FALSE;
+ DateFmt = pLoc->getDateFormat();
+ break;
+ case NF_EVALDATEFORMAT_FORMAT :
+ bFormatTurn = TRUE;
+ DateFmt = pFormat->GetDateOrder();
+ break;
+ case NF_EVALDATEFORMAT_INTL_FORMAT :
+ if ( nTryOrder == 1 )
+ {
+ bFormatTurn = FALSE;
+ DateFmt = pLoc->getDateFormat();
+ }
+ else
+ {
+ bFormatTurn = TRUE;
+ DateFmt = pFormat->GetDateOrder();
+ }
+ break;
+ case NF_EVALDATEFORMAT_FORMAT_INTL :
+ if ( nTryOrder == 2 )
+ {
+ bFormatTurn = FALSE;
+ DateFmt = pLoc->getDateFormat();
+ }
+ else
+ {
+ bFormatTurn = TRUE;
+ DateFmt = pFormat->GetDateOrder();
+ }
+ break;
+ default:
+ DBG_ERROR( "ImpSvNumberInputScan::GetDateRef: unknown NfEvalDateFormat" );
+ DateFmt = YMD;
+ bFormatTurn = FALSE;
+ }
+ if ( bFormatTurn )
+ {
+#if 0
+/* TODO:
+We are currently not able to fully support a switch to another calendar during
+input for the following reasons:
+1. We do have a problem if both (locale's default and format's) calendars
+ define the same YMD order and use the same date separator, there is no way
+ to distinguish between them if the input results in valid calendar input for
+ both calendars. How to solve? Would NfEvalDateFormat be sufficient? Should
+ it always be set to NF_EVALDATEFORMAT_FORMAT_INTL and thus the format's
+ calendar be preferred? This could be confusing if a Calc cell was formatted
+ different to the locale's default and has no content yet, then the user has
+ no clue about the format or calendar being set.
+2. In Calc cell edit mode a date is always displayed and edited using the
+ default edit format of the default calendar (normally being Gregorian). If
+ input was ambiguous due to issue #1 we'd need a mechanism to tell that a
+ date was edited and not newly entered. Not feasible. Otherwise we'd need a
+ mechanism to use a specific edit format with a specific calendar according
+ to the format set.
+3. For some calendars like Japanese Gengou we'd need era input, which isn't
+ implemented at all. Though this is a rare and special case, forcing a
+ calendar dependent edit format as suggested in item #2 might require era
+ input, if it shouldn't result in a fallback to Gregorian calendar.
+4. Last and least: the GetMonth() method currently only matches month names of
+ the default calendar. Alternating month names of the actual format's
+ calendar would have to be implemented. No problem.
+
+*/
+ if ( pFormat->IsOtherCalendar( nStringScanNumFor ) )
+ pFormat->SwitchToOtherCalendar( aOrgCalendar, fOrgDateTime );
+ else
+ pFormat->SwitchToSpecifiedCalendar( aOrgCalendar, fOrgDateTime,
+ nStringScanNumFor );
+#endif
+ }
+
+ res = TRUE;
+ nCounter = 0;
+ // For incomplete dates, always assume first day of month if not specified.
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, 1 );
+
+ switch (nAnzNums) // count of numbers in string
+ {
+ case 0: // none
+ if (nMonthPos) // only month (Jan)
+ pCal->setValue( CalendarFieldIndex::MONTH, Abs(nMonth)-1 );
+ else
+ res = FALSE;
+ break;
+
+ case 1: // only one number
+ nCounter = 1;
+ switch (nMonthPos) // where is the month
+ {
+ case 0: // not found => only day entered
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(0) );
+ break;
+ case 1: // month at the beginning (Jan 01)
+ pCal->setValue( CalendarFieldIndex::MONTH, Abs(nMonth)-1 );
+ switch (DateFmt)
+ {
+ case MDY:
+ case YMD:
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(0) );
+ break;
+ case DMY:
+ pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(0) );
+ break;
+ default:
+ res = FALSE;
+ break;
+ }
+ break;
+ case 3: // month at the end (10 Jan)
+ pCal->setValue( CalendarFieldIndex::MONTH, Abs(nMonth)-1 );
+ switch (DateFmt)
+ {
+ case DMY:
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(0) );
+ break;
+ case YMD:
+ pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(0) );
+ break;
+ default:
+ res = FALSE;
+ break;
+ }
+ break;
+ default:
+ res = FALSE;
+ break;
+ } // switch (nMonthPos)
+ break;
+
+ case 2: // 2 numbers
+ nCounter = 2;
+ switch (nMonthPos) // where is the month
+ {
+ case 0: // not found
+ {
+ bool bHadExact;
+ sal_uInt32 nExactDateOrder = (bFormatTurn ? pFormat->GetExactDateOrder() : 0);
+ if ( 0xff < nExactDateOrder && nExactDateOrder <= 0xffff )
+ { // formatted as date and exactly 2 parts
+ bHadExact = true;
+ switch ( (nExactDateOrder >> 8) & 0xff )
+ {
+ case 'Y':
+ pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(0) );
+ break;
+ case 'M':
+ pCal->setValue( CalendarFieldIndex::MONTH, ImplGetMonth(0) );
+ break;
+ case 'D':
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(0) );
+ break;
+ default:
+ bHadExact = false;
+ }
+ switch ( nExactDateOrder & 0xff )
+ {
+ case 'Y':
+ pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(1) );
+ break;
+ case 'M':
+ pCal->setValue( CalendarFieldIndex::MONTH, ImplGetMonth(1) );
+ break;
+ case 'D':
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(1) );
+ break;
+ default:
+ bHadExact = false;
+ }
+ }
+ else
+ bHadExact = false;
+ if ( !bHadExact || !pCal->isValid() )
+ {
+ if ( !bHadExact && nExactDateOrder )
+ pCal->setGregorianDateTime( Date() ); // reset today
+ switch (DateFmt)
+ {
+ case MDY:
+ // M D
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(1) );
+ pCal->setValue( CalendarFieldIndex::MONTH, ImplGetMonth(0) );
+ break;
+ case DMY:
+ // D M
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(0) );
+ pCal->setValue( CalendarFieldIndex::MONTH, ImplGetMonth(1) );
+ if ( !pCal->isValid() ) // 2nd try
+ { // M Y
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, 1 );
+ pCal->setValue( CalendarFieldIndex::MONTH, ImplGetMonth(0) );
+ pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(1) );
+ }
+ break;
+ case YMD:
+ // M D
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(1) );
+ pCal->setValue( CalendarFieldIndex::MONTH, ImplGetMonth(0) );
+ if ( !pCal->isValid() ) // 2nd try
+ { // Y M
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, 1 );
+ pCal->setValue( CalendarFieldIndex::MONTH, ImplGetMonth(1) );
+ pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(0) );
+ }
+ break;
+ default:
+ res = FALSE;
+ break;
+ }
+ }
+ }
+ break;
+ case 1: // month at the beginning (Jan 01 01)
+ {
+ // The input is valid as MDY in almost any
+ // constellation, there is no date order (M)YD except if
+ // set in a format applied.
+ pCal->setValue( CalendarFieldIndex::MONTH, Abs(nMonth)-1 );
+ sal_uInt32 nExactDateOrder = (bFormatTurn ? pFormat->GetExactDateOrder() : 0);
+ if ((((nExactDateOrder >> 8) & 0xff) == 'Y') && ((nExactDateOrder & 0xff) == 'D'))
+ {
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(1) );
+ pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(0) );
+ }
+ else
+ {
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(0) );
+ pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(1) );
+ }
+ }
+ break;
+ case 2: // month in the middle (10 Jan 94)
+ pCal->setValue( CalendarFieldIndex::MONTH, Abs(nMonth)-1 );
+ switch (DateFmt)
+ {
+ case MDY: // yes, "10-Jan-94" is valid
+ case DMY:
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(0) );
+ pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(1) );
+ break;
+ case YMD:
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(1) );
+ pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(0) );
+ break;
+ default:
+ res = FALSE;
+ break;
+ }
+ break;
+ default: // else, e.g. month at the end (94 10 Jan)
+ res = FALSE;
+ break;
+ } // switch (nMonthPos)
+ break;
+
+ default: // more than two numbers (31.12.94 8:23) (31.12. 8:23)
+ switch (nMonthPos) // where is the month
+ {
+ case 0: // not found
+ {
+ nCounter = 3;
+ if ( nTimePos > 1 )
+ { // find first time number index (should only be 3 or 2 anyway)
+ for ( USHORT j = 0; j < nAnzNums; j++ )
+ {
+ if ( nNums[j] == nTimePos - 2 )
+ {
+ nCounter = j;
+ break; // for
+ }
+ }
+ }
+ // ISO 8601 yyyy-mm-dd forced recognition
+ DateFormat eDF = (MayBeIso8601() ? YMD : DateFmt);
+ switch (eDF)
+ {
+ case MDY:
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(1) );
+ pCal->setValue( CalendarFieldIndex::MONTH, ImplGetMonth(0) );
+ if ( nCounter > 2 )
+ pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(2) );
+ break;
+ case DMY:
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(0) );
+ pCal->setValue( CalendarFieldIndex::MONTH, ImplGetMonth(1) );
+ if ( nCounter > 2 )
+ pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(2) );
+ break;
+ case YMD:
+ if ( nCounter > 2 )
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(2) );
+ pCal->setValue( CalendarFieldIndex::MONTH, ImplGetMonth(1) );
+ pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(0) );
+ break;
+ default:
+ res = FALSE;
+ break;
+ }
+ }
+ break;
+ case 1: // month at the beginning (Jan 01 01 8:23)
+ nCounter = 2;
+ switch (DateFmt)
+ {
+ case MDY:
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(0) );
+ pCal->setValue( CalendarFieldIndex::MONTH, Abs(nMonth)-1 );
+ pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(1) );
+ break;
+ default:
+ res = FALSE;
+ break;
+ }
+ break;
+ case 2: // month in the middle (10 Jan 94 8:23)
+ nCounter = 2;
+ pCal->setValue( CalendarFieldIndex::MONTH, Abs(nMonth)-1 );
+ switch (DateFmt)
+ {
+ case DMY:
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(0) );
+ pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(1) );
+ break;
+ case YMD:
+ pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(1) );
+ pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(0) );
+ break;
+ default:
+ res = FALSE;
+ break;
+ }
+ break;
+ default: // else, e.g. month at the end (94 10 Jan 8:23)
+ nCounter = 2;
+ res = FALSE;
+ break;
+ } // switch (nMonthPos)
+ break;
+ } // switch (nAnzNums)
+
+ if ( res && pCal->isValid() )
+ {
+ double fDiff = DateTime(*pNullDate) - pCal->getEpochStart();
+ fDays = ::rtl::math::approxFloor( pCal->getLocalDateTime() );
+ fDays -= fDiff;
+ nTryOrder = nFormatOrder; // break for
+ }
+ else
+ res = FALSE;
+
+ if ( aOrgCalendar.Len() )
+ pCal->loadCalendar( aOrgCalendar, pLoc->getLocale() ); // restore calendar
+
+#if NF_TEST_CALENDAR
+{
+ using namespace ::com::sun::star;
+ struct entry { const char* lan; const char* cou; const char* cal; };
+ const entry cals[] = {
+ { "en", "US", "gregorian" },
+ { "ar", "TN", "hijri" },
+ { "he", "IL", "jewish" },
+ { "ja", "JP", "gengou" },
+ { "ko", "KR", "hanja_yoil" },
+ { "th", "TH", "buddhist" },
+ { "zh", "TW", "ROC" },
+ 0
+ };
+ lang::Locale aLocale;
+ sal_Bool bValid;
+ sal_Int16 nDay, nMonth, nYear, nHour, nMinute, nSecond;
+ sal_Int16 nDaySet, nMonthSet, nYearSet, nHourSet, nMinuteSet, nSecondSet;
+ sal_Int16 nZO, nDST1, nDST2, nDST;
+ uno::Reference< lang::XMultiServiceFactory > xSMgr =
+ ::comphelper::getProcessServiceFactory();
+ uno::Reference< ::com::sun::star::i18n::XExtendedCalendar > xCal(
+ xSMgr->createInstance( ::rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.i18n.LocaleCalendar" ) ) ),
+ uno::UNO_QUERY );
+ for ( const entry* p = cals; p->lan; ++p )
+ {
+ aLocale.Language = ::rtl::OUString::createFromAscii( p->lan );
+ aLocale.Country = ::rtl::OUString::createFromAscii( p->cou );
+ xCal->loadCalendar( ::rtl::OUString::createFromAscii( p->cal ),
+ aLocale );
+ double nDateTime = 0.0; // 1-Jan-1970 00:00:00
+ nZO = xCal->getValue( i18n::CalendarFieldIndex::ZONE_OFFSET );
+ nDST1 = xCal->getValue( i18n::CalendarFieldIndex::DST_OFFSET );
+ nDateTime -= (double)(nZO + nDST1) / 60.0 / 24.0;
+ xCal->setDateTime( nDateTime );
+ nDST2 = xCal->getValue( i18n::CalendarFieldIndex::DST_OFFSET );
+ if ( nDST1 != nDST2 )
+ {
+ nDateTime = 0.0 - (double)(nZO + nDST2) / 60.0 / 24.0;
+ xCal->setDateTime( nDateTime );
+ }
+ nDaySet = xCal->getValue( i18n::CalendarFieldIndex::DAY_OF_MONTH );
+ nMonthSet = xCal->getValue( i18n::CalendarFieldIndex::MONTH );
+ nYearSet = xCal->getValue( i18n::CalendarFieldIndex::YEAR );
+ nHourSet = xCal->getValue( i18n::CalendarFieldIndex::HOUR );
+ nMinuteSet = xCal->getValue( i18n::CalendarFieldIndex::MINUTE );
+ nSecondSet = xCal->getValue( i18n::CalendarFieldIndex::SECOND );
+ nZO = xCal->getValue( i18n::CalendarFieldIndex::ZONE_OFFSET );
+ nDST = xCal->getValue( i18n::CalendarFieldIndex::DST_OFFSET );
+ xCal->setValue( i18n::CalendarFieldIndex::DAY_OF_MONTH, nDaySet );
+ xCal->setValue( i18n::CalendarFieldIndex::MONTH, nMonthSet );
+ xCal->setValue( i18n::CalendarFieldIndex::YEAR, nYearSet );
+ xCal->setValue( i18n::CalendarFieldIndex::HOUR, nHourSet );
+ xCal->setValue( i18n::CalendarFieldIndex::MINUTE, nMinuteSet );
+ xCal->setValue( i18n::CalendarFieldIndex::SECOND, nSecondSet );
+ bValid = xCal->isValid();
+ nDay = xCal->getValue( i18n::CalendarFieldIndex::DAY_OF_MONTH );
+ nMonth = xCal->getValue( i18n::CalendarFieldIndex::MONTH );
+ nYear = xCal->getValue( i18n::CalendarFieldIndex::YEAR );
+ nHour = xCal->getValue( i18n::CalendarFieldIndex::HOUR );
+ nMinute = xCal->getValue( i18n::CalendarFieldIndex::MINUTE );
+ nSecond = xCal->getValue( i18n::CalendarFieldIndex::SECOND );
+ bValid = bValid && nDay == nDaySet && nMonth == nMonthSet && nYear ==
+ nYearSet && nHour == nHourSet && nMinute == nMinuteSet && nSecond
+ == nSecondSet;
+ }
+}
+#endif // NF_TEST_CALENDAR
+
+ }
+
+ return res;
+}
+
+
+//---------------------------------------------------------------------------
+// ScanStartString
+//
+// ersten String analysieren
+// Alles weg => TRUE
+// sonst => FALSE
+
+BOOL ImpSvNumberInputScan::ScanStartString( const String& rString,
+ const SvNumberformat* pFormat )
+{
+ xub_StrLen nPos = 0;
+ int nDayOfWeek;
+
+ // First of all, eat leading blanks
+ SkipBlanks(rString, nPos);
+
+ // Yes, nMatchedAllStrings should know about the sign position
+ nSign = GetSign(rString, nPos);
+ if ( nSign ) // sign?
+ SkipBlanks(rString, nPos);
+
+ // #102371# match against format string only if start string is not a sign character
+ if ( nMatchedAllStrings && !(nSign && rString.Len() == 1) )
+ { // Match against format in any case, so later on for a "x1-2-3" input
+ // we may distinguish between a xy-m-d (or similar) date and a x0-0-0
+ // format. No sign detection here!
+ if ( ScanStringNumFor( rString, nPos, pFormat, 0, TRUE ) )
+ nMatchedAllStrings |= nMatchedStartString;
+ else
+ nMatchedAllStrings = 0;
+ }
+
+ if ( GetDecSep(rString, nPos) ) // decimal separator in start string
+ {
+ nDecPos = 1;
+ SkipBlanks(rString, nPos);
+ }
+ else if ( GetCurrency(rString, nPos, pFormat) ) // currency (DM 1)?
+ {
+ eScannedType = NUMBERFORMAT_CURRENCY; // !!! it IS currency !!!
+ SkipBlanks(rString, nPos);
+ if (nSign == 0) // no sign yet
+ {
+ nSign = GetSign(rString, nPos);
+ if ( nSign ) // DM -1
+ SkipBlanks(rString, nPos);
+ }
+ }
+ else
+ {
+ nMonth = GetMonth(rString, nPos);
+ if ( nMonth ) // month (Jan 1)?
+ {
+ eScannedType = NUMBERFORMAT_DATE; // !!! it IS a date !!!
+ nMonthPos = 1; // month at the beginning
+ if ( nMonth < 0 )
+ SkipChar( '.', rString, nPos ); // abbreviated
+ SkipBlanks(rString, nPos);
+ }
+ else
+ {
+ nDayOfWeek = GetDayOfWeek( rString, nPos );
+ if ( nDayOfWeek )
+ { // day of week is just parsed away
+ eScannedType = NUMBERFORMAT_DATE; // !!! it IS a date !!!
+ if ( nPos < rString.Len() )
+ {
+ if ( nDayOfWeek < 0 )
+ { // abbreviated
+ if ( rString.GetChar( nPos ) == '.' )
+ ++nPos;
+ }
+ else
+ { // full long name
+ SkipBlanks(rString, nPos);
+ SkipString( pFormatter->GetLocaleData()->getLongDateDayOfWeekSep(), rString, nPos );
+ }
+ SkipBlanks(rString, nPos);
+ nMonth = GetMonth(rString, nPos);
+ if ( nMonth ) // month (Jan 1)?
+ {
+ nMonthPos = 1; // month a the beginning
+ if ( nMonth < 0 )
+ SkipChar( '.', rString, nPos ); // abbreviated
+ SkipBlanks(rString, nPos);
+ }
+ }
+ }
+ }
+ }
+
+ if (nPos < rString.Len()) // not everything consumed
+ {
+ // Does input StartString equal StartString of format?
+ // This time with sign detection!
+ if ( !ScanStringNumFor( rString, nPos, pFormat, 0 ) )
+ return MatchedReturn();
+ }
+
+ return TRUE;
+}
+
+
+//---------------------------------------------------------------------------
+// ScanMidString
+//
+// String in der Mitte analysieren
+// Alles weg => TRUE
+// sonst => FALSE
+
+BOOL ImpSvNumberInputScan::ScanMidString( const String& rString,
+ USHORT nStringPos, const SvNumberformat* pFormat )
+{
+ xub_StrLen nPos = 0;
+ short eOldScannedType = eScannedType;
+
+ if ( nMatchedAllStrings )
+ { // Match against format in any case, so later on for a "1-2-3-4" input
+ // we may distinguish between a y-m-d (or similar) date and a 0-0-0-0
+ // format.
+ if ( ScanStringNumFor( rString, 0, pFormat, nStringPos ) )
+ nMatchedAllStrings |= nMatchedMidString;
+ else
+ nMatchedAllStrings = 0;
+ }
+
+ SkipBlanks(rString, nPos);
+ if (GetDecSep(rString, nPos)) // decimal separator?
+ {
+ if (nDecPos == 1 || nDecPos == 3) // .12.4 or 1.E2.1
+ return MatchedReturn();
+ else if (nDecPos == 2) // . dup: 12.4.
+ {
+ if (bDecSepInDateSeps) // . also date separator
+ {
+ if ( eScannedType != NUMBERFORMAT_UNDEFINED &&
+ eScannedType != NUMBERFORMAT_DATE &&
+ eScannedType != NUMBERFORMAT_DATETIME) // already another type
+ return MatchedReturn();
+ if (eScannedType == NUMBERFORMAT_UNDEFINED)
+ eScannedType = NUMBERFORMAT_DATE; // !!! it IS a date
+ SkipBlanks(rString, nPos);
+ }
+ else
+ return MatchedReturn();
+ }
+ else
+ {
+ nDecPos = 2; // . in mid string
+ SkipBlanks(rString, nPos);
+ }
+ }
+ else if ( ((eScannedType & NUMBERFORMAT_TIME) == NUMBERFORMAT_TIME)
+ && GetTime100SecSep( rString, nPos ) )
+ { // hundredth seconds separator
+ if ( nDecPos )
+ return MatchedReturn();
+ nDecPos = 2; // . in mid string
+ SkipBlanks(rString, nPos);
+ }
+
+ if (SkipChar('/', rString, nPos)) // fraction?
+ {
+ if ( eScannedType != NUMBERFORMAT_UNDEFINED // already another type
+ && eScannedType != NUMBERFORMAT_DATE) // except date
+ return MatchedReturn(); // => jan/31/1994
+ else if ( eScannedType != NUMBERFORMAT_DATE // analyzed date until now
+ && ( eSetType == NUMBERFORMAT_FRACTION // and preset was fraction
+ || (nAnzNums == 3 // or 3 numbers
+ && nStringPos > 2) ) ) // and what ???
+ {
+ SkipBlanks(rString, nPos);
+ eScannedType = NUMBERFORMAT_FRACTION; // !!! it IS a fraction
+ }
+ else
+ nPos--; // put '/' back
+ }
+
+ if (GetThousandSep(rString, nPos, nStringPos)) // 1,000
+ {
+ if ( eScannedType != NUMBERFORMAT_UNDEFINED // already another type
+ && eScannedType != NUMBERFORMAT_CURRENCY) // except currency
+ return MatchedReturn();
+ nThousand++;
+ }
+
+ const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData();
+ const String& rDate = pFormatter->GetDateSep();
+ const String& rTime = pLoc->getTimeSep();
+ sal_Unicode cTime = rTime.GetChar(0);
+ SkipBlanks(rString, nPos);
+ if ( SkipString(rDate, rString, nPos) // 10., 10-, 10/
+ || ((cTime != '.') && SkipChar('.', rString, nPos)) // TRICKY:
+ || ((cTime != '/') && SkipChar('/', rString, nPos)) // short boolean
+ || ((cTime != '-') && SkipChar('-', rString, nPos)) ) // evaluation!
+ {
+ if ( eScannedType != NUMBERFORMAT_UNDEFINED // already another type
+ && eScannedType != NUMBERFORMAT_DATE) // except date
+ return MatchedReturn();
+ SkipBlanks(rString, nPos);
+ eScannedType = NUMBERFORMAT_DATE; // !!! it IS a date
+ short nTmpMonth = GetMonth(rString, nPos); // 10. Jan 94
+ if (nMonth && nTmpMonth) // month dup
+ return MatchedReturn();
+ if (nTmpMonth)
+ {
+ nMonth = nTmpMonth;
+ nMonthPos = 2; // month in the middle
+ if ( nMonth < 0 && SkipChar( '.', rString, nPos ) )
+ ; // short month may be abbreviated Jan.
+ else if ( SkipChar( '-', rString, nPos ) )
+ ; // #79632# recognize 17-Jan-2001 to be a date
+ // #99065# short and long month name
+ else
+ SkipString( pLoc->getLongDateMonthSep(), rString, nPos );
+ SkipBlanks(rString, nPos);
+ }
+ }
+
+ short nTempMonth = GetMonth(rString, nPos); // month in the middle (10 Jan 94)
+ if (nTempMonth)
+ {
+ if (nMonth != 0) // month dup
+ return MatchedReturn();
+ if ( eScannedType != NUMBERFORMAT_UNDEFINED // already another type
+ && eScannedType != NUMBERFORMAT_DATE) // except date
+ return MatchedReturn();
+ eScannedType = NUMBERFORMAT_DATE; // !!! it IS a date
+ nMonth = nTempMonth;
+ nMonthPos = 2; // month in the middle
+ if ( nMonth < 0 )
+ SkipChar( '.', rString, nPos ); // abbreviated
+ SkipString( pLoc->getLongDateMonthSep(), rString, nPos );
+ SkipBlanks(rString, nPos);
+ }
+
+ if ( SkipChar('E', rString, nPos) // 10E, 10e, 10,Ee
+ || SkipChar('e', rString, nPos) )
+ {
+ if (eScannedType != NUMBERFORMAT_UNDEFINED) // already another type
+ return MatchedReturn();
+ else
+ {
+ SkipBlanks(rString, nPos);
+ eScannedType = NUMBERFORMAT_SCIENTIFIC; // !!! it IS scientific
+ if ( nThousand+2 == nAnzNums // special case 1.E2
+ && nDecPos == 2 )
+ nDecPos = 3; // 1,100.E2 1,100,100.E3
+ }
+ nESign = GetESign(rString, nPos); // signed exponent?
+ SkipBlanks(rString, nPos);
+ }
+
+ if ( SkipString(rTime, rString, nPos) ) // time separator?
+ {
+ if (nDecPos) // already . => maybe error
+ {
+ if (bDecSepInDateSeps) // . also date sep
+ {
+ if ( eScannedType != NUMBERFORMAT_DATE && // already another type than date
+ eScannedType != NUMBERFORMAT_DATETIME) // or date time
+ return MatchedReturn();
+ if (eScannedType == NUMBERFORMAT_DATE)
+ nDecPos = 0; // reset for time transition
+ }
+ else
+ return MatchedReturn();
+ }
+ if ( ( eScannedType == NUMBERFORMAT_DATE // already date type
+ || eScannedType == NUMBERFORMAT_DATETIME) // or date time
+ && nAnzNums > 3) // and more than 3 numbers? (31.Dez.94 8:23)
+ {
+ SkipBlanks(rString, nPos);
+ eScannedType = NUMBERFORMAT_DATETIME; // !!! it IS date with time
+ }
+ else if ( eScannedType != NUMBERFORMAT_UNDEFINED // already another type
+ && eScannedType != NUMBERFORMAT_TIME) // except time
+ return MatchedReturn();
+ else
+ {
+ SkipBlanks(rString, nPos);
+ eScannedType = NUMBERFORMAT_TIME; // !!! it IS a time
+ }
+ if ( !nTimePos )
+ nTimePos = nStringPos + 1;
+ }
+
+ if (nPos < rString.Len())
+ {
+ switch (eScannedType)
+ {
+ case NUMBERFORMAT_DATE:
+ if (nMonthPos == 1 && pLoc->getLongDateFormat() == MDY)
+ {
+ // #68232# recognize long date separators like ", " in "September 5, 1999"
+ if (SkipString( pLoc->getLongDateDaySep(), rString, nPos ))
+ SkipBlanks( rString, nPos );
+ }
+ else if (nStringPos == 5 && nPos == 0 && rString.Len() == 1 &&
+ rString.GetChar(0) == 'T' && MayBeIso8601())
+ {
+ // ISO 8601 combined date and time, yyyy-mm-ddThh:mm
+ ++nPos;
+ }
+ break;
+#if NF_RECOGNIZE_ISO8601_TIMEZONES
+ case NUMBERFORMAT_DATETIME:
+ if (nPos == 0 && rString.Len() == 1 && nStringPos >= 9 &&
+ MayBeIso8601())
+ {
+ // ISO 8601 timezone offset
+ switch (rString.GetChar(0))
+ {
+ case '+':
+ case '-':
+ if (nStringPos == nAnzStrings-2 ||
+ nStringPos == nAnzStrings-4)
+ {
+ ++nPos; // yyyy-mm-ddThh:mm[:ss]+xx[[:]yy]
+ // nTimezonePos needed for GetTimeRef()
+ if (!nTimezonePos)
+ nTimezonePos = nStringPos + 1;
+ }
+ break;
+ case ':':
+ if (nTimezonePos && nStringPos >= 11 &&
+ nStringPos == nAnzStrings-2)
+ ++nPos; // yyyy-mm-ddThh:mm[:ss]+xx:yy
+ break;
+ }
+ }
+ break;
+#endif
+ }
+ }
+
+ if (nPos < rString.Len()) // not everything consumed?
+ {
+ if ( nMatchedAllStrings & ~nMatchedVirgin )
+ eScannedType = eOldScannedType;
+ else
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+//---------------------------------------------------------------------------
+// ScanEndString
+//
+// Schlussteil analysieren
+// Alles weg => TRUE
+// sonst => FALSE
+
+BOOL ImpSvNumberInputScan::ScanEndString( const String& rString,
+ const SvNumberformat* pFormat )
+{
+ xub_StrLen nPos = 0;
+
+ if ( nMatchedAllStrings )
+ { // Match against format in any case, so later on for a "1-2-3-4" input
+ // we may distinguish between a y-m-d (or similar) date and a 0-0-0-0
+ // format.
+ if ( ScanStringNumFor( rString, 0, pFormat, 0xFFFF ) )
+ nMatchedAllStrings |= nMatchedEndString;
+ else
+ nMatchedAllStrings = 0;
+ }
+
+ SkipBlanks(rString, nPos);
+ if (GetDecSep(rString, nPos)) // decimal separator?
+ {
+ if (nDecPos == 1 || nDecPos == 3) // .12.4 or 12.E4.
+ return MatchedReturn();
+ else if (nDecPos == 2) // . dup: 12.4.
+ {
+ if (bDecSepInDateSeps) // . also date sep
+ {
+ if ( eScannedType != NUMBERFORMAT_UNDEFINED &&
+ eScannedType != NUMBERFORMAT_DATE &&
+ eScannedType != NUMBERFORMAT_DATETIME) // already another type
+ return MatchedReturn();
+ if (eScannedType == NUMBERFORMAT_UNDEFINED)
+ eScannedType = NUMBERFORMAT_DATE; // !!! it IS a date
+ SkipBlanks(rString, nPos);
+ }
+ else
+ return MatchedReturn();
+ }
+ else
+ {
+ nDecPos = 3; // . in end string
+ SkipBlanks(rString, nPos);
+ }
+ }
+
+ if ( nSign == 0 // conflict - not signed
+ && eScannedType != NUMBERFORMAT_DATE) // and not date
+//!? catch time too?
+ { // not signed yet
+ nSign = GetSign(rString, nPos); // 1- DM
+ if (nNegCheck) // '(' as sign
+ return MatchedReturn();
+ }
+
+ SkipBlanks(rString, nPos);
+ if (nNegCheck && SkipChar(')', rString, nPos)) // skip ')' if appropriate
+ {
+ nNegCheck = 0;
+ SkipBlanks(rString, nPos);
+ }
+
+ if ( GetCurrency(rString, nPos, pFormat) ) // currency symbol?
+ {
+ if (eScannedType != NUMBERFORMAT_UNDEFINED) // currency dup
+ return MatchedReturn();
+ else
+ {
+ SkipBlanks(rString, nPos);
+ eScannedType = NUMBERFORMAT_CURRENCY;
+ } // behind currency a '-' is allowed
+ if (nSign == 0) // not signed yet
+ {
+ nSign = GetSign(rString, nPos); // DM -
+ SkipBlanks(rString, nPos);
+ if (nNegCheck) // 3 DM (
+ return MatchedReturn();
+ }
+ if ( nNegCheck && eScannedType == NUMBERFORMAT_CURRENCY
+ && SkipChar(')', rString, nPos) )
+ {
+ nNegCheck = 0; // ')' skipped
+ SkipBlanks(rString, nPos); // only if currency
+ }
+ }
+
+ if ( SkipChar('%', rString, nPos) ) // 1 %
+ {
+ if (eScannedType != NUMBERFORMAT_UNDEFINED) // already another type
+ return MatchedReturn();
+ SkipBlanks(rString, nPos);
+ eScannedType = NUMBERFORMAT_PERCENT;
+ }
+
+ const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData();
+ const String& rDate = pFormatter->GetDateSep();
+ const String& rTime = pLoc->getTimeSep();
+ if ( SkipString(rTime, rString, nPos) ) // 10:
+ {
+ if (nDecPos) // already , => error
+ return MatchedReturn();
+ if (eScannedType == NUMBERFORMAT_DATE && nAnzNums > 2) // 31.Dez.94 8:
+ {
+ SkipBlanks(rString, nPos);
+ eScannedType = NUMBERFORMAT_DATETIME;
+ }
+ else if (eScannedType != NUMBERFORMAT_UNDEFINED &&
+ eScannedType != NUMBERFORMAT_TIME) // already another type
+ return MatchedReturn();
+ else
+ {
+ SkipBlanks(rString, nPos);
+ eScannedType = NUMBERFORMAT_TIME;
+ }
+ if ( !nTimePos )
+ nTimePos = nAnzStrings;
+ }
+
+ sal_Unicode cTime = rTime.GetChar(0);
+ if ( SkipString(rDate, rString, nPos) // 10., 10-, 10/
+ || ((cTime != '.') && SkipChar('.', rString, nPos)) // TRICKY:
+ || ((cTime != '/') && SkipChar('/', rString, nPos)) // short boolean
+ || ((cTime != '-') && SkipChar('-', rString, nPos)) ) // evaluation!
+ {
+ if (eScannedType != NUMBERFORMAT_UNDEFINED &&
+ eScannedType != NUMBERFORMAT_DATE) // already another type
+ return MatchedReturn();
+ else
+ {
+ SkipBlanks(rString, nPos);
+ eScannedType = NUMBERFORMAT_DATE;
+ }
+ short nTmpMonth = GetMonth(rString, nPos); // 10. Jan
+ if (nMonth && nTmpMonth) // month dup
+ return MatchedReturn();
+ if (nTmpMonth)
+ {
+ nMonth = nTmpMonth;
+ nMonthPos = 3; // month at end
+ if ( nMonth < 0 )
+ SkipChar( '.', rString, nPos ); // abbreviated
+ SkipBlanks(rString, nPos);
+ }
+ }
+
+ short nTempMonth = GetMonth(rString, nPos); // 10 Jan
+ if (nTempMonth)
+ {
+ if (nMonth) // month dup
+ return MatchedReturn();
+ if (eScannedType != NUMBERFORMAT_UNDEFINED &&
+ eScannedType != NUMBERFORMAT_DATE) // already another type
+ return MatchedReturn();
+ eScannedType = NUMBERFORMAT_DATE;
+ nMonth = nTempMonth;
+ nMonthPos = 3; // month at end
+ if ( nMonth < 0 )
+ SkipChar( '.', rString, nPos ); // abbreviated
+ SkipBlanks(rString, nPos);
+ }
+
+ xub_StrLen nOrigPos = nPos;
+ if (GetTimeAmPm(rString, nPos))
+ {
+ if (eScannedType != NUMBERFORMAT_UNDEFINED &&
+ eScannedType != NUMBERFORMAT_TIME &&
+ eScannedType != NUMBERFORMAT_DATETIME) // already another type
+ return MatchedReturn();
+ else
+ {
+ // If not already scanned as time, 6.78am does not result in 6
+ // seconds and 78 hundredths in the morning. Keep as suffix.
+ if (eScannedType != NUMBERFORMAT_TIME && nDecPos == 2 && nAnzNums == 2)
+ nPos = nOrigPos; // rewind am/pm
+ else
+ {
+ SkipBlanks(rString, nPos);
+ if ( eScannedType != NUMBERFORMAT_DATETIME )
+ eScannedType = NUMBERFORMAT_TIME;
+ }
+ }
+ }
+
+ if ( nNegCheck && SkipChar(')', rString, nPos) )
+ {
+ if (eScannedType == NUMBERFORMAT_CURRENCY) // only if currency
+ {
+ nNegCheck = 0; // skip ')'
+ SkipBlanks(rString, nPos);
+ }
+ else
+ return MatchedReturn();
+ }
+
+ if ( nPos < rString.Len() &&
+ (eScannedType == NUMBERFORMAT_DATE
+ || eScannedType == NUMBERFORMAT_DATETIME) )
+ { // day of week is just parsed away
+ xub_StrLen nOldPos = nPos;
+ const String& rSep = pFormatter->GetLocaleData()->getLongDateDayOfWeekSep();
+ if ( StringContains( rSep, rString, nPos ) )
+ {
+ nPos = nPos + rSep.Len();
+ SkipBlanks(rString, nPos);
+ }
+ int nDayOfWeek = GetDayOfWeek( rString, nPos );
+ if ( nDayOfWeek )
+ {
+ if ( nPos < rString.Len() )
+ {
+ if ( nDayOfWeek < 0 )
+ { // short
+ if ( rString.GetChar( nPos ) == '.' )
+ ++nPos;
+ }
+ SkipBlanks(rString, nPos);
+ }
+ }
+ else
+ nPos = nOldPos;
+ }
+
+#if NF_RECOGNIZE_ISO8601_TIMEZONES
+ if (nPos == 0 && eScannedType == NUMBERFORMAT_DATETIME &&
+ rString.Len() == 1 && rString.GetChar(0) == 'Z' && MayBeIso8601())
+ {
+ // ISO 8601 timezone UTC yyyy-mm-ddThh:mmZ
+ ++nPos;
+ }
+#endif
+
+ if (nPos < rString.Len()) // everything consumed?
+ {
+ // does input EndString equal EndString in Format?
+ if ( !ScanStringNumFor( rString, nPos, pFormat, 0xFFFF ) )
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+BOOL ImpSvNumberInputScan::ScanStringNumFor(
+ const String& rString, // String to scan
+ xub_StrLen nPos, // Position until which was consumed
+ const SvNumberformat* pFormat, // The format to match
+ USHORT nString, // Substring of format, 0xFFFF => last
+ BOOL bDontDetectNegation // Suppress sign detection
+ )
+{
+ if ( !pFormat )
+ return FALSE;
+ const ::utl::TransliterationWrapper* pTransliteration = pFormatter->GetTransliteration();
+ const String* pStr;
+ String aString( rString );
+ BOOL bFound = FALSE;
+ BOOL bFirst = TRUE;
+ BOOL bContinue = TRUE;
+ USHORT nSub;
+ do
+ {
+ // Don't try "lower" subformats ff the very first match was the second
+ // or third subformat.
+ nSub = nStringScanNumFor;
+ do
+ { // Step through subformats, first positive, then negative, then
+ // other, but not the last (text) subformat.
+ pStr = pFormat->GetNumForString( nSub, nString, TRUE );
+ if ( pStr && pTransliteration->isEqual( aString, *pStr ) )
+ {
+ bFound = TRUE;
+ bContinue = FALSE;
+ }
+ else if ( nSub < 2 )
+ ++nSub;
+ else
+ bContinue = FALSE;
+ } while ( bContinue );
+ if ( !bFound && bFirst && nPos )
+ { // try remaining substring
+ bFirst = FALSE;
+ aString.Erase( 0, nPos );
+ bContinue = TRUE;
+ }
+ } while ( bContinue );
+
+ if ( !bFound )
+ {
+ if ( !bDontDetectNegation && (nString == 0) && !bFirst && (nSign < 0)
+ && pFormat->IsNegativeRealNegative() )
+ { // simply negated twice? --1
+ aString.EraseAllChars( ' ' );
+ if ( (aString.Len() == 1) && (aString.GetChar(0) == '-') )
+ {
+ bFound = TRUE;
+ nStringScanSign = -1;
+ nSub = 0; //! not 1
+ }
+ }
+ if ( !bFound )
+ return FALSE;
+ }
+ else if ( !bDontDetectNegation && (nSub == 1) &&
+ pFormat->IsNegativeRealNegative() )
+ { // negative
+ if ( nStringScanSign < 0 )
+ {
+ if ( (nSign < 0) && (nStringScanNumFor != 1) )
+ nStringScanSign = 1; // triple negated --1 yyy
+ }
+ else if ( nStringScanSign == 0 )
+ {
+ if ( nSign < 0 )
+ { // nSign and nStringScanSign will be combined later,
+ // flip sign if doubly negated
+ if ( (nString == 0) && !bFirst
+ && SvNumberformat::HasStringNegativeSign( aString ) )
+ nStringScanSign = -1; // direct double negation
+ else if ( pFormat->IsNegativeWithoutSign() )
+ nStringScanSign = -1; // indirect double negation
+ }
+ else
+ nStringScanSign = -1;
+ }
+ else // > 0
+ nStringScanSign = -1;
+ }
+ nStringScanNumFor = nSub;
+ return TRUE;
+}
+
+
+//---------------------------------------------------------------------------
+// IsNumberFormatMain
+//
+// Recognizes types of number, exponential, fraction, percent, currency, date, time.
+// Else text => return FALSE
+
+BOOL ImpSvNumberInputScan::IsNumberFormatMain(
+ const String& rString, // string to be analyzed
+ double& , // OUT: result as number, if possible
+ const SvNumberformat* pFormat ) // maybe number format set to match against
+{
+ Reset();
+ NumberStringDivision( rString ); // breakdown into strings and numbers
+ if (nAnzStrings >= SV_MAX_ANZ_INPUT_STRINGS) // too many elements
+ return FALSE; // Njet, Nope, ...
+
+ if (nAnzNums == 0) // no number in input
+ {
+ if ( nAnzStrings > 0 )
+ {
+ // Here we may change the original, we don't need it anymore.
+ // This saves copies and ToUpper() in GetLogical() and is faster.
+ String& rStrArray = sStrArray[0];
+ rStrArray.EraseTrailingChars( ' ' );
+ rStrArray.EraseLeadingChars( ' ' );
+ nLogical = GetLogical( rStrArray );
+ if ( nLogical )
+ {
+ eScannedType = NUMBERFORMAT_LOGICAL; // !!! it's a BOOLEAN
+ nMatchedAllStrings &= ~nMatchedVirgin;
+ return TRUE;
+ }
+ else
+ return FALSE; // simple text
+ }
+ else
+ return FALSE; // simple text
+ }
+
+ USHORT i = 0; // mark any symbol
+ USHORT j = 0; // mark only numbers
+
+ switch ( nAnzNums )
+ {
+ case 1 : // Exactly 1 number in input
+ { // nAnzStrings >= 1
+ if (GetNextNumber(i,j)) // i=1,0
+ { // Number at start
+ if (eSetType == NUMBERFORMAT_FRACTION) // Fraction 1 = 1/1
+ {
+ if (i >= nAnzStrings || // no end string nor decimal separator
+ sStrArray[i] == pFormatter->GetNumDecimalSep())
+ {
+ eScannedType = NUMBERFORMAT_FRACTION;
+ nMatchedAllStrings &= ~nMatchedVirgin;
+ return TRUE;
+ }
+ }
+ }
+ else
+ { // Analyze start string
+ if (!ScanStartString( sStrArray[i], pFormat )) // i=0
+ return FALSE; // already an error
+ i++; // next symbol, i=1
+ }
+ GetNextNumber(i,j); // i=1,2
+ if (eSetType == NUMBERFORMAT_FRACTION) // Fraction -1 = -1/1
+ {
+ if (nSign && !nNegCheck && // Sign +, -
+ eScannedType == NUMBERFORMAT_UNDEFINED && // not date or currency
+ nDecPos == 0 && // no previous decimal separator
+ (i >= nAnzStrings || // no end string nor decimal separator
+ sStrArray[i] == pFormatter->GetNumDecimalSep())
+ )
+ {
+ eScannedType = NUMBERFORMAT_FRACTION;
+ nMatchedAllStrings &= ~nMatchedVirgin;
+ return TRUE;
+ }
+ }
+ if (i < nAnzStrings && !ScanEndString( sStrArray[i], pFormat ))
+ return FALSE;
+ }
+ break;
+ case 2 : // Exactly 2 numbers in input
+ { // nAnzStrings >= 3
+ if (!GetNextNumber(i,j)) // i=1,0
+ { // Analyze start string
+ if (!ScanStartString( sStrArray[i], pFormat ))
+ return FALSE; // already an error
+ i++; // i=1
+ }
+ GetNextNumber(i,j); // i=1,2
+ if ( !ScanMidString( sStrArray[i], i, pFormat ) )
+ return FALSE;
+ i++; // next symbol, i=2,3
+ GetNextNumber(i,j); // i=3,4
+ if (i < nAnzStrings && !ScanEndString( sStrArray[i], pFormat ))
+ return FALSE;
+ if (eSetType == NUMBERFORMAT_FRACTION) // -1,200. as fraction
+ {
+ if (!nNegCheck && // no sign '('
+ eScannedType == NUMBERFORMAT_UNDEFINED &&
+ (nDecPos == 0 || nDecPos == 3) // no decimal separator or at end
+ )
+ {
+ eScannedType = NUMBERFORMAT_FRACTION;
+ nMatchedAllStrings &= ~nMatchedVirgin;
+ return TRUE;
+ }
+ }
+ }
+ break;
+ case 3 : // Exactly 3 numbers in input
+ { // nAnzStrings >= 5
+ if (!GetNextNumber(i,j)) // i=1,0
+ { // Analyze start string
+ if (!ScanStartString( sStrArray[i], pFormat ))
+ return FALSE; // already an error
+ i++; // i=1
+ if (nDecPos == 1) // decimal separator at start => error
+ return FALSE;
+ }
+ GetNextNumber(i,j); // i=1,2
+ if ( !ScanMidString( sStrArray[i], i, pFormat ) )
+ return FALSE;
+ i++; // i=2,3
+ if (eScannedType == NUMBERFORMAT_SCIENTIFIC) // E only at end
+ return FALSE;
+ GetNextNumber(i,j); // i=3,4
+ if ( !ScanMidString( sStrArray[i], i, pFormat ) )
+ return FALSE;
+ i++; // i=4,5
+ GetNextNumber(i,j); // i=5,6
+ if (i < nAnzStrings && !ScanEndString( sStrArray[i], pFormat ))
+ return FALSE;
+ if (eSetType == NUMBERFORMAT_FRACTION) // -1,200,100. as fraction
+ {
+ if (!nNegCheck && // no sign '('
+ eScannedType == NUMBERFORMAT_UNDEFINED &&
+ (nDecPos == 0 || nDecPos == 3) // no decimal separator or at end
+ )
+ {
+ eScannedType = NUMBERFORMAT_FRACTION;
+ nMatchedAllStrings &= ~nMatchedVirgin;
+ return TRUE;
+ }
+ }
+ if ( eScannedType == NUMBERFORMAT_FRACTION && nDecPos )
+ return FALSE; // #36857# not a real fraction
+ }
+ break;
+ default: // More than 3 numbers in input
+ { // nAnzStrings >= 7
+ if (!GetNextNumber(i,j)) // i=1,0
+ { // Analyze startstring
+ if (!ScanStartString( sStrArray[i], pFormat ))
+ return FALSE; // already an error
+ i++; // i=1
+ if (nDecPos == 1) // decimal separator at start => error
+ return FALSE;
+ }
+ GetNextNumber(i,j); // i=1,2
+ if ( !ScanMidString( sStrArray[i], i, pFormat ) )
+ return FALSE;
+ i++; // i=2,3
+ USHORT nThOld = 10; // just not 0 or 1
+ while (nThOld != nThousand && j < nAnzNums-1)
+ // Execute at least one time
+ // but leave one number.
+ { // Loop over group separators
+ nThOld = nThousand;
+ if (eScannedType == NUMBERFORMAT_SCIENTIFIC) // E only at end
+ return FALSE;
+ GetNextNumber(i,j);
+ if ( i < nAnzStrings && !ScanMidString( sStrArray[i], i, pFormat ) )
+ return FALSE;
+ i++;
+ }
+ if (eScannedType == NUMBERFORMAT_DATE || // long date or
+ eScannedType == NUMBERFORMAT_TIME || // long time or
+ eScannedType == NUMBERFORMAT_UNDEFINED) // long number
+ {
+ for (USHORT k = j; k < nAnzNums-1; k++)
+ {
+ if (eScannedType == NUMBERFORMAT_SCIENTIFIC) // E only at endd
+ return FALSE;
+ GetNextNumber(i,j);
+ if ( i < nAnzStrings && !ScanMidString( sStrArray[i], i, pFormat ) )
+ return FALSE;
+ i++;
+ }
+ }
+ GetNextNumber(i,j);
+ if (i < nAnzStrings && !ScanEndString( sStrArray[i], pFormat ))
+ return FALSE;
+ if (eSetType == NUMBERFORMAT_FRACTION) // -1,200,100. as fraction
+ {
+ if (!nNegCheck && // no sign '('
+ eScannedType == NUMBERFORMAT_UNDEFINED &&
+ (nDecPos == 0 || nDecPos == 3) // no decimal separator or at end
+ )
+ {
+ eScannedType = NUMBERFORMAT_FRACTION;
+ nMatchedAllStrings &= ~nMatchedVirgin;
+ return TRUE;
+ }
+ }
+ if ( eScannedType == NUMBERFORMAT_FRACTION && nDecPos )
+ return FALSE; // #36857# not a real fraction
+ }
+ }
+
+ if (eScannedType == NUMBERFORMAT_UNDEFINED)
+ {
+ nMatchedAllStrings &= ~nMatchedVirgin;
+ // did match including nMatchedUsedAsReturn
+ BOOL bDidMatch = (nMatchedAllStrings != 0);
+ if ( nMatchedAllStrings )
+ {
+ BOOL bMatch = (pFormat ? pFormat->IsNumForStringElementCountEqual(
+ nStringScanNumFor, nAnzStrings, nAnzNums ) : FALSE);
+ if ( !bMatch )
+ nMatchedAllStrings = 0;
+ }
+ if ( nMatchedAllStrings )
+ eScannedType = eSetType;
+ else if ( bDidMatch )
+ return FALSE;
+ else
+ eScannedType = NUMBERFORMAT_NUMBER;
+ // everything else should have been recognized by now
+ }
+ else if ( eScannedType == NUMBERFORMAT_DATE )
+ { // the very relaxed date input checks may interfere with a preset format
+ nMatchedAllStrings &= ~nMatchedVirgin;
+ BOOL bWasReturn = ((nMatchedAllStrings & nMatchedUsedAsReturn) != 0);
+ if ( nMatchedAllStrings )
+ {
+ BOOL bMatch = (pFormat ? pFormat->IsNumForStringElementCountEqual(
+ nStringScanNumFor, nAnzStrings, nAnzNums ) : FALSE);
+ if ( !bMatch )
+ nMatchedAllStrings = 0;
+ }
+ if ( nMatchedAllStrings )
+ eScannedType = eSetType;
+ else if ( bWasReturn )
+ return FALSE;
+ }
+ else
+ nMatchedAllStrings = 0; // reset flag to no substrings matched
+
+ return TRUE;
+}
+
+
+//---------------------------------------------------------------------------
+// return TRUE or FALSE depending on the nMatched... state and remember usage
+BOOL ImpSvNumberInputScan::MatchedReturn()
+{
+ if ( nMatchedAllStrings & ~nMatchedVirgin )
+ {
+ nMatchedAllStrings |= nMatchedUsedAsReturn;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+//---------------------------------------------------------------------------
+// Initialize uppercase months and weekdays
+
+void ImpSvNumberInputScan::InitText()
+{
+ sal_Int32 j, nElems;
+ const CharClass* pChrCls = pFormatter->GetCharClass();
+ const CalendarWrapper* pCal = pFormatter->GetCalendar();
+ delete [] pUpperMonthText;
+ delete [] pUpperAbbrevMonthText;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > xElems
+ = pCal->getMonths();
+ nElems = xElems.getLength();
+ pUpperMonthText = new String[nElems];
+ pUpperAbbrevMonthText = new String[nElems];
+ for ( j=0; j<nElems; j++ )
+ {
+ pUpperMonthText[j] = pChrCls->upper( xElems[j].FullName );
+ pUpperAbbrevMonthText[j] = pChrCls->upper( xElems[j].AbbrevName );
+ }
+ delete [] pUpperDayText;
+ delete [] pUpperAbbrevDayText;
+ xElems = pCal->getDays();
+ nElems = xElems.getLength();
+ pUpperDayText = new String[nElems];
+ pUpperAbbrevDayText = new String[nElems];
+ for ( j=0; j<nElems; j++ )
+ {
+ pUpperDayText[j] = pChrCls->upper( xElems[j].FullName );
+ pUpperAbbrevDayText[j] = pChrCls->upper( xElems[j].AbbrevName );
+ }
+ bTextInitialized = TRUE;
+}
+
+
+//===========================================================================
+// P U B L I C
+
+//---------------------------------------------------------------------------
+// ChangeIntl
+//
+// MUST be called if International/Locale is changed
+
+void ImpSvNumberInputScan::ChangeIntl()
+{
+ sal_Unicode cDecSep = pFormatter->GetNumDecimalSep().GetChar(0);
+ bDecSepInDateSeps = ( cDecSep == '-' ||
+ cDecSep == '/' ||
+ cDecSep == '.' ||
+ cDecSep == pFormatter->GetDateSep().GetChar(0) );
+ bTextInitialized = FALSE;
+ aUpperCurrSymbol.Erase();
+}
+
+
+//---------------------------------------------------------------------------
+// ChangeNullDate
+
+void ImpSvNumberInputScan::ChangeNullDate(
+ const USHORT Day,
+ const USHORT Month,
+ const USHORT Year )
+{
+ if ( pNullDate )
+ *pNullDate = Date(Day, Month, Year);
+ else
+ pNullDate = new Date(Day, Month, Year);
+}
+
+
+//---------------------------------------------------------------------------
+// IsNumberFormat
+//
+// => does rString represent a number (also date, time et al)
+
+BOOL ImpSvNumberInputScan::IsNumberFormat(
+ const String& rString, // string to be analyzed
+ short& F_Type, // IN: old type, OUT: new type
+ double& fOutNumber, // OUT: number if convertable
+ const SvNumberformat* pFormat ) // maybe a number format to match against
+{
+ String sResString;
+ String aString;
+ BOOL res; // return value
+ eSetType = F_Type; // old type set
+
+ if ( !rString.Len() )
+ res = FALSE;
+ else if (rString.Len() > 308) // arbitrary
+ res = FALSE;
+ else
+ {
+ // NoMoreUpperNeeded, all comparisons on UpperCase
+ aString = pFormatter->GetCharClass()->upper( rString );
+ // convert native number to ASCII if necessary
+ TransformInput( aString );
+ res = IsNumberFormatMain( aString, fOutNumber, pFormat );
+ }
+
+ if (res)
+ {
+ if ( nNegCheck // ')' not found for '('
+ || (nSign && (eScannedType == NUMBERFORMAT_DATE
+ || eScannedType == NUMBERFORMAT_DATETIME))
+ ) // signed date/datetime
+ res = FALSE;
+ else
+ { // check count of partial number strings
+ switch (eScannedType)
+ {
+ case NUMBERFORMAT_PERCENT:
+ case NUMBERFORMAT_CURRENCY:
+ case NUMBERFORMAT_NUMBER:
+ if (nDecPos == 1) // .05
+ {
+ // matched MidStrings function like group separators
+ if ( nMatchedAllStrings )
+ nThousand = nAnzNums - 1;
+ else if ( nAnzNums != 1 )
+ res = FALSE;
+ }
+ else if (nDecPos == 2) // 1.05
+ {
+ // matched MidStrings function like group separators
+ if ( nMatchedAllStrings )
+ nThousand = nAnzNums - 1;
+ else if ( nAnzNums != nThousand+2 )
+ res = FALSE;
+ }
+ else // 1,100 or 1,100.
+ {
+ // matched MidStrings function like group separators
+ if ( nMatchedAllStrings )
+ nThousand = nAnzNums - 1;
+ else if ( nAnzNums != nThousand+1 )
+ res = FALSE;
+ }
+ break;
+
+ case NUMBERFORMAT_SCIENTIFIC: // 1.0e-2
+ if (nDecPos == 1) // .05
+ {
+ if (nAnzNums != 2)
+ res = FALSE;
+ }
+ else if (nDecPos == 2) // 1.05
+ {
+ if (nAnzNums != nThousand+3)
+ res = FALSE;
+ }
+ else // 1,100 or 1,100.
+ {
+ if (nAnzNums != nThousand+2)
+ res = FALSE;
+ }
+ break;
+
+ case NUMBERFORMAT_DATE:
+ if (nMonth)
+ { // month name and numbers
+ if (nAnzNums > 2)
+ res = FALSE;
+ }
+ else
+ {
+ if (nAnzNums > 3)
+ res = FALSE;
+ }
+ break;
+
+ case NUMBERFORMAT_TIME:
+ if (nDecPos)
+ { // hundredth seconds included
+ if (nAnzNums > 4)
+ res = FALSE;
+ }
+ else
+ {
+ if (nAnzNums > 3)
+ res = FALSE;
+ }
+ break;
+
+ case NUMBERFORMAT_DATETIME:
+ if (nMonth)
+ { // month name and numbers
+ if (nDecPos)
+ { // hundredth seconds included
+ if (nAnzNums > 6)
+ res = FALSE;
+ }
+ else
+ {
+ if (nAnzNums > 5)
+ res = FALSE;
+ }
+ }
+ else
+ {
+ if (nDecPos)
+ { // hundredth seconds included
+ if (nAnzNums > 7)
+ res = FALSE;
+ }
+ else
+ {
+ if (nAnzNums > 6)
+ res = FALSE;
+ }
+ }
+ break;
+
+ default:
+ break;
+ } // switch
+ } // else
+ } // if (res)
+
+ if (res)
+ { // we finally have a number
+ switch (eScannedType)
+ {
+ case NUMBERFORMAT_LOGICAL:
+ if (nLogical == 1)
+ fOutNumber = 1.0; // True
+ else if (nLogical == -1)
+ fOutNumber = 0.0; // False
+ else
+ res = FALSE; // Oops
+ break;
+
+ case NUMBERFORMAT_PERCENT:
+ case NUMBERFORMAT_CURRENCY:
+ case NUMBERFORMAT_NUMBER:
+ case NUMBERFORMAT_SCIENTIFIC:
+ case NUMBERFORMAT_DEFINED: // if no category detected handle as number
+ {
+ if ( nDecPos == 1 ) // . at start
+ sResString.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "0." ) );
+ else
+ sResString.Erase();
+ USHORT k;
+ for ( k = 0; k <= nThousand; k++)
+ sResString += sStrArray[nNums[k]]; // integer part
+ if ( nDecPos == 2 && k < nAnzNums ) // . somewhere
+ {
+ sResString += '.';
+ USHORT nStop = (eScannedType == NUMBERFORMAT_SCIENTIFIC ?
+ nAnzNums-1 : nAnzNums);
+ for ( ; k < nStop; k++)
+ sResString += sStrArray[nNums[k]]; // fractional part
+ }
+
+ if (eScannedType != NUMBERFORMAT_SCIENTIFIC)
+ fOutNumber = StringToDouble(sResString);
+ else
+ { // append exponent
+ sResString += 'E';
+ if ( nESign == -1 )
+ sResString += '-';
+ sResString += sStrArray[nNums[nAnzNums-1]];
+ rtl_math_ConversionStatus eStatus;
+ fOutNumber = ::rtl::math::stringToDouble(
+ sResString, '.', ',', &eStatus, NULL );
+ if ( eStatus == rtl_math_ConversionStatus_OutOfRange )
+ {
+ F_Type = NUMBERFORMAT_TEXT; // overflow/underflow -> Text
+ if (nESign == -1)
+ fOutNumber = 0.0;
+ else
+ fOutNumber = DBL_MAX;
+/*!*/ return TRUE;
+ }
+ }
+
+ if ( nStringScanSign )
+ {
+ if ( nSign )
+ nSign *= nStringScanSign;
+ else
+ nSign = nStringScanSign;
+ }
+ if ( nSign < 0 )
+ fOutNumber = -fOutNumber;
+
+ if (eScannedType == NUMBERFORMAT_PERCENT)
+ fOutNumber/= 100.0;
+ }
+ break;
+
+ case NUMBERFORMAT_FRACTION:
+ if (nAnzNums == 1)
+ fOutNumber = StringToDouble(sStrArray[nNums[0]]);
+ else if (nAnzNums == 2)
+ {
+ if (nThousand == 1)
+ {
+ sResString = sStrArray[nNums[0]];
+ sResString += sStrArray[nNums[1]]; // integer part
+ fOutNumber = StringToDouble(sResString);
+ }
+ else
+ {
+ double fZaehler = StringToDouble(sStrArray[nNums[0]]);
+ double fNenner = StringToDouble(sStrArray[nNums[1]]);
+ if (fNenner != 0.0)
+ fOutNumber = fZaehler/fNenner;
+ else
+ res = FALSE;
+ }
+ }
+ else // nAnzNums > 2
+ {
+ USHORT k = 1;
+ sResString = sStrArray[nNums[0]];
+ if (nThousand > 0)
+ for (k = 1; k <= nThousand; k++)
+ sResString += sStrArray[nNums[k]];
+ fOutNumber = StringToDouble(sResString);
+
+ if (k == nAnzNums-2)
+ {
+ double fZaehler = StringToDouble(sStrArray[nNums[k]]);
+ double fNenner = StringToDouble(sStrArray[nNums[k+1]]);
+ if (fNenner != 0.0)
+ fOutNumber += fZaehler/fNenner;
+ else
+ res = FALSE;
+ }
+ }
+
+ if ( nStringScanSign )
+ {
+ if ( nSign )
+ nSign *= nStringScanSign;
+ else
+ nSign = nStringScanSign;
+ }
+ if ( nSign < 0 )
+ fOutNumber = -fOutNumber;
+ break;
+
+ case NUMBERFORMAT_TIME:
+ GetTimeRef(fOutNumber, 0, nAnzNums);
+ if ( nSign < 0 )
+ fOutNumber = -fOutNumber;
+ break;
+
+ case NUMBERFORMAT_DATE:
+ {
+ USHORT nCounter = 0; // dummy here
+ res = GetDateRef( fOutNumber, nCounter, pFormat );
+ }
+ break;
+
+ case NUMBERFORMAT_DATETIME:
+ {
+ USHORT nCounter = 0; // needed here
+ res = GetDateRef( fOutNumber, nCounter, pFormat );
+ if ( res )
+ {
+ double fTime;
+ GetTimeRef( fTime, nCounter, nAnzNums - nCounter );
+ fOutNumber += fTime;
+ }
+ }
+ break;
+
+ default:
+ DBG_ERRORFILE( "Some number recognized but what's it?" );
+ fOutNumber = 0.0;
+ break;
+ }
+ }
+
+ if (res) // overflow/underflow -> Text
+ {
+ if (fOutNumber < -DBL_MAX) // -1.7E308
+ {
+ F_Type = NUMBERFORMAT_TEXT;
+ fOutNumber = -DBL_MAX;
+ return TRUE;
+ }
+ else if (fOutNumber > DBL_MAX) // 1.7E308
+ {
+ F_Type = NUMBERFORMAT_TEXT;
+ fOutNumber = DBL_MAX;
+ return TRUE;
+ }
+ }
+
+ if (res == FALSE)
+ {
+ eScannedType = NUMBERFORMAT_TEXT;
+ fOutNumber = 0.0;
+ }
+
+ F_Type = eScannedType;
+ return res;
+}
+
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/numbers/svt_zforlist.cxx b/binfilter/bf_svtools/source/numbers/svt_zforlist.cxx
new file mode 100644
index 000000000000..a5afb10969aa
--- /dev/null
+++ b/binfilter/bf_svtools/source/numbers/svt_zforlist.cxx
@@ -0,0 +1,4004 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/debug.hxx>
+#include <vcl/sound.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+#include <unotools/charclass.hxx>
+#include <i18npool/mslangid.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <unotools/numberformatcodewrapper.hxx>
+#include <unotools/calendarwrapper.hxx>
+#include <com/sun/star/i18n/KNumberFormatUsage.hpp>
+#include <com/sun/star/i18n/KNumberFormatType.hpp>
+#include <comphelper/processfactory.hxx>
+
+#define _SVSTDARR_USHORTS
+#include <bf_svtools/svstdarr.hxx>
+
+#define _ZFORLIST_CXX
+#include <osl/mutex.hxx>
+#include <bf_svtools/zforlist.hxx>
+#undef _ZFORLIST_CXX
+
+#include "zforscan.hxx"
+#include "zforfind.hxx"
+#include <bf_svtools/zformat.hxx>
+#include "numhead.hxx"
+
+#include <bf_svtools/syslocaleoptions.hxx>
+#include "listener.hxx"
+#include <bf_svtools/smplhint.hxx>
+
+#include <rtl/logfile.hxx>
+#include <rtl/instance.hxx>
+
+#include <unotools/misccfg.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::lang;
+
+namespace binfilter
+{
+
+
+// Constants for type offsets per Country/Language (CL)
+#define ZF_STANDARD 0
+#define ZF_STANDARD_PERCENT 10
+#define ZF_STANDARD_CURRENCY 20
+#define ZF_STANDARD_DATE 30
+#define ZF_STANDARD_TIME 40
+#define ZF_STANDARD_DATETIME 50
+#define ZF_STANDARD_SCIENTIFIC 60
+#define ZF_STANDARD_FRACTION 70
+#define ZF_STANDARD_NEWEXTENDED 75
+#define ZF_STANDARD_NEWEXTENDEDMAX SV_MAX_ANZ_STANDARD_FORMATE-2 // 98
+#define ZF_STANDARD_LOGICAL SV_MAX_ANZ_STANDARD_FORMATE-1 // 99
+#define ZF_STANDARD_TEXT SV_MAX_ANZ_STANDARD_FORMATE // 100
+
+/* Locale that is set if an unknown locale (from another system) is loaded of
+ * legacy documents. Can not be SYSTEM because else, for example, a German "DM"
+ * (old currency) is recognized as a date (#53155#). */
+#define UNKNOWN_SUBSTITUTE LANGUAGE_ENGLISH_US
+
+static BOOL bIndexTableInitialized = FALSE;
+static sal_uInt32 __FAR_DATA theIndexTable[NF_INDEX_TABLE_ENTRIES];
+
+
+// ====================================================================
+
+/**
+ instead of every number formatter being a listener we have a registry which
+ also handles one instance of the SysLocale options
+ */
+
+class SvNumberFormatterRegistry_Impl : public SvtListener
+{
+ List aFormatters;
+ SvtSysLocaleOptions aSysLocaleOptions;
+ LanguageType eSysLanguage;
+
+public:
+ SvNumberFormatterRegistry_Impl();
+ virtual ~SvNumberFormatterRegistry_Impl();
+
+ void Insert( SvNumberFormatter* pThis )
+ { aFormatters.Insert( pThis, LIST_APPEND ); }
+ SvNumberFormatter* Remove( SvNumberFormatter* pThis )
+ { return (SvNumberFormatter*)aFormatters.Remove( pThis ); }
+ sal_uInt32 Count()
+ { return aFormatters.Count(); }
+
+ virtual void Notify( SvtBroadcaster& rBC, const SfxHint& rHint );
+
+};
+
+
+SvNumberFormatterRegistry_Impl::SvNumberFormatterRegistry_Impl()
+{
+ eSysLanguage = MsLangId::getRealLanguage( LANGUAGE_SYSTEM );
+ aSysLocaleOptions.AddListener( *this );
+}
+
+
+SvNumberFormatterRegistry_Impl::~SvNumberFormatterRegistry_Impl()
+{
+ aSysLocaleOptions.RemoveListener( *this );
+}
+
+
+void SvNumberFormatterRegistry_Impl::Notify( SvtBroadcaster&, const SfxHint& rHint )
+{
+ const SfxSimpleHint* pHint = PTR_CAST( SfxSimpleHint, &rHint );
+ if( pHint )
+ {
+ if ( pHint->GetId() & SYSLOCALEOPTIONS_HINT_LOCALE )
+ {
+ ::osl::MutexGuard aGuard( SvNumberFormatter::GetMutex() );
+ for ( SvNumberFormatter* p = (SvNumberFormatter*)aFormatters.First();
+ p; p = (SvNumberFormatter*)aFormatters.Next() )
+ {
+ p->ReplaceSystemCL( eSysLanguage );
+ }
+ eSysLanguage = MsLangId::getRealLanguage( LANGUAGE_SYSTEM );
+ }
+ if ( pHint->GetId() & SYSLOCALEOPTIONS_HINT_CURRENCY )
+ {
+ ::osl::MutexGuard aGuard( SvNumberFormatter::GetMutex() );
+ for ( SvNumberFormatter* p = (SvNumberFormatter*)aFormatters.First();
+ p; p = (SvNumberFormatter*)aFormatters.Next() )
+ {
+ p->ResetDefaultSystemCurrency();
+ }
+ }
+ }
+}
+
+
+// ====================================================================
+
+SvNumberFormatterRegistry_Impl* SvNumberFormatter::pFormatterRegistry = NULL;
+BOOL SvNumberFormatter::bCurrencyTableInitialized = FALSE;
+namespace
+{
+ struct theCurrencyTable :
+ public rtl::Static< NfCurrencyTable, theCurrencyTable > {};
+
+ struct theLegacyOnlyCurrencyTable :
+ public rtl::Static< NfCurrencyTable, theLegacyOnlyCurrencyTable > {};
+}
+USHORT SvNumberFormatter::nSystemCurrencyPosition = 0;
+SV_IMPL_PTRARR( NfCurrencyTable, NfCurrencyEntry* );
+SV_IMPL_PTRARR( NfWSStringsDtor, String* );
+
+// ob das BankSymbol immer am Ende ist (1 $;-1 $) oder sprachabhaengig
+#define NF_BANKSYMBOL_FIX_POSITION 1
+
+
+/***********************Funktionen SvNumberFormatter**************************/
+
+SvNumberFormatter::SvNumberFormatter(
+ const Reference< XMultiServiceFactory >& xSMgr,
+ LanguageType eLang )
+ :
+ xServiceManager( xSMgr )
+{
+ ImpConstruct( eLang );
+}
+
+
+SvNumberFormatter::~SvNumberFormatter()
+{
+ {
+ ::osl::MutexGuard aGuard( GetMutex() );
+ pFormatterRegistry->Remove( this );
+ if ( !pFormatterRegistry->Count() )
+ {
+ delete pFormatterRegistry;
+ pFormatterRegistry = NULL;
+ }
+ }
+
+ SvNumberformat* pEntry = aFTable.First();
+ while (pEntry)
+ {
+ delete pEntry;
+ pEntry = aFTable.Next();
+ }
+ delete pFormatTable;
+ delete pCharClass;
+ delete pStringScanner;
+ delete pFormatScanner;
+ ClearMergeTable();
+ delete pMergeTable;
+}
+
+
+void SvNumberFormatter::ImpConstruct( LanguageType eLang )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aTimeLog, "svtools", "er93726", "SvNumberFormatter::ImpConstruct" );
+
+ if ( eLang == LANGUAGE_DONTKNOW )
+ eLang = UNKNOWN_SUBSTITUTE;
+ IniLnge = eLang;
+ ActLnge = eLang;
+ eEvalDateFormat = NF_EVALDATEFORMAT_INTL;
+ nDefaultSystemCurrencyFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
+
+ aLocale = MsLangId::convertLanguageToLocale( eLang );
+ pCharClass = new CharClass( xServiceManager, aLocale );
+ xLocaleData.init( xServiceManager, aLocale, eLang );
+ xCalendar.init( xServiceManager, aLocale );
+ xTransliteration.init( xServiceManager, eLang,
+ ::com::sun::star::i18n::TransliterationModules_IGNORE_CASE );
+ xNatNum.init( xServiceManager );
+
+ // cached locale data items
+ const LocaleDataWrapper* pLoc = GetLocaleData();
+ aDecimalSep = pLoc->getNumDecimalSep();
+ aThousandSep = pLoc->getNumThousandSep();
+ aDateSep = pLoc->getDateSep();
+
+ pStringScanner = new ImpSvNumberInputScan( this );
+ pFormatScanner = new ImpSvNumberformatScan( this );
+ pFormatTable = NULL;
+ MaxCLOffset = 0;
+ ImpGenerateFormats( 0, FALSE ); // 0 .. 999 for initialized language formats
+ pMergeTable = NULL;
+ bNoZero = FALSE;
+
+ ::osl::MutexGuard aGuard( GetMutex() );
+ GetFormatterRegistry().Insert( this );
+}
+
+
+void SvNumberFormatter::ChangeIntl(LanguageType eLnge)
+{
+ if (ActLnge != eLnge)
+ {
+ ActLnge = eLnge;
+
+ aLocale = MsLangId::convertLanguageToLocale( eLnge );
+ pCharClass->setLocale( aLocale );
+ xLocaleData.changeLocale( aLocale, eLnge );
+ xCalendar.changeLocale( aLocale );
+ xTransliteration.changeLocale( eLnge );
+
+ // cached locale data items, initialize BEFORE calling ChangeIntl below
+ const LocaleDataWrapper* pLoc = GetLocaleData();
+ aDecimalSep = pLoc->getNumDecimalSep();
+ aThousandSep = pLoc->getNumThousandSep();
+ aDateSep = pLoc->getDateSep();
+
+ pFormatScanner->ChangeIntl();
+ pStringScanner->ChangeIntl();
+ }
+}
+
+
+// static
+::osl::Mutex& SvNumberFormatter::GetMutex()
+{
+ static ::osl::Mutex* pMutex = NULL;
+ if( !pMutex )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( !pMutex )
+ {
+ // #i77768# Due to a static reference in the toolkit lib
+ // we need a mutex that lives longer than the svtools library.
+ // Otherwise the dtor would use a destructed mutex!!
+ pMutex = new ::osl::Mutex;
+ }
+ }
+ return *pMutex;
+}
+
+
+// static
+SvNumberFormatterRegistry_Impl& SvNumberFormatter::GetFormatterRegistry()
+{
+ ::osl::MutexGuard aGuard( GetMutex() );
+ if ( !pFormatterRegistry )
+ pFormatterRegistry = new SvNumberFormatterRegistry_Impl;
+ return *pFormatterRegistry;
+}
+
+
+Color* SvNumberFormatter::GetUserDefColor(USHORT nIndex)
+{
+ if( aColorLink.IsSet() )
+ return (Color*) ( aColorLink.Call( (void*) &nIndex ));
+ else
+ return NULL;
+}
+
+void SvNumberFormatter::ChangeNullDate(USHORT nDay,
+ USHORT nMonth,
+ USHORT nYear)
+{
+ pFormatScanner->ChangeNullDate(nDay, nMonth, nYear);
+ pStringScanner->ChangeNullDate(nDay, nMonth, nYear);
+}
+
+Date* SvNumberFormatter::GetNullDate()
+{
+ return pFormatScanner->GetNullDate();
+}
+
+void SvNumberFormatter::ChangeStandardPrec(short nPrec)
+{
+ pFormatScanner->ChangeStandardPrec(nPrec);
+}
+
+short SvNumberFormatter::GetStandardPrec()
+{
+ return pFormatScanner->GetStandardPrec();
+}
+
+void SvNumberFormatter::ImpChangeSysCL( LanguageType eLnge, BOOL bLoadingSO5 )
+{
+ if (eLnge == LANGUAGE_DONTKNOW)
+ eLnge = UNKNOWN_SUBSTITUTE;
+ if (eLnge != IniLnge)
+ {
+ IniLnge = eLnge;
+ ChangeIntl(eLnge);
+ SvNumberformat* pEntry = aFTable.First();
+ while (pEntry) // delete old formats
+ {
+ pEntry = (SvNumberformat*) aFTable.Remove(aFTable.GetCurKey());
+ delete pEntry;
+ pEntry = (SvNumberformat*) aFTable.First();
+ }
+ ImpGenerateFormats( 0, bLoadingSO5 ); // new standard formats
+ }
+ else if ( bLoadingSO5 )
+ { // delete additional standard formats
+ sal_uInt32 nKey;
+ aFTable.Seek( SV_MAX_ANZ_STANDARD_FORMATE + 1 );
+ while ( (nKey = aFTable.GetCurKey()) > SV_MAX_ANZ_STANDARD_FORMATE &&
+ nKey < SV_COUNTRY_LANGUAGE_OFFSET )
+ {
+ SvNumberformat* pEntry = (SvNumberformat*) aFTable.Remove( nKey );
+ delete pEntry;
+ }
+ }
+}
+
+
+void SvNumberFormatter::ReplaceSystemCL( LanguageType eOldLanguage )
+{
+ sal_uInt32 nCLOffset = ImpGetCLOffset( LANGUAGE_SYSTEM );
+ if ( nCLOffset > MaxCLOffset )
+ return ; // no SYSTEM entries to replace
+
+ const sal_uInt32 nMaxBuiltin = nCLOffset + SV_MAX_ANZ_STANDARD_FORMATE;
+ const sal_uInt32 nNextCL = nCLOffset + SV_COUNTRY_LANGUAGE_OFFSET;
+ sal_uInt32 nKey;
+
+ // remove old builtin formats
+ aFTable.Seek( nCLOffset );
+ while ( (nKey = aFTable.GetCurKey()) >= nCLOffset && nKey <= nMaxBuiltin && aFTable.Count() )
+ {
+ SvNumberformat* pEntry = (SvNumberformat*) aFTable.Remove( nKey );
+ delete pEntry;
+ }
+
+ // move additional and user defined to temporary table
+ Table aOldTable;
+ while ( (nKey = aFTable.GetCurKey()) >= nCLOffset && nKey < nNextCL && aFTable.Count() )
+ {
+ SvNumberformat* pEntry = (SvNumberformat*) aFTable.Remove( nKey );
+ aOldTable.Insert( nKey, pEntry );
+ }
+
+ // generate new old builtin formats
+ // reset ActLnge otherwise ChangeIntl() wouldn't switch if already LANGUAGE_SYSTEM
+ ActLnge = LANGUAGE_DONTKNOW;
+ ChangeIntl( LANGUAGE_SYSTEM );
+ ImpGenerateFormats( nCLOffset, TRUE );
+
+ // convert additional and user defined from old system to new system
+ SvNumberformat* pStdFormat = (SvNumberformat*) aFTable.Get( nCLOffset + ZF_STANDARD );
+ sal_uInt32 nLastKey = nMaxBuiltin;
+ pFormatScanner->SetConvertMode( eOldLanguage, LANGUAGE_SYSTEM, TRUE );
+ aOldTable.First();
+ while ( aOldTable.Count() )
+ {
+ nKey = aOldTable.GetCurKey();
+ if ( nLastKey < nKey )
+ nLastKey = nKey;
+ SvNumberformat* pOldEntry = (SvNumberformat*) aOldTable.Remove( nKey );
+ String aString( pOldEntry->GetFormatstring() );
+ xub_StrLen nCheckPos = STRING_NOTFOUND;
+
+ // Same as PutEntry() but assures key position even if format code is
+ // a duplicate. Also won't mix up any LastInsertKey.
+ ChangeIntl( eOldLanguage );
+ LanguageType eLge = eOldLanguage; // ConvertMode changes this
+ BOOL bCheck = FALSE;
+ SvNumberformat* pNewEntry = new SvNumberformat( aString, pFormatScanner,
+ pStringScanner, nCheckPos, eLge );
+ if ( nCheckPos != 0 )
+ delete pNewEntry;
+ else
+ {
+ short eCheckType = pNewEntry->GetType();
+ if ( eCheckType != NUMBERFORMAT_UNDEFINED )
+ pNewEntry->SetType( eCheckType | NUMBERFORMAT_DEFINED );
+ else
+ pNewEntry->SetType( NUMBERFORMAT_DEFINED );
+
+ if ( !aFTable.Insert( nKey, pNewEntry ) )
+ delete pNewEntry;
+ else
+ bCheck = TRUE;
+ }
+ DBG_ASSERT( bCheck, "SvNumberFormatter::ReplaceSystemCL: couldn't convert" );
+
+ delete pOldEntry;
+ }
+ pFormatScanner->SetConvertMode(FALSE);
+ pStdFormat->SetLastInsertKey( USHORT(nLastKey - nCLOffset) );
+
+ // append new system additional formats
+ NumberFormatCodeWrapper aNumberFormatCode( xServiceManager, GetLocale() );
+ ImpGenerateAdditionalFormats( nCLOffset, aNumberFormatCode, TRUE );
+}
+
+
+BOOL SvNumberFormatter::IsTextFormat(sal_uInt32 F_Index) const
+{
+ SvNumberformat* pFormat = (SvNumberformat*) aFTable.Get(F_Index);
+ if (!pFormat)
+ return FALSE;
+ else
+ return pFormat->IsTextFormat();
+}
+
+BOOL SvNumberFormatter::PutEntry(String& rString,
+ xub_StrLen& nCheckPos,
+ short& nType,
+ sal_uInt32& nKey, // Formatnummer
+ LanguageType eLnge)
+{
+ nKey = 0;
+ if (rString.Len() == 0) // keinen Leerstring
+ {
+ nCheckPos = 1; // -> Fehler
+ return FALSE;
+ }
+ if (eLnge == LANGUAGE_DONTKNOW)
+ eLnge = IniLnge;
+
+ ChangeIntl(eLnge); // ggfs. austauschen
+ LanguageType eLge = eLnge; // Umgehung const fuer ConvertMode
+ BOOL bCheck = FALSE;
+ SvNumberformat* p_Entry = new SvNumberformat(rString,
+ pFormatScanner,
+ pStringScanner,
+ nCheckPos,
+ eLge);
+ if (nCheckPos == 0) // Format ok
+ { // Typvergleich:
+ short eCheckType = p_Entry->GetType();
+ if ( eCheckType != NUMBERFORMAT_UNDEFINED)
+ {
+ p_Entry->SetType(eCheckType | NUMBERFORMAT_DEFINED);
+ nType = eCheckType;
+ }
+ else
+ {
+ p_Entry->SetType(NUMBERFORMAT_DEFINED);
+ nType = NUMBERFORMAT_DEFINED;
+ }
+ sal_uInt32 CLOffset = ImpGenerateCL(eLge); // ggfs. neu Standard-
+ // formate anlegen
+ nKey = ImpIsEntry(p_Entry->GetFormatstring(),CLOffset, eLge);
+ if (nKey != NUMBERFORMAT_ENTRY_NOT_FOUND) // schon vorhanden
+ delete p_Entry;
+ else
+ {
+ SvNumberformat* pStdFormat =
+ (SvNumberformat*) aFTable.Get(CLOffset + ZF_STANDARD);
+ sal_uInt32 nPos = CLOffset + pStdFormat->GetLastInsertKey();
+ if (nPos - CLOffset >= SV_COUNTRY_LANGUAGE_OFFSET)
+ {
+ Sound::Beep();
+ DBG_ERROR("SvNumberFormatter:: Zu viele Formate pro CL");
+ delete p_Entry;
+ }
+ else if (!aFTable.Insert(nPos+1,p_Entry))
+ delete p_Entry;
+ else
+ {
+ bCheck = TRUE;
+ nKey = nPos+1;
+ pStdFormat->SetLastInsertKey((USHORT) (nKey-CLOffset));
+ }
+ }
+ }
+ else
+ delete p_Entry;
+ return bCheck;
+}
+
+BOOL SvNumberFormatter::PutandConvertEntry(String& rString,
+ xub_StrLen& nCheckPos,
+ short& nType,
+ sal_uInt32& nKey,
+ LanguageType eLnge,
+ LanguageType eNewLnge)
+{
+ BOOL bRes;
+ if (eNewLnge == LANGUAGE_DONTKNOW)
+ eNewLnge = IniLnge;
+
+ pFormatScanner->SetConvertMode(eLnge, eNewLnge);
+ bRes = PutEntry(rString, nCheckPos, nType, nKey, eLnge);
+ pFormatScanner->SetConvertMode(FALSE);
+ return bRes;
+}
+
+
+BOOL SvNumberFormatter::PutandConvertEntrySystem(String& rString,
+ xub_StrLen& nCheckPos,
+ short& nType,
+ sal_uInt32& nKey,
+ LanguageType eLnge,
+ LanguageType eNewLnge)
+{
+ BOOL bRes;
+ if (eNewLnge == LANGUAGE_DONTKNOW)
+ eNewLnge = IniLnge;
+
+ pFormatScanner->SetConvertMode(eLnge, eNewLnge, TRUE);
+ bRes = PutEntry(rString, nCheckPos, nType, nKey, eLnge);
+ pFormatScanner->SetConvertMode(FALSE);
+ return bRes;
+}
+
+void SvNumberFormatter::DeleteEntry(sal_uInt32 nKey)
+{
+ SvNumberformat* pEntry = aFTable.Remove(nKey);
+ delete pEntry;
+}
+
+BOOL SvNumberFormatter::Load( SvStream& rStream )
+{
+ LanguageType eSysLang = Application::GetSettings().GetLanguage();
+ SvNumberFormatter* pConverter = NULL;
+
+ ImpSvNumMultipleReadHeader aHdr( rStream );
+ USHORT nVersion;
+ rStream >> nVersion;
+ SvNumberformat* pEntry;
+ sal_uInt32 nPos;
+ LanguageType eSaveSysLang, eLoadSysLang;
+ USHORT nSysOnStore, eLge, eDummy; // Dummy fuer kompatibles Format
+ rStream >> nSysOnStore >> eLge; // Systemeinstellung aus
+ // Dokument
+ eSaveSysLang = (nVersion < SV_NUMBERFORMATTER_VERSION_SYSTORE ?
+ LANGUAGE_SYSTEM : (LanguageType) nSysOnStore);
+ LanguageType eLnge = (LanguageType) eLge;
+ ImpChangeSysCL( eLnge, TRUE );
+
+ rStream >> nPos;
+ while (nPos != NUMBERFORMAT_ENTRY_NOT_FOUND)
+ {
+ rStream >> eDummy >> eLge;
+ eLnge = (LanguageType) eLge;
+ ImpGenerateCL( eLnge, TRUE ); // ggfs. neue Standardformate anlegen
+
+ sal_uInt32 nOffset = nPos % SV_COUNTRY_LANGUAGE_OFFSET; // relativIndex
+ BOOL bUserDefined = (nOffset > SV_MAX_ANZ_STANDARD_FORMATE);
+ //! HACK! ER 29.07.97 15:15
+ // SaveLang wurde bei SYSTEM nicht gespeichert sondern war auch SYSTEM,
+ // erst ab 364i Unterscheidung moeglich
+ BOOL bConversionHack;
+ if ( eLnge == LANGUAGE_SYSTEM )
+ {
+ if ( nVersion < SV_NUMBERFORMATTER_VERSION_SYSTORE )
+ {
+ bConversionHack = bUserDefined;
+ eLoadSysLang = eSaveSysLang;
+ }
+ else
+ {
+ bConversionHack = FALSE;
+ eLoadSysLang = eSysLang;
+ }
+ }
+ else
+ {
+ bConversionHack = FALSE;
+ eLoadSysLang = eSaveSysLang;
+ }
+
+ pEntry = new SvNumberformat(*pFormatScanner, eLnge);
+ if ( bConversionHack )
+ { // SYSTEM
+ // nVersion < SV_NUMBERFORMATTER_VERSION_SYSTORE
+ // nVersion < SV_NUMBERFORMATTER_VERSION_KEYWORDS
+ if ( !pConverter )
+ pConverter = new SvNumberFormatter( xServiceManager, eSysLang );
+ NfHackConversion eHackConversion = pEntry->Load(
+ rStream, aHdr, pConverter, *pStringScanner );
+ switch ( eHackConversion )
+ {
+ case NF_CONVERT_GERMAN_ENGLISH :
+ pEntry->ConvertLanguage( *pConverter,
+ LANGUAGE_ENGLISH_US, eSysLang, TRUE );
+ break;
+ case NF_CONVERT_ENGLISH_GERMAN :
+ switch ( eSysLang )
+ {
+ case LANGUAGE_GERMAN:
+ case LANGUAGE_GERMAN_SWISS:
+ case LANGUAGE_GERMAN_AUSTRIAN:
+ case LANGUAGE_GERMAN_LUXEMBOURG:
+ case LANGUAGE_GERMAN_LIECHTENSTEIN:
+ // alles beim alten
+ break;
+ default:
+ pEntry->ConvertLanguage( *pConverter,
+ LANGUAGE_GERMAN, eSysLang, TRUE );
+ }
+ break;
+ case NF_CONVERT_NONE :
+ break; // -Wall not handled.
+ }
+
+ }
+ else
+ {
+ pEntry->Load( rStream, aHdr, NULL, *pStringScanner );
+ if ( !bUserDefined )
+ bUserDefined = (pEntry->GetNewStandardDefined() > SV_NUMBERFORMATTER_VERSION);
+ if ( bUserDefined )
+ {
+ if ( eSaveSysLang != eLoadSysLang )
+ { // SYSTEM verschieden
+ if ( !pConverter )
+ pConverter = new SvNumberFormatter( xServiceManager, eSysLang );
+ if ( nVersion < SV_NUMBERFORMATTER_VERSION_KEYWORDS )
+ {
+ switch ( eSaveSysLang )
+ {
+ case LANGUAGE_GERMAN:
+ case LANGUAGE_GERMAN_SWISS:
+ case LANGUAGE_GERMAN_AUSTRIAN:
+ case LANGUAGE_GERMAN_LUXEMBOURG:
+ case LANGUAGE_GERMAN_LIECHTENSTEIN:
+ // alles beim alten
+ pEntry->ConvertLanguage( *pConverter,
+ eSaveSysLang, eLoadSysLang, TRUE );
+ break;
+ default:
+ // alte english nach neuem anderen
+ pEntry->ConvertLanguage( *pConverter,
+ LANGUAGE_ENGLISH_US, eLoadSysLang, TRUE );
+ }
+ }
+ else
+ pEntry->ConvertLanguage( *pConverter,
+ eSaveSysLang, eLoadSysLang, TRUE );
+ }
+ else
+ { // nicht SYSTEM oder gleiches SYSTEM
+ if ( nVersion < SV_NUMBERFORMATTER_VERSION_KEYWORDS )
+ {
+ LanguageType eLoadLang;
+ BOOL bSystem;
+ if ( eLnge == LANGUAGE_SYSTEM )
+ {
+ eLoadLang = eSysLang;
+ bSystem = TRUE;
+ }
+ else
+ {
+ eLoadLang = eLnge;
+ bSystem = FALSE;
+ }
+ switch ( eLoadLang )
+ {
+ case LANGUAGE_GERMAN:
+ case LANGUAGE_GERMAN_SWISS:
+ case LANGUAGE_GERMAN_AUSTRIAN:
+ case LANGUAGE_GERMAN_LUXEMBOURG:
+ case LANGUAGE_GERMAN_LIECHTENSTEIN:
+ // alles beim alten
+ break;
+ default:
+ // alte english nach neuem anderen
+ if ( !pConverter )
+ pConverter = new SvNumberFormatter( xServiceManager, eSysLang );
+ pEntry->ConvertLanguage( *pConverter,
+ LANGUAGE_ENGLISH_US, eLoadLang, bSystem );
+ }
+ }
+ }
+ }
+ }
+ if ( nOffset == 0 ) // StandardFormat
+ {
+ SvNumberformat* pEnt = aFTable.Get(nPos);
+ if (pEnt)
+ pEnt->SetLastInsertKey(pEntry->GetLastInsertKey());
+ }
+ if (!aFTable.Insert(nPos, pEntry))
+ delete pEntry;
+ rStream >> nPos;
+ }
+
+ // ab SV_NUMBERFORMATTER_VERSION_YEAR2000
+ if ( nVersion >= SV_NUMBERFORMATTER_VERSION_YEAR2000 )
+ {
+ aHdr.StartEntry();
+ if ( aHdr.BytesLeft() >= sizeof(UINT16) )
+ {
+ UINT16 nY2k;
+ rStream >> nY2k;
+ if ( nVersion < SV_NUMBERFORMATTER_VERSION_TWODIGITYEAR && nY2k < 100 )
+ nY2k += 1901; // war vor src513e: 29, jetzt: 1930
+ SetYear2000( nY2k );
+ }
+ aHdr.EndEntry();
+ }
+
+ if ( pConverter )
+ delete pConverter;
+
+ // generate additional i18n standard formats for all used locales
+ LanguageType eOldLanguage = ActLnge;
+ NumberFormatCodeWrapper aNumberFormatCode( xServiceManager, GetLocale() );
+ SvUShorts aList;
+ GetUsedLanguages( aList );
+ USHORT nCount = aList.Count();
+ for ( USHORT j=0; j<nCount; j++ )
+ {
+ LanguageType eLang = aList[j];
+ ChangeIntl( eLang );
+ sal_uInt32 CLOffset = ImpGetCLOffset( eLang );
+ ImpGenerateAdditionalFormats( CLOffset, aNumberFormatCode, TRUE );
+ }
+ ChangeIntl( eOldLanguage );
+
+ if (rStream.GetError())
+ return FALSE;
+ else
+ return TRUE;
+}
+
+BOOL SvNumberFormatter::Save( SvStream& rStream ) const
+{
+ ImpSvNumMultipleWriteHeader aHdr( rStream );
+ // ab 364i wird gespeichert was SYSTEM wirklich war, vorher hart LANGUAGE_SYSTEM
+ rStream << (USHORT) SV_NUMBERFORMATTER_VERSION;
+ rStream << (USHORT) Application::GetSettings().GetLanguage() << (USHORT) IniLnge;
+ SvNumberFormatTable* pTable = (SvNumberFormatTable*) &aFTable;
+ SvNumberformat* pEntry = (SvNumberformat*) pTable->First();
+ while (pEntry)
+ {
+ // Gespeichert werden alle markierten, benutzerdefinierten Formate und
+ // jeweils das Standardformat zu allen angewaehlten CL-Kombinationen
+ // sowie NewStandardDefined
+ if ( pEntry->GetUsed() || (pEntry->GetType() & NUMBERFORMAT_DEFINED) ||
+ pEntry->GetNewStandardDefined() ||
+ (pTable->GetCurKey() % SV_COUNTRY_LANGUAGE_OFFSET == 0) )
+ {
+ rStream << static_cast<sal_uInt32>(pTable->GetCurKey())
+ << (USHORT) LANGUAGE_SYSTEM
+ << (USHORT) pEntry->GetLanguage();
+ pEntry->Save(rStream, aHdr);
+ }
+ pEntry = (SvNumberformat*) pTable->Next();
+ }
+ rStream << NUMBERFORMAT_ENTRY_NOT_FOUND; // EndeKennung
+
+ // ab SV_NUMBERFORMATTER_VERSION_YEAR2000
+ aHdr.StartEntry();
+ rStream << (UINT16) GetYear2000();
+ aHdr.EndEntry();
+
+ if (rStream.GetError())
+ return FALSE;
+ else
+ return TRUE;
+}
+
+// static
+void SvNumberFormatter::SkipNumberFormatterInStream( SvStream& rStream )
+{
+ ImpSvNumMultipleReadHeader::Skip( rStream );
+}
+
+void SvNumberFormatter::GetUsedLanguages( SvUShorts& rList )
+{
+ rList.Remove( 0, rList.Count() );
+
+ sal_uInt32 nOffset = 0;
+ while (nOffset <= MaxCLOffset)
+ {
+ SvNumberformat* pFormat = (SvNumberformat*) aFTable.Get(nOffset);
+ if (pFormat)
+ rList.Insert( pFormat->GetLanguage(), rList.Count() );
+ nOffset += SV_COUNTRY_LANGUAGE_OFFSET;
+ }
+}
+
+
+String SvNumberFormatter::GetKeyword( LanguageType eLnge, USHORT nIndex )
+{
+ ChangeIntl(eLnge);
+ const String* pTable = pFormatScanner->GetKeywords();
+ if ( pTable && nIndex < NF_KEYWORD_ENTRIES_COUNT )
+ return pTable[nIndex];
+
+ DBG_ERROR("GetKeyword: invalid index");
+ return String();
+}
+
+
+String SvNumberFormatter::GetStandardName( LanguageType eLnge )
+{
+ ChangeIntl( eLnge );
+ return pFormatScanner->GetStandardName();
+}
+
+
+sal_uInt32 SvNumberFormatter::ImpGetCLOffset(LanguageType eLnge) const
+{
+ SvNumberformat* pFormat;
+ sal_uInt32 nOffset = 0;
+ while (nOffset <= MaxCLOffset)
+ {
+ pFormat = (SvNumberformat*) aFTable.Get(nOffset);
+ if (pFormat && pFormat->GetLanguage() == eLnge)
+ return nOffset;
+ nOffset += SV_COUNTRY_LANGUAGE_OFFSET;
+ }
+ return nOffset;
+}
+
+sal_uInt32 SvNumberFormatter::ImpIsEntry(const String& rString,
+ sal_uInt32 nCLOffset,
+ LanguageType eLnge)
+{
+#ifndef NF_COMMENT_IN_FORMATSTRING
+#error NF_COMMENT_IN_FORMATSTRING not defined (zformat.hxx)
+#endif
+#if NF_COMMENT_IN_FORMATSTRING
+ String aStr( rString );
+ SvNumberformat::EraseComment( aStr );
+#endif
+ sal_uInt32 res = NUMBERFORMAT_ENTRY_NOT_FOUND;
+ SvNumberformat* pEntry;
+ pEntry = (SvNumberformat*) aFTable.Seek(nCLOffset);
+ while ( res == NUMBERFORMAT_ENTRY_NOT_FOUND &&
+ pEntry && pEntry->GetLanguage() == eLnge )
+ {
+#if NF_COMMENT_IN_FORMATSTRING
+ if ( pEntry->GetComment().Len() )
+ {
+ String aFormat( pEntry->GetFormatstring() );
+ SvNumberformat::EraseComment( aFormat );
+ if ( aStr == aFormat )
+ res = aFTable.GetCurKey();
+ else
+ pEntry = (SvNumberformat*) aFTable.Next();
+ }
+ else
+ {
+ if ( aStr == pEntry->GetFormatstring() )
+ res = aFTable.GetCurKey();
+ else
+ pEntry = (SvNumberformat*) aFTable.Next();
+ }
+#else
+ if ( rString == pEntry->GetFormatstring() )
+ res = aFTable.GetCurKey();
+ else
+ pEntry = (SvNumberformat*) aFTable.Next();
+#endif
+ }
+ return res;
+}
+
+sal_uInt32 SvNumberFormatter::ImpGenerateCL( LanguageType eLnge, BOOL bLoadingSO5 )
+{
+ ChangeIntl(eLnge);
+ sal_uInt32 CLOffset = ImpGetCLOffset(ActLnge);
+ if (CLOffset > MaxCLOffset)
+ { // new CL combination
+ if (LocaleDataWrapper::areChecksEnabled())
+ {
+ Locale aLoadedLocale = xLocaleData->getLoadedLocale();
+ if ( aLoadedLocale.Language != aLocale.Language ||
+ aLoadedLocale.Country != aLocale.Country )
+ {
+ String aMsg( RTL_CONSTASCII_USTRINGPARAM(
+ "SvNumerFormatter::ImpGenerateCL: locales don't match:"));
+ LocaleDataWrapper::outputCheckMessage(
+ xLocaleData->appendLocaleInfo( aMsg ));
+ }
+ // test XML locale data FormatElement entries
+ {
+ uno::Sequence< i18n::FormatElement > xSeq =
+ xLocaleData->getAllFormats();
+ // A test for completeness of formatindex="0" ...
+ // formatindex="47" is not needed here since it is done in
+ // ImpGenerateFormats().
+
+ // Test for dupes of formatindex="..."
+ for ( sal_Int32 j = 0; j < xSeq.getLength(); j++ )
+ {
+ sal_Int16 nIdx = xSeq[j].formatIndex;
+ String aDupes;
+ for ( sal_Int32 i = 0; i < xSeq.getLength(); i++ )
+ {
+ if ( i != j && xSeq[i].formatIndex == nIdx )
+ {
+ aDupes += String::CreateFromInt32( i );
+ aDupes += '(';
+ aDupes += String( xSeq[i].formatKey );
+ aDupes += ')';
+ aDupes += ' ';
+ }
+ }
+ if ( aDupes.Len() )
+ {
+ String aMsg( RTL_CONSTASCII_USTRINGPARAM(
+ "XML locale data FormatElement formatindex dupe: "));
+ aMsg += String::CreateFromInt32( nIdx );
+ aMsg.AppendAscii( RTL_CONSTASCII_STRINGPARAM(
+ "\nFormatElements: "));
+ aMsg += String::CreateFromInt32( j );
+ aMsg += '(';
+ aMsg += String( xSeq[j].formatKey );
+ aMsg += ')';
+ aMsg += ' ';
+ aMsg += aDupes;
+ LocaleDataWrapper::outputCheckMessage(
+ xLocaleData->appendLocaleInfo( aMsg ));
+ }
+ }
+ }
+ }
+
+ MaxCLOffset += SV_COUNTRY_LANGUAGE_OFFSET;
+ ImpGenerateFormats( MaxCLOffset, bLoadingSO5 );
+ CLOffset = MaxCLOffset;
+ }
+ return CLOffset;
+}
+
+SvNumberFormatTable& SvNumberFormatter::ChangeCL(short eType,
+ sal_uInt32& FIndex,
+ LanguageType eLnge)
+{
+ ImpGenerateCL(eLnge);
+ return GetEntryTable(eType, FIndex, ActLnge);
+}
+
+SvNumberFormatTable& SvNumberFormatter::GetEntryTable(
+ short eType,
+ sal_uInt32& FIndex,
+ LanguageType eLnge)
+{
+ if ( pFormatTable )
+ pFormatTable->Clear();
+ else
+ pFormatTable = new SvNumberFormatTable;
+ ChangeIntl(eLnge);
+ sal_uInt32 CLOffset = ImpGetCLOffset(ActLnge);
+
+ // Might generate and insert a default format for the given type
+ // (e.g. currency) => has to be done before collecting formats.
+ sal_uInt32 nDefaultIndex = GetStandardFormat( eType, ActLnge );
+
+ SvNumberformat* pEntry;
+ pEntry = (SvNumberformat*) aFTable.Seek(CLOffset);
+
+ if (eType == NUMBERFORMAT_ALL)
+ {
+ while (pEntry && pEntry->GetLanguage() == ActLnge)
+ { // copy all entries to output table
+ pFormatTable->Insert( aFTable.GetCurKey(), pEntry );
+ pEntry = (SvNumberformat*) aFTable.Next();
+ }
+ }
+ else
+ {
+ while (pEntry && pEntry->GetLanguage() == ActLnge)
+ { // copy entries of queried type to output table
+ if ((pEntry->GetType()) & eType)
+ pFormatTable->Insert(aFTable.GetCurKey(),pEntry);
+ pEntry = (SvNumberformat*) aFTable.Next();
+ }
+ }
+ if ( pFormatTable->Count() > 0 )
+ { // select default if queried format doesn't exist or queried type or
+ // language differ from existing format
+ pEntry = aFTable.Get(FIndex);
+ if ( !pEntry || !(pEntry->GetType() & eType) || pEntry->GetLanguage() != ActLnge )
+ FIndex = nDefaultIndex;
+ }
+ return *pFormatTable;
+}
+
+BOOL SvNumberFormatter::IsNumberFormat(const String& sString,
+ sal_uInt32& F_Index,
+ double& fOutNumber)
+{
+ short FType;
+ const SvNumberformat* pFormat = (SvNumberformat*) aFTable.Get(F_Index);
+ if (!pFormat)
+ {
+// DBG_ERROR("SvNumberFormatter:: Unbekanntes altes Zahlformat (2)");
+ ChangeIntl(IniLnge);
+ FType = NUMBERFORMAT_NUMBER;
+ }
+ else
+ {
+ FType = pFormat->GetType() &~NUMBERFORMAT_DEFINED;
+ if (FType == 0)
+ FType = NUMBERFORMAT_DEFINED;
+ ChangeIntl(pFormat->GetLanguage());
+ }
+ BOOL res;
+ short RType = FType;
+ // Ergebnistyp
+ // ohne def-Kennung
+ if (RType == NUMBERFORMAT_TEXT) // Zahlzelle ->Stringz.
+ res = FALSE;
+ else
+ res = pStringScanner->IsNumberFormat(sString, RType, fOutNumber, pFormat);
+
+ if (res && !IsCompatible(FType, RType)) // unpassender Typ
+ {
+ switch ( RType )
+ {
+ case NUMBERFORMAT_TIME :
+ {
+ if ( pStringScanner->GetDecPos() )
+ { // 100stel Sekunden
+ if ( pStringScanner->GetAnzNums() > 3 || fOutNumber < 0.0 )
+ F_Index = GetFormatIndex( NF_TIME_HH_MMSS00, ActLnge );
+ else
+ F_Index = GetFormatIndex( NF_TIME_MMSS00, ActLnge );
+ }
+ else if ( fOutNumber >= 1.0 || fOutNumber < 0.0 )
+ F_Index = GetFormatIndex( NF_TIME_HH_MMSS, ActLnge );
+ else
+ F_Index = GetStandardFormat( RType, ActLnge );
+ }
+ break;
+ default:
+ F_Index = GetStandardFormat( RType, ActLnge );
+ }
+ }
+ return res;
+}
+
+BOOL SvNumberFormatter::IsCompatible(short eOldType,
+ short eNewType)
+{
+ if (eOldType == eNewType)
+ return TRUE;
+ else if (eOldType == NUMBERFORMAT_DEFINED)
+ return TRUE;
+ else
+ {
+ switch (eNewType)
+ {
+ case NUMBERFORMAT_NUMBER:
+ {
+ switch (eOldType)
+ {
+ case NUMBERFORMAT_PERCENT:
+ case NUMBERFORMAT_CURRENCY:
+ case NUMBERFORMAT_SCIENTIFIC:
+ case NUMBERFORMAT_FRACTION:
+// case NUMBERFORMAT_LOGICAL:
+ case NUMBERFORMAT_DEFINED:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+ }
+ break;
+ case NUMBERFORMAT_DATE:
+ {
+ switch (eOldType)
+ {
+ case NUMBERFORMAT_DATETIME:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+ }
+ break;
+ case NUMBERFORMAT_TIME:
+ {
+ switch (eOldType)
+ {
+ case NUMBERFORMAT_DATETIME:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+ }
+ break;
+ case NUMBERFORMAT_DATETIME:
+ {
+ switch (eOldType)
+ {
+ case NUMBERFORMAT_TIME:
+ case NUMBERFORMAT_DATE:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+ }
+ break;
+ default:
+ return FALSE;
+ }
+ return FALSE;
+ }
+}
+
+
+sal_uInt32 SvNumberFormatter::ImpGetDefaultFormat( short nType )
+{
+ sal_uInt32 CLOffset = ImpGetCLOffset( ActLnge );
+ sal_uInt32 nSearch;
+ switch( nType )
+ {
+ case NUMBERFORMAT_DATE :
+ nSearch = CLOffset + ZF_STANDARD_DATE;
+ break;
+ case NUMBERFORMAT_TIME :
+ nSearch = CLOffset + ZF_STANDARD_TIME;
+ break;
+ case NUMBERFORMAT_DATETIME :
+ nSearch = CLOffset + ZF_STANDARD_DATETIME;
+ break;
+ case NUMBERFORMAT_PERCENT :
+ nSearch = CLOffset + ZF_STANDARD_PERCENT;
+ break;
+ case NUMBERFORMAT_SCIENTIFIC:
+ nSearch = CLOffset + ZF_STANDARD_SCIENTIFIC;
+ break;
+ default:
+ nSearch = CLOffset + ZF_STANDARD;
+ }
+ sal_uInt32 nDefaultFormat = (sal_uInt32)(sal_uIntPtr) aDefaultFormatKeys.Get( nSearch );
+ if ( !nDefaultFormat )
+ nDefaultFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
+ if ( nDefaultFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
+ { // look for a defined standard
+ sal_uInt32 nStopKey = CLOffset + SV_COUNTRY_LANGUAGE_OFFSET;
+ sal_uInt32 nKey;
+ aFTable.Seek( CLOffset );
+ while ( (nKey = aFTable.GetCurKey()) >= CLOffset && nKey < nStopKey )
+ {
+ const SvNumberformat* pEntry =
+ (const SvNumberformat*) aFTable.GetCurObject();
+ if ( pEntry->IsStandard() && ((pEntry->GetType() &
+ ~NUMBERFORMAT_DEFINED) == nType) )
+ {
+ nDefaultFormat = nKey;
+ break; // while
+ }
+ aFTable.Next();
+ }
+
+ if ( nDefaultFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
+ { // none found, use old fixed standards
+ switch( nType )
+ {
+ case NUMBERFORMAT_DATE :
+ nDefaultFormat = CLOffset + ZF_STANDARD_DATE;
+ break;
+ case NUMBERFORMAT_TIME :
+ nDefaultFormat = CLOffset + ZF_STANDARD_TIME+1;
+ break;
+ case NUMBERFORMAT_DATETIME :
+ nDefaultFormat = CLOffset + ZF_STANDARD_DATETIME;
+ break;
+ case NUMBERFORMAT_PERCENT :
+ nDefaultFormat = CLOffset + ZF_STANDARD_PERCENT+1;
+ break;
+ case NUMBERFORMAT_SCIENTIFIC:
+ nDefaultFormat = CLOffset + ZF_STANDARD_SCIENTIFIC;
+ break;
+ default:
+ nDefaultFormat = CLOffset + ZF_STANDARD;
+ }
+ }
+ aDefaultFormatKeys.Insert( nSearch, (void*) nDefaultFormat );
+ }
+ return nDefaultFormat;
+}
+
+
+sal_uInt32 SvNumberFormatter::GetStandardFormat( short eType, LanguageType eLnge )
+{
+ sal_uInt32 CLOffset = ImpGenerateCL(eLnge);
+ switch(eType)
+ {
+ case NUMBERFORMAT_CURRENCY :
+ {
+ if ( eLnge == LANGUAGE_SYSTEM )
+ return ImpGetDefaultSystemCurrencyFormat();
+ else
+ return ImpGetDefaultCurrencyFormat();
+ }
+ case NUMBERFORMAT_DATE :
+ case NUMBERFORMAT_TIME :
+ case NUMBERFORMAT_DATETIME :
+ case NUMBERFORMAT_PERCENT :
+ case NUMBERFORMAT_SCIENTIFIC:
+ return ImpGetDefaultFormat( eType );
+
+ case NUMBERFORMAT_FRACTION : return CLOffset + ZF_STANDARD_FRACTION;
+ case NUMBERFORMAT_LOGICAL : return CLOffset + ZF_STANDARD_LOGICAL;
+ case NUMBERFORMAT_TEXT : return CLOffset + ZF_STANDARD_TEXT;
+ case NUMBERFORMAT_ALL :
+ case NUMBERFORMAT_DEFINED :
+ case NUMBERFORMAT_NUMBER :
+ case NUMBERFORMAT_UNDEFINED :
+ default : return CLOffset + ZF_STANDARD;
+ }
+}
+
+BOOL SvNumberFormatter::IsSpecialStandardFormat( sal_uInt32 nFIndex,
+ LanguageType eLnge )
+{
+ return
+ nFIndex == GetFormatIndex( NF_TIME_MMSS00, eLnge ) ||
+ nFIndex == GetFormatIndex( NF_TIME_HH_MMSS00, eLnge ) ||
+ nFIndex == GetFormatIndex( NF_TIME_HH_MMSS, eLnge )
+ ;
+}
+
+sal_uInt32 SvNumberFormatter::GetStandardFormat( sal_uInt32 nFIndex, short eType,
+ LanguageType eLnge )
+{
+ if ( IsSpecialStandardFormat( nFIndex, eLnge ) )
+ return nFIndex;
+ else
+ return GetStandardFormat( eType, eLnge );
+}
+
+sal_uInt32 SvNumberFormatter::GetStandardFormat( double fNumber, sal_uInt32 nFIndex,
+ short eType, LanguageType eLnge )
+{
+ if ( IsSpecialStandardFormat( nFIndex, eLnge ) )
+ return nFIndex;
+
+ switch( eType )
+ {
+ case NUMBERFORMAT_TIME :
+ {
+ BOOL bSign;
+ if ( fNumber < 0.0 )
+ {
+ bSign = TRUE;
+ fNumber = -fNumber;
+ }
+ else
+ bSign = FALSE;
+ double fSeconds = fNumber * 86400;
+ if ( floor( fSeconds + 0.5 ) * 100 != floor( fSeconds * 100 + 0.5 ) )
+ { // mit 100stel Sekunden
+ if ( bSign || fSeconds >= 3600 )
+ return GetFormatIndex( NF_TIME_HH_MMSS00, eLnge );
+ else
+ return GetFormatIndex( NF_TIME_MMSS00, eLnge );
+ }
+ else
+ {
+ if ( bSign || fNumber >= 1.0 )
+ return GetFormatIndex( NF_TIME_HH_MMSS, eLnge );
+ else
+ return GetStandardFormat( eType, eLnge );
+ }
+ }
+ default:
+ return GetStandardFormat( eType, eLnge );
+ }
+}
+
+void SvNumberFormatter::GetInputLineString(const double& fOutNumber,
+ sal_uInt32 nFIndex,
+ String& sOutString)
+{
+ SvNumberformat* pFormat;
+ short nOldPrec;
+ Color* pColor;
+ pFormat = (SvNumberformat*) aFTable.Get(nFIndex);
+ if (!pFormat)
+ pFormat = aFTable.Get(ZF_STANDARD);
+ LanguageType eLang = pFormat->GetLanguage();
+ ChangeIntl( eLang );
+ short eType = pFormat->GetType() & ~NUMBERFORMAT_DEFINED;
+ if (eType == 0)
+ eType = NUMBERFORMAT_DEFINED;
+ nOldPrec = -1;
+ if (eType == NUMBERFORMAT_NUMBER || eType == NUMBERFORMAT_PERCENT
+ || eType == NUMBERFORMAT_CURRENCY
+ || eType == NUMBERFORMAT_SCIENTIFIC
+ || eType == NUMBERFORMAT_FRACTION)
+ {
+ if (eType != NUMBERFORMAT_PERCENT) // spaeter Sonderbehandlung %
+ eType = NUMBERFORMAT_NUMBER;
+ nOldPrec = pFormatScanner->GetStandardPrec();
+ ChangeStandardPrec(300); // Merkwert
+ }
+ sal_uInt32 nKey = nFIndex;
+ switch ( eType )
+ { // #61619# immer vierstelliges Jahr editieren
+ case NUMBERFORMAT_DATE :
+ nKey = GetFormatIndex( NF_DATE_SYS_DDMMYYYY, eLang );
+ break;
+ case NUMBERFORMAT_DATETIME :
+ nKey = GetFormatIndex( NF_DATETIME_SYS_DDMMYYYY_HHMMSS, eLang );
+ break;
+ default:
+ nKey = GetStandardFormat( fOutNumber, nFIndex, eType, eLang );
+ }
+ if ( nKey != nFIndex )
+ pFormat = (SvNumberformat*) aFTable.Get( nKey );
+ if (pFormat)
+ {
+ if ( eType == NUMBERFORMAT_TIME && pFormat->GetFormatPrecision() )
+ {
+ nOldPrec = pFormatScanner->GetStandardPrec();
+ ChangeStandardPrec(300); // Merkwert
+ }
+ pFormat->GetOutputString(fOutNumber, sOutString, &pColor);
+ }
+ if (nOldPrec != -1)
+ ChangeStandardPrec(nOldPrec);
+}
+
+void SvNumberFormatter::GetOutputString(const double& fOutNumber,
+ sal_uInt32 nFIndex,
+ String& sOutString,
+ Color** ppColor)
+{
+ if (bNoZero && fOutNumber == 0.0)
+ {
+ sOutString.Erase();
+ return;
+ }
+ SvNumberformat* pFormat = (SvNumberformat*) aFTable.Get(nFIndex);
+ if (!pFormat)
+ pFormat = aFTable.Get(ZF_STANDARD);
+ ChangeIntl(pFormat->GetLanguage());
+ pFormat->GetOutputString(fOutNumber, sOutString, ppColor);
+}
+
+void SvNumberFormatter::GetOutputString(String& sString,
+ sal_uInt32 nFIndex,
+ String& sOutString,
+ Color** ppColor)
+{
+ SvNumberformat* pFormat = (SvNumberformat*) aFTable.Get(nFIndex);
+ if (!pFormat)
+ pFormat = aFTable.Get(ZF_STANDARD_TEXT);
+ if (!pFormat->IsTextFormat() && !pFormat->HasTextFormat())
+ {
+ *ppColor = NULL;
+ sOutString = sString;
+ }
+ else
+ {
+ ChangeIntl(pFormat->GetLanguage());
+ pFormat->GetOutputString(sString, sOutString, ppColor);
+ }
+}
+
+BOOL SvNumberFormatter::GetPreviewString(const String& sFormatString,
+ double fPreviewNumber,
+ String& sOutString,
+ Color** ppColor,
+ LanguageType eLnge)
+{
+ if (sFormatString.Len() == 0) // keinen Leerstring
+ return FALSE;
+
+ xub_StrLen nCheckPos = STRING_NOTFOUND;
+ sal_uInt32 nKey;
+ if (eLnge == LANGUAGE_DONTKNOW)
+ eLnge = IniLnge;
+ ChangeIntl(eLnge); // ggfs. austauschen
+ eLnge = ActLnge;
+ String sTmpString = sFormatString;
+ SvNumberformat* p_Entry = new SvNumberformat(sTmpString,
+ pFormatScanner,
+ pStringScanner,
+ nCheckPos,
+ eLnge);
+ if (nCheckPos == 0) // String ok
+ {
+ sal_uInt32 CLOffset = ImpGenerateCL(eLnge); // ggfs. neu Standard-
+ // formate anlegen
+ nKey = ImpIsEntry(p_Entry->GetFormatstring(),CLOffset, eLnge);
+ if (nKey != NUMBERFORMAT_ENTRY_NOT_FOUND) // schon vorhanden
+ GetOutputString(fPreviewNumber,nKey,sOutString,ppColor);
+ else
+ p_Entry->GetOutputString(fPreviewNumber,sOutString, ppColor);
+ delete p_Entry;
+ return TRUE;
+ }
+ else
+ {
+ delete p_Entry;
+ return FALSE;
+ }
+}
+
+BOOL SvNumberFormatter::GetPreviewStringGuess( const String& sFormatString,
+ double fPreviewNumber,
+ String& sOutString,
+ Color** ppColor,
+ LanguageType eLnge )
+{
+ if (sFormatString.Len() == 0) // keinen Leerstring
+ return FALSE;
+
+ if (eLnge == LANGUAGE_DONTKNOW)
+ eLnge = IniLnge;
+
+ ChangeIntl( eLnge );
+ eLnge = ActLnge;
+ BOOL bEnglish = (eLnge == LANGUAGE_ENGLISH_US);
+
+ String aFormatStringUpper( pCharClass->upper( sFormatString ) );
+ sal_uInt32 nCLOffset = ImpGenerateCL( eLnge );
+ sal_uInt32 nKey = ImpIsEntry( aFormatStringUpper, nCLOffset, eLnge );
+ if ( nKey != NUMBERFORMAT_ENTRY_NOT_FOUND )
+ { // Zielformat vorhanden
+ GetOutputString( fPreviewNumber, nKey, sOutString, ppColor );
+ return TRUE;
+ }
+
+ SvNumberformat *pEntry = NULL;
+ xub_StrLen nCheckPos = STRING_NOTFOUND;
+ String sTmpString;
+
+ if ( bEnglish )
+ {
+ sTmpString = sFormatString;
+ pEntry = new SvNumberformat( sTmpString, pFormatScanner,
+ pStringScanner, nCheckPos, eLnge );
+ }
+ else
+ {
+ nCLOffset = ImpGenerateCL( LANGUAGE_ENGLISH_US );
+ nKey = ImpIsEntry( aFormatStringUpper, nCLOffset, LANGUAGE_ENGLISH_US );
+ BOOL bEnglishFormat = (nKey != NUMBERFORMAT_ENTRY_NOT_FOUND);
+
+ // try english --> other bzw. english nach other konvertieren
+ LanguageType eFormatLang = LANGUAGE_ENGLISH_US;
+ pFormatScanner->SetConvertMode( LANGUAGE_ENGLISH_US, eLnge );
+ sTmpString = sFormatString;
+ pEntry = new SvNumberformat( sTmpString, pFormatScanner,
+ pStringScanner, nCheckPos, eFormatLang );
+ pFormatScanner->SetConvertMode( FALSE );
+ ChangeIntl( eLnge );
+
+ if ( !bEnglishFormat )
+ {
+ if ( nCheckPos > 0 || xTransliteration->isEqual( sFormatString,
+ pEntry->GetFormatstring() ) )
+ { // other Format
+ delete pEntry;
+ sTmpString = sFormatString;
+ pEntry = new SvNumberformat( sTmpString, pFormatScanner,
+ pStringScanner, nCheckPos, eLnge );
+ }
+ else
+ { // verify english
+ xub_StrLen nCheckPos2 = STRING_NOTFOUND;
+ // try other --> english
+ eFormatLang = eLnge;
+ pFormatScanner->SetConvertMode( eLnge, LANGUAGE_ENGLISH_US );
+ sTmpString = sFormatString;
+ SvNumberformat* pEntry2 = new SvNumberformat( sTmpString, pFormatScanner,
+ pStringScanner, nCheckPos2, eFormatLang );
+ pFormatScanner->SetConvertMode( FALSE );
+ ChangeIntl( eLnge );
+ if ( nCheckPos2 == 0 && !xTransliteration->isEqual( sFormatString,
+ pEntry2->GetFormatstring() ) )
+ { // other Format
+ delete pEntry;
+ sTmpString = sFormatString;
+ pEntry = new SvNumberformat( sTmpString, pFormatScanner,
+ pStringScanner, nCheckPos, eLnge );
+ }
+ delete pEntry2;
+ }
+ }
+ }
+
+ if (nCheckPos == 0) // String ok
+ {
+ ImpGenerateCL( eLnge ); // ggfs. neu Standardformate anlegen
+ pEntry->GetOutputString( fPreviewNumber, sOutString, ppColor );
+ delete pEntry;
+ return TRUE;
+ }
+ delete pEntry;
+ return FALSE;
+}
+
+SvNumberformat* SvNumberFormatter::ImpInsertFormat(
+ const ::com::sun::star::i18n::NumberFormatCode& rCode,
+ sal_uInt32 nPos, BOOL bAfterLoadingSO5, sal_Int16 nOrgIndex )
+{
+ String aCodeStr( rCode.Code );
+ if ( rCode.Index < NF_INDEX_TABLE_ENTRIES &&
+ rCode.Usage == ::com::sun::star::i18n::KNumberFormatUsage::CURRENCY &&
+ rCode.Index != NF_CURRENCY_1000DEC2_CCC )
+ { // strip surrounding [$...] on automatic currency
+ if ( aCodeStr.SearchAscii( "[$" ) != STRING_NOTFOUND )
+ aCodeStr = SvNumberformat::StripNewCurrencyDelimiters( aCodeStr, FALSE );
+ else
+ {
+ if (LocaleDataWrapper::areChecksEnabled() &&
+ rCode.Index != NF_CURRENCY_1000DEC2_CCC )
+ {
+ String aMsg( RTL_CONSTASCII_USTRINGPARAM(
+ "SvNumberFormatter::ImpInsertFormat: no [$...] on currency format code, index "));
+ aMsg += String::CreateFromInt32( rCode.Index );
+ aMsg.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ":\n"));
+ aMsg += String( rCode.Code );
+ LocaleDataWrapper::outputCheckMessage(
+ xLocaleData->appendLocaleInfo( aMsg));
+ }
+ }
+ }
+ xub_StrLen nCheckPos = 0;
+ SvNumberformat* pFormat = new SvNumberformat(aCodeStr,
+ pFormatScanner,
+ pStringScanner,
+ nCheckPos,
+ ActLnge);
+ if ( !pFormat || nCheckPos > 0 )
+ {
+ if (LocaleDataWrapper::areChecksEnabled())
+ {
+ String aMsg( RTL_CONSTASCII_USTRINGPARAM(
+ "SvNumberFormatter::ImpInsertFormat: bad format code, index "));
+ aMsg += String::CreateFromInt32( rCode.Index );
+ aMsg += '\n';
+ aMsg += String( rCode.Code );
+ LocaleDataWrapper::outputCheckMessage(
+ xLocaleData->appendLocaleInfo( aMsg));
+ }
+ delete pFormat;
+ return NULL;
+ }
+ if ( rCode.Index >= NF_INDEX_TABLE_ENTRIES )
+ {
+ sal_uInt32 nCLOffset = nPos - (nPos % SV_COUNTRY_LANGUAGE_OFFSET);
+ sal_uInt32 nKey = ImpIsEntry( aCodeStr, nCLOffset, ActLnge );
+ if ( nKey != NUMBERFORMAT_ENTRY_NOT_FOUND )
+ {
+ if (LocaleDataWrapper::areChecksEnabled())
+ {
+ switch ( nOrgIndex )
+ {
+ // These may be dupes of integer versions for locales where
+ // currencies have no decimals like Italian Lira.
+ case NF_CURRENCY_1000DEC2 : // NF_CURRENCY_1000INT
+ case NF_CURRENCY_1000DEC2_RED : // NF_CURRENCY_1000INT_RED
+ case NF_CURRENCY_1000DEC2_DASHED : // NF_CURRENCY_1000INT_RED
+ break;
+ default:
+ if ( !bAfterLoadingSO5 )
+ { // If bAfterLoadingSO5 there will definitely be some dupes,
+ // don't cry. But we need this test for verification of locale
+ // data if not loading old SO5 documents.
+ String aMsg( RTL_CONSTASCII_USTRINGPARAM(
+ "SvNumberFormatter::ImpInsertFormat: dup format code, index "));
+ aMsg += String::CreateFromInt32( rCode.Index );
+ aMsg += '\n';
+ aMsg += String( rCode.Code );
+ LocaleDataWrapper::outputCheckMessage(
+ xLocaleData->appendLocaleInfo( aMsg));
+ }
+ }
+ }
+ delete pFormat;
+ return NULL;
+ }
+ else if ( nPos - nCLOffset >= SV_COUNTRY_LANGUAGE_OFFSET )
+ {
+ if (LocaleDataWrapper::areChecksEnabled())
+ {
+ String aMsg( RTL_CONSTASCII_USTRINGPARAM(
+ "SvNumberFormatter::ImpInsertFormat: too many format codes, index "));
+ aMsg += String::CreateFromInt32( rCode.Index );
+ aMsg += '\n';
+ aMsg += String( rCode.Code );
+ LocaleDataWrapper::outputCheckMessage(
+ xLocaleData->appendLocaleInfo( aMsg));
+ }
+ delete pFormat;
+ return NULL;
+ }
+ }
+ if ( !aFTable.Insert( nPos, pFormat ) )
+ {
+ if (LocaleDataWrapper::areChecksEnabled())
+ {
+ String aMsg( RTL_CONSTASCII_USTRINGPARAM(
+ "ImpInsertFormat: can't insert number format key pos: "));
+ aMsg += String::CreateFromInt32( nPos );
+ aMsg.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ", code index "));
+ aMsg += String::CreateFromInt32( rCode.Index );
+ aMsg += '\n';
+ aMsg += String( rCode.Code );
+ LocaleDataWrapper::outputCheckMessage(
+ xLocaleData->appendLocaleInfo( aMsg));
+ }
+ delete pFormat;
+ return NULL;
+ }
+ if ( rCode.Default )
+ pFormat->SetStandard();
+ if ( rCode.DefaultName.getLength() )
+ pFormat->SetComment( rCode.DefaultName );
+ return pFormat;
+}
+
+SvNumberformat* SvNumberFormatter::ImpInsertNewStandardFormat(
+ const ::com::sun::star::i18n::NumberFormatCode& rCode,
+ sal_uInt32 nPos, USHORT nVersion, BOOL bAfterLoadingSO5,
+ sal_Int16 nOrgIndex )
+{
+ SvNumberformat* pNewFormat = ImpInsertFormat( rCode, nPos,
+ bAfterLoadingSO5, nOrgIndex );
+ if (pNewFormat)
+ pNewFormat->SetNewStandardDefined( nVersion );
+ // so that it gets saved, displayed properly, and converted by old versions
+ return pNewFormat;
+}
+
+void SvNumberFormatter::GetFormatSpecialInfo(sal_uInt32 nFormat,
+ BOOL& bThousand,
+ BOOL& IsRed,
+ USHORT& nPrecision,
+ USHORT& nAnzLeading)
+
+{
+ const SvNumberformat* pFormat = aFTable.Get(nFormat);
+ if (pFormat)
+ pFormat->GetFormatSpecialInfo(bThousand, IsRed,
+ nPrecision, nAnzLeading);
+ else
+ {
+ bThousand = FALSE;
+ IsRed = FALSE;
+ nPrecision = pFormatScanner->GetStandardPrec();
+ nAnzLeading = 0;
+ }
+}
+
+USHORT SvNumberFormatter::GetFormatPrecision( sal_uInt32 nFormat ) const
+{
+ const SvNumberformat* pFormat = aFTable.Get( nFormat );
+ if ( pFormat )
+ return pFormat->GetFormatPrecision();
+ else
+ return pFormatScanner->GetStandardPrec();
+}
+
+
+inline sal_uInt32 SetIndexTable( NfIndexTableOffset nTabOff, sal_uInt32 nIndOff )
+{
+ if ( !bIndexTableInitialized )
+ {
+ DBG_ASSERT( theIndexTable[nTabOff] == NUMBERFORMAT_ENTRY_NOT_FOUND,
+ "SetIndexTable: theIndexTable[nTabOff] already occupied" );
+ theIndexTable[nTabOff] = nIndOff;
+ }
+ return nIndOff;
+}
+
+
+sal_Int32 SvNumberFormatter::ImpGetFormatCodeIndex(
+ ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode >& rSeq,
+ const NfIndexTableOffset nTabOff )
+{
+ const sal_Int32 nLen = rSeq.getLength();
+ for ( sal_Int32 j=0; j<nLen; j++ )
+ {
+ if ( rSeq[j].Index == nTabOff )
+ return j;
+ }
+ if (LocaleDataWrapper::areChecksEnabled() && (nTabOff < NF_CURRENCY_START
+ || NF_CURRENCY_END < nTabOff || nTabOff == NF_CURRENCY_1000INT
+ || nTabOff == NF_CURRENCY_1000INT_RED
+ || nTabOff == NF_CURRENCY_1000DEC2_CCC))
+ { // currency entries with decimals might not exist, e.g. Italian Lira
+ String aMsg( RTL_CONSTASCII_USTRINGPARAM(
+ "SvNumberFormatter::ImpGetFormatCodeIndex: not found: "));
+ aMsg += String::CreateFromInt32( nTabOff );
+ LocaleDataWrapper::outputCheckMessage( xLocaleData->appendLocaleInfo(
+ aMsg));
+ }
+ if ( nLen )
+ {
+ sal_Int32 j;
+ // look for a preset default
+ for ( j=0; j<nLen; j++ )
+ {
+ if ( rSeq[j].Default )
+ return j;
+ }
+ // currencies are special, not all format codes must exist, but all
+ // builtin number format key index positions must have a format assigned
+ if ( NF_CURRENCY_START <= nTabOff && nTabOff <= NF_CURRENCY_END )
+ {
+ // look for a format with decimals
+ for ( j=0; j<nLen; j++ )
+ {
+ if ( rSeq[j].Index == NF_CURRENCY_1000DEC2 )
+ return j;
+ }
+ // last resort: look for a format without decimals
+ for ( j=0; j<nLen; j++ )
+ {
+ if ( rSeq[j].Index == NF_CURRENCY_1000INT )
+ return j;
+ }
+ }
+ }
+ else
+ { // we need at least _some_ format
+ rSeq.realloc(1);
+ rSeq[0] = ::com::sun::star::i18n::NumberFormatCode();
+ String aTmp( '0' );
+ aTmp += GetNumDecimalSep();
+ aTmp.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "############" ) );
+ rSeq[0].Code = aTmp;
+ }
+ return 0;
+}
+
+
+sal_Int32 SvNumberFormatter::ImpAdjustFormatCodeDefault(
+ ::com::sun::star::i18n::NumberFormatCode * pFormatArr,
+ sal_Int32 nCnt, BOOL bCheckCorrectness )
+{
+ using namespace ::com::sun::star;
+
+ if ( !nCnt )
+ return -1;
+ if (bCheckCorrectness && LocaleDataWrapper::areChecksEnabled())
+ { // check the locale data for correctness
+ ByteString aMsg;
+ sal_Int32 nElem, nShort, nMedium, nLong, nShortDef, nMediumDef, nLongDef;
+ nShort = nMedium = nLong = nShortDef = nMediumDef = nLongDef = -1;
+ for ( nElem = 0; nElem < nCnt; nElem++ )
+ {
+ switch ( pFormatArr[nElem].Type )
+ {
+ case i18n::KNumberFormatType::SHORT :
+ nShort = nElem;
+ break;
+ case i18n::KNumberFormatType::MEDIUM :
+ nMedium = nElem;
+ break;
+ case i18n::KNumberFormatType::LONG :
+ nLong = nElem;
+ break;
+ default:
+ aMsg = "unknown type";
+ }
+ if ( pFormatArr[nElem].Default )
+ {
+ switch ( pFormatArr[nElem].Type )
+ {
+ case i18n::KNumberFormatType::SHORT :
+ if ( nShortDef != -1 )
+ aMsg = "dupe short type default";
+ nShortDef = nElem;
+ break;
+ case i18n::KNumberFormatType::MEDIUM :
+ if ( nMediumDef != -1 )
+ aMsg = "dupe medium type default";
+ nMediumDef = nElem;
+ break;
+ case i18n::KNumberFormatType::LONG :
+ if ( nLongDef != -1 )
+ aMsg = "dupe long type default";
+ nLongDef = nElem;
+ break;
+ }
+ }
+ if ( aMsg.Len() )
+ {
+ aMsg.Insert( "SvNumberFormatter::ImpAdjustFormatCodeDefault: ", 0 );
+ aMsg += "\nXML locale data FormatElement formatindex: ";
+ aMsg += ByteString::CreateFromInt32( pFormatArr[nElem].Index );
+ String aUMsg( aMsg, RTL_TEXTENCODING_ASCII_US);
+ LocaleDataWrapper::outputCheckMessage(
+ xLocaleData->appendLocaleInfo( aUMsg));
+ aMsg.Erase();
+ }
+ }
+ if ( nShort != -1 && nShortDef == -1 )
+ aMsg += "no short type default ";
+ if ( nMedium != -1 && nMediumDef == -1 )
+ aMsg += "no medium type default ";
+ if ( nLong != -1 && nLongDef == -1 )
+ aMsg += "no long type default ";
+ if ( aMsg.Len() )
+ {
+ aMsg.Insert( "SvNumberFormatter::ImpAdjustFormatCodeDefault: ", 0 );
+ aMsg += "\nXML locale data FormatElement group of: ";
+ String aUMsg( aMsg, RTL_TEXTENCODING_ASCII_US);
+ aUMsg += String( pFormatArr[0].NameID );
+ LocaleDataWrapper::outputCheckMessage(
+ xLocaleData->appendLocaleInfo( aUMsg));
+ aMsg.Erase();
+ }
+ }
+ // find the default (medium preferred, then long) and reset all other defaults
+ sal_Int32 nElem, nDef, nMedium;
+ nDef = nMedium = -1;
+ for ( nElem = 0; nElem < nCnt; nElem++ )
+ {
+ if ( pFormatArr[nElem].Default )
+ {
+ switch ( pFormatArr[nElem].Type )
+ {
+ case i18n::KNumberFormatType::MEDIUM :
+ nDef = nMedium = nElem;
+ break;
+ case i18n::KNumberFormatType::LONG :
+ if ( nMedium == -1 )
+ nDef = nElem;
+ // fallthru
+ default:
+ if ( nDef == -1 )
+ nDef = nElem;
+ pFormatArr[nElem].Default = sal_False;
+ }
+ }
+ }
+ if ( nDef == -1 )
+ nDef = 0;
+ pFormatArr[nDef].Default = sal_True;
+ return nDef;
+}
+
+
+void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, BOOL bLoadingSO5 )
+{
+ using namespace ::com::sun::star;
+
+ if ( !bIndexTableInitialized )
+ {
+ for ( USHORT j=0; j<NF_INDEX_TABLE_ENTRIES; j++ )
+ {
+ theIndexTable[j] = NUMBERFORMAT_ENTRY_NOT_FOUND;
+ }
+ }
+ BOOL bOldConvertMode = pFormatScanner->GetConvertMode();
+ if (bOldConvertMode)
+ pFormatScanner->SetConvertMode(FALSE); // switch off for this function
+
+ NumberFormatCodeWrapper aNumberFormatCode( xServiceManager, GetLocale() );
+
+ xub_StrLen nCheckPos = 0;
+ SvNumberformat* pNewFormat = NULL;
+ String aFormatCode;
+ sal_Int32 nIdx;
+ sal_Bool bDefault;
+
+ // Counter for additional builtin formats not fitting into the first 10
+ // of a category (TLOT:=The Legacy Of Templin), altogether about 20 formats.
+ // Has to be incremented on each ImpInsertNewStandardformat, new formats
+ // must be appended, not inserted!
+ USHORT nNewExtended = ZF_STANDARD_NEWEXTENDED;
+
+ // General
+ aFormatCode = pFormatScanner->GetStandardName();
+ SvNumberformat* pStdFormat = new SvNumberformat( aFormatCode,
+ pFormatScanner, pStringScanner, nCheckPos, ActLnge );
+ pStdFormat->SetType( NUMBERFORMAT_NUMBER );
+ pStdFormat->SetStandard();
+ if ( !aFTable.Insert(
+ CLOffset + SetIndexTable( NF_NUMBER_STANDARD, ZF_STANDARD ),
+ pStdFormat ) )
+ {
+ if (LocaleDataWrapper::areChecksEnabled())
+ {
+ String aMsg( RTL_CONSTASCII_USTRINGPARAM(
+ "SvNumberFormatter::ImpGenerateFormats: General format not insertable, nothing will work"));
+ LocaleDataWrapper::outputCheckMessage(
+ xLocaleData->appendLocaleInfo( aMsg));
+ }
+ delete pStdFormat;
+ pStdFormat = NULL;
+ }
+ else
+ pStdFormat->SetLastInsertKey( SV_MAX_ANZ_STANDARD_FORMATE );
+
+ // Boolean
+ aFormatCode = pFormatScanner->GetBooleanString();
+ pNewFormat = new SvNumberformat( aFormatCode,
+ pFormatScanner, pStringScanner, nCheckPos, ActLnge );
+ pNewFormat->SetType(NUMBERFORMAT_LOGICAL);
+ pNewFormat->SetStandard();
+ if ( !aFTable.Insert(
+ CLOffset + SetIndexTable( NF_BOOLEAN, ZF_STANDARD_LOGICAL ),
+ pNewFormat))
+ delete pNewFormat;
+
+ // Text
+ aFormatCode = '@';
+ pNewFormat = new SvNumberformat( aFormatCode,
+ pFormatScanner, pStringScanner, nCheckPos, ActLnge );
+ pNewFormat->SetType(NUMBERFORMAT_TEXT);
+ pNewFormat->SetStandard();
+ if ( !aFTable.Insert(
+ CLOffset + SetIndexTable( NF_TEXT, ZF_STANDARD_TEXT ),
+ pNewFormat))
+ delete pNewFormat;
+
+
+
+ // Number
+ uno::Sequence< i18n::NumberFormatCode > aFormatSeq
+ = aNumberFormatCode.getAllFormatCode( i18n::KNumberFormatUsage::FIXED_NUMBER );
+ ImpAdjustFormatCodeDefault( aFormatSeq.getArray(), aFormatSeq.getLength() );
+
+ // 0
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_NUMBER_INT );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_NUMBER_INT, ZF_STANDARD+1 ));
+
+ // 0.00
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_NUMBER_DEC2 );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_NUMBER_DEC2, ZF_STANDARD+2 ));
+
+ // #,##0
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_NUMBER_1000INT );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_NUMBER_1000INT, ZF_STANDARD+3 ));
+
+ // #,##0.00
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_NUMBER_1000DEC2 );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_NUMBER_1000DEC2, ZF_STANDARD+4 ));
+
+ // #.##0,00 System country/language dependent since number formatter version 6
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_NUMBER_SYSTEM );
+ ImpInsertNewStandardFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_NUMBER_SYSTEM, ZF_STANDARD+5 ),
+ SV_NUMBERFORMATTER_VERSION_NEWSTANDARD );
+
+
+ // Percent number
+ aFormatSeq = aNumberFormatCode.getAllFormatCode( i18n::KNumberFormatUsage::PERCENT_NUMBER );
+ ImpAdjustFormatCodeDefault( aFormatSeq.getArray(), aFormatSeq.getLength() );
+
+ // 0%
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_PERCENT_INT );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_PERCENT_INT, ZF_STANDARD_PERCENT ));
+
+ // 0.00%
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_PERCENT_DEC2 );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_PERCENT_DEC2, ZF_STANDARD_PERCENT+1 ));
+
+
+
+ // Currency. NO default standard option! Default is determined of locale
+ // data default currency and format is generated if needed.
+ aFormatSeq = aNumberFormatCode.getAllFormatCode( i18n::KNumberFormatUsage::CURRENCY );
+ if (LocaleDataWrapper::areChecksEnabled())
+ {
+ // though no default desired here, test for correctness of locale data
+ ImpAdjustFormatCodeDefault( aFormatSeq.getArray(), aFormatSeq.getLength() );
+ }
+
+ // #,##0
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_CURRENCY_1000INT );
+ bDefault = aFormatSeq[nIdx].Default;
+ aFormatSeq[nIdx].Default = sal_False;
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_CURRENCY_1000INT, ZF_STANDARD_CURRENCY ));
+ aFormatSeq[nIdx].Default = bDefault;
+
+ // #,##0.00
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_CURRENCY_1000DEC2 );
+ bDefault = aFormatSeq[nIdx].Default;
+ aFormatSeq[nIdx].Default = sal_False;
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_CURRENCY_1000DEC2, ZF_STANDARD_CURRENCY+1 ));
+ aFormatSeq[nIdx].Default = bDefault;
+
+ // #,##0 negative red
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_CURRENCY_1000INT_RED );
+ bDefault = aFormatSeq[nIdx].Default;
+ aFormatSeq[nIdx].Default = sal_False;
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_CURRENCY_1000INT_RED, ZF_STANDARD_CURRENCY+2 ));
+ aFormatSeq[nIdx].Default = bDefault;
+
+ // #,##0.00 negative red
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_CURRENCY_1000DEC2_RED );
+ bDefault = aFormatSeq[nIdx].Default;
+ aFormatSeq[nIdx].Default = sal_False;
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_CURRENCY_1000DEC2_RED, ZF_STANDARD_CURRENCY+3 ));
+ aFormatSeq[nIdx].Default = bDefault;
+
+ // #,##0.00 USD since number formatter version 3
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_CURRENCY_1000DEC2_CCC );
+ bDefault = aFormatSeq[nIdx].Default;
+ aFormatSeq[nIdx].Default = sal_False;
+ pNewFormat = ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_CURRENCY_1000DEC2_CCC, ZF_STANDARD_CURRENCY+4 ));
+ if ( pNewFormat )
+ pNewFormat->SetUsed(TRUE); // must be saved for older versions
+ aFormatSeq[nIdx].Default = bDefault;
+
+ // #.##0,-- since number formatter version 6
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_CURRENCY_1000DEC2_DASHED );
+ bDefault = aFormatSeq[nIdx].Default;
+ aFormatSeq[nIdx].Default = sal_False;
+ ImpInsertNewStandardFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_CURRENCY_1000DEC2_DASHED, ZF_STANDARD_CURRENCY+5 ),
+ SV_NUMBERFORMATTER_VERSION_NEWSTANDARD );
+ aFormatSeq[nIdx].Default = bDefault;
+
+
+
+ // Date
+ aFormatSeq = aNumberFormatCode.getAllFormatCode( i18n::KNumberFormatUsage::DATE );
+ ImpAdjustFormatCodeDefault( aFormatSeq.getArray(), aFormatSeq.getLength() );
+
+ // DD.MM.YY System
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_SYSTEM_SHORT );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_SYSTEM_SHORT, ZF_STANDARD_DATE ));
+
+ // NN DD.MMM YY
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_DEF_NNDDMMMYY );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_DEF_NNDDMMMYY, ZF_STANDARD_DATE+1 ));
+
+ // DD.MM.YY def/System
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_SYS_MMYY );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_SYS_MMYY, ZF_STANDARD_DATE+2 ));
+
+ // DD MMM
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_SYS_DDMMM );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_SYS_DDMMM, ZF_STANDARD_DATE+3 ));
+
+ // MMMM
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_MMMM );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_MMMM, ZF_STANDARD_DATE+4 ));
+
+ // QQ YY
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_QQJJ );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_QQJJ, ZF_STANDARD_DATE+5 ));
+
+ // DD.MM.YYYY since number formatter version 2, was DD.MM.[YY]YY
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_SYS_DDMMYYYY );
+ pNewFormat = ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_SYS_DDMMYYYY, ZF_STANDARD_DATE+6 ));
+ if ( pNewFormat )
+ pNewFormat->SetUsed(TRUE); // must be saved for older versions
+
+ // DD.MM.YY def/System, since number formatter version 6
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_SYS_DDMMYY );
+ ImpInsertNewStandardFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_SYS_DDMMYY, ZF_STANDARD_DATE+7 ),
+ SV_NUMBERFORMATTER_VERSION_NEWSTANDARD );
+
+ // NNN, D. MMMM YYYY System
+ // Long day of week: "NNNN" instead of "NNN," because of compatibility
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_SYSTEM_LONG );
+ ImpInsertNewStandardFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_SYSTEM_LONG, ZF_STANDARD_DATE+8 ),
+ SV_NUMBERFORMATTER_VERSION_NEWSTANDARD );
+
+ // Hard coded but system (regional settings) delimiters dependent long date formats
+ // since numberformatter version 6
+
+ // D. MMM YY def/System
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_SYS_DMMMYY );
+ ImpInsertNewStandardFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_SYS_DMMMYY, ZF_STANDARD_DATE+9 ),
+ SV_NUMBERFORMATTER_VERSION_NEWSTANDARD );
+
+ //! Unfortunally TLOT intended only 10 builtin formats per category, more
+ //! would overwrite the next category (ZF_STANDARD_TIME) :-((
+ //! Therefore they are inserted with nNewExtended++ (which is also limited)
+
+ // D. MMM YYYY def/System
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_SYS_DMMMYYYY );
+ ImpInsertNewStandardFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_SYS_DMMMYYYY, nNewExtended++ ),
+ SV_NUMBERFORMATTER_VERSION_NEWSTANDARD );
+
+ // D. MMMM YYYY def/System
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_SYS_DMMMMYYYY );
+ ImpInsertNewStandardFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_SYS_DMMMMYYYY, nNewExtended++ ),
+ SV_NUMBERFORMATTER_VERSION_NEWSTANDARD );
+
+ // NN, D. MMM YY def/System
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_SYS_NNDMMMYY );
+ ImpInsertNewStandardFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_SYS_NNDMMMYY, nNewExtended++ ),
+ SV_NUMBERFORMATTER_VERSION_NEWSTANDARD );
+
+ // NN, D. MMMM YYYY def/System
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_SYS_NNDMMMMYYYY );
+ ImpInsertNewStandardFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_SYS_NNDMMMMYYYY, nNewExtended++ ),
+ SV_NUMBERFORMATTER_VERSION_NEWSTANDARD );
+
+ // NNN, D. MMMM YYYY def/System
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_SYS_NNNNDMMMMYYYY );
+ ImpInsertNewStandardFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_SYS_NNNNDMMMMYYYY, nNewExtended++ ),
+ SV_NUMBERFORMATTER_VERSION_NEWSTANDARD );
+
+ // Hard coded DIN (Deutsche Industrie Norm) and EN (European Norm) date formats
+
+ // D. MMM. YYYY DIN/EN
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_DIN_DMMMYYYY );
+ ImpInsertNewStandardFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_DIN_DMMMYYYY, nNewExtended++ ),
+ SV_NUMBERFORMATTER_VERSION_NEWSTANDARD );
+
+ // D. MMMM YYYY DIN/EN
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_DIN_DMMMMYYYY );
+ ImpInsertNewStandardFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_DIN_DMMMMYYYY, nNewExtended++ ),
+ SV_NUMBERFORMATTER_VERSION_NEWSTANDARD );
+
+ // MM-DD DIN/EN
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_DIN_MMDD );
+ ImpInsertNewStandardFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_DIN_MMDD, nNewExtended++ ),
+ SV_NUMBERFORMATTER_VERSION_NEWSTANDARD );
+
+ // YY-MM-DD DIN/EN
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_DIN_YYMMDD );
+ ImpInsertNewStandardFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_DIN_YYMMDD, nNewExtended++ ),
+ SV_NUMBERFORMATTER_VERSION_NEWSTANDARD );
+
+ // YYYY-MM-DD DIN/EN
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_DIN_YYYYMMDD );
+ ImpInsertNewStandardFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATE_DIN_YYYYMMDD, nNewExtended++ ),
+ SV_NUMBERFORMATTER_VERSION_NEWSTANDARD );
+
+
+
+ // Time
+ aFormatSeq = aNumberFormatCode.getAllFormatCode( i18n::KNumberFormatUsage::TIME );
+ ImpAdjustFormatCodeDefault( aFormatSeq.getArray(), aFormatSeq.getLength() );
+
+ // HH:MM
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_TIME_HHMM );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_TIME_HHMM, ZF_STANDARD_TIME ));
+
+ // HH:MM:SS
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_TIME_HHMMSS );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_TIME_HHMMSS, ZF_STANDARD_TIME+1 ));
+
+ // HH:MM AM/PM
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_TIME_HHMMAMPM );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_TIME_HHMMAMPM, ZF_STANDARD_TIME+2 ));
+
+ // HH:MM:SS AM/PM
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_TIME_HHMMSSAMPM );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_TIME_HHMMSSAMPM, ZF_STANDARD_TIME+3 ));
+
+ // [HH]:MM:SS
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_TIME_HH_MMSS );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_TIME_HH_MMSS, ZF_STANDARD_TIME+4 ));
+
+ // MM:SS,00
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_TIME_MMSS00 );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_TIME_MMSS00, ZF_STANDARD_TIME+5 ));
+
+ // [HH]:MM:SS,00
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_TIME_HH_MMSS00 );
+ ImpInsertNewStandardFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_TIME_HH_MMSS00, ZF_STANDARD_TIME+6 ),
+ SV_NUMBERFORMATTER_VERSION_NF_TIME_HH_MMSS00 );
+
+
+
+ // DateTime
+ aFormatSeq = aNumberFormatCode.getAllFormatCode( i18n::KNumberFormatUsage::DATE_TIME );
+ ImpAdjustFormatCodeDefault( aFormatSeq.getArray(), aFormatSeq.getLength() );
+
+ // DD.MM.YY HH:MM System
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATETIME_SYSTEM_SHORT_HHMM );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATETIME_SYSTEM_SHORT_HHMM, ZF_STANDARD_DATETIME ));
+
+ // DD.MM.YYYY HH:MM:SS System
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATETIME_SYS_DDMMYYYY_HHMMSS );
+ ImpInsertNewStandardFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_DATETIME_SYS_DDMMYYYY_HHMMSS, ZF_STANDARD_DATETIME+1 ),
+ SV_NUMBERFORMATTER_VERSION_NF_DATETIME_SYS_DDMMYYYY_HHMMSS );
+
+
+
+ // Scientific number
+ aFormatSeq = aNumberFormatCode.getAllFormatCode( i18n::KNumberFormatUsage::SCIENTIFIC_NUMBER );
+ ImpAdjustFormatCodeDefault( aFormatSeq.getArray(), aFormatSeq.getLength() );
+
+ // 0.00E+000
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_SCIENTIFIC_000E000 );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_SCIENTIFIC_000E000, ZF_STANDARD_SCIENTIFIC ));
+
+ // 0.00E+00
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_SCIENTIFIC_000E00 );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + SetIndexTable( NF_SCIENTIFIC_000E00, ZF_STANDARD_SCIENTIFIC+1 ));
+
+
+
+ // Fraction number (no default option)
+ i18n::NumberFormatCode aSingleFormatCode;
+
+ // # ?/?
+ aSingleFormatCode.Code = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "# ?/?" ) );
+ String s25( RTL_CONSTASCII_USTRINGPARAM( "# ?/?" ) ); // # ?/?
+ ImpInsertFormat( aSingleFormatCode,
+ CLOffset + SetIndexTable( NF_FRACTION_1, ZF_STANDARD_FRACTION ));
+
+ // # ??/??
+ //! "??/" would be interpreted by the compiler as a trigraph for '\'
+ aSingleFormatCode.Code = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "# ?\?/?\?" ) );
+ ImpInsertFormat( aSingleFormatCode,
+ CLOffset + SetIndexTable( NF_FRACTION_2, ZF_STANDARD_FRACTION+1 ));
+
+ // Week of year must be appended here because of nNewExtended
+ const String* pKeyword = pFormatScanner->GetKeywords();
+ aSingleFormatCode.Code = pKeyword[NF_KEY_WW];
+ ImpInsertNewStandardFormat( aSingleFormatCode,
+ CLOffset + SetIndexTable( NF_DATE_WW, nNewExtended++ ),
+ SV_NUMBERFORMATTER_VERSION_NF_DATE_WW );
+
+
+
+ bIndexTableInitialized = TRUE;
+ DBG_ASSERT( nNewExtended <= ZF_STANDARD_NEWEXTENDEDMAX,
+ "ImpGenerateFormats: overflow of nNewExtended standard formats" );
+
+ // Now all additional format codes provided by I18N, but only if not
+ // loading from old SO5 file format, then they are appended last.
+ if ( !bLoadingSO5 )
+ ImpGenerateAdditionalFormats( CLOffset, aNumberFormatCode, FALSE );
+
+ if (bOldConvertMode)
+ pFormatScanner->SetConvertMode(TRUE);
+}
+
+
+void SvNumberFormatter::ImpGenerateAdditionalFormats( sal_uInt32 CLOffset,
+ NumberFormatCodeWrapper& rNumberFormatCode, BOOL bAfterLoadingSO5 )
+{
+ using namespace ::com::sun::star;
+
+ SvNumberformat* pStdFormat =
+ (SvNumberformat*) aFTable.Get( CLOffset + ZF_STANDARD );
+ if ( !pStdFormat )
+ {
+ DBG_ERRORFILE( "ImpGenerateAdditionalFormats: no GENERAL format" );
+ return ;
+ }
+ sal_uInt32 nPos = CLOffset + pStdFormat->GetLastInsertKey();
+ rNumberFormatCode.setLocale( GetLocale() );
+ sal_Int32 j;
+
+ // All currencies, this time with [$...] which was stripped in
+ // ImpGenerateFormats for old "automatic" currency formats.
+ uno::Sequence< i18n::NumberFormatCode > aFormatSeq =
+ rNumberFormatCode.getAllFormatCode( i18n::KNumberFormatUsage::CURRENCY );
+ i18n::NumberFormatCode * pFormatArr = aFormatSeq.getArray();
+ sal_Int32 nCodes = aFormatSeq.getLength();
+ ImpAdjustFormatCodeDefault( aFormatSeq.getArray(), nCodes );
+ for ( j = 0; j < nCodes; j++ )
+ {
+ if ( nPos - CLOffset >= SV_COUNTRY_LANGUAGE_OFFSET )
+ {
+ DBG_ERRORFILE( "ImpGenerateAdditionalFormats: too many formats" );
+ break; // for
+ }
+ if ( pFormatArr[j].Index < NF_INDEX_TABLE_ENTRIES &&
+ pFormatArr[j].Index != NF_CURRENCY_1000DEC2_CCC )
+ { // Insert only if not already inserted, but internal index must be
+ // above so ImpInsertFormat can distinguish it.
+ sal_Int16 nOrgIndex = pFormatArr[j].Index;
+ pFormatArr[j].Index = sal::static_int_cast< sal_Int16 >(
+ pFormatArr[j].Index + nCodes + NF_INDEX_TABLE_ENTRIES);
+ //! no default on currency
+ sal_Bool bDefault = aFormatSeq[j].Default;
+ aFormatSeq[j].Default = sal_False;
+ if ( ImpInsertNewStandardFormat( pFormatArr[j], nPos+1,
+ SV_NUMBERFORMATTER_VERSION_ADDITIONAL_I18N_FORMATS,
+ bAfterLoadingSO5, nOrgIndex ) )
+ nPos++;
+ pFormatArr[j].Index = nOrgIndex;
+ aFormatSeq[j].Default = bDefault;
+ }
+ }
+
+ // all additional format codes provided by I18N that are not old standard index
+ aFormatSeq = rNumberFormatCode.getAllFormatCodes();
+ nCodes = aFormatSeq.getLength();
+ if ( nCodes )
+ {
+ pFormatArr = aFormatSeq.getArray();
+ // don't check ALL
+ sal_Int32 nDef = ImpAdjustFormatCodeDefault( pFormatArr, nCodes, FALSE);
+ // don't have any defaults here
+ pFormatArr[nDef].Default = sal_False;
+ for ( j = 0; j < nCodes; j++ )
+ {
+ if ( nPos - CLOffset >= SV_COUNTRY_LANGUAGE_OFFSET )
+ {
+ DBG_ERRORFILE( "ImpGenerateAdditionalFormats: too many formats" );
+ break; // for
+ }
+ if ( pFormatArr[j].Index >= NF_INDEX_TABLE_ENTRIES )
+ if ( ImpInsertNewStandardFormat( pFormatArr[j], nPos+1,
+ SV_NUMBERFORMATTER_VERSION_ADDITIONAL_I18N_FORMATS,
+ bAfterLoadingSO5 ) )
+ nPos++;
+ }
+ }
+
+ pStdFormat->SetLastInsertKey( (USHORT)(nPos - CLOffset) );
+}
+
+
+void SvNumberFormatter::ImpGetPosCurrFormat( String& sPosStr, const String& rCurrSymbol )
+{
+ NfCurrencyEntry::CompletePositiveFormatString( sPosStr,
+ rCurrSymbol, xLocaleData->getCurrPositiveFormat() );
+}
+
+void SvNumberFormatter::ImpGetNegCurrFormat( String& sNegStr, const String& rCurrSymbol )
+{
+ NfCurrencyEntry::CompleteNegativeFormatString( sNegStr,
+ rCurrSymbol, xLocaleData->getCurrNegativeFormat() );
+}
+
+void SvNumberFormatter::GenerateFormat(String& sString,
+ sal_uInt32 nIndex,
+ LanguageType eLnge,
+ BOOL bThousand,
+ BOOL IsRed,
+ USHORT nPrecision,
+ USHORT nAnzLeading)
+{
+ if (eLnge == LANGUAGE_DONTKNOW)
+ eLnge = IniLnge;
+ short eType = GetType(nIndex);
+ USHORT i;
+ ImpGenerateCL(eLnge); // ggfs. neu Standard-
+ // formate anlegen
+ sString.Erase();
+
+ const String& rThSep = GetNumThousandSep();
+ if (nAnzLeading == 0)
+ {
+ if (!bThousand)
+ sString += '#';
+ else
+ {
+ sString += '#';
+ sString += rThSep;
+ sString.Expand( sString.Len() + 3, '#' );
+ }
+ }
+ else
+ {
+ for (i = 0; i < nAnzLeading; i++)
+ {
+ if (bThousand && i%3 == 0 && i > 0)
+ sString.Insert( rThSep, 0 );
+ sString.Insert('0',0);
+ }
+ if (bThousand && nAnzLeading < 4)
+ {
+ for (i = nAnzLeading; i < 4; i++)
+ {
+ if (bThousand && i%3 == 0)
+ sString.Insert( rThSep, 0 );
+ sString.Insert('#',0);
+ }
+ }
+ }
+ if (nPrecision > 0)
+ {
+ sString += GetNumDecimalSep();
+ sString.Expand( sString.Len() + nPrecision, '0' );
+ }
+ if (eType == NUMBERFORMAT_PERCENT)
+ sString += '%';
+ else if (eType == NUMBERFORMAT_CURRENCY)
+ {
+ String sNegStr = sString;
+ String aCurr;
+ const NfCurrencyEntry* pEntry;
+ BOOL bBank;
+ if ( GetNewCurrencySymbolString( nIndex, aCurr, &pEntry, &bBank ) )
+ {
+ if ( pEntry )
+ {
+ USHORT nPosiForm = NfCurrencyEntry::GetEffectivePositiveFormat(
+ xLocaleData->getCurrPositiveFormat(),
+ pEntry->GetPositiveFormat(), bBank );
+ USHORT nNegaForm = NfCurrencyEntry::GetEffectiveNegativeFormat(
+ xLocaleData->getCurrNegativeFormat(),
+ pEntry->GetNegativeFormat(), bBank );
+ pEntry->CompletePositiveFormatString( sString, bBank,
+ nPosiForm );
+ pEntry->CompleteNegativeFormatString( sNegStr, bBank,
+ nNegaForm );
+ }
+ else
+ { // assume currency abbreviation (AKA banking symbol), not symbol
+ USHORT nPosiForm = NfCurrencyEntry::GetEffectivePositiveFormat(
+ xLocaleData->getCurrPositiveFormat(),
+ xLocaleData->getCurrPositiveFormat(), TRUE );
+ USHORT nNegaForm = NfCurrencyEntry::GetEffectiveNegativeFormat(
+ xLocaleData->getCurrNegativeFormat(),
+ xLocaleData->getCurrNegativeFormat(), TRUE );
+ NfCurrencyEntry::CompletePositiveFormatString( sString, aCurr,
+ nPosiForm );
+ NfCurrencyEntry::CompleteNegativeFormatString( sNegStr, aCurr,
+ nNegaForm );
+ }
+ }
+ else
+ { // "automatic" old style
+ String aSymbol, aAbbrev;
+ GetCompatibilityCurrency( aSymbol, aAbbrev );
+ ImpGetPosCurrFormat( sString, aSymbol );
+ ImpGetNegCurrFormat( sNegStr, aSymbol );
+ }
+ if (IsRed)
+ {
+ sString += ';';
+ sString += '[';
+ sString += pFormatScanner->GetRedString();
+ sString += ']';
+ }
+ else
+ sString += ';';
+ sString += sNegStr;
+ }
+ if (IsRed && eType != NUMBERFORMAT_CURRENCY)
+ {
+ String sTmpStr = sString;
+ sTmpStr += ';';
+ sTmpStr += '[';
+ sTmpStr += pFormatScanner->GetRedString();
+ sTmpStr += ']';
+ sTmpStr += '-';
+ sTmpStr +=sString;
+ sString = sTmpStr;
+ }
+}
+
+sal_uInt32 SvNumberFormatter::GetEntryKey(const String& sStr,
+ LanguageType eLnge)
+{
+ if (eLnge == LANGUAGE_DONTKNOW)
+ eLnge = IniLnge;
+ sal_uInt32 CLOffset = ImpGenerateCL(eLnge); // ggfs. neu Standard-
+ // formate anlegen
+ return ImpIsEntry(sStr, CLOffset, eLnge);
+}
+
+sal_uInt32 SvNumberFormatter::GetStandardIndex(LanguageType eLnge)
+{
+ if (eLnge == LANGUAGE_DONTKNOW)
+ eLnge = IniLnge;
+ return GetStandardFormat(NUMBERFORMAT_NUMBER, eLnge);
+}
+
+short SvNumberFormatter::GetType(sal_uInt32 nFIndex)
+{
+ short eType;
+ SvNumberformat* pFormat = (SvNumberformat*) aFTable.Get(nFIndex);
+ if (!pFormat)
+ eType = NUMBERFORMAT_UNDEFINED;
+ else
+ {
+ eType = pFormat->GetType() &~NUMBERFORMAT_DEFINED;
+ if (eType == 0)
+ eType = NUMBERFORMAT_DEFINED;
+ }
+ return eType;
+}
+
+void SvNumberFormatter::ClearMergeTable()
+{
+ if ( pMergeTable )
+ {
+ sal_uInt32* pIndex = (sal_uInt32*) pMergeTable->First();
+ while (pIndex)
+ {
+ delete pIndex;
+ pIndex = pMergeTable->Next();
+ }
+ pMergeTable->Clear();
+ }
+}
+
+SvNumberFormatterIndexTable* SvNumberFormatter::MergeFormatter(SvNumberFormatter& rTable)
+{
+ if ( pMergeTable )
+ ClearMergeTable();
+ else
+ pMergeTable = new SvNumberFormatterIndexTable;
+ sal_uInt32 nCLOffset = 0;
+ sal_uInt32 nOldKey, nOffset, nNewKey;
+ sal_uInt32* pNewIndex;
+ SvNumberformat* pNewEntry;
+ SvNumberformat* pFormat = rTable.aFTable.First();
+ while (pFormat)
+ {
+ nOldKey = rTable.aFTable.GetCurKey();
+ nOffset = nOldKey % SV_COUNTRY_LANGUAGE_OFFSET; // relativIndex
+ if (nOffset == 0) // 1. Format von CL
+ nCLOffset = ImpGenerateCL(pFormat->GetLanguage());
+
+ if (nOffset <= SV_MAX_ANZ_STANDARD_FORMATE) // Std.form.
+ {
+ nNewKey = nCLOffset + nOffset;
+ if (!aFTable.Get(nNewKey)) // noch nicht da
+ {
+// pNewEntry = new SvNumberformat(*pFormat); // Copy reicht nicht !!!
+ pNewEntry = new SvNumberformat( *pFormat, *pFormatScanner );
+ if (!aFTable.Insert(nNewKey, pNewEntry))
+ delete pNewEntry;
+ }
+ if (nNewKey != nOldKey) // neuer Index
+ {
+ pNewIndex = new sal_uInt32(nNewKey);
+ if (!pMergeTable->Insert(nOldKey,pNewIndex))
+ delete pNewIndex;
+ }
+ }
+ else // benutzerdef.
+ {
+// pNewEntry = new SvNumberformat(*pFormat); // Copy reicht nicht !!!
+ pNewEntry = new SvNumberformat( *pFormat, *pFormatScanner );
+ nNewKey = ImpIsEntry(pNewEntry->GetFormatstring(),
+ nCLOffset,
+ pFormat->GetLanguage());
+ if (nNewKey != NUMBERFORMAT_ENTRY_NOT_FOUND) // schon vorhanden
+ delete pNewEntry;
+ else
+ {
+ SvNumberformat* pStdFormat =
+ (SvNumberformat*) aFTable.Get(nCLOffset + ZF_STANDARD);
+ sal_uInt32 nPos = nCLOffset + pStdFormat->GetLastInsertKey();
+ nNewKey = nPos+1;
+ if (nPos - nCLOffset >= SV_COUNTRY_LANGUAGE_OFFSET)
+ {
+ Sound::Beep();
+ DBG_ERROR(
+ "SvNumberFormatter:: Zu viele Formate pro CL");
+ delete pNewEntry;
+ }
+ else if (!aFTable.Insert(nNewKey, pNewEntry))
+ delete pNewEntry;
+ else
+ pStdFormat->SetLastInsertKey((USHORT) (nNewKey - nCLOffset));
+ }
+ if (nNewKey != nOldKey) // neuer Index
+ {
+ pNewIndex = new sal_uInt32(nNewKey);
+ if (!pMergeTable->Insert(nOldKey,pNewIndex))
+ delete pNewIndex;
+ }
+ }
+ pFormat = rTable.aFTable.Next();
+ }
+ return pMergeTable;
+}
+
+
+sal_uInt32 SvNumberFormatter::GetFormatForLanguageIfBuiltIn( sal_uInt32 nFormat,
+ LanguageType eLnge )
+{
+ if ( eLnge == LANGUAGE_DONTKNOW )
+ eLnge = IniLnge;
+ if ( nFormat < SV_COUNTRY_LANGUAGE_OFFSET && eLnge == IniLnge )
+ return nFormat; // es bleibt wie es ist
+ sal_uInt32 nOffset = nFormat % SV_COUNTRY_LANGUAGE_OFFSET; // relativIndex
+ if ( nOffset > SV_MAX_ANZ_STANDARD_FORMATE )
+ return nFormat; // kein eingebautes Format
+ sal_uInt32 nCLOffset = ImpGenerateCL(eLnge); // ggbf. generieren
+ return nCLOffset + nOffset;
+}
+
+
+sal_uInt32 SvNumberFormatter::GetFormatIndex( NfIndexTableOffset nTabOff,
+ LanguageType eLnge )
+{
+ if ( nTabOff >= NF_INDEX_TABLE_ENTRIES
+ || theIndexTable[nTabOff] == NUMBERFORMAT_ENTRY_NOT_FOUND )
+ return NUMBERFORMAT_ENTRY_NOT_FOUND;
+ if ( eLnge == LANGUAGE_DONTKNOW )
+ eLnge = IniLnge;
+ sal_uInt32 nCLOffset = ImpGenerateCL(eLnge); // ggbf. generieren
+ return nCLOffset + theIndexTable[nTabOff];
+}
+
+
+NfIndexTableOffset SvNumberFormatter::GetIndexTableOffset( sal_uInt32 nFormat ) const
+{
+ sal_uInt32 nOffset = nFormat % SV_COUNTRY_LANGUAGE_OFFSET; // relativIndex
+ if ( nOffset > SV_MAX_ANZ_STANDARD_FORMATE )
+ return NF_INDEX_TABLE_ENTRIES; // kein eingebautes Format
+ for ( USHORT j = 0; j < NF_INDEX_TABLE_ENTRIES; j++ )
+ {
+ if ( theIndexTable[j] == nOffset )
+ return (NfIndexTableOffset) j;
+ }
+ return NF_INDEX_TABLE_ENTRIES; // bad luck
+}
+
+
+void SvNumberFormatter::SetYear2000( USHORT nVal )
+{
+ pStringScanner->SetYear2000( nVal );
+}
+
+
+USHORT SvNumberFormatter::GetYear2000() const
+{
+ return pStringScanner->GetYear2000();
+}
+
+
+USHORT SvNumberFormatter::ExpandTwoDigitYear( USHORT nYear ) const
+{
+ if ( nYear < 100 )
+ return SvNumberFormatter::ExpandTwoDigitYear( nYear,
+ pStringScanner->GetYear2000() );
+ return nYear;
+}
+
+
+// static
+USHORT SvNumberFormatter::GetYear2000Default()
+{
+// return Application::GetSettings().GetMiscSettings().GetTwoDigitYearStart();
+ return (USHORT) ::utl::MiscCfg().GetYear2000();
+}
+
+
+// static
+const NfCurrencyTable& SvNumberFormatter::GetTheCurrencyTable()
+{
+ ::osl::MutexGuard aGuard( GetMutex() );
+ while ( !bCurrencyTableInitialized )
+ ImpInitCurrencyTable();
+ return theCurrencyTable::get();
+}
+
+
+// static
+const NfCurrencyEntry* SvNumberFormatter::MatchSystemCurrency()
+{
+ // MUST call GetTheCurrencyTable() before accessing nSystemCurrencyPosition
+ const NfCurrencyTable& rTable = GetTheCurrencyTable();
+ return nSystemCurrencyPosition ? rTable[nSystemCurrencyPosition] : NULL;
+}
+
+
+// static
+const NfCurrencyEntry& SvNumberFormatter::GetCurrencyEntry( LanguageType eLang )
+{
+ if ( eLang == LANGUAGE_SYSTEM )
+ {
+ const NfCurrencyEntry* pCurr = MatchSystemCurrency();
+ return pCurr ? *pCurr : *(GetTheCurrencyTable()[0]);
+ }
+ else
+ {
+ eLang = MsLangId::getRealLanguage( eLang );
+ const NfCurrencyTable& rTable = GetTheCurrencyTable();
+ USHORT nCount = rTable.Count();
+ const NfCurrencyEntryPtr* ppData = rTable.GetData();
+ for ( USHORT j = 0; j < nCount; j++, ppData++ )
+ {
+ if ( (*ppData)->GetLanguage() == eLang )
+ return **ppData;
+ }
+ return *(rTable[0]);
+ }
+}
+
+
+// static
+IMPL_STATIC_LINK_NOINSTANCE( SvNumberFormatter, CurrencyChangeLink, void*, EMPTYARG )
+{
+ ::osl::MutexGuard aGuard( GetMutex() );
+ String aAbbrev;
+ LanguageType eLang = LANGUAGE_SYSTEM;
+ SvtSysLocaleOptions().GetCurrencyAbbrevAndLanguage( aAbbrev, eLang );
+ SetDefaultSystemCurrency( aAbbrev, eLang );
+ return 0;
+}
+
+
+// static
+void SvNumberFormatter::SetDefaultSystemCurrency( const String& rAbbrev, LanguageType eLang )
+{
+ ::osl::MutexGuard aGuard( GetMutex() );
+ if ( eLang == LANGUAGE_SYSTEM )
+ eLang = Application::GetSettings().GetLanguage();
+ const NfCurrencyTable& rTable = GetTheCurrencyTable();
+ USHORT nCount = rTable.Count();
+ const NfCurrencyEntryPtr* ppData = rTable.GetData();
+ if ( rAbbrev.Len() )
+ {
+ for ( USHORT j = 0; j < nCount; j++, ppData++ )
+ {
+ if ( (*ppData)->GetLanguage() == eLang && (*ppData)->GetBankSymbol() == rAbbrev )
+ {
+ nSystemCurrencyPosition = j;
+ return ;
+ }
+ }
+ }
+ else
+ {
+ for ( USHORT j = 0; j < nCount; j++, ppData++ )
+ {
+ if ( (*ppData)->GetLanguage() == eLang )
+ {
+ nSystemCurrencyPosition = j;
+ return ;
+ }
+ }
+ }
+ nSystemCurrencyPosition = 0; // not found => simple SYSTEM
+}
+
+
+void SvNumberFormatter::ResetDefaultSystemCurrency()
+{
+ nDefaultSystemCurrencyFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
+}
+
+
+sal_uInt32 SvNumberFormatter::ImpGetDefaultSystemCurrencyFormat()
+{
+ if ( nDefaultSystemCurrencyFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
+ {
+ xub_StrLen nCheck;
+ short nType;
+ NfWSStringsDtor aCurrList;
+ USHORT nDefault = GetCurrencyFormatStrings( aCurrList,
+ GetCurrencyEntry( LANGUAGE_SYSTEM ), FALSE );
+ DBG_ASSERT( aCurrList.Count(), "where is the NewCurrency System standard format?!?" );
+ // if already loaded or user defined nDefaultSystemCurrencyFormat
+ // will be set to the right value
+ PutEntry( *aCurrList.GetObject( nDefault ), nCheck, nType,
+ nDefaultSystemCurrencyFormat, LANGUAGE_SYSTEM );
+ DBG_ASSERT( nCheck == 0, "NewCurrency CheckError" );
+ DBG_ASSERT( nDefaultSystemCurrencyFormat != NUMBERFORMAT_ENTRY_NOT_FOUND,
+ "nDefaultSystemCurrencyFormat == NUMBERFORMAT_ENTRY_NOT_FOUND" );
+ }
+ return nDefaultSystemCurrencyFormat;
+}
+
+
+sal_uInt32 SvNumberFormatter::ImpGetDefaultCurrencyFormat()
+{
+ sal_uInt32 CLOffset = ImpGetCLOffset( ActLnge );
+ sal_uInt32 nDefaultCurrencyFormat =
+ (sal_uInt32)(sal_uIntPtr) aDefaultFormatKeys.Get( CLOffset + ZF_STANDARD_CURRENCY );
+ if ( !nDefaultCurrencyFormat )
+ nDefaultCurrencyFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
+ if ( nDefaultCurrencyFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
+ {
+ // look for a defined standard
+ sal_uInt32 nStopKey = CLOffset + SV_COUNTRY_LANGUAGE_OFFSET;
+ sal_uInt32 nKey;
+ aFTable.Seek( CLOffset );
+ while ( (nKey = aFTable.GetCurKey()) >= CLOffset && nKey < nStopKey )
+ {
+ const SvNumberformat* pEntry =
+ (const SvNumberformat*) aFTable.GetCurObject();
+ if ( pEntry->IsStandard() && (pEntry->GetType() & NUMBERFORMAT_CURRENCY) )
+ {
+ nDefaultCurrencyFormat = nKey;
+ break; // while
+ }
+ aFTable.Next();
+ }
+
+ if ( nDefaultCurrencyFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
+ { // none found, create one
+ xub_StrLen nCheck;
+ short nType;
+ NfWSStringsDtor aCurrList;
+ USHORT nDefault = GetCurrencyFormatStrings( aCurrList,
+ GetCurrencyEntry( ActLnge ), FALSE );
+ DBG_ASSERT( aCurrList.Count(), "where is the NewCurrency standard format?" );
+ if ( aCurrList.Count() )
+ {
+ // if already loaded or user defined nDefaultSystemCurrencyFormat
+ // will be set to the right value
+ PutEntry( *aCurrList.GetObject( nDefault ), nCheck, nType,
+ nDefaultCurrencyFormat, ActLnge );
+ DBG_ASSERT( nCheck == 0, "NewCurrency CheckError" );
+ DBG_ASSERT( nDefaultCurrencyFormat != NUMBERFORMAT_ENTRY_NOT_FOUND,
+ "nDefaultCurrencyFormat == NUMBERFORMAT_ENTRY_NOT_FOUND" );
+ }
+ // old automatic currency format as a last resort
+ if ( nDefaultCurrencyFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
+ nDefaultCurrencyFormat = CLOffset + ZF_STANDARD_CURRENCY+3;
+ else
+ { // mark as standard so that it is found next time
+ SvNumberformat* pEntry = aFTable.Get( nDefaultCurrencyFormat );
+ if ( pEntry )
+ pEntry->SetStandard();
+ }
+ }
+ aDefaultFormatKeys.Insert( CLOffset + ZF_STANDARD_CURRENCY,
+ (void*) nDefaultCurrencyFormat );
+ }
+ return nDefaultCurrencyFormat;
+}
+
+
+// static
+// try to make it inline if possible since this a loop body
+// TRUE: continue; FALSE: break loop, if pFoundEntry==NULL dupe found
+#ifndef DBG_UTIL
+inline
+#endif
+ BOOL SvNumberFormatter::ImpLookupCurrencyEntryLoopBody(
+ const NfCurrencyEntry*& pFoundEntry, BOOL& bFoundBank,
+ const NfCurrencyEntry* pData, USHORT nPos, const String& rSymbol )
+{
+ BOOL bFound;
+ if ( pData->GetSymbol() == rSymbol )
+ {
+ bFound = TRUE;
+ bFoundBank = FALSE;
+ }
+ else if ( pData->GetBankSymbol() == rSymbol )
+ {
+ bFound = TRUE;
+ bFoundBank = TRUE;
+ }
+ else
+ bFound = FALSE;
+ if ( bFound )
+ {
+ if ( pFoundEntry && pFoundEntry != pData )
+ {
+ pFoundEntry = NULL;
+ return FALSE; // break loop, not unique
+ }
+ if ( nPos == 0 )
+ { // first entry is SYSTEM
+ pFoundEntry = MatchSystemCurrency();
+ if ( pFoundEntry )
+ return FALSE; // break loop
+ // even if there are more matching entries
+ // this one is propably the one we are looking for
+ else
+ pFoundEntry = pData;
+ }
+ else
+ pFoundEntry = pData;
+ }
+ return TRUE;
+}
+
+
+BOOL SvNumberFormatter::GetNewCurrencySymbolString( sal_uInt32 nFormat,
+ String& rStr, const NfCurrencyEntry** ppEntry /* = NULL */,
+ BOOL* pBank /* = NULL */ ) const
+{
+ rStr.Erase();
+ if ( ppEntry )
+ *ppEntry = NULL;
+ if ( pBank )
+ *pBank = FALSE;
+ SvNumberformat* pFormat = (SvNumberformat*) aFTable.Get( nFormat );
+ if ( pFormat )
+ {
+ String aSymbol, aExtension;
+ if ( pFormat->GetNewCurrencySymbol( aSymbol, aExtension ) )
+ {
+ if ( ppEntry )
+ {
+ BOOL bFoundBank = FALSE;
+ // we definiteley need an entry matching the format code string
+ const NfCurrencyEntry* pFoundEntry = GetCurrencyEntry(
+ bFoundBank, aSymbol, aExtension, pFormat->GetLanguage(),
+ TRUE );
+ if ( pFoundEntry )
+ {
+ *ppEntry = pFoundEntry;
+ if ( pBank )
+ *pBank = bFoundBank;
+ pFoundEntry->BuildSymbolString( rStr, bFoundBank );
+ }
+ }
+ if ( !rStr.Len() )
+ { // analog zu BuildSymbolString
+ rStr = '[';
+ rStr += '$';
+ if ( aSymbol.Search( '-' ) != STRING_NOTFOUND ||
+ aSymbol.Search( ']' ) != STRING_NOTFOUND )
+ {
+ rStr += '"';
+ rStr += aSymbol;
+ rStr += '"';
+ }
+ else
+ rStr += aSymbol;
+ if ( aExtension.Len() )
+ rStr += aExtension;
+ rStr += ']';
+ }
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+// static
+const NfCurrencyEntry* SvNumberFormatter::GetCurrencyEntry( BOOL & bFoundBank,
+ const String& rSymbol, const String& rExtension,
+ LanguageType eFormatLanguage, BOOL bOnlyStringLanguage )
+{
+ xub_StrLen nExtLen = rExtension.Len();
+ LanguageType eExtLang;
+ if ( nExtLen )
+ {
+ sal_Int32 nExtLang = ::rtl::OUString( rExtension ).toInt32( 16 );
+ if ( !nExtLang )
+ eExtLang = LANGUAGE_DONTKNOW;
+ else
+ eExtLang = (LanguageType) ((nExtLang < 0) ?
+ -nExtLang : nExtLang);
+ }
+ else
+ eExtLang = LANGUAGE_DONTKNOW;
+ const NfCurrencyEntry* pFoundEntry = NULL;
+ const NfCurrencyTable& rTable = GetTheCurrencyTable();
+ USHORT nCount = rTable.Count();
+ BOOL bCont = TRUE;
+
+ // first try with given extension language/country
+ if ( nExtLen )
+ {
+ const NfCurrencyEntryPtr* ppData = rTable.GetData();
+ for ( USHORT j = 0; j < nCount && bCont; j++, ppData++ )
+ {
+ LanguageType eLang = (*ppData)->GetLanguage();
+ if ( eLang == eExtLang ||
+ ((eExtLang == LANGUAGE_DONTKNOW) &&
+ (eLang == LANGUAGE_SYSTEM))
+ )
+ {
+ bCont = ImpLookupCurrencyEntryLoopBody( pFoundEntry, bFoundBank,
+ *ppData, j, rSymbol );
+ }
+ }
+ }
+
+ // ok?
+ if ( pFoundEntry || !bCont || (bOnlyStringLanguage && nExtLen) )
+ return pFoundEntry;
+
+ if ( !bOnlyStringLanguage )
+ {
+ // now try the language/country of the number format
+ const NfCurrencyEntryPtr* ppData = rTable.GetData();
+ for ( USHORT j = 0; j < nCount && bCont; j++, ppData++ )
+ {
+ LanguageType eLang = (*ppData)->GetLanguage();
+ if ( eLang == eFormatLanguage ||
+ ((eFormatLanguage == LANGUAGE_DONTKNOW) &&
+ (eLang == LANGUAGE_SYSTEM))
+ )
+ {
+ bCont = ImpLookupCurrencyEntryLoopBody( pFoundEntry, bFoundBank,
+ *ppData, j, rSymbol );
+ }
+ }
+
+ // ok?
+ if ( pFoundEntry || !bCont )
+ return pFoundEntry;
+ }
+
+ // then try without language/country if no extension specified
+ if ( !nExtLen )
+ {
+ const NfCurrencyEntryPtr* ppData = rTable.GetData();
+ for ( USHORT j = 0; j < nCount && bCont; j++, ppData++ )
+ {
+ bCont = ImpLookupCurrencyEntryLoopBody( pFoundEntry, bFoundBank,
+ *ppData, j, rSymbol );
+ }
+ }
+
+ return pFoundEntry;
+}
+
+
+void SvNumberFormatter::GetCompatibilityCurrency( String& rSymbol, String& rAbbrev ) const
+{
+ ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Currency2 >
+ xCurrencies = xLocaleData->getAllCurrencies();
+ sal_Int32 nCurrencies = xCurrencies.getLength();
+ sal_Int32 j;
+ for ( j=0; j < nCurrencies; ++j )
+ {
+ if ( xCurrencies[j].UsedInCompatibleFormatCodes )
+ {
+ rSymbol = xCurrencies[j].Symbol;
+ rAbbrev = xCurrencies[j].BankSymbol;
+ break;
+ }
+ }
+ if ( j >= nCurrencies )
+ {
+ if (LocaleDataWrapper::areChecksEnabled())
+ {
+ String aMsg( RTL_CONSTASCII_USTRINGPARAM(
+ "GetCompatibilityCurrency: none?"));
+ LocaleDataWrapper::outputCheckMessage(
+ xLocaleData->appendLocaleInfo( aMsg));
+ }
+ rSymbol = xLocaleData->getCurrSymbol();
+ rAbbrev = xLocaleData->getCurrBankSymbol();
+ }
+}
+
+
+void lcl_CheckCurrencySymbolPosition( const NfCurrencyEntry& rCurr )
+{
+ short nPos = -1; // -1:=unknown, 0:=vorne, 1:=hinten
+ short nNeg = -1;
+ switch ( rCurr.GetPositiveFormat() )
+ {
+ case 0: // $1
+ nPos = 0;
+ break;
+ case 1: // 1$
+ nPos = 1;
+ break;
+ case 2: // $ 1
+ nPos = 0;
+ break;
+ case 3: // 1 $
+ nPos = 1;
+ break;
+ default:
+ LocaleDataWrapper::outputCheckMessage(
+ "lcl_CheckCurrencySymbolPosition: unknown PositiveFormat");
+ break;
+ }
+ switch ( rCurr.GetNegativeFormat() )
+ {
+ case 0: // ($1)
+ nNeg = 0;
+ break;
+ case 1: // -$1
+ nNeg = 0;
+ break;
+ case 2: // $-1
+ nNeg = 0;
+ break;
+ case 3: // $1-
+ nNeg = 0;
+ break;
+ case 4: // (1$)
+ nNeg = 1;
+ break;
+ case 5: // -1$
+ nNeg = 1;
+ break;
+ case 6: // 1-$
+ nNeg = 1;
+ break;
+ case 7: // 1$-
+ nNeg = 1;
+ break;
+ case 8: // -1 $
+ nNeg = 1;
+ break;
+ case 9: // -$ 1
+ nNeg = 0;
+ break;
+ case 10: // 1 $-
+ nNeg = 1;
+ break;
+ case 11: // $ -1
+ nNeg = 0;
+ break;
+ case 12 : // $ 1-
+ nNeg = 0;
+ break;
+ case 13 : // 1- $
+ nNeg = 1;
+ break;
+ case 14 : // ($ 1)
+ nNeg = 0;
+ break;
+ case 15 : // (1 $)
+ nNeg = 1;
+ break;
+ default:
+ LocaleDataWrapper::outputCheckMessage(
+ "lcl_CheckCurrencySymbolPosition: unknown NegativeFormat");
+ break;
+ }
+ if ( nPos >= 0 && nNeg >= 0 && nPos != nNeg )
+ {
+ ByteString aStr( "positions of currency symbols differ\nLanguage: " );
+ aStr += ByteString::CreateFromInt32( rCurr.GetLanguage() );
+ aStr += " <";
+ aStr += ByteString( rCurr.GetSymbol(), RTL_TEXTENCODING_UTF8 );
+ aStr += "> positive: ";
+ aStr += ByteString::CreateFromInt32( rCurr.GetPositiveFormat() );
+ aStr += ( nPos ? " (postfix)" : " (prefix)" );
+ aStr += ", negative: ";
+ aStr += ByteString::CreateFromInt32( rCurr.GetNegativeFormat() );
+ aStr += ( nNeg ? " (postfix)" : " (prefix)" );
+#if 0
+// seems that there really are some currencies which differ, e.g. YugoDinar
+ DBG_ERRORFILE( aStr.GetBuffer() );
+#endif
+ }
+}
+
+
+// static
+void SvNumberFormatter::ImpInitCurrencyTable()
+{
+ // racing condition possible:
+ // ::osl::MutexGuard aGuard( GetMutex() );
+ // while ( !bCurrencyTableInitialized )
+ // ImpInitCurrencyTable();
+ static BOOL bInitializing = FALSE;
+ if ( bCurrencyTableInitialized || bInitializing )
+ return ;
+ bInitializing = TRUE;
+
+ RTL_LOGFILE_CONTEXT_AUTHOR( aTimeLog, "svtools", "er93726", "SvNumberFormatter::ImpInitCurrencyTable" );
+
+ LanguageType eSysLang = Application::GetSettings().GetLanguage();
+ LocaleDataWrapper* pLocaleData = new LocaleDataWrapper(
+ ::comphelper::getProcessServiceFactory(),
+ MsLangId::convertLanguageToLocale( eSysLang ) );
+ // get user configured currency
+ String aConfiguredCurrencyAbbrev;
+ LanguageType eConfiguredCurrencyLanguage = LANGUAGE_SYSTEM;
+ SvtSysLocaleOptions().GetCurrencyAbbrevAndLanguage(
+ aConfiguredCurrencyAbbrev, eConfiguredCurrencyLanguage );
+ USHORT nSecondarySystemCurrencyPosition = 0;
+ USHORT nMatchingSystemCurrencyPosition = 0;
+ NfCurrencyEntryPtr pEntry;
+
+ // first entry is SYSTEM
+ pEntry = new NfCurrencyEntry( *pLocaleData, LANGUAGE_SYSTEM );
+ theCurrencyTable::get().Insert( pEntry, 0 );
+ USHORT nCurrencyPos = 1;
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > xLoc =
+ LocaleDataWrapper::getInstalledLocaleNames();
+ sal_Int32 nLocaleCount = xLoc.getLength();
+ RTL_LOGFILE_CONTEXT_TRACE1( aTimeLog, "number of locales: %ld", nLocaleCount );
+ Locale const * const pLocales = xLoc.getConstArray();
+ NfCurrencyTable &rCurrencyTable = theCurrencyTable::get();
+ NfCurrencyTable &rLegacyOnlyCurrencyTable = theLegacyOnlyCurrencyTable::get();
+ USHORT nLegacyOnlyCurrencyPos = 0;
+ for ( sal_Int32 nLocale = 0; nLocale < nLocaleCount; nLocale++ )
+ {
+ LanguageType eLang = MsLangId::convertLocaleToLanguage(
+ pLocales[nLocale]);
+#if OSL_DEBUG_LEVEL > 1
+ LanguageType eReal = MsLangId::getRealLanguage( eLang );
+ if ( eReal != eLang ) {
+ BOOL bBreak;
+ bBreak = TRUE;
+ }
+#endif
+ pLocaleData->setLocale( pLocales[nLocale] );
+ Sequence< Currency2 > aCurrSeq = pLocaleData->getAllCurrencies();
+ sal_Int32 nCurrencyCount = aCurrSeq.getLength();
+ Currency2 const * const pCurrencies = aCurrSeq.getConstArray();
+
+ // one default currency for each locale, insert first so it is found first
+ sal_Int32 nDefault;
+ for ( nDefault = 0; nDefault < nCurrencyCount; nDefault++ )
+ {
+ if ( pCurrencies[nDefault].Default )
+ break;
+ }
+ if ( nDefault < nCurrencyCount )
+ pEntry = new NfCurrencyEntry( pCurrencies[nDefault], *pLocaleData, eLang );
+ else
+ pEntry = new NfCurrencyEntry( *pLocaleData, eLang ); // first or ShellsAndPebbles
+
+ if (LocaleDataWrapper::areChecksEnabled())
+ lcl_CheckCurrencySymbolPosition( *pEntry );
+
+ rCurrencyTable.Insert( pEntry, nCurrencyPos++ );
+ if ( !nSystemCurrencyPosition && (aConfiguredCurrencyAbbrev.Len() ?
+ pEntry->GetBankSymbol() == aConfiguredCurrencyAbbrev &&
+ pEntry->GetLanguage() == eConfiguredCurrencyLanguage : FALSE) )
+ nSystemCurrencyPosition = nCurrencyPos-1;
+ if ( !nMatchingSystemCurrencyPosition &&
+ pEntry->GetLanguage() == eSysLang )
+ nMatchingSystemCurrencyPosition = nCurrencyPos-1;
+
+ // all remaining currencies for each locale
+ if ( nCurrencyCount > 1 )
+ {
+ sal_Int32 nCurrency;
+ for ( nCurrency = 0; nCurrency < nCurrencyCount; nCurrency++ )
+ {
+ if (pCurrencies[nCurrency].LegacyOnly)
+ {
+ pEntry = new NfCurrencyEntry( pCurrencies[nCurrency], *pLocaleData, eLang );
+ rLegacyOnlyCurrencyTable.Insert( pEntry, nLegacyOnlyCurrencyPos++ );
+ }
+ else if ( nCurrency != nDefault )
+ {
+ pEntry = new NfCurrencyEntry( pCurrencies[nCurrency], *pLocaleData, eLang );
+ // no dupes
+ BOOL bInsert = TRUE;
+ NfCurrencyEntry const * const * pData = rCurrencyTable.GetData();
+ USHORT n = rCurrencyTable.Count();
+ pData++; // skip first SYSTEM entry
+ for ( USHORT j=1; j<n; j++ )
+ {
+ if ( *(*pData++) == *pEntry )
+ {
+ bInsert = FALSE;
+ break; // for
+ }
+ }
+ if ( !bInsert )
+ delete pEntry;
+ else
+ {
+ rCurrencyTable.Insert( pEntry, nCurrencyPos++ );
+ if ( !nSecondarySystemCurrencyPosition &&
+ (aConfiguredCurrencyAbbrev.Len() ?
+ pEntry->GetBankSymbol() == aConfiguredCurrencyAbbrev :
+ pEntry->GetLanguage() == eConfiguredCurrencyLanguage) )
+ nSecondarySystemCurrencyPosition = nCurrencyPos-1;
+ if ( !nMatchingSystemCurrencyPosition &&
+ pEntry->GetLanguage() == eSysLang )
+ nMatchingSystemCurrencyPosition = nCurrencyPos-1;
+ }
+ }
+ }
+ }
+ }
+ if ( !nSystemCurrencyPosition )
+ nSystemCurrencyPosition = nSecondarySystemCurrencyPosition;
+ if ((aConfiguredCurrencyAbbrev.Len() && !nSystemCurrencyPosition) &&
+ LocaleDataWrapper::areChecksEnabled())
+ LocaleDataWrapper::outputCheckMessage(
+ "SvNumberFormatter::ImpInitCurrencyTable: configured currency not in I18N locale data.");
+ // match SYSTEM if no configured currency found
+ if ( !nSystemCurrencyPosition )
+ nSystemCurrencyPosition = nMatchingSystemCurrencyPosition;
+ if ((!aConfiguredCurrencyAbbrev.Len() && !nSystemCurrencyPosition) &&
+ LocaleDataWrapper::areChecksEnabled())
+ LocaleDataWrapper::outputCheckMessage(
+ "SvNumberFormatter::ImpInitCurrencyTable: system currency not in I18N locale data.");
+ delete pLocaleData;
+ SvtSysLocaleOptions::SetCurrencyChangeLink(
+ STATIC_LINK( NULL, SvNumberFormatter, CurrencyChangeLink ) );
+ bInitializing = FALSE;
+ bCurrencyTableInitialized = TRUE;
+}
+
+
+USHORT SvNumberFormatter::GetCurrencyFormatStrings( NfWSStringsDtor& rStrArr,
+ const NfCurrencyEntry& rCurr, BOOL bBank ) const
+{
+ USHORT nDefault = 0;
+ if ( bBank )
+ { // nur Bankensymbole
+ String aPositiveBank, aNegativeBank;
+ rCurr.BuildPositiveFormatString( aPositiveBank, TRUE, *xLocaleData, 1 );
+ rCurr.BuildNegativeFormatString( aNegativeBank, TRUE, *xLocaleData, 1 );
+
+ WSStringPtr pFormat1 = new String( aPositiveBank );
+ *pFormat1 += ';';
+ WSStringPtr pFormat2 = new String( *pFormat1 );
+
+ String aRed( '[' );
+ aRed += pFormatScanner->GetRedString();
+ aRed += ']';
+
+ *pFormat2 += aRed;
+
+ *pFormat1 += aNegativeBank;
+ *pFormat2 += aNegativeBank;
+
+ rStrArr.Insert( pFormat1, rStrArr.Count() );
+ rStrArr.Insert( pFormat2, rStrArr.Count() );
+ nDefault = rStrArr.Count() - 1;
+ }
+ else
+ { // gemischte Formate wie in SvNumberFormatter::ImpGenerateFormats
+ // aber keine doppelten, wenn keine Nachkommastellen in Waehrung
+ String aPositive, aNegative, aPositiveNoDec, aNegativeNoDec,
+ aPositiveDashed, aNegativeDashed;
+ WSStringPtr pFormat1, pFormat2, pFormat3, pFormat4, pFormat5;
+
+ String aRed( '[' );
+ aRed += pFormatScanner->GetRedString();
+ aRed += ']';
+
+ rCurr.BuildPositiveFormatString( aPositive, FALSE, *xLocaleData, 1 );
+ rCurr.BuildNegativeFormatString( aNegative, FALSE, *xLocaleData, 1 );
+ if ( rCurr.GetDigits() )
+ {
+ rCurr.BuildPositiveFormatString( aPositiveNoDec, FALSE, *xLocaleData, 0 );
+ rCurr.BuildNegativeFormatString( aNegativeNoDec, FALSE, *xLocaleData, 0 );
+ rCurr.BuildPositiveFormatString( aPositiveDashed, FALSE, *xLocaleData, 2 );
+ rCurr.BuildNegativeFormatString( aNegativeDashed, FALSE, *xLocaleData, 2 );
+
+ pFormat1 = new String( aPositiveNoDec );
+ *pFormat1 += ';';
+ pFormat3 = new String( *pFormat1 );
+ pFormat5 = new String( aPositiveDashed );
+ *pFormat5 += ';';
+
+ *pFormat1 += aNegativeNoDec;
+
+ *pFormat3 += aRed;
+ *pFormat5 += aRed;
+
+ *pFormat3 += aNegativeNoDec;
+ *pFormat5 += aNegativeDashed;
+ }
+ else
+ {
+ pFormat1 = NULL;
+ pFormat3 = NULL;
+ pFormat5 = NULL;
+ }
+
+ pFormat2 = new String( aPositive );
+ *pFormat2 += ';';
+ pFormat4 = new String( *pFormat2 );
+
+ *pFormat2 += aNegative;
+
+ *pFormat4 += aRed;
+ *pFormat4 += aNegative;
+
+ if ( pFormat1 )
+ rStrArr.Insert( pFormat1, rStrArr.Count() );
+ rStrArr.Insert( pFormat2, rStrArr.Count() );
+ if ( pFormat3 )
+ rStrArr.Insert( pFormat3, rStrArr.Count() );
+ rStrArr.Insert( pFormat4, rStrArr.Count() );
+ nDefault = rStrArr.Count() - 1;
+ if ( pFormat5 )
+ rStrArr.Insert( pFormat5, rStrArr.Count() );
+ }
+ return nDefault;
+}
+
+
+//--- NfCurrencyEntry ----------------------------------------------------
+
+NfCurrencyEntry::NfCurrencyEntry( const LocaleDataWrapper& rLocaleData, LanguageType eLang )
+{
+ aSymbol = rLocaleData.getCurrSymbol();
+ aBankSymbol = rLocaleData.getCurrBankSymbol();
+ eLanguage = eLang;
+ nPositiveFormat = rLocaleData.getCurrPositiveFormat();
+ nNegativeFormat = rLocaleData.getCurrNegativeFormat();
+ nDigits = rLocaleData.getCurrDigits();
+ cZeroChar = rLocaleData.getCurrZeroChar();
+}
+
+
+NfCurrencyEntry::NfCurrencyEntry( const ::com::sun::star::i18n::Currency & rCurr,
+ const LocaleDataWrapper& rLocaleData, LanguageType eLang )
+{
+ aSymbol = rCurr.Symbol;
+ aBankSymbol = rCurr.BankSymbol;
+ eLanguage = eLang;
+ nPositiveFormat = rLocaleData.getCurrPositiveFormat();
+ nNegativeFormat = rLocaleData.getCurrNegativeFormat();
+ nDigits = rCurr.DecimalPlaces;
+ cZeroChar = rLocaleData.getCurrZeroChar();
+}
+
+
+BOOL NfCurrencyEntry::operator==( const NfCurrencyEntry& r ) const
+{
+ return aSymbol == r.aSymbol
+ && aBankSymbol == r.aBankSymbol
+ && eLanguage == r.eLanguage
+ ;
+}
+
+
+void NfCurrencyEntry::BuildSymbolString( String& rStr, BOOL bBank,
+ BOOL bWithoutExtension ) const
+{
+ rStr = '[';
+ rStr += '$';
+ if ( bBank )
+ rStr += aBankSymbol;
+ else
+ {
+ if ( aSymbol.Search( '-' ) != STRING_NOTFOUND || aSymbol.Search( ']' ) != STRING_NOTFOUND )
+ {
+ rStr += '"';
+ rStr += aSymbol;
+ rStr += '"';
+ }
+ else
+ rStr += aSymbol;
+ if ( !bWithoutExtension && eLanguage != LANGUAGE_DONTKNOW && eLanguage != LANGUAGE_SYSTEM )
+ {
+ rStr += '-';
+ rStr += String::CreateFromInt32( sal_Int32( eLanguage ), 16 ).ToUpperAscii();
+ }
+ }
+ rStr += ']';
+}
+
+
+void NfCurrencyEntry::Impl_BuildFormatStringNumChars( String& rStr,
+ const LocaleDataWrapper& rLoc, USHORT nDecimalFormat ) const
+{
+ rStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "###0" ) );
+ rStr.Insert( rLoc.getNumThousandSep(), 1 );
+ if ( nDecimalFormat && nDigits )
+ {
+ rStr += rLoc.getNumDecimalSep();
+ rStr.Expand( rStr.Len() + nDigits, (nDecimalFormat == 2 ? '-' : cZeroChar) );
+ }
+}
+
+
+void NfCurrencyEntry::BuildPositiveFormatString( String& rStr, BOOL bBank,
+ const LocaleDataWrapper& rLoc, USHORT nDecimalFormat ) const
+{
+ Impl_BuildFormatStringNumChars( rStr, rLoc, nDecimalFormat );
+ USHORT nPosiForm = NfCurrencyEntry::GetEffectivePositiveFormat(
+ rLoc.getCurrPositiveFormat(), nPositiveFormat, bBank );
+ CompletePositiveFormatString( rStr, bBank, nPosiForm );
+}
+
+
+void NfCurrencyEntry::BuildNegativeFormatString( String& rStr, BOOL bBank,
+ const LocaleDataWrapper& rLoc, USHORT nDecimalFormat ) const
+{
+ Impl_BuildFormatStringNumChars( rStr, rLoc, nDecimalFormat );
+ USHORT nNegaForm = NfCurrencyEntry::GetEffectiveNegativeFormat(
+ rLoc.getCurrNegativeFormat(), nNegativeFormat, bBank );
+ CompleteNegativeFormatString( rStr, bBank, nNegaForm );
+}
+
+
+void NfCurrencyEntry::CompletePositiveFormatString( String& rStr, BOOL bBank,
+ USHORT nPosiForm ) const
+{
+ String aSymStr;
+ BuildSymbolString( aSymStr, bBank );
+ NfCurrencyEntry::CompletePositiveFormatString( rStr, aSymStr, nPosiForm );
+}
+
+
+void NfCurrencyEntry::CompleteNegativeFormatString( String& rStr, BOOL bBank,
+ USHORT nNegaForm ) const
+{
+ String aSymStr;
+ BuildSymbolString( aSymStr, bBank );
+ NfCurrencyEntry::CompleteNegativeFormatString( rStr, aSymStr, nNegaForm );
+}
+
+
+// static
+void NfCurrencyEntry::CompletePositiveFormatString( String& rStr,
+ const String& rSymStr, USHORT nPositiveFormat )
+{
+ switch( nPositiveFormat )
+ {
+ case 0: // $1
+ rStr.Insert( rSymStr , 0 );
+ break;
+ case 1: // 1$
+ rStr += rSymStr;
+ break;
+ case 2: // $ 1
+ {
+ rStr.Insert( ' ', 0 );
+ rStr.Insert( rSymStr, 0 );
+ }
+ break;
+ case 3: // 1 $
+ {
+ rStr += ' ';
+ rStr += rSymStr;
+ }
+ break;
+ default:
+ DBG_ERROR("NfCurrencyEntry::CompletePositiveFormatString: unknown option");
+ break;
+ }
+}
+
+
+// static
+void NfCurrencyEntry::CompleteNegativeFormatString( String& rStr,
+ const String& rSymStr, USHORT nNegativeFormat )
+{
+ switch( nNegativeFormat )
+ {
+ case 0: // ($1)
+ {
+ rStr.Insert( rSymStr, 0);
+ rStr.Insert('(',0);
+ rStr += ')';
+ }
+ break;
+ case 1: // -$1
+ {
+ rStr.Insert( rSymStr, 0);
+ rStr.Insert('-',0);
+ }
+ break;
+ case 2: // $-1
+ {
+ rStr.Insert('-',0);
+ rStr.Insert( rSymStr, 0);
+ }
+ break;
+ case 3: // $1-
+ {
+ rStr.Insert( rSymStr, 0);
+ rStr += '-';
+ }
+ break;
+ case 4: // (1$)
+ {
+ rStr.Insert('(',0);
+ rStr += rSymStr;
+ rStr += ')';
+ }
+ break;
+ case 5: // -1$
+ {
+ rStr += rSymStr;
+ rStr.Insert('-',0);
+ }
+ break;
+ case 6: // 1-$
+ {
+ rStr += '-';
+ rStr += rSymStr;
+ }
+ break;
+ case 7: // 1$-
+ {
+ rStr += rSymStr;
+ rStr += '-';
+ }
+ break;
+ case 8: // -1 $
+ {
+ rStr += ' ';
+ rStr += rSymStr;
+ rStr.Insert('-',0);
+ }
+ break;
+ case 9: // -$ 1
+ {
+ rStr.Insert(' ',0);
+ rStr.Insert( rSymStr, 0);
+ rStr.Insert('-',0);
+ }
+ break;
+ case 10: // 1 $-
+ {
+ rStr += ' ';
+ rStr += rSymStr;
+ rStr += '-';
+ }
+ break;
+ case 11: // $ -1
+ {
+ String aTmp( rSymStr );
+ aTmp += ' ';
+ aTmp += '-';
+ rStr.Insert( aTmp, 0 );
+ }
+ break;
+ case 12 : // $ 1-
+ {
+ rStr.Insert(' ', 0);
+ rStr.Insert( rSymStr, 0);
+ rStr += '-';
+ }
+ break;
+ case 13 : // 1- $
+ {
+ rStr += '-';
+ rStr += ' ';
+ rStr += rSymStr;
+ }
+ break;
+ case 14 : // ($ 1)
+ {
+ rStr.Insert(' ',0);
+ rStr.Insert( rSymStr, 0);
+ rStr.Insert('(',0);
+ rStr += ')';
+ }
+ break;
+ case 15 : // (1 $)
+ {
+ rStr.Insert('(',0);
+ rStr += ' ';
+ rStr += rSymStr;
+ rStr += ')';
+ }
+ break;
+ default:
+ DBG_ERROR("NfCurrencyEntry::CompleteNegativeFormatString: unknown option");
+ break;
+ }
+}
+
+
+// static
+USHORT NfCurrencyEntry::GetEffectivePositiveFormat( USHORT
+#if ! NF_BANKSYMBOL_FIX_POSITION
+ nIntlFormat
+#endif
+ , USHORT nCurrFormat, BOOL bBank )
+{
+ if ( bBank )
+ {
+#if NF_BANKSYMBOL_FIX_POSITION
+ return 3;
+#else
+ switch ( nIntlFormat )
+ {
+ case 0: // $1
+ nIntlFormat = 2; // $ 1
+ break;
+ case 1: // 1$
+ nIntlFormat = 3; // 1 $
+ break;
+ case 2: // $ 1
+ break;
+ case 3: // 1 $
+ break;
+ default:
+ DBG_ERROR("NfCurrencyEntry::GetEffectivePositiveFormat: unknown option");
+ break;
+ }
+ return nIntlFormat;
+#endif
+ }
+ else
+ return nCurrFormat;
+}
+
+
+// nur aufrufen, wenn nCurrFormat wirklich mit Klammern ist
+USHORT lcl_MergeNegativeParenthesisFormat( USHORT nIntlFormat, USHORT nCurrFormat )
+{
+ short nSign = 0; // -1:=Klammer 0:=links, 1:=mitte, 2:=rechts
+ switch ( nIntlFormat )
+ {
+ case 0: // ($1)
+ case 4: // (1$)
+ case 14 : // ($ 1)
+ case 15 : // (1 $)
+ return nCurrFormat;
+ case 1: // -$1
+ case 5: // -1$
+ case 8: // -1 $
+ case 9: // -$ 1
+ nSign = 0;
+ break;
+ case 2: // $-1
+ case 6: // 1-$
+ case 11 : // $ -1
+ case 13 : // 1- $
+ nSign = 1;
+ break;
+ case 3: // $1-
+ case 7: // 1$-
+ case 10: // 1 $-
+ case 12 : // $ 1-
+ nSign = 2;
+ break;
+ default:
+ DBG_ERROR("lcl_MergeNegativeParenthesisFormat: unknown option");
+ break;
+ }
+
+ switch ( nCurrFormat )
+ {
+ case 0: // ($1)
+ switch ( nSign )
+ {
+ case 0:
+ return 1; // -$1
+ case 1:
+ return 2; // $-1
+ case 2:
+ return 3; // $1-
+ }
+ break;
+ case 4: // (1$)
+ switch ( nSign )
+ {
+ case 0:
+ return 5; // -1$
+ case 1:
+ return 6; // 1-$
+ case 2:
+ return 7; // 1$-
+ }
+ break;
+ case 14 : // ($ 1)
+ switch ( nSign )
+ {
+ case 0:
+ return 9; // -$ 1
+ case 1:
+ return 11; // $ -1
+ case 2:
+ return 12; // $ 1-
+ }
+ break;
+ case 15 : // (1 $)
+ switch ( nSign )
+ {
+ case 0:
+ return 8; // -1 $
+ case 1:
+ return 13; // 1- $
+ case 2:
+ return 10; // 1 $-
+ }
+ break;
+ }
+ return nCurrFormat;
+}
+
+
+// static
+USHORT NfCurrencyEntry::GetEffectiveNegativeFormat( USHORT nIntlFormat,
+ USHORT nCurrFormat, BOOL bBank )
+{
+ if ( bBank )
+ {
+#if NF_BANKSYMBOL_FIX_POSITION
+ return 8;
+#else
+ switch ( nIntlFormat )
+ {
+ case 0: // ($1)
+// nIntlFormat = 14; // ($ 1)
+ nIntlFormat = 9; // -$ 1
+ break;
+ case 1: // -$1
+ nIntlFormat = 9; // -$ 1
+ break;
+ case 2: // $-1
+ nIntlFormat = 11; // $ -1
+ break;
+ case 3: // $1-
+ nIntlFormat = 12; // $ 1-
+ break;
+ case 4: // (1$)
+// nIntlFormat = 15; // (1 $)
+ nIntlFormat = 8; // -1 $
+ break;
+ case 5: // -1$
+ nIntlFormat = 8; // -1 $
+ break;
+ case 6: // 1-$
+ nIntlFormat = 13; // 1- $
+ break;
+ case 7: // 1$-
+ nIntlFormat = 10; // 1 $-
+ break;
+ case 8: // -1 $
+ break;
+ case 9: // -$ 1
+ break;
+ case 10: // 1 $-
+ break;
+ case 11: // $ -1
+ break;
+ case 12 : // $ 1-
+ break;
+ case 13 : // 1- $
+ break;
+ case 14 : // ($ 1)
+// nIntlFormat = 14; // ($ 1)
+ nIntlFormat = 9; // -$ 1
+ break;
+ case 15 : // (1 $)
+// nIntlFormat = 15; // (1 $)
+ nIntlFormat = 8; // -1 $
+ break;
+ default:
+ DBG_ERROR("NfCurrencyEntry::GetEffectiveNegativeFormat: unknown option");
+ break;
+ }
+#endif
+ }
+ else if ( nIntlFormat != nCurrFormat )
+ {
+ switch ( nCurrFormat )
+ {
+ case 0: // ($1)
+ nIntlFormat = lcl_MergeNegativeParenthesisFormat(
+ nIntlFormat, nCurrFormat );
+ break;
+ case 1: // -$1
+ nIntlFormat = nCurrFormat;
+ break;
+ case 2: // $-1
+ nIntlFormat = nCurrFormat;
+ break;
+ case 3: // $1-
+ nIntlFormat = nCurrFormat;
+ break;
+ case 4: // (1$)
+ nIntlFormat = lcl_MergeNegativeParenthesisFormat(
+ nIntlFormat, nCurrFormat );
+ break;
+ case 5: // -1$
+ nIntlFormat = nCurrFormat;
+ break;
+ case 6: // 1-$
+ nIntlFormat = nCurrFormat;
+ break;
+ case 7: // 1$-
+ nIntlFormat = nCurrFormat;
+ break;
+ case 8: // -1 $
+ nIntlFormat = nCurrFormat;
+ break;
+ case 9: // -$ 1
+ nIntlFormat = nCurrFormat;
+ break;
+ case 10: // 1 $-
+ nIntlFormat = nCurrFormat;
+ break;
+ case 11: // $ -1
+ nIntlFormat = nCurrFormat;
+ break;
+ case 12 : // $ 1-
+ nIntlFormat = nCurrFormat;
+ break;
+ case 13 : // 1- $
+ nIntlFormat = nCurrFormat;
+ break;
+ case 14 : // ($ 1)
+ nIntlFormat = lcl_MergeNegativeParenthesisFormat(
+ nIntlFormat, nCurrFormat );
+ break;
+ case 15 : // (1 $)
+ nIntlFormat = lcl_MergeNegativeParenthesisFormat(
+ nIntlFormat, nCurrFormat );
+ break;
+ default:
+ DBG_ERROR("NfCurrencyEntry::GetEffectiveNegativeFormat: unknown option");
+ break;
+ }
+ }
+ return nIntlFormat;
+}
+
+
+// we only support default encodings here
+// static
+sal_Char NfCurrencyEntry::GetEuroSymbol( rtl_TextEncoding eTextEncoding )
+{
+ switch ( eTextEncoding )
+ {
+ case RTL_TEXTENCODING_MS_1252 : // WNT Ansi
+ case RTL_TEXTENCODING_ISO_8859_1 : // UNX for use with TrueType fonts
+ return '\x80';
+ case RTL_TEXTENCODING_ISO_8859_15 : // UNX real
+ return '\xA4';
+ case RTL_TEXTENCODING_IBM_850 : // OS2
+ return '\xD5';
+ case RTL_TEXTENCODING_APPLE_ROMAN : // MAC
+ return '\xDB';
+ default: // default system
+#if WNT
+ return '\x80';
+#elif OS2
+ return '\xD5';
+#elif UNX
+// return '\xA4'; // #56121# 0xA4 waere korrekt fuer iso-8859-15
+ return '\x80'; // aber Windoze-Code fuer die konvertierten TrueType-Fonts
+#else
+#error EuroSymbol is what?
+ return '\x80';
+#endif
+ }
+ return '\x80';
+}
+
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/numbers/svt_zformat.cxx b/binfilter/bf_svtools/source/numbers/svt_zformat.cxx
new file mode 100644
index 000000000000..fd362215fa7f
--- /dev/null
+++ b/binfilter/bf_svtools/source/numbers/svt_zformat.cxx
@@ -0,0 +1,4071 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <stdio.h>
+#include <ctype.h>
+#include <float.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include <tools/debug.hxx>
+#include <i18npool/mslangid.hxx>
+#include <rtl/math.hxx>
+#include <rtl/instance.hxx>
+#include <unotools/charclass.hxx>
+#include <unotools/calendarwrapper.hxx>
+#include <unotools/nativenumberwrapper.hxx>
+#include <com/sun/star/i18n/CalendarFieldIndex.hpp>
+#include <com/sun/star/i18n/CalendarDisplayIndex.hpp>
+#include <com/sun/star/i18n/CalendarDisplayCode.hpp>
+#include <com/sun/star/i18n/AmPmValue.hpp>
+
+#define _ZFORMAT_CXX
+#include <bf_svtools/zformat.hxx>
+#include "zforscan.hxx"
+
+#include "zforfind.hxx"
+#include <bf_svtools/zforlist.hxx>
+#include "numhead.hxx"
+
+#include "nfsymbol.hxx"
+
+namespace binfilter
+{
+
+namespace {
+struct Gregorian
+ : public rtl::StaticWithInit<const ::rtl::OUString, Gregorian> {
+ const ::rtl::OUString operator () () {
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("gregorian"));
+ }
+};
+}
+
+const double _D_MAX_U_LONG_ = (double) 0xffffffff; // 4294967295.0
+const double _D_MAX_LONG_ = (double) 0x7fffffff; // 2147483647.0
+const USHORT _MAX_FRACTION_PREC = 3;
+const double D_EPS = 1.0E-2;
+
+const double _D_MAX_D_BY_100 = 1.7E306;
+const double _D_MIN_M_BY_1000 = 2.3E-305;
+
+static BYTE cCharWidths[ 128-32 ] = {
+ 1,1,1,2,2,3,2,1,1,1,1,2,1,1,1,1,
+ 2,2,2,2,2,2,2,2,2,2,1,1,2,2,2,2,
+ 3,2,2,2,2,2,2,3,2,1,2,2,2,3,3,3,
+ 2,3,2,2,2,2,2,3,2,2,2,1,1,1,2,2,
+ 1,2,2,2,2,2,1,2,2,1,1,2,1,3,2,2,
+ 2,2,1,2,1,2,2,2,2,2,2,1,1,1,2,1
+};
+
+// static
+xub_StrLen SvNumberformat::InsertBlanks( String& r, xub_StrLen nPos, sal_Unicode c )
+{
+ if( c >= 32 )
+ {
+ USHORT n = 2; // Default fuer Zeichen > 128 (HACK!)
+ if( c <= 127 )
+ n = cCharWidths[ c - 32 ];
+ while( n-- )
+ r.Insert( ' ', nPos++ );
+ }
+ return nPos;
+}
+
+static long GetPrecExp( double fAbsVal )
+{
+ DBG_ASSERT( fAbsVal > 0.0, "GetPrecExp: fAbsVal <= 0.0" );
+ if ( fAbsVal < 1e-7 || fAbsVal > 1e7 )
+ { // die Schere, ob's schneller ist oder nicht, liegt zwischen 1e6 und 1e7
+ return (long) floor( log10( fAbsVal ) ) + 1;
+ }
+ else
+ {
+ long nPrecExp = 1;
+ while( fAbsVal < 1 )
+ {
+ fAbsVal *= 10;
+ nPrecExp--;
+ }
+ while( fAbsVal >= 10 )
+ {
+ fAbsVal /= 10;
+ nPrecExp++;
+ }
+ return nPrecExp;
+ }
+}
+
+const USHORT nNewCurrencyVersionId = 0x434E; // "NC"
+const sal_Unicode cNewCurrencyMagic = 0x01; // Magic for format code in comment
+const USHORT nNewStandardFlagVersionId = 0x4653; // "SF"
+
+/***********************Funktion SvNumberformatInfo******************************/
+
+void ImpSvNumberformatInfo::Copy( const ImpSvNumberformatInfo& rNumFor, USHORT nAnz )
+{
+ for (USHORT i = 0; i < nAnz; i++)
+ {
+ sStrArray[i] = rNumFor.sStrArray[i];
+ nTypeArray[i] = rNumFor.nTypeArray[i];
+ }
+ eScannedType = rNumFor.eScannedType;
+ bThousand = rNumFor.bThousand;
+ nThousand = rNumFor.nThousand;
+ nCntPre = rNumFor.nCntPre;
+ nCntPost = rNumFor.nCntPost;
+ nCntExp = rNumFor.nCntExp;
+}
+
+void ImpSvNumberformatInfo::Save(SvStream& rStream, USHORT nAnz) const
+{
+ for (USHORT i = 0; i < nAnz; i++)
+ {
+ rStream.WriteByteString( sStrArray[i], rStream.GetStreamCharSet() );
+ short nType = nTypeArray[i];
+ switch ( nType )
+ { // der Krampf fuer Versionen vor SV_NUMBERFORMATTER_VERSION_NEW_CURR
+ case NF_SYMBOLTYPE_CURRENCY :
+ rStream << short( NF_SYMBOLTYPE_STRING );
+ break;
+ case NF_SYMBOLTYPE_CURRDEL :
+ case NF_SYMBOLTYPE_CURREXT :
+ rStream << short(0); // werden ignoriert (hoffentlich..)
+ break;
+ default:
+ if ( nType > NF_KEY_LASTKEYWORD_SO5 )
+ rStream << short( NF_SYMBOLTYPE_STRING ); // all new keywords are string
+ else
+ rStream << nType;
+ }
+
+ }
+ rStream << eScannedType << bThousand << nThousand
+ << nCntPre << nCntPost << nCntExp;
+}
+
+void ImpSvNumberformatInfo::Load(SvStream& rStream, USHORT nAnz)
+{
+ for (USHORT i = 0; i < nAnz; i++)
+ {
+ SvNumberformat::LoadString( rStream, sStrArray[i] );
+ rStream >> nTypeArray[i];
+ }
+ rStream >> eScannedType >> bThousand >> nThousand
+ >> nCntPre >> nCntPost >> nCntExp;
+}
+
+
+//============================================================================
+
+// static
+BYTE SvNumberNatNum::MapDBNumToNatNum( BYTE nDBNum, LanguageType eLang, BOOL bDate )
+{
+ BYTE nNatNum = 0;
+ eLang = MsLangId::getRealLanguage( eLang ); // resolve SYSTEM etc.
+ eLang &= 0x03FF; // 10 bit primary language
+ if ( bDate )
+ {
+ if ( nDBNum == 4 && eLang == LANGUAGE_KOREAN )
+ nNatNum = 9;
+ else if ( nDBNum <= 3 )
+ nNatNum = nDBNum; // known to be good for: zh,ja,ko / 1,2,3
+ }
+ else
+ {
+ switch ( nDBNum )
+ {
+ case 1:
+ switch ( eLang )
+ {
+ case (LANGUAGE_CHINESE & 0x03FF) : nNatNum = 4; break;
+ case (LANGUAGE_JAPANESE & 0x03FF) : nNatNum = 1; break;
+ case (LANGUAGE_KOREAN & 0x03FF) : nNatNum = 1; break;
+ }
+ break;
+ case 2:
+ switch ( eLang )
+ {
+ case (LANGUAGE_CHINESE & 0x03FF) : nNatNum = 5; break;
+ case (LANGUAGE_JAPANESE & 0x03FF) : nNatNum = 4; break;
+ case (LANGUAGE_KOREAN & 0x03FF) : nNatNum = 2; break;
+ }
+ break;
+ case 3:
+ switch ( eLang )
+ {
+ case (LANGUAGE_CHINESE & 0x03FF) : nNatNum = 6; break;
+ case (LANGUAGE_JAPANESE & 0x03FF) : nNatNum = 5; break;
+ case (LANGUAGE_KOREAN & 0x03FF) : nNatNum = 3; break;
+ }
+ break;
+ case 4:
+ switch ( eLang )
+ {
+ case (LANGUAGE_JAPANESE & 0x03FF) : nNatNum = 7; break;
+ case (LANGUAGE_KOREAN & 0x03FF) : nNatNum = 9; break;
+ }
+ break;
+ }
+ }
+ return nNatNum;
+}
+
+/***********************Funktionen SvNumFor******************************/
+
+ImpSvNumFor::ImpSvNumFor()
+{
+ nAnzStrings = 0;
+ aI.nTypeArray = NULL;
+ aI.sStrArray = NULL;
+ aI.eScannedType = NUMBERFORMAT_UNDEFINED;
+ aI.bThousand = FALSE;
+ aI.nThousand = 0;
+ aI.nCntPre = 0;
+ aI.nCntPost = 0;
+ aI.nCntExp = 0;
+ pColor = NULL;
+}
+
+ImpSvNumFor::~ImpSvNumFor()
+{
+ for (USHORT i = 0; i < nAnzStrings; i++)
+ aI.sStrArray[i].Erase();
+ delete [] aI.sStrArray;
+ delete [] aI.nTypeArray;
+}
+
+void ImpSvNumFor::Enlarge(USHORT nAnz)
+{
+ if ( nAnzStrings != nAnz )
+ {
+ if ( aI.nTypeArray )
+ delete [] aI.nTypeArray;
+ if ( aI.sStrArray )
+ delete [] aI.sStrArray;
+ nAnzStrings = nAnz;
+ if ( nAnz )
+ {
+ aI.nTypeArray = new short[nAnz];
+ aI.sStrArray = new String[nAnz];
+ }
+ else
+ {
+ aI.nTypeArray = NULL;
+ aI.sStrArray = NULL;
+ }
+ }
+}
+
+void ImpSvNumFor::Copy( const ImpSvNumFor& rNumFor, ImpSvNumberformatScan* pSc )
+{
+ Enlarge( rNumFor.nAnzStrings );
+ aI.Copy( rNumFor.aI, nAnzStrings );
+ sColorName = rNumFor.sColorName;
+ if ( pSc )
+ pColor = pSc->GetColor( sColorName ); // #121103# don't copy pointer between documents
+ else
+ pColor = rNumFor.pColor;
+ aNatNum = rNumFor.aNatNum;
+}
+
+void ImpSvNumFor::Save(SvStream& rStream) const
+{
+ rStream << nAnzStrings;
+ aI.Save(rStream, nAnzStrings);
+ rStream.WriteByteString( sColorName, rStream.GetStreamCharSet() );
+}
+
+void ImpSvNumFor::Load(SvStream& rStream, ImpSvNumberformatScan& rSc,
+ String& rLoadedColorName )
+{
+ USHORT nAnz;
+ rStream >> nAnz; //! noch nicht direkt nAnzStrings wg. Enlarge
+ Enlarge( nAnz );
+ aI.Load( rStream, nAnz );
+ rStream.ReadByteString( sColorName, rStream.GetStreamCharSet() );
+ rLoadedColorName = sColorName;
+ pColor = rSc.GetColor(sColorName);
+}
+
+
+BOOL ImpSvNumFor::HasNewCurrency() const
+{
+ for ( USHORT j=0; j<nAnzStrings; j++ )
+ {
+ if ( aI.nTypeArray[j] == NF_SYMBOLTYPE_CURRENCY )
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+BOOL ImpSvNumFor::GetNewCurrencySymbol( String& rSymbol,
+ String& rExtension ) const
+{
+ for ( USHORT j=0; j<nAnzStrings; j++ )
+ {
+ if ( aI.nTypeArray[j] == NF_SYMBOLTYPE_CURRENCY )
+ {
+ rSymbol = aI.sStrArray[j];
+ if ( j < nAnzStrings-1 && aI.nTypeArray[j+1] == NF_SYMBOLTYPE_CURREXT )
+ rExtension = aI.sStrArray[j+1];
+ else
+ rExtension.Erase();
+ return TRUE;
+ }
+ }
+ //! kein Erase an rSymbol, rExtension
+ return FALSE;
+}
+
+
+void ImpSvNumFor::SaveNewCurrencyMap( SvStream& rStream ) const
+{
+ USHORT j;
+ USHORT nCnt = 0;
+ for ( j=0; j<nAnzStrings; j++ )
+ {
+ switch ( aI.nTypeArray[j] )
+ {
+ case NF_SYMBOLTYPE_CURRENCY :
+ case NF_SYMBOLTYPE_CURRDEL :
+ case NF_SYMBOLTYPE_CURREXT :
+ nCnt++;
+ break;
+ }
+ }
+ rStream << nCnt;
+ for ( j=0; j<nAnzStrings; j++ )
+ {
+ switch ( aI.nTypeArray[j] )
+ {
+ case NF_SYMBOLTYPE_CURRENCY :
+ case NF_SYMBOLTYPE_CURRDEL :
+ case NF_SYMBOLTYPE_CURREXT :
+ rStream << j << aI.nTypeArray[j];
+ break;
+ }
+ }
+}
+
+
+void ImpSvNumFor::LoadNewCurrencyMap( SvStream& rStream )
+{
+ USHORT nCnt;
+ rStream >> nCnt;
+ for ( USHORT j=0; j<nCnt; j++ )
+ {
+ USHORT nPos;
+ short nType;
+ rStream >> nPos >> nType;
+ if ( nPos < nAnzStrings )
+ aI.nTypeArray[nPos] = nType;
+ }
+}
+
+
+/***********************Funktionen SvNumberformat************************/
+
+enum BracketFormatSymbolType
+{
+ BRACKET_SYMBOLTYPE_FORMAT = -1, // subformat string
+ BRACKET_SYMBOLTYPE_COLOR = -2, // color
+ BRACKET_SYMBOLTYPE_ERROR = -3, // error
+ BRACKET_SYMBOLTYPE_DBNUM1 = -4, // DoubleByteNumber, represent numbers
+ BRACKET_SYMBOLTYPE_DBNUM2 = -5, // using CJK characters, Excel compatible.
+ BRACKET_SYMBOLTYPE_DBNUM3 = -6,
+ BRACKET_SYMBOLTYPE_DBNUM4 = -7,
+ BRACKET_SYMBOLTYPE_DBNUM5 = -8,
+ BRACKET_SYMBOLTYPE_DBNUM6 = -9,
+ BRACKET_SYMBOLTYPE_DBNUM7 = -10,
+ BRACKET_SYMBOLTYPE_DBNUM8 = -11,
+ BRACKET_SYMBOLTYPE_DBNUM9 = -12,
+ BRACKET_SYMBOLTYPE_LOCALE = -13,
+ BRACKET_SYMBOLTYPE_NATNUM0 = -14, // Our NativeNumber support, ASCII
+ BRACKET_SYMBOLTYPE_NATNUM1 = -15, // Our NativeNumber support, represent
+ BRACKET_SYMBOLTYPE_NATNUM2 = -16, // numbers using CJK, CTL, ...
+ BRACKET_SYMBOLTYPE_NATNUM3 = -17,
+ BRACKET_SYMBOLTYPE_NATNUM4 = -18,
+ BRACKET_SYMBOLTYPE_NATNUM5 = -19,
+ BRACKET_SYMBOLTYPE_NATNUM6 = -20,
+ BRACKET_SYMBOLTYPE_NATNUM7 = -21,
+ BRACKET_SYMBOLTYPE_NATNUM8 = -22,
+ BRACKET_SYMBOLTYPE_NATNUM9 = -23,
+ BRACKET_SYMBOLTYPE_NATNUM10 = -24,
+ BRACKET_SYMBOLTYPE_NATNUM11 = -25,
+ BRACKET_SYMBOLTYPE_NATNUM12 = -26,
+ BRACKET_SYMBOLTYPE_NATNUM13 = -27,
+ BRACKET_SYMBOLTYPE_NATNUM14 = -28,
+ BRACKET_SYMBOLTYPE_NATNUM15 = -29,
+ BRACKET_SYMBOLTYPE_NATNUM16 = -30,
+ BRACKET_SYMBOLTYPE_NATNUM17 = -31,
+ BRACKET_SYMBOLTYPE_NATNUM18 = -32,
+ BRACKET_SYMBOLTYPE_NATNUM19 = -33
+};
+
+SvNumberformat::SvNumberformat( ImpSvNumberformatScan& rSc, LanguageType eLge )
+ :
+ rScan(rSc),
+ eLnge(eLge),
+ nNewStandardDefined(0),
+ bStarFlag( FALSE )
+{
+}
+
+void SvNumberformat::ImpCopyNumberformat( const SvNumberformat& rFormat )
+{
+ sFormatstring = rFormat.sFormatstring;
+ eType = rFormat.eType;
+ eLnge = rFormat.eLnge;
+ fLimit1 = rFormat.fLimit1;
+ fLimit2 = rFormat.fLimit2;
+ eOp1 = rFormat.eOp1;
+ eOp2 = rFormat.eOp2;
+ bStandard = rFormat.bStandard;
+ bIsUsed = rFormat.bIsUsed;
+ sComment = rFormat.sComment;
+ nNewStandardDefined = rFormat.nNewStandardDefined;
+
+ // #121103# when copying between documents, get color pointers from own scanner
+ ImpSvNumberformatScan* pColorSc = ( &rScan != &rFormat.rScan ) ? &rScan : NULL;
+
+ for (USHORT i = 0; i < 4; i++)
+ NumFor[i].Copy(rFormat.NumFor[i], pColorSc);
+}
+
+SvNumberformat::SvNumberformat( const SvNumberformat& rFormat )
+ : rScan(rFormat.rScan), bStarFlag( rFormat.bStarFlag )
+{
+ ImpCopyNumberformat( rFormat );
+}
+
+SvNumberformat::SvNumberformat( SvNumberformat& rFormat, ImpSvNumberformatScan& rSc )
+ : rScan(rSc), bStarFlag( rFormat.bStarFlag )
+{
+ ImpCopyNumberformat( rFormat );
+}
+
+
+BOOL lcl_SvNumberformat_IsBracketedPrefix( short nSymbolType )
+{
+ if ( nSymbolType > 0 )
+ return TRUE; // conditions
+ switch ( nSymbolType )
+ {
+ case BRACKET_SYMBOLTYPE_COLOR :
+ case BRACKET_SYMBOLTYPE_DBNUM1 :
+ case BRACKET_SYMBOLTYPE_DBNUM2 :
+ case BRACKET_SYMBOLTYPE_DBNUM3 :
+ case BRACKET_SYMBOLTYPE_DBNUM4 :
+ case BRACKET_SYMBOLTYPE_DBNUM5 :
+ case BRACKET_SYMBOLTYPE_DBNUM6 :
+ case BRACKET_SYMBOLTYPE_DBNUM7 :
+ case BRACKET_SYMBOLTYPE_DBNUM8 :
+ case BRACKET_SYMBOLTYPE_DBNUM9 :
+ case BRACKET_SYMBOLTYPE_LOCALE :
+ case BRACKET_SYMBOLTYPE_NATNUM0 :
+ case BRACKET_SYMBOLTYPE_NATNUM1 :
+ case BRACKET_SYMBOLTYPE_NATNUM2 :
+ case BRACKET_SYMBOLTYPE_NATNUM3 :
+ case BRACKET_SYMBOLTYPE_NATNUM4 :
+ case BRACKET_SYMBOLTYPE_NATNUM5 :
+ case BRACKET_SYMBOLTYPE_NATNUM6 :
+ case BRACKET_SYMBOLTYPE_NATNUM7 :
+ case BRACKET_SYMBOLTYPE_NATNUM8 :
+ case BRACKET_SYMBOLTYPE_NATNUM9 :
+ case BRACKET_SYMBOLTYPE_NATNUM10 :
+ case BRACKET_SYMBOLTYPE_NATNUM11 :
+ case BRACKET_SYMBOLTYPE_NATNUM12 :
+ case BRACKET_SYMBOLTYPE_NATNUM13 :
+ case BRACKET_SYMBOLTYPE_NATNUM14 :
+ case BRACKET_SYMBOLTYPE_NATNUM15 :
+ case BRACKET_SYMBOLTYPE_NATNUM16 :
+ case BRACKET_SYMBOLTYPE_NATNUM17 :
+ case BRACKET_SYMBOLTYPE_NATNUM18 :
+ case BRACKET_SYMBOLTYPE_NATNUM19 :
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+SvNumberformat::SvNumberformat(String& rString,
+ ImpSvNumberformatScan* pSc,
+ ImpSvNumberInputScan* pISc,
+ xub_StrLen& nCheckPos,
+ LanguageType& eLan,
+ BOOL bStan)
+ :
+ rScan(*pSc),
+ nNewStandardDefined(0),
+ bStarFlag( FALSE )
+{
+ // If the group (AKA thousand) separator is a Non-Breaking Space (French)
+ // replace all occurences by a simple space.
+ // The tokens will be changed to the LocaleData separator again later on.
+ const sal_Unicode cNBSp = 0xA0;
+ const String& rThSep = GetFormatter().GetNumThousandSep();
+ if ( rThSep.GetChar(0) == cNBSp && rThSep.Len() == 1 )
+ {
+ xub_StrLen nIndex = 0;
+ do
+ nIndex = rString.SearchAndReplace( cNBSp, ' ', nIndex );
+ while ( nIndex != STRING_NOTFOUND );
+ }
+
+ if (rScan.GetConvertMode())
+ {
+ eLnge = rScan.GetNewLnge();
+ eLan = eLnge; // Wechsel auch zurueckgeben
+ }
+ else
+ eLnge = eLan;
+ bStandard = bStan;
+ bIsUsed = FALSE;
+ fLimit1 = 0.0;
+ fLimit2 = 0.0;
+ eOp1 = NUMBERFORMAT_OP_NO;
+ eOp2 = NUMBERFORMAT_OP_NO;
+ eType = NUMBERFORMAT_DEFINED;
+
+ BOOL bCancel = FALSE;
+ BOOL bCondition = FALSE;
+ short eSymbolType;
+ xub_StrLen nPos = 0;
+ xub_StrLen nPosOld;
+ nCheckPos = 0;
+ String aComment;
+
+ // Split into 4 sub formats
+ USHORT nIndex;
+ for ( nIndex = 0; nIndex < 4 && !bCancel; nIndex++ )
+ {
+ // Original language/country may have to be reestablished
+ if (rScan.GetConvertMode())
+ (rScan.GetNumberformatter())->ChangeIntl(rScan.GetTmpLnge());
+
+ String sStr;
+ nPosOld = nPos; // Start position of substring
+ // first get bracketed prefixes; e.g. conditions, color
+ do
+ {
+ eSymbolType = ImpNextSymbol(rString, nPos, sStr);
+ if (eSymbolType > 0) // condition
+ {
+ if ( nIndex == 0 && !bCondition )
+ {
+ bCondition = TRUE;
+ eOp1 = (SvNumberformatLimitOps) eSymbolType;
+ }
+ else if ( nIndex == 1 && bCondition )
+ eOp2 = (SvNumberformatLimitOps) eSymbolType;
+ else // error
+ {
+ bCancel = TRUE; // break for
+ nCheckPos = nPosOld;
+ }
+ if (!bCancel)
+ {
+ double fNumber;
+ xub_StrLen nAnzChars = ImpGetNumber(rString, nPos, sStr);
+ if (nAnzChars > 0)
+ {
+ short F_Type;
+ if (!pISc->IsNumberFormat(sStr,F_Type,fNumber) ||
+ ( F_Type != NUMBERFORMAT_NUMBER &&
+ F_Type != NUMBERFORMAT_SCIENTIFIC) )
+ {
+ fNumber = 0.0;
+ nPos = nPos - nAnzChars;
+ rString.Erase(nPos, nAnzChars);
+ rString.Insert('0',nPos);
+ nPos++;
+ }
+ }
+ else
+ {
+ fNumber = 0.0;
+ rString.Insert('0',nPos++);
+ }
+ if (nIndex == 0)
+ fLimit1 = fNumber;
+ else
+ fLimit2 = fNumber;
+ if ( rString.GetChar(nPos) == ']' )
+ nPos++;
+ else
+ {
+ bCancel = TRUE; // break for
+ nCheckPos = nPos;
+ }
+ }
+ nPosOld = nPos; // position before string
+ }
+ else if ( lcl_SvNumberformat_IsBracketedPrefix( eSymbolType ) )
+ {
+ switch ( eSymbolType )
+ {
+ case BRACKET_SYMBOLTYPE_COLOR :
+ {
+ if ( NumFor[nIndex].GetColor() != NULL )
+ { // error, more than one color
+ bCancel = TRUE; // break for
+ nCheckPos = nPosOld;
+ }
+ else
+ {
+ Color* pColor = pSc->GetColor( sStr);
+ NumFor[nIndex].SetColor( pColor, sStr);
+ if (pColor == NULL)
+ { // error
+ bCancel = TRUE; // break for
+ nCheckPos = nPosOld;
+ }
+ }
+ }
+ break;
+ case BRACKET_SYMBOLTYPE_NATNUM0 :
+ case BRACKET_SYMBOLTYPE_NATNUM1 :
+ case BRACKET_SYMBOLTYPE_NATNUM2 :
+ case BRACKET_SYMBOLTYPE_NATNUM3 :
+ case BRACKET_SYMBOLTYPE_NATNUM4 :
+ case BRACKET_SYMBOLTYPE_NATNUM5 :
+ case BRACKET_SYMBOLTYPE_NATNUM6 :
+ case BRACKET_SYMBOLTYPE_NATNUM7 :
+ case BRACKET_SYMBOLTYPE_NATNUM8 :
+ case BRACKET_SYMBOLTYPE_NATNUM9 :
+ case BRACKET_SYMBOLTYPE_NATNUM10 :
+ case BRACKET_SYMBOLTYPE_NATNUM11 :
+ case BRACKET_SYMBOLTYPE_NATNUM12 :
+ case BRACKET_SYMBOLTYPE_NATNUM13 :
+ case BRACKET_SYMBOLTYPE_NATNUM14 :
+ case BRACKET_SYMBOLTYPE_NATNUM15 :
+ case BRACKET_SYMBOLTYPE_NATNUM16 :
+ case BRACKET_SYMBOLTYPE_NATNUM17 :
+ case BRACKET_SYMBOLTYPE_NATNUM18 :
+ case BRACKET_SYMBOLTYPE_NATNUM19 :
+ {
+ if ( NumFor[nIndex].GetNatNum().IsSet() )
+ {
+ bCancel = TRUE; // break for
+ nCheckPos = nPosOld;
+ }
+ else
+ {
+ sStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "NatNum" ) );
+ //! eSymbolType is negative
+ BYTE nNum = sal::static_int_cast< BYTE >(0 - (eSymbolType - BRACKET_SYMBOLTYPE_NATNUM0));
+ sStr += String::CreateFromInt32( nNum );
+ NumFor[nIndex].SetNatNumNum( nNum, FALSE );
+ }
+ }
+ break;
+ case BRACKET_SYMBOLTYPE_DBNUM1 :
+ case BRACKET_SYMBOLTYPE_DBNUM2 :
+ case BRACKET_SYMBOLTYPE_DBNUM3 :
+ case BRACKET_SYMBOLTYPE_DBNUM4 :
+ case BRACKET_SYMBOLTYPE_DBNUM5 :
+ case BRACKET_SYMBOLTYPE_DBNUM6 :
+ case BRACKET_SYMBOLTYPE_DBNUM7 :
+ case BRACKET_SYMBOLTYPE_DBNUM8 :
+ case BRACKET_SYMBOLTYPE_DBNUM9 :
+ {
+ if ( NumFor[nIndex].GetNatNum().IsSet() )
+ {
+ bCancel = TRUE; // break for
+ nCheckPos = nPosOld;
+ }
+ else
+ {
+ sStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "DBNum" ) );
+ //! eSymbolType is negative
+ BYTE nNum = sal::static_int_cast< BYTE >(1 - (eSymbolType - BRACKET_SYMBOLTYPE_DBNUM1));
+ sStr += static_cast< sal_Unicode >('0' + nNum);
+ NumFor[nIndex].SetNatNumNum( nNum, TRUE );
+ }
+ }
+ break;
+ case BRACKET_SYMBOLTYPE_LOCALE :
+ {
+ if ( NumFor[nIndex].GetNatNum().GetLang() != LANGUAGE_DONTKNOW )
+ {
+ bCancel = TRUE; // break for
+ nCheckPos = nPosOld;
+ }
+ else
+ {
+ xub_StrLen nTmp = 2;
+ LanguageType eLang = ImpGetLanguageType( sStr, nTmp );
+ if ( eLang == LANGUAGE_DONTKNOW )
+ {
+ bCancel = TRUE; // break for
+ nCheckPos = nPosOld;
+ }
+ else
+ {
+ sStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "$-" ) );
+ sStr += String::CreateFromInt32( sal_Int32( eLang ), 16 ).ToUpperAscii();
+ NumFor[nIndex].SetNatNumLang( eLang );
+ }
+ }
+ }
+ break;
+ }
+ if ( !bCancel )
+ {
+ rString.Erase(nPosOld,nPos-nPosOld);
+ rString.Insert(sStr,nPosOld);
+ nPos = nPosOld + sStr.Len();
+ rString.Insert(']', nPos);
+ rString.Insert('[', nPosOld);
+ nPos += 2;
+ nPosOld = nPos; // position before string
+ }
+ }
+ } while ( !bCancel && lcl_SvNumberformat_IsBracketedPrefix( eSymbolType ) );
+
+ // The remaining format code string
+ if ( !bCancel )
+ {
+ if (eSymbolType == BRACKET_SYMBOLTYPE_FORMAT)
+ {
+ if (nIndex == 1 && eOp1 == NUMBERFORMAT_OP_NO)
+ eOp1 = NUMBERFORMAT_OP_GT; // undefined condition, default: > 0
+ else if (nIndex == 2 && eOp2 == NUMBERFORMAT_OP_NO)
+ eOp2 = NUMBERFORMAT_OP_LT; // undefined condition, default: < 0
+ if (sStr.Len() == 0)
+ { // empty sub format
+ }
+ else
+ {
+ xub_StrLen nStrPos = pSc->ScanFormat( sStr, aComment );
+ USHORT nAnz = pSc->GetAnzResStrings();
+ if (nAnz == 0) // error
+ nStrPos = 1;
+ if (nStrPos == 0) // ok
+ {
+ // e.g. Thai T speciality
+ if (pSc->GetNatNumModifier() && !NumFor[nIndex].GetNatNum().IsSet())
+ {
+ String aNat( RTL_CONSTASCII_USTRINGPARAM( "[NatNum"));
+ aNat += String::CreateFromInt32( pSc->GetNatNumModifier());
+ aNat += ']';
+ sStr.Insert( aNat, 0);
+ NumFor[nIndex].SetNatNumNum( pSc->GetNatNumModifier(), FALSE );
+ }
+ // #i53826# #i42727# For the Thai T speciality we need
+ // to freeze the locale and immunize it against
+ // conversions during exports, just in case we want to
+ // save to Xcl. This disables the feature of being able
+ // to convert a NatNum to another locale. You can't
+ // have both.
+ // FIXME: implement a specialized export conversion
+ // that works on tokens (have to tokenize all first)
+ // and doesn't use the format string and
+ // PutandConvertEntry() to LANGUAGE_ENGLISH_US in
+ // sc/source/filter/excel/xestyle.cxx
+ // XclExpNumFmtBuffer::WriteFormatRecord().
+ LanguageType eLanguage;
+ if (NumFor[nIndex].GetNatNum().GetNatNum() == 1 &&
+ ((eLanguage =
+ MsLangId::getRealLanguage( eLan))
+ == LANGUAGE_THAI) &&
+ NumFor[nIndex].GetNatNum().GetLang() ==
+ LANGUAGE_DONTKNOW)
+ {
+ String aLID( RTL_CONSTASCII_USTRINGPARAM( "[$-"));
+ aLID += String::CreateFromInt32( sal_Int32(
+ eLanguage), 16 ).ToUpperAscii();
+ aLID += ']';
+ sStr.Insert( aLID, 0);
+ NumFor[nIndex].SetNatNumLang( eLanguage);
+ }
+ rString.Erase(nPosOld,nPos-nPosOld);
+ rString.Insert(sStr,nPosOld);
+ nPos = nPosOld + sStr.Len();
+ if (nPos < rString.Len())
+ {
+ rString.Insert(';',nPos);
+ nPos++;
+ }
+ NumFor[nIndex].Enlarge(nAnz);
+ pSc->CopyInfo(&(NumFor[nIndex].Info()), nAnz);
+ // type check
+ if (nIndex == 0)
+ eType = (short) NumFor[nIndex].Info().eScannedType;
+ else if (nIndex == 3)
+ { // #77026# Everything recognized IS text
+ NumFor[nIndex].Info().eScannedType = NUMBERFORMAT_TEXT;
+ }
+ else if ( (short) NumFor[nIndex].Info().eScannedType !=
+ eType)
+ eType = NUMBERFORMAT_DEFINED;
+ }
+ else
+ {
+ nCheckPos = nPosOld + nStrPos; // error in string
+ bCancel = TRUE; // break for
+ }
+ }
+ }
+ else if (eSymbolType == BRACKET_SYMBOLTYPE_ERROR) // error
+ {
+ nCheckPos = nPosOld;
+ bCancel = TRUE;
+ }
+ else if ( lcl_SvNumberformat_IsBracketedPrefix( eSymbolType ) )
+ {
+ nCheckPos = nPosOld+1; // error, prefix in string
+ bCancel = TRUE; // break for
+ }
+ }
+ if ( bCancel && !nCheckPos )
+ nCheckPos = 1; // nCheckPos is used as an error condition
+ if ( !bCancel )
+ {
+ if ( NumFor[nIndex].GetNatNum().IsSet() &&
+ NumFor[nIndex].GetNatNum().GetLang() == LANGUAGE_DONTKNOW )
+ NumFor[nIndex].SetNatNumLang( eLan );
+ }
+ if (rString.Len() == nPos)
+ {
+ if ( nIndex == 2 && eSymbolType == BRACKET_SYMBOLTYPE_FORMAT &&
+ rString.GetChar(nPos-1) == ';' )
+ { // #83510# A 4th subformat explicitly specified to be empty
+ // hides any text. Need the type here for HasTextFormat()
+ NumFor[3].Info().eScannedType = NUMBERFORMAT_TEXT;
+ }
+ bCancel = TRUE;
+ }
+ if ( NumFor[nIndex].GetNatNum().IsSet() )
+ NumFor[nIndex].SetNatNumDate(
+ (NumFor[nIndex].Info().eScannedType & NUMBERFORMAT_DATE) != 0 );
+ }
+
+ if ( bCondition && !nCheckPos )
+ {
+ if ( nIndex == 1 && NumFor[0].GetnAnz() == 0 &&
+ rString.GetChar(rString.Len()-1) != ';' )
+ { // No format code => GENERAL but not if specified empty
+ String aAdd( pSc->GetStandardName() );
+ String aTmp;
+ if ( !pSc->ScanFormat( aAdd, aTmp ) )
+ {
+ USHORT nAnz = pSc->GetAnzResStrings();
+ if ( nAnz )
+ {
+ NumFor[0].Enlarge(nAnz);
+ pSc->CopyInfo( &(NumFor[0].Info()), nAnz );
+ rString += aAdd;
+ }
+ }
+ }
+ else if ( nIndex == 1 && NumFor[nIndex].GetnAnz() == 0 &&
+ rString.GetChar(rString.Len()-1) != ';' &&
+ (NumFor[0].GetnAnz() > 1 || (NumFor[0].GetnAnz() == 1 &&
+ NumFor[0].Info().nTypeArray[0] != NF_KEY_GENERAL)) )
+ { // No trailing second subformat => GENERAL but not if specified empty
+ // and not if first subformat is GENERAL
+ String aAdd( pSc->GetStandardName() );
+ String aTmp;
+ if ( !pSc->ScanFormat( aAdd, aTmp ) )
+ {
+ USHORT nAnz = pSc->GetAnzResStrings();
+ if ( nAnz )
+ {
+ NumFor[nIndex].Enlarge(nAnz);
+ pSc->CopyInfo( &(NumFor[nIndex].Info()), nAnz );
+ rString += ';';
+ rString += aAdd;
+ }
+ }
+ }
+ else if ( nIndex == 2 && NumFor[nIndex].GetnAnz() == 0 &&
+ rString.GetChar(rString.Len()-1) != ';' &&
+ eOp2 != NUMBERFORMAT_OP_NO )
+ { // No trailing third subformat => GENERAL but not if specified empty
+ String aAdd( pSc->GetStandardName() );
+ String aTmp;
+ if ( !pSc->ScanFormat( aAdd, aTmp ) )
+ {
+ USHORT nAnz = pSc->GetAnzResStrings();
+ if ( nAnz )
+ {
+ NumFor[nIndex].Enlarge(nAnz);
+ pSc->CopyInfo( &(NumFor[nIndex].Info()), nAnz );
+ rString += ';';
+ rString += aAdd;
+ }
+ }
+ }
+ }
+ sFormatstring = rString;
+ if ( aComment.Len() )
+ {
+ SetComment( aComment ); // setzt sComment und sFormatstring
+ rString = sFormatstring; // geaenderten sFormatstring uebernehmen
+ }
+ if (NumFor[2].GetnAnz() == 0 && // kein 3. Teilstring
+ eOp1 == NUMBERFORMAT_OP_GT && eOp2 == NUMBERFORMAT_OP_NO &&
+ fLimit1 == 0.0 && fLimit2 == 0.0)
+ eOp1 = NUMBERFORMAT_OP_GE; // 0 zum ersten Format dazu
+
+}
+
+SvNumberformat::~SvNumberformat()
+{
+}
+
+//---------------------------------------------------------------------------
+// Next_Symbol
+//---------------------------------------------------------------------------
+// Zerlegt die Eingabe in Symbole fuer die weitere
+// Verarbeitung (Turing-Maschine).
+//---------------------------------------------------------------------------
+// Ausgangs Zustand = SsStart
+//---------------+-------------------+-----------------------+---------------
+// Alter Zustand | gelesenes Zeichen | Aktion | Neuer Zustand
+//---------------+-------------------+-----------------------+---------------
+// SsStart | ; | Pos-- | SsGetString
+// | [ | Symbol += Zeichen | SsGetBracketed
+// | ] | Fehler | SsStop
+// | BLANK | |
+// | Sonst | Symbol += Zeichen | SsGetString
+//---------------+-------------------+-----------------------+---------------
+// SsGetString | ; | | SsStop
+// | Sonst | Symbol+=Zeichen |
+//---------------+-------------------+-----------------------+---------------
+// SsGetBracketed| <, > = | del [ |
+// | | Symbol += Zeichen | SsGetCon
+// | BLANK | |
+// | h, H, m, M, s, S | Symbol += Zeichen | SsGetTime
+// | sonst | del [ |
+// | | Symbol += Zeichen | SsGetPrefix
+//---------------+-------------------+-----------------------+---------------
+// SsGetTime | ] | Symbol += Zeichen | SsGetString
+// | h, H, m, M, s, S | Symbol += Zeichen, * | SsGetString
+// | sonst | del [; Symbol+=Zeichen| SsGetPrefix
+//---------------+-------------------+-----------------------+---------------
+// SsGetPrefix | ] | | SsStop
+// | sonst | Symbol += Zeichen |
+//---------------+-------------------+-----------------------+---------------
+// SsGetCon | >, = | Symbol+=Zeichen |
+// | ] | | SsStop
+// | sonst | Fehler | SsStop
+//---------------+-------------------+-----------------------+---------------
+// * : Sonderbedingung
+
+enum ScanState
+{
+ SsStop,
+ SsStart,
+ SsGetCon, // condition
+ SsGetString, // format string
+ SsGetPrefix, // color or NatNumN
+ SsGetTime, // [HH] for time
+ SsGetBracketed // any [...] not decided yet
+};
+
+
+// read a string until ']' and delete spaces in input
+// static
+xub_StrLen SvNumberformat::ImpGetNumber(String& rString,
+ xub_StrLen& nPos,
+ String& sSymbol)
+{
+ xub_StrLen nStartPos = nPos;
+ sal_Unicode cToken;
+ xub_StrLen nLen = rString.Len();
+ sSymbol.Erase();
+ while ( nPos < nLen && ((cToken = rString.GetChar(nPos)) != ']') )
+ {
+ if (cToken == ' ')
+ { // delete spaces
+ rString.Erase(nPos,1);
+ nLen--;
+ }
+ else
+ {
+ nPos++;
+ sSymbol += cToken;
+ }
+ }
+ return nPos - nStartPos;
+}
+
+
+// static
+LanguageType SvNumberformat::ImpGetLanguageType( const String& rString,
+ xub_StrLen& nPos )
+{
+ sal_Int32 nNum = 0;
+ sal_Unicode cToken = 0;
+ xub_StrLen nLen = rString.Len();
+ while ( nPos < nLen && ((cToken = rString.GetChar(nPos)) != ']') )
+ {
+ if ( '0' <= cToken && cToken <= '9' )
+ {
+ nNum *= 16;
+ nNum += cToken - '0';
+ }
+ else if ( 'a' <= cToken && cToken <= 'f' )
+ {
+ nNum *= 16;
+ nNum += cToken - 'a' + 10;
+ }
+ else if ( 'A' <= cToken && cToken <= 'F' )
+ {
+ nNum *= 16;
+ nNum += cToken - 'A' + 10;
+ }
+ else
+ return LANGUAGE_DONTKNOW;
+ ++nPos;
+ }
+ return (nNum && (cToken == ']' || nPos == nLen)) ? (LanguageType)nNum :
+ LANGUAGE_DONTKNOW;
+}
+
+
+short SvNumberformat::ImpNextSymbol(String& rString,
+ xub_StrLen& nPos,
+ String& sSymbol)
+{
+ short eSymbolType = BRACKET_SYMBOLTYPE_FORMAT;
+ sal_Unicode cToken;
+ sal_Unicode cLetter = ' '; // Zwischenergebnis
+ xub_StrLen nLen = rString.Len();
+ ScanState eState = SsStart;
+ sSymbol.Erase();
+ const String* pKeywords = rScan.GetKeywords();
+ while (nPos < nLen && eState != SsStop)
+ {
+ cToken = rString.GetChar(nPos);
+ nPos++;
+ switch (eState)
+ {
+ case SsStart:
+ {
+ if (cToken == '[')
+ {
+ eState = SsGetBracketed;
+ sSymbol += cToken;
+ }
+ else if (cToken == ';')
+ {
+ eState = SsGetString;
+ nPos--;
+ eSymbolType = BRACKET_SYMBOLTYPE_FORMAT;
+ }
+ else if (cToken == ']')
+ {
+ eState = SsStop;
+ eSymbolType = BRACKET_SYMBOLTYPE_ERROR;
+ }
+ else if (cToken == ' ') // Skip Blanks
+ {
+ rString.Erase(nPos-1,1);
+ nPos--;
+ nLen--;
+ }
+ else
+ {
+ sSymbol += cToken;
+ eState = SsGetString;
+ eSymbolType = BRACKET_SYMBOLTYPE_FORMAT;
+ }
+ }
+ break;
+ case SsGetBracketed:
+ {
+ switch (cToken)
+ {
+ case '<':
+ case '>':
+ case '=':
+ {
+ sSymbol.EraseAllChars('[');
+ sSymbol += cToken;
+ cLetter = cToken;
+ eState = SsGetCon;
+ switch (cToken)
+ {
+ case '<': eSymbolType = NUMBERFORMAT_OP_LT; break;
+ case '>': eSymbolType = NUMBERFORMAT_OP_GT; break;
+ case '=': eSymbolType = NUMBERFORMAT_OP_EQ; break;
+ default: break;
+ }
+ }
+ break;
+ case ' ':
+ {
+ rString.Erase(nPos-1,1);
+ nPos--;
+ nLen--;
+ }
+ break;
+ case '$' :
+ {
+ if ( rString.GetChar(nPos) == '-' )
+ { // [$-xxx] locale
+ sSymbol.EraseAllChars('[');
+ eSymbolType = BRACKET_SYMBOLTYPE_LOCALE;
+ eState = SsGetPrefix;
+ }
+ else
+ { // currency as of SV_NUMBERFORMATTER_VERSION_NEW_CURR
+ eSymbolType = BRACKET_SYMBOLTYPE_FORMAT;
+ eState = SsGetString;
+ }
+ sSymbol += cToken;
+ }
+ break;
+ case '~' :
+ { // calendarID as of SV_NUMBERFORMATTER_VERSION_CALENDAR
+ eSymbolType = BRACKET_SYMBOLTYPE_FORMAT;
+ sSymbol += cToken;
+ eState = SsGetString;
+ }
+ break;
+ default:
+ {
+ static const String aNatNum( RTL_CONSTASCII_USTRINGPARAM( "NATNUM" ) );
+ static const String aDBNum( RTL_CONSTASCII_USTRINGPARAM( "DBNUM" ) );
+ String aUpperNatNum( rChrCls().toUpper( rString, nPos-1, aNatNum.Len() ) );
+ String aUpperDBNum( rChrCls().toUpper( rString, nPos-1, aDBNum.Len() ) );
+ sal_Unicode cUpper = aUpperNatNum.GetChar(0);
+ sal_Int32 nNatNumNum = rString.Copy( nPos-1+aNatNum.Len() ).ToInt32();
+ sal_Unicode cDBNum = rString.GetChar( nPos-1+aDBNum.Len() );
+ if ( aUpperNatNum == aNatNum && 0 <= nNatNumNum && nNatNumNum <= 19 )
+ {
+ sSymbol.EraseAllChars('[');
+ sSymbol += rString.Copy( --nPos, aNatNum.Len()+1 );
+ nPos += aNatNum.Len()+1;
+ //! SymbolType is negative
+ eSymbolType = (short) (BRACKET_SYMBOLTYPE_NATNUM0 - nNatNumNum);
+ eState = SsGetPrefix;
+ }
+ else if ( aUpperDBNum == aDBNum && '1' <= cDBNum && cDBNum <= '9' )
+ {
+ sSymbol.EraseAllChars('[');
+ sSymbol += rString.Copy( --nPos, aDBNum.Len()+1 );
+ nPos += aDBNum.Len()+1;
+ //! SymbolType is negative
+ eSymbolType = sal::static_int_cast< short >(
+ BRACKET_SYMBOLTYPE_DBNUM1 - (cDBNum - '1'));
+ eState = SsGetPrefix;
+ }
+ else if (cUpper == pKeywords[NF_KEY_H].GetChar(0) || // H
+ cUpper == pKeywords[NF_KEY_MI].GetChar(0) || // M
+ cUpper == pKeywords[NF_KEY_S].GetChar(0) ) // S
+ {
+ sSymbol += cToken;
+ eState = SsGetTime;
+ cLetter = cToken;
+ }
+ else
+ {
+ sSymbol.EraseAllChars('[');
+ sSymbol += cToken;
+ eSymbolType = BRACKET_SYMBOLTYPE_COLOR;
+ eState = SsGetPrefix;
+ }
+ }
+ break;
+ }
+ }
+ break;
+ case SsGetString:
+ {
+ if (cToken == ';')
+ eState = SsStop;
+ else
+ sSymbol += cToken;
+ }
+ break;
+ case SsGetTime:
+ {
+ if (cToken == ']')
+ {
+ sSymbol += cToken;
+ eState = SsGetString;
+ eSymbolType = BRACKET_SYMBOLTYPE_FORMAT;
+ }
+ else
+ {
+ sal_Unicode cUpper = rChrCls().toUpper( rString, nPos-1, 1 ).GetChar(0);
+ if (cUpper == pKeywords[NF_KEY_H].GetChar(0) || // H
+ cUpper == pKeywords[NF_KEY_MI].GetChar(0) || // M
+ cUpper == pKeywords[NF_KEY_S].GetChar(0) ) // S
+ {
+ if (cLetter == cToken)
+ {
+ sSymbol += cToken;
+ cLetter = ' ';
+ }
+ else
+ {
+ sSymbol.EraseAllChars('[');
+ sSymbol += cToken;
+ eState = SsGetPrefix;
+ }
+ }
+ else
+ {
+ sSymbol.EraseAllChars('[');
+ sSymbol += cToken;
+ eSymbolType = BRACKET_SYMBOLTYPE_COLOR;
+ eState = SsGetPrefix;
+ }
+ }
+ }
+ break;
+ case SsGetCon:
+ {
+ switch (cToken)
+ {
+ case '<':
+ {
+ eState = SsStop;
+ eSymbolType = BRACKET_SYMBOLTYPE_ERROR;
+ }
+ break;
+ case '>':
+ {
+ if (cLetter == '<')
+ {
+ sSymbol += cToken;
+ cLetter = ' ';
+ eState = SsStop;
+ eSymbolType = NUMBERFORMAT_OP_NE;
+ }
+ else
+ {
+ eState = SsStop;
+ eSymbolType = BRACKET_SYMBOLTYPE_ERROR;
+ }
+ }
+ break;
+ case '=':
+ {
+ if (cLetter == '<')
+ {
+ sSymbol += cToken;
+ cLetter = ' ';
+ eSymbolType = NUMBERFORMAT_OP_LE;
+ }
+ else if (cLetter == '>')
+ {
+ sSymbol += cToken;
+ cLetter = ' ';
+ eSymbolType = NUMBERFORMAT_OP_GE;
+ }
+ else
+ {
+ eState = SsStop;
+ eSymbolType = BRACKET_SYMBOLTYPE_ERROR;
+ }
+ }
+ break;
+ case ' ':
+ {
+ rString.Erase(nPos-1,1);
+ nPos--;
+ nLen--;
+ }
+ break;
+ default:
+ {
+ eState = SsStop;
+ nPos--;
+ }
+ break;
+ }
+ }
+ break;
+ case SsGetPrefix:
+ {
+ if (cToken == ']')
+ eState = SsStop;
+ else
+ sSymbol += cToken;
+ }
+ break;
+ default:
+ break;
+ } // of switch
+ } // of while
+
+ return eSymbolType;
+}
+
+NfHackConversion SvNumberformat::Load( SvStream& rStream,
+ ImpSvNumMultipleReadHeader& rHdr, SvNumberFormatter* pHackConverter,
+ ImpSvNumberInputScan& rISc )
+{
+ rHdr.StartEntry();
+ USHORT nOp1, nOp2;
+ SvNumberformat::LoadString( rStream, sFormatstring );
+ rStream >> eType >> fLimit1 >> fLimit2
+ >> nOp1 >> nOp2 >> bStandard >> bIsUsed;
+ NfHackConversion eHackConversion = NF_CONVERT_NONE;
+ BOOL bOldConvert = FALSE;
+ LanguageType eOldTmpLang = 0;
+ LanguageType eOldNewLang = 0;
+ if ( pHackConverter )
+ { // werden nur hierbei gebraucht
+ bOldConvert = rScan.GetConvertMode();
+ eOldTmpLang = rScan.GetTmpLnge();
+ eOldNewLang = rScan.GetNewLnge();
+ }
+ String aLoadedColorName;
+ for (USHORT i = 0; i < 4; i++)
+ {
+ NumFor[i].Load( rStream, rScan, aLoadedColorName );
+ if ( pHackConverter && eHackConversion == NF_CONVERT_NONE )
+ {
+ //! HACK! ER 29.07.97 13:52
+ // leider wurde nicht gespeichert, was SYSTEM on Save wirklich war :-/
+ // aber immerhin wird manchmal fuer einen Entry FARBE oder COLOR gespeichert..
+ // System-German FARBE nach System-xxx COLOR umsetzen und vice versa,
+ //! geht davon aus, dass onSave nur GERMAN und ENGLISH KeyWords in
+ //! ImpSvNumberformatScan existierten
+ if ( aLoadedColorName.Len() && !NumFor[i].GetColor()
+ && aLoadedColorName != rScan.GetColorString() )
+ {
+ if ( rScan.GetColorString().EqualsAscii( "FARBE" ) )
+ { // English -> German
+ eHackConversion = NF_CONVERT_ENGLISH_GERMAN;
+ rScan.GetNumberformatter()->ChangeIntl( LANGUAGE_ENGLISH_US );
+ rScan.SetConvertMode( LANGUAGE_ENGLISH_US, LANGUAGE_GERMAN );
+ }
+ else
+ { // German -> English
+ eHackConversion = NF_CONVERT_GERMAN_ENGLISH;
+ rScan.GetNumberformatter()->ChangeIntl( LANGUAGE_GERMAN );
+ rScan.SetConvertMode( LANGUAGE_GERMAN, LANGUAGE_ENGLISH_US );
+ }
+ String aColorName = NumFor[i].GetColorName();
+ const Color* pColor = rScan.GetColor( aColorName );
+ if ( !pColor && aLoadedColorName == aColorName )
+ eHackConversion = NF_CONVERT_NONE;
+ rScan.GetNumberformatter()->ChangeIntl( LANGUAGE_SYSTEM );
+ rScan.SetConvertMode( eOldTmpLang, eOldNewLang );
+ rScan.SetConvertMode( bOldConvert );
+ }
+ }
+ }
+ eOp1 = (SvNumberformatLimitOps) nOp1;
+ eOp2 = (SvNumberformatLimitOps) nOp2;
+ String aComment; // wird nach dem NewCurrency-Geraffel richtig gesetzt
+ if ( rHdr.BytesLeft() )
+ { // ab SV_NUMBERFORMATTER_VERSION_NEWSTANDARD
+ SvNumberformat::LoadString( rStream, aComment );
+ rStream >> nNewStandardDefined;
+ }
+
+ xub_StrLen nNewCurrencyEnd = STRING_NOTFOUND;
+ BOOL bNewCurrencyComment = ( aComment.GetChar(0) == cNewCurrencyMagic &&
+ (nNewCurrencyEnd = aComment.Search( cNewCurrencyMagic, 1 )) != STRING_NOTFOUND );
+ BOOL bNewCurrencyLoaded = FALSE;
+ BOOL bNewCurrency = FALSE;
+
+ BOOL bGoOn = TRUE;
+ while ( rHdr.BytesLeft() && bGoOn )
+ { // as of SV_NUMBERFORMATTER_VERSION_NEW_CURR
+ USHORT nId;
+ rStream >> nId;
+ switch ( nId )
+ {
+ case nNewCurrencyVersionId :
+ {
+ bNewCurrencyLoaded = TRUE;
+ rStream >> bNewCurrency;
+ if ( bNewCurrency )
+ {
+ for ( USHORT j=0; j<4; j++ )
+ {
+ NumFor[j].LoadNewCurrencyMap( rStream );
+ }
+ }
+ }
+ break;
+ case nNewStandardFlagVersionId :
+ rStream >> bStandard; // the real standard flag
+ break;
+ default:
+ DBG_ERRORFILE( "SvNumberformat::Load: unknown header bytes left nId" );
+ bGoOn = FALSE; // stop reading unknown stream left over of newer versions
+ // Would be nice to have multiple read/write headers instead
+ // but old versions wouldn't know it, TLOT.
+ }
+ }
+ rHdr.EndEntry();
+
+ if ( bNewCurrencyLoaded )
+ {
+ if ( bNewCurrency && bNewCurrencyComment )
+ { // original Formatstring und Kommentar wiederherstellen
+ sFormatstring = aComment.Copy( 1, nNewCurrencyEnd-1 );
+ aComment.Erase( 0, nNewCurrencyEnd+1 );
+ }
+ }
+ else if ( bNewCurrencyComment )
+ { // neu, aber mit Version vor SV_NUMBERFORMATTER_VERSION_NEW_CURR gespeichert
+ // original Formatstring und Kommentar wiederherstellen
+ sFormatstring = aComment.Copy( 1, nNewCurrencyEnd-1 );
+ aComment.Erase( 0, nNewCurrencyEnd+1 );
+ // Zustaende merken
+ short nDefined = ( eType & NUMBERFORMAT_DEFINED );
+ USHORT nNewStandard = nNewStandardDefined;
+ // neu parsen etc.
+ String aStr( sFormatstring );
+ xub_StrLen nCheckPos = 0;
+ SvNumberformat* pFormat = new SvNumberformat( aStr, &rScan, &rISc,
+ nCheckPos, eLnge, bStandard );
+ DBG_ASSERT( !nCheckPos, "SvNumberformat::Load: NewCurrencyRescan nCheckPos" );
+ ImpCopyNumberformat( *pFormat );
+ delete pFormat;
+ // Zustaende wiederherstellen
+ eType |= nDefined;
+ if ( nNewStandard )
+ SetNewStandardDefined( nNewStandard );
+ }
+ SetComment( aComment );
+
+ if ( eHackConversion != NF_CONVERT_NONE )
+ { //! und weiter mit dem HACK!
+ switch ( eHackConversion )
+ {
+ case NF_CONVERT_ENGLISH_GERMAN :
+ ConvertLanguage( *pHackConverter,
+ LANGUAGE_ENGLISH_US, LANGUAGE_GERMAN, TRUE );
+ break;
+ case NF_CONVERT_GERMAN_ENGLISH :
+ ConvertLanguage( *pHackConverter,
+ LANGUAGE_GERMAN, LANGUAGE_ENGLISH_US, TRUE );
+ break;
+ default:
+ DBG_ERRORFILE( "SvNumberformat::Load: eHackConversion unknown" );
+ }
+ }
+ return eHackConversion;
+}
+
+void SvNumberformat::ConvertLanguage( SvNumberFormatter& rConverter,
+ LanguageType eConvertFrom, LanguageType eConvertTo, BOOL bSystem )
+{
+ xub_StrLen nCheckPos;
+ sal_uInt32 nKey;
+ short nType = eType;
+ String aFormatString( sFormatstring );
+ if ( bSystem )
+ rConverter.PutandConvertEntrySystem( aFormatString, nCheckPos, nType,
+ nKey, eConvertFrom, eConvertTo );
+ else
+ rConverter.PutandConvertEntry( aFormatString, nCheckPos, nType,
+ nKey, eConvertFrom, eConvertTo );
+ const SvNumberformat* pFormat = rConverter.GetEntry( nKey );
+ DBG_ASSERT( pFormat, "SvNumberformat::ConvertLanguage: Conversion ohne Format" );
+ if ( pFormat )
+ {
+ ImpCopyNumberformat( *pFormat );
+ // aus Formatter/Scanner uebernommene Werte zuruecksetzen
+ if ( bSystem )
+ eLnge = LANGUAGE_SYSTEM;
+ // pColor zeigt noch auf Tabelle in temporaerem Formatter/Scanner
+ for ( USHORT i = 0; i < 4; i++ )
+ {
+ String aColorName = NumFor[i].GetColorName();
+ Color* pColor = rScan.GetColor( aColorName );
+ NumFor[i].SetColor( pColor, aColorName );
+ }
+ }
+}
+
+
+// static
+void SvNumberformat::LoadString( SvStream& rStream, String& rStr )
+{
+ CharSet eStream = rStream.GetStreamCharSet();
+ ByteString aStr;
+ rStream.ReadByteString( aStr );
+ sal_Char cStream = NfCurrencyEntry::GetEuroSymbol( eStream );
+ if ( aStr.Search( cStream ) == STRING_NOTFOUND )
+ { // simple conversion to unicode
+ rStr = UniString( aStr, eStream );
+ }
+ else
+ {
+ sal_Unicode cTarget = NfCurrencyEntry::GetEuroSymbol();
+ register const sal_Char* p = aStr.GetBuffer();
+ register const sal_Char* const pEnd = p + aStr.Len();
+ register sal_Unicode* pUni = rStr.AllocBuffer( aStr.Len() );
+ while ( p < pEnd )
+ {
+ if ( *p == cStream )
+ *pUni = cTarget;
+ else
+ *pUni = ByteString::ConvertToUnicode( *p, eStream );
+ p++;
+ pUni++;
+ }
+ *pUni = 0;
+ }
+}
+
+
+void SvNumberformat::Save( SvStream& rStream, ImpSvNumMultipleWriteHeader& rHdr ) const
+{
+ String aFormatstring( sFormatstring );
+ String aComment( sComment );
+#if NF_COMMENT_IN_FORMATSTRING
+ // der Kommentar im Formatstring wird nicht gespeichert, um in alten Versionen
+ // nicht ins schleudern zu kommen und spaeter getrennte Verarbeitung
+ // (z.B. im Dialog) zu ermoeglichen
+ SetComment( "", aFormatstring, aComment );
+#endif
+
+ BOOL bNewCurrency = HasNewCurrency();
+ if ( bNewCurrency )
+ { // SV_NUMBERFORMATTER_VERSION_NEW_CURR im Kommentar speichern
+ aComment.Insert( cNewCurrencyMagic, 0 );
+ aComment.Insert( cNewCurrencyMagic, 0 );
+ aComment.Insert( aFormatstring, 1 );
+ Build50Formatstring( aFormatstring ); // alten Formatstring generieren
+ }
+
+ // old SO5 versions do behave strange (no output) if standard flag is set
+ // on formats not prepared for it (not having the following exact types)
+ BOOL bOldStandard = bStandard;
+ if ( bOldStandard )
+ {
+ switch ( eType )
+ {
+ case NUMBERFORMAT_NUMBER :
+ case NUMBERFORMAT_DATE :
+ case NUMBERFORMAT_TIME :
+ case NUMBERFORMAT_DATETIME :
+ case NUMBERFORMAT_PERCENT :
+ case NUMBERFORMAT_SCIENTIFIC :
+ // ok to save
+ break;
+ default:
+ bOldStandard = FALSE;
+ }
+ }
+
+ rHdr.StartEntry();
+ rStream.WriteByteString( aFormatstring, rStream.GetStreamCharSet() );
+ rStream << eType << fLimit1 << fLimit2 << (USHORT) eOp1 << (USHORT) eOp2
+ << bOldStandard << bIsUsed;
+ for (USHORT i = 0; i < 4; i++)
+ NumFor[i].Save(rStream);
+ // ab SV_NUMBERFORMATTER_VERSION_NEWSTANDARD
+ rStream.WriteByteString( aComment, rStream.GetStreamCharSet() );
+ rStream << nNewStandardDefined;
+ // ab SV_NUMBERFORMATTER_VERSION_NEW_CURR
+ rStream << nNewCurrencyVersionId;
+ rStream << bNewCurrency;
+ if ( bNewCurrency )
+ {
+ for ( USHORT j=0; j<4; j++ )
+ {
+ NumFor[j].SaveNewCurrencyMap( rStream );
+ }
+ }
+
+ // the real standard flag to load with versions >638 if different
+ if ( bStandard != bOldStandard )
+ {
+ rStream << nNewStandardFlagVersionId;
+ rStream << bStandard;
+ }
+
+ rHdr.EndEntry();
+}
+
+
+BOOL SvNumberformat::HasNewCurrency() const
+{
+ for ( USHORT j=0; j<4; j++ )
+ {
+ if ( NumFor[j].HasNewCurrency() )
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+BOOL SvNumberformat::GetNewCurrencySymbol( String& rSymbol,
+ String& rExtension ) const
+{
+ for ( USHORT j=0; j<4; j++ )
+ {
+ if ( NumFor[j].GetNewCurrencySymbol( rSymbol, rExtension ) )
+ return TRUE;
+ }
+ rSymbol.Erase();
+ rExtension.Erase();
+ return FALSE;
+}
+
+
+// static
+String SvNumberformat::StripNewCurrencyDelimiters( const String& rStr,
+ BOOL bQuoteSymbol )
+{
+ String aTmp;
+ xub_StrLen nStartPos, nPos, nLen;
+ nLen = rStr.Len();
+ nStartPos = 0;
+ while ( (nPos = rStr.SearchAscii( "[$", nStartPos )) != STRING_NOTFOUND )
+ {
+ xub_StrLen nEnd;
+ if ( (nEnd = GetQuoteEnd( rStr, nPos )) < nLen )
+ {
+ aTmp += rStr.Copy( nStartPos, ++nEnd - nStartPos );
+ nStartPos = nEnd;
+ }
+ else
+ {
+ aTmp += rStr.Copy( nStartPos, nPos - nStartPos );
+ nStartPos = nPos + 2;
+ xub_StrLen nDash;
+ nEnd = nStartPos - 1;
+ do
+ {
+ nDash = rStr.Search( '-', ++nEnd );
+ } while ( (nEnd = GetQuoteEnd( rStr, nDash )) < nLen );
+ xub_StrLen nClose;
+ nEnd = nStartPos - 1;
+ do
+ {
+ nClose = rStr.Search( ']', ++nEnd );
+ } while ( (nEnd = GetQuoteEnd( rStr, nClose )) < nLen );
+ nPos = ( nDash < nClose ? nDash : nClose );
+ if ( !bQuoteSymbol || rStr.GetChar( nStartPos ) == '"' )
+ aTmp += rStr.Copy( nStartPos, nPos - nStartPos );
+ else
+ {
+ aTmp += '"';
+ aTmp += rStr.Copy( nStartPos, nPos - nStartPos );
+ aTmp += '"';
+ }
+ nStartPos = nClose + 1;
+ }
+ }
+ if ( nLen > nStartPos )
+ aTmp += rStr.Copy( nStartPos, nLen - nStartPos );
+ return aTmp;
+}
+
+
+void SvNumberformat::Build50Formatstring( String& rStr ) const
+{
+ rStr = StripNewCurrencyDelimiters( sFormatstring, TRUE );
+}
+
+
+void SvNumberformat::ImpGetOutputStandard(double& fNumber, String& OutString)
+{
+ USHORT nStandardPrec = rScan.GetStandardPrec();
+ if ( fabs(fNumber) > 1.0E15 ) // #58531# war E16
+ OutString = ::rtl::math::doubleToUString( fNumber,
+ rtl_math_StringFormat_E, nStandardPrec /*2*/,
+ GetFormatter().GetNumDecimalSep().GetChar(0));
+ else
+ {
+#if 0
+{
+ // debugger test case for ANSI standard correctness
+ ::rtl::OUString aTest;
+ // expect 0.00123 OK
+ aTest = ::rtl::math::doubleToUString( 0.001234567,
+ rtl_math_StringFormat_G, 3, '.', sal_True );
+ // expect 123 OK
+ aTest = ::rtl::math::doubleToUString( 123.4567,
+ rtl_math_StringFormat_G, 3, '.', sal_True );
+ // expect 123.5 OK
+ aTest = ::rtl::math::doubleToUString( 123.4567,
+ rtl_math_StringFormat_G, 4, '.', sal_True );
+ // expect 1e+03 (as 999.6 rounded to 3 significant digits results in
+ // 1000 with an exponent equal to significant digits)
+ // Currently (24-Jan-2003) we do fail in this case and output 1000
+ // instead, negligible.
+ aTest = ::rtl::math::doubleToUString( 999.6,
+ rtl_math_StringFormat_G, 3, '.', sal_True );
+ // expect what? result is 1.2e+004
+ aTest = ::rtl::math::doubleToUString( 12345.6789,
+ rtl_math_StringFormat_G, -3, '.', sal_True );
+}
+#endif
+
+ OutString = ::rtl::math::doubleToUString( fNumber,
+ rtl_math_StringFormat_F, nStandardPrec /*2*/,
+ GetFormatter().GetNumDecimalSep().GetChar(0), sal_True );
+ if (OutString.GetChar(0) == '-' &&
+ OutString.GetTokenCount('0') == OutString.Len())
+ OutString.EraseLeadingChars('-'); // nicht -0
+ }
+ return;
+}
+
+void SvNumberformat::ImpGetOutputInputLine(double fNumber, String& OutString)
+{
+ BOOL bModified = FALSE;
+ if ( (eType & NUMBERFORMAT_PERCENT) && (fabs(fNumber) < _D_MAX_D_BY_100))
+ {
+ if (fNumber == 0.0)
+ {
+ OutString.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "0%" ) );
+ return;
+ }
+ fNumber *= 100;
+ bModified = TRUE;
+ }
+
+ if (fNumber == 0.0)
+ {
+ OutString = '0';
+ return;
+ }
+
+ OutString = ::rtl::math::doubleToUString( fNumber,
+ rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
+ GetFormatter().GetNumDecimalSep().GetChar(0), sal_True );
+
+ if ( eType & NUMBERFORMAT_PERCENT && bModified)
+ OutString += '%';
+ return;
+}
+
+short SvNumberformat::ImpCheckCondition(double& fNumber,
+ double& fLimit,
+ SvNumberformatLimitOps eOp)
+{
+ switch(eOp)
+ {
+ case NUMBERFORMAT_OP_NO: return -1;
+ case NUMBERFORMAT_OP_EQ: return (short) (fNumber == fLimit);
+ case NUMBERFORMAT_OP_NE: return (short) (fNumber != fLimit);
+ case NUMBERFORMAT_OP_LT: return (short) (fNumber < fLimit);
+ case NUMBERFORMAT_OP_LE: return (short) (fNumber <= fLimit);
+ case NUMBERFORMAT_OP_GT: return (short) (fNumber > fLimit);
+ case NUMBERFORMAT_OP_GE: return (short) (fNumber >= fLimit);
+ default: return -1;
+ }
+}
+
+BOOL SvNumberformat::GetOutputString(String& sString,
+ String& OutString,
+ Color** ppColor)
+{
+ OutString.Erase();
+ USHORT nIx;
+ if (eType & NUMBERFORMAT_TEXT)
+ nIx = 0;
+ else if (NumFor[3].GetnAnz() > 0)
+ nIx = 3;
+ else
+ {
+ *ppColor = NULL; // no change of color
+ return FALSE;
+ }
+ *ppColor = NumFor[nIx].GetColor();
+ const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info();
+ if (rInfo.eScannedType == NUMBERFORMAT_TEXT)
+ {
+ BOOL bRes = FALSE;
+ const USHORT nAnz = NumFor[nIx].GetnAnz();
+ for (USHORT i = 0; i < nAnz; i++)
+ {
+ switch (rInfo.nTypeArray[i])
+ {
+ case NF_SYMBOLTYPE_STAR:
+ if( bStarFlag )
+ {
+ OutString += (sal_Unicode) 0x1B;
+ OutString += rInfo.sStrArray[i].GetChar(1);
+ bRes = TRUE;
+ }
+ break;
+ case NF_SYMBOLTYPE_BLANK:
+ InsertBlanks( OutString, OutString.Len(),
+ rInfo.sStrArray[i].GetChar(1) );
+ break;
+ case NF_KEY_GENERAL : // #77026# "General" is the same as "@"
+ case NF_SYMBOLTYPE_DEL :
+ OutString += sString;
+ break;
+ default:
+ OutString += rInfo.sStrArray[i];
+ }
+ }
+ return bRes;
+ }
+ return FALSE;
+}
+/*
+void SvNumberformat::GetNextFareyNumber(ULONG nPrec, ULONG x0, ULONG x1,
+ ULONG y0, ULONG y1,
+ ULONG& x2,ULONG& y2)
+{
+ x2 = ((y0+nPrec)/y1)*x1 - x0;
+ y2 = ((y0+nPrec)/y1)*y1 - y0;
+}
+*/
+ULONG SvNumberformat::ImpGGT(ULONG x, ULONG y)
+{
+ if (y == 0)
+ return x;
+ else
+ {
+ ULONG z = x%y;
+ while (z)
+ {
+ x = y;
+ y = z;
+ z = x%y;
+ }
+ return y;
+ }
+}
+
+ULONG SvNumberformat::ImpGGTRound(ULONG x, ULONG y)
+{
+ if (y == 0)
+ return x;
+ else
+ {
+ ULONG z = x%y;
+ while ((double)z/(double)y > D_EPS)
+ {
+ x = y;
+ y = z;
+ z = x%y;
+ }
+ return y;
+ }
+}
+
+BOOL SvNumberformat::GetOutputString(double fNumber,
+ String& OutString,
+ Color** ppColor)
+{
+ BOOL bRes = FALSE;
+ OutString.Erase(); // alles loeschen
+ *ppColor = NULL; // keine Farbaenderung
+ if (eType & NUMBERFORMAT_LOGICAL)
+ {
+ if (fNumber)
+ OutString = rScan.GetTrueString();
+ else
+ OutString = rScan.GetFalseString();
+ return FALSE;
+ }
+ if (eType & NUMBERFORMAT_TEXT && bStandard)
+ {
+ ImpGetOutputStandard(fNumber, OutString);
+ return FALSE;
+ }
+ BOOL bHadStandard = FALSE;
+ if (bStandard) // einzelne Standardformate
+ {
+ if (rScan.GetStandardPrec() == 300) // alle Zahlformate InputLine
+ {
+ ImpGetOutputInputLine(fNumber, OutString);
+ return FALSE;
+ }
+ switch (eType)
+ {
+ case NUMBERFORMAT_NUMBER: // Standardzahlformat
+ ImpGetOutputStandard(fNumber, OutString);
+ bHadStandard = TRUE;
+ break;
+ case NUMBERFORMAT_DATE:
+ bRes |= ImpGetDateOutput(fNumber, 0, OutString);
+ bHadStandard = TRUE;
+ break;
+ case NUMBERFORMAT_TIME:
+ bRes |= ImpGetTimeOutput(fNumber, 0, OutString);
+ bHadStandard = TRUE;
+ break;
+ case NUMBERFORMAT_DATETIME:
+ bRes |= ImpGetDateTimeOutput(fNumber, 0, OutString);
+ bHadStandard = TRUE;
+ break;
+ }
+ }
+ if ( !bHadStandard )
+ {
+ USHORT nIx; // Index des Teilformats
+ short nCheck = ImpCheckCondition(fNumber, fLimit1, eOp1);
+ if (nCheck == -1 || nCheck == 1) // nur 1 String oder True
+ nIx = 0;
+ else
+ {
+ nCheck = ImpCheckCondition(fNumber, fLimit2, eOp2);
+ if (nCheck == -1 || nCheck == 1)
+ nIx = 1;
+ else
+ nIx = 2;
+ }
+ if (nIx == 1 && fNumber < 0.0 && // negatives Format
+ IsNegativeRealNegative() ) // ohne Vorzeichen
+ fNumber = -fNumber; // Vorzeichen eliminieren
+ *ppColor = NumFor[nIx].GetColor();
+ const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info();
+ const USHORT nAnz = NumFor[nIx].GetnAnz();
+ if (nAnz == 0 && rInfo.eScannedType == NUMBERFORMAT_UNDEFINED)
+ return FALSE; // leer => nichts
+ else if (nAnz == 0) // sonst Standard-Format
+ {
+ ImpGetOutputStandard(fNumber, OutString);
+ return FALSE;
+ }
+ switch (rInfo.eScannedType)
+ {
+ case NUMBERFORMAT_TEXT:
+ case NUMBERFORMAT_DEFINED:
+ {
+ for (USHORT i = 0; i < nAnz; i++)
+ {
+ switch (rInfo.nTypeArray[i])
+ {
+ case NF_SYMBOLTYPE_STAR:
+ if( bStarFlag )
+ {
+ OutString += (sal_Unicode) 0x1B;
+ OutString += rInfo.sStrArray[i].GetChar(1);
+ bRes = TRUE;
+ }
+ break;
+ case NF_SYMBOLTYPE_BLANK:
+ InsertBlanks( OutString, OutString.Len(),
+ rInfo.sStrArray[i].GetChar(1) );
+ break;
+ case NF_SYMBOLTYPE_STRING:
+ case NF_SYMBOLTYPE_CURRENCY:
+ OutString += rInfo.sStrArray[i];
+ break;
+ case NF_SYMBOLTYPE_THSEP:
+ if (rInfo.nThousand == 0)
+ OutString += rInfo.sStrArray[i];
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ break;
+ case NUMBERFORMAT_DATE:
+ bRes |= ImpGetDateOutput(fNumber, nIx, OutString);
+ break;
+ case NUMBERFORMAT_TIME:
+ bRes |= ImpGetTimeOutput(fNumber, nIx, OutString);
+ break;
+ case NUMBERFORMAT_DATETIME:
+ bRes |= ImpGetDateTimeOutput(fNumber, nIx, OutString);
+ break;
+ case NUMBERFORMAT_NUMBER:
+ case NUMBERFORMAT_PERCENT:
+ case NUMBERFORMAT_CURRENCY:
+ bRes |= ImpGetNumberOutput(fNumber, nIx, OutString);
+ break;
+ case NUMBERFORMAT_FRACTION:
+ {
+ String sStr, sFrac, sDiv; // Strings, Wert fuer
+ ULONG nFrac, nDiv; // Vorkommaanteil
+ // Zaehler und Nenner
+ BOOL bSign = FALSE;
+ if (fNumber < 0)
+ {
+ if (nIx == 0) // nicht in hinteren
+ bSign = TRUE; // Formaten
+ fNumber = -fNumber;
+ }
+ double fNum = floor(fNumber); // Vorkommateil
+ fNumber -= fNum; // Nachkommateil
+ if (fNum > _D_MAX_U_LONG_ || rInfo.nCntExp > 9)
+ // zu gross
+ {
+ OutString = rScan.GetErrorString();
+ return FALSE;
+ }
+ if (rInfo.nCntExp == 0)
+ {
+ DBG_ERROR("SvNumberformat:: Bruch, nCntExp == 0");
+ return FALSE;
+ }
+ ULONG nBasis = ((ULONG)floor( // 9, 99, 999 ,...
+ pow(10.0,rInfo.nCntExp))) - 1;
+ ULONG x0, y0, x1, y1;
+
+ if (rInfo.nCntExp <= _MAX_FRACTION_PREC)
+ {
+ BOOL bUpperHalf;
+ if (fNumber > 0.5)
+ {
+ bUpperHalf = TRUE;
+ fNumber -= (fNumber - 0.5) * 2.0;
+ }
+ else
+ bUpperHalf = FALSE;
+ // Einstieg in Farey-Serie
+ // finden:
+ x0 = (ULONG) floor(fNumber*nBasis); // z.B. 2/9 <= x < 3/9
+ if (x0 == 0) // => x0 = 2
+ {
+ y0 = 1;
+ x1 = 1;
+ y1 = nBasis;
+ }
+ else if (x0 == (nBasis-1)/2) // (b-1)/2, 1/2
+ { // geht (nBasis ungerade)
+ y0 = nBasis;
+ x1 = 1;
+ y1 = 2;
+ }
+ else if (x0 == 1)
+ {
+ y0 = nBasis; // 1/n; 1/(n-1)
+ x1 = 1;
+ y1 = nBasis - 1;
+ }
+ else
+ {
+ y0 = nBasis; // z.B. 2/9 2/8
+ x1 = x0;
+ y1 = nBasis - 1;
+ double fUg = (double) x0 / (double) y0;
+ double fOg = (double) x1 / (double) y1;
+ ULONG nGgt = ImpGGT(y0, x0); // x0/y0 kuerzen
+ x0 /= nGgt;
+ y0 /= nGgt; // Einschachteln:
+ double fTest;
+ ULONG x2 = 0;
+ ULONG y2 = 0;
+ BOOL bStop = FALSE;
+ while (!bStop)
+ {
+ fTest = (double)x1/(double)y1;
+ while (!bStop)
+ {
+ while (fTest > fOg)
+ {
+ x1--;
+ fTest = (double)x1/(double)y1;
+ }
+ while (fTest < fUg && y1 > 1)
+ {
+ y1--;
+ fTest = (double)x1/(double)y1;
+ }
+ if (fTest <= fOg)
+ {
+ fOg = fTest;
+ bStop = TRUE;
+ }
+ else if (y1 == 1)
+ bStop = TRUE;
+ } // of while
+ nGgt = ImpGGT(y1, x1); // x1/y1 kuerzen
+ x2 = x1 / nGgt;
+ y2 = y1 / nGgt;
+ if (x2*y0 - x0*y2 == 1 || y1 <= 1) // Test, ob x2/y2
+ bStop = TRUE; // naechste Farey-Zahl
+ else
+ {
+ y1--;
+ bStop = FALSE;
+ }
+ } // of while
+ x1 = x2;
+ y1 = y2;
+ } // of else
+ double fup, flow;
+ flow = (double)x0/(double)y0;
+ fup = (double)x1/(double)y1;
+ while (fNumber > fup)
+ {
+ ULONG x2 = ((y0+nBasis)/y1)*x1 - x0; // naechste Farey-Zahl
+ ULONG y2 = ((y0+nBasis)/y1)*y1 - y0;
+// GetNextFareyNumber(nBasis, x0, x1, y0, y1, x2, y2);
+ x0 = x1;
+ y0 = y1;
+ x1 = x2;
+ y1 = y2;
+ flow = fup;
+ fup = (double)x1/(double)y1;
+ }
+ if (fNumber - flow < fup - fNumber)
+ {
+ nFrac = x0;
+ nDiv = y0;
+ }
+ else
+ {
+ nFrac = x1;
+ nDiv = y1;
+ }
+ if (bUpperHalf) // Original restaur.
+ {
+ if (nFrac == 0 && nDiv == 1) // 1/1
+ fNum += 1.0;
+ else
+ nFrac = nDiv - nFrac;
+ }
+ }
+ else // grosse Nenner
+ { // 0,1234->123/1000
+ ULONG nGgt;
+/*
+ nDiv = nBasis+1;
+ nFrac = ((ULONG)floor(0.5 + fNumber *
+ pow(10.0,rInfo.nCntExp)));
+*/
+ nDiv = 10000000;
+ nFrac = ((ULONG)floor(0.5 + fNumber * 10000000.0));
+ nGgt = ImpGGT(nDiv, nFrac);
+ if (nGgt > 1)
+ {
+ nDiv /= nGgt;
+ nFrac /= nGgt;
+ }
+ if (nDiv > nBasis)
+ {
+ nGgt = ImpGGTRound(nDiv, nFrac);
+ if (nGgt > 1)
+ {
+ nDiv /= nGgt;
+ nFrac /= nGgt;
+ }
+ }
+ if (nDiv > nBasis)
+ {
+ nDiv = nBasis;
+ nFrac = ((ULONG)floor(0.5 + fNumber *
+ pow(10.0,rInfo.nCntExp)));
+ nGgt = ImpGGTRound(nDiv, nFrac);
+ if (nGgt > 1)
+ {
+ nDiv /= nGgt;
+ nFrac /= nGgt;
+ }
+ }
+ }
+
+ if (rInfo.nCntPre == 0) // unechter Bruch
+ {
+ double fNum1 = fNum * (double)nDiv + (double)nFrac;
+ if (fNum1 > _D_MAX_U_LONG_)
+ {
+ OutString = rScan.GetErrorString();
+ return FALSE;
+ }
+ nFrac = (ULONG) floor(fNum1);
+ sStr.Erase();
+ }
+ else if (fNum == 0.0 && nFrac != 0)
+ sStr.Erase();
+ else
+ {
+ char aBuf[100];
+ sprintf( aBuf, "%.f", fNum ); // simple rounded integer (#100211# - checked)
+ sStr.AssignAscii( aBuf );
+ ImpTransliterate( sStr, NumFor[nIx].GetNatNum() );
+ }
+ if (rInfo.nCntPre > 0 && nFrac == 0)
+ {
+ sFrac.Erase();
+ sDiv.Erase();
+ }
+ else
+ {
+ sFrac = ImpIntToString( nIx, nFrac );
+ sDiv = ImpIntToString( nIx, nDiv );
+ }
+
+ USHORT j = nAnz-1; // letztes Symbol->rueckw.
+ xub_StrLen k; // Nenner:
+ bRes |= ImpNumberFill(sDiv, fNumber, k, j, nIx, NF_SYMBOLTYPE_FRAC);
+ BOOL bCont = TRUE;
+ if (rInfo.nTypeArray[j] == NF_SYMBOLTYPE_FRAC)
+ {
+ if (rInfo.nCntPre > 0 && nFrac == 0)
+ sDiv.Insert(' ',0);
+ else
+ sDiv.Insert( rInfo.sStrArray[j].GetChar(0), 0 );
+ if ( j )
+ j--;
+ else
+ bCont = FALSE;
+ }
+ // weiter Zaehler:
+ if ( !bCont )
+ sFrac.Erase();
+ else
+ {
+ bRes |= ImpNumberFill(sFrac, fNumber, k, j, nIx, NF_SYMBOLTYPE_FRACBLANK);
+ if (rInfo.nTypeArray[j] == NF_SYMBOLTYPE_FRACBLANK)
+ {
+ sFrac.Insert(rInfo.sStrArray[j],0);
+ if ( j )
+ j--;
+ else
+ bCont = FALSE;
+ }
+ }
+ // weiter Hauptzahl
+ if ( !bCont )
+ sStr.Erase();
+ else
+ {
+ k = sStr.Len(); // hinter letzter Ziffer
+ bRes |= ImpNumberFillWithThousands(sStr, fNumber, k, j, nIx,
+ rInfo.nCntPre);
+ }
+ if (bSign && !(nFrac == 0 && fNum == 0.0))
+ OutString.Insert('-',0); // nicht -0
+ OutString += sStr;
+ OutString += sFrac;
+ OutString += sDiv;
+ }
+ break;
+ case NUMBERFORMAT_SCIENTIFIC:
+ {
+ BOOL bSign = FALSE;
+ if (fNumber < 0)
+ {
+ if (nIx == 0) // nicht in hinteren
+ bSign = TRUE; // Formaten
+ fNumber = -fNumber;
+ }
+ String sStr( ::rtl::math::doubleToUString( fNumber,
+ rtl_math_StringFormat_E,
+ rInfo.nCntPre + rInfo.nCntPost - 1, '.' ));
+
+ String ExpStr;
+ short nExpSign = 1;
+ xub_StrLen nExPos = sStr.Search('E');
+ if ( nExPos != STRING_NOTFOUND )
+ {
+ // split into mantisse and exponent and get rid of "E+" or "E-"
+ xub_StrLen nExpStart = nExPos + 1;
+ switch ( sStr.GetChar( nExpStart ) )
+ {
+ case '-' :
+ nExpSign = -1;
+ // fallthru
+ case '+' :
+ ++nExpStart;
+ break;
+ }
+ ExpStr = sStr.Copy( nExpStart ); // part following the "E+"
+ sStr.Erase( nExPos );
+ sStr.EraseAllChars('.'); // cut any decimal delimiter
+ if ( rInfo.nCntPre != 1 ) // rescale Exp
+ {
+ sal_Int32 nExp = ExpStr.ToInt32() * nExpSign;
+ nExp -= sal_Int32(rInfo.nCntPre)-1;
+ if ( nExp < 0 )
+ {
+ nExpSign = -1;
+ nExp = -nExp;
+ }
+ else
+ nExpSign = 1;
+ ExpStr = String::CreateFromInt32( nExp );
+ }
+ }
+ USHORT j = nAnz-1; // last symbol
+ xub_StrLen k;
+ bRes |= ImpNumberFill(ExpStr, fNumber, k, j, nIx, NF_SYMBOLTYPE_EXP);
+
+ while (k > 0) // erase leading zeros
+ {
+ k--;
+ if (ExpStr.GetChar(k) == '0')
+ ExpStr.Erase(0,1);
+ }
+ BOOL bCont = TRUE;
+ if (rInfo.nTypeArray[j] == NF_SYMBOLTYPE_EXP)
+ {
+ const String& rStr = rInfo.sStrArray[j];
+ if (nExpSign == -1)
+ ExpStr.Insert('-',0);
+ else if (rStr.Len() > 1 && rStr.GetChar(1) == '+')
+ ExpStr.Insert('+',0);
+ ExpStr.Insert(rStr.GetChar(0),0);
+ if ( j )
+ j--;
+ else
+ bCont = FALSE;
+ }
+ // weiter Hauptzahl:
+ if ( !bCont )
+ sStr.Erase();
+ else
+ {
+ k = sStr.Len(); // hinter letzter Ziffer
+ bRes |= ImpNumberFillWithThousands(sStr,fNumber, k,j,nIx,
+ rInfo.nCntPre +
+ rInfo.nCntPost);
+ }
+ if (bSign)
+ sStr.Insert('-',0);
+ OutString = sStr;
+ OutString += ExpStr;
+ }
+ break;
+ }
+ }
+ return bRes;
+}
+
+BOOL SvNumberformat::ImpGetTimeOutput(double fNumber,
+ USHORT nIx,
+ String& OutString)
+{
+ using namespace ::com::sun::star::i18n;
+ BOOL bCalendarSet = FALSE;
+ double fNumberOrig = fNumber;
+ BOOL bRes = FALSE;
+ BOOL bSign = FALSE;
+ if (fNumber < 0.0)
+ {
+ fNumber = -fNumber;
+ if (nIx == 0)
+ bSign = TRUE;
+ }
+ const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info();
+ if (rInfo.bThousand) // []-Format
+ {
+ if (fNumber > 1.0E10) // zu gross
+ {
+ OutString = rScan.GetErrorString();
+ return FALSE;
+ }
+ }
+ else
+ fNumber -= floor(fNumber); // sonst Datum abtrennen
+ BOOL bInputLine;
+ xub_StrLen nCntPost;
+ if ( rScan.GetStandardPrec() == 300 &&
+ 0 < rInfo.nCntPost && rInfo.nCntPost < 7 )
+ { // round at 7 decimals (+5 of 86400 == 12 significant digits)
+ bInputLine = TRUE;
+ nCntPost = 7;
+ }
+ else
+ {
+ bInputLine = FALSE;
+ nCntPost = xub_StrLen(rInfo.nCntPost);
+ }
+ if (bSign && !rInfo.bThousand) // kein []-Format
+ fNumber = 1.0 - fNumber; // "Kehrwert"
+ double fTime = fNumber * 86400.0;
+ fTime = ::rtl::math::round( fTime, int(nCntPost) );
+ if (bSign && fTime == 0.0)
+ bSign = FALSE; // nicht -00:00:00
+
+ if( floor( fTime ) > _D_MAX_U_LONG_ )
+ {
+ OutString = rScan.GetErrorString();
+ return FALSE;
+ }
+ ULONG nSeconds = (ULONG)floor( fTime );
+
+ String sSecStr( ::rtl::math::doubleToUString( fTime-nSeconds,
+ rtl_math_StringFormat_F, int(nCntPost), '.'));
+ sSecStr.EraseLeadingChars('0');
+ sSecStr.EraseLeadingChars('.');
+ if ( bInputLine )
+ {
+ sSecStr.EraseTrailingChars('0');
+ if ( sSecStr.Len() < xub_StrLen(rInfo.nCntPost) )
+ sSecStr.Expand( xub_StrLen(rInfo.nCntPost), '0' );
+ ImpTransliterate( sSecStr, NumFor[nIx].GetNatNum() );
+ nCntPost = sSecStr.Len();
+ }
+ else
+ ImpTransliterate( sSecStr, NumFor[nIx].GetNatNum() );
+
+ xub_StrLen nSecPos = 0; // Zum Ziffernweisen
+ // abarbeiten
+ ULONG nHour, nMin, nSec;
+ if (!rInfo.bThousand) // kein [] Format
+ {
+ nHour = (nSeconds/3600) % 24;
+ nMin = (nSeconds%3600) / 60;
+ nSec = nSeconds%60;
+ }
+ else if (rInfo.nThousand == 3) // [ss]
+ {
+ nHour = 0;
+ nMin = 0;
+ nSec = nSeconds;
+ }
+ else if (rInfo.nThousand == 2) // [mm]:ss
+ {
+ nHour = 0;
+ nMin = nSeconds / 60;
+ nSec = nSeconds % 60;
+ }
+ else if (rInfo.nThousand == 1) // [hh]:mm:ss
+ {
+ nHour = nSeconds / 3600;
+ nMin = (nSeconds%3600) / 60;
+ nSec = nSeconds%60;
+ }
+ else {
+ // TODO What should these be set to?
+ nHour = 0;
+ nMin = 0;
+ nSec = 0;
+ }
+
+ sal_Unicode cAmPm = ' '; // a oder p
+ if (rInfo.nCntExp) // AM/PM
+ {
+ if (nHour == 0)
+ {
+ nHour = 12;
+ cAmPm = 'a';
+ }
+ else if (nHour < 12)
+ cAmPm = 'a';
+ else
+ {
+ cAmPm = 'p';
+ if (nHour > 12)
+ nHour -= 12;
+ }
+ }
+ const USHORT nAnz = NumFor[nIx].GetnAnz();
+ for (USHORT i = 0; i < nAnz; i++)
+ {
+ switch (rInfo.nTypeArray[i])
+ {
+ case NF_SYMBOLTYPE_STAR:
+ if( bStarFlag )
+ {
+ OutString += (sal_Unicode) 0x1B;
+ OutString += rInfo.sStrArray[i].GetChar(1);
+ bRes = TRUE;
+ }
+ break;
+ case NF_SYMBOLTYPE_BLANK:
+ InsertBlanks( OutString, OutString.Len(),
+ rInfo.sStrArray[i].GetChar(1) );
+ break;
+ case NF_SYMBOLTYPE_STRING:
+ case NF_SYMBOLTYPE_CURRENCY:
+ case NF_SYMBOLTYPE_DATESEP:
+ case NF_SYMBOLTYPE_TIMESEP:
+ case NF_SYMBOLTYPE_TIME100SECSEP:
+ OutString += rInfo.sStrArray[i];
+ break;
+ case NF_SYMBOLTYPE_DIGIT:
+ {
+ xub_StrLen nLen = ( bInputLine && i > 0 &&
+ (rInfo.nTypeArray[i-1] == NF_SYMBOLTYPE_STRING ||
+ rInfo.nTypeArray[i-1] == NF_SYMBOLTYPE_TIME100SECSEP) ?
+ nCntPost : rInfo.sStrArray[i].Len() );
+ for (xub_StrLen j = 0; j < nLen && nSecPos < nCntPost; j++)
+ {
+ OutString += sSecStr.GetChar(nSecPos);
+ nSecPos++;
+ }
+ }
+ break;
+ case NF_KEY_AMPM: // AM/PM
+ {
+ if ( !bCalendarSet )
+ {
+ double fDiff = DateTime(*(rScan.GetNullDate())) - GetCal().getEpochStart();
+ fDiff += fNumberOrig;
+ GetCal().setLocalDateTime( fDiff );
+ bCalendarSet = TRUE;
+ }
+ if (cAmPm == 'a')
+ OutString += GetCal().getDisplayName(
+ CalendarDisplayIndex::AM_PM, AmPmValue::AM, 0 );
+ else
+ OutString += GetCal().getDisplayName(
+ CalendarDisplayIndex::AM_PM, AmPmValue::PM, 0 );
+ }
+ break;
+ case NF_KEY_AP: // A/P
+ {
+ if (cAmPm == 'a')
+ OutString += 'a';
+ else
+ OutString += 'p';
+ }
+ break;
+ case NF_KEY_MI: // M
+ OutString += ImpIntToString( nIx, nMin );
+ break;
+ case NF_KEY_MMI: // MM
+ OutString += ImpIntToString( nIx, nMin, 2 );
+ break;
+ case NF_KEY_H: // H
+ OutString += ImpIntToString( nIx, nHour );
+ break;
+ case NF_KEY_HH: // HH
+ OutString += ImpIntToString( nIx, nHour, 2 );
+ break;
+ case NF_KEY_S: // S
+ OutString += ImpIntToString( nIx, nSec );
+ break;
+ case NF_KEY_SS: // SS
+ OutString += ImpIntToString( nIx, nSec, 2 );
+ break;
+ default:
+ break;
+ }
+ }
+ if (bSign && rInfo.bThousand)
+ OutString.Insert('-',0);
+ return bRes;
+}
+
+
+BOOL SvNumberformat::ImpIsOtherCalendar( const ImpSvNumFor& rNumFor ) const
+{
+ if ( GetCal().getUniqueID() != Gregorian::get() )
+ return FALSE;
+ const ImpSvNumberformatInfo& rInfo = rNumFor.Info();
+ const USHORT nAnz = rNumFor.GetnAnz();
+ USHORT i;
+ for ( i = 0; i < nAnz; i++ )
+ {
+ switch ( rInfo.nTypeArray[i] )
+ {
+ case NF_SYMBOLTYPE_CALENDAR :
+ return FALSE;
+ case NF_KEY_EC :
+ case NF_KEY_EEC :
+ case NF_KEY_R :
+ case NF_KEY_RR :
+ case NF_KEY_AAA :
+ case NF_KEY_AAAA :
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+void SvNumberformat::SwitchToOtherCalendar( String& rOrgCalendar,
+ double& fOrgDateTime ) const
+{
+ CalendarWrapper& rCal = GetCal();
+ const rtl::OUString &rGregorian = Gregorian::get();
+ if ( rCal.getUniqueID() == rGregorian )
+ {
+ using namespace ::com::sun::star::i18n;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > xCals
+ = rCal.getAllCalendars( rLoc().getLocale() );
+ sal_Int32 nCnt = xCals.getLength();
+ if ( nCnt > 1 )
+ {
+ for ( sal_Int32 j=0; j < nCnt; j++ )
+ {
+ if ( xCals[j] != rGregorian )
+ {
+ if ( !rOrgCalendar.Len() )
+ {
+ rOrgCalendar = rCal.getUniqueID();
+ fOrgDateTime = rCal.getDateTime();
+ }
+ rCal.loadCalendar( xCals[j], rLoc().getLocale() );
+ rCal.setDateTime( fOrgDateTime );
+ break; // for
+ }
+ }
+ }
+ }
+}
+
+
+void SvNumberformat::SwitchToGregorianCalendar( const String& rOrgCalendar,
+ double fOrgDateTime ) const
+{
+ CalendarWrapper& rCal = GetCal();
+ const rtl::OUString &rGregorian = Gregorian::get();
+ if ( rOrgCalendar.Len() && rCal.getUniqueID() != rGregorian )
+ {
+ rCal.loadCalendar( rGregorian, rLoc().getLocale() );
+ rCal.setDateTime( fOrgDateTime );
+ }
+}
+
+
+BOOL SvNumberformat::ImpFallBackToGregorianCalendar( String& rOrgCalendar, double& fOrgDateTime )
+{
+ using namespace ::com::sun::star::i18n;
+ CalendarWrapper& rCal = GetCal();
+ const rtl::OUString &rGregorian = Gregorian::get();
+ if ( rCal.getUniqueID() != rGregorian )
+ {
+ sal_Int16 nVal = rCal.getValue( CalendarFieldIndex::ERA );
+ if ( nVal == 0 && rCal.getLoadedCalendar().Eras[0].ID.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "Dummy" ) ) )
+ {
+ if ( !rOrgCalendar.Len() )
+ {
+ rOrgCalendar = rCal.getUniqueID();
+ fOrgDateTime = rCal.getDateTime();
+ }
+ else if ( rOrgCalendar == String(rGregorian) )
+ rOrgCalendar.Erase();
+ rCal.loadCalendar( rGregorian, rLoc().getLocale() );
+ rCal.setDateTime( fOrgDateTime );
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+// static
+void SvNumberformat::ImpAppendEraG( String& OutString,
+ const CalendarWrapper& rCal, sal_Int16 nNatNum )
+{
+ using namespace ::com::sun::star::i18n;
+ if ( rCal.getUniqueID().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "gengou" ) ) )
+ {
+ sal_Unicode cEra;
+ sal_Int16 nVal = rCal.getValue( CalendarFieldIndex::ERA );
+ switch ( nVal )
+ {
+ case 1 : cEra = 'M'; break;
+ case 2 : cEra = 'T'; break;
+ case 3 : cEra = 'S'; break;
+ case 4 : cEra = 'H'; break;
+ default:
+ cEra = '?';
+ }
+ OutString += cEra;
+ }
+ else
+ OutString += rCal.getDisplayString( CalendarDisplayCode::SHORT_ERA, nNatNum );
+}
+
+
+BOOL SvNumberformat::ImpGetDateOutput(double fNumber,
+ USHORT nIx,
+ String& OutString)
+{
+ using namespace ::com::sun::star::i18n;
+ BOOL bRes = FALSE;
+ CalendarWrapper& rCal = GetCal();
+ double fDiff = DateTime(*(rScan.GetNullDate())) - rCal.getEpochStart();
+ fNumber += fDiff;
+ rCal.setLocalDateTime( fNumber );
+ String aOrgCalendar; // empty => not changed yet
+ double fOrgDateTime;
+ BOOL bOtherCalendar = ImpIsOtherCalendar( NumFor[nIx] );
+ if ( bOtherCalendar )
+ SwitchToOtherCalendar( aOrgCalendar, fOrgDateTime );
+ if ( ImpFallBackToGregorianCalendar( aOrgCalendar, fOrgDateTime ) )
+ bOtherCalendar = FALSE;
+ const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info();
+ const USHORT nAnz = NumFor[nIx].GetnAnz();
+ sal_Int16 nNatNum = NumFor[nIx].GetNatNum().GetNatNum();
+ for (USHORT i = 0; i < nAnz; i++)
+ {
+ switch (rInfo.nTypeArray[i])
+ {
+ case NF_SYMBOLTYPE_CALENDAR :
+ if ( !aOrgCalendar.Len() )
+ {
+ aOrgCalendar = rCal.getUniqueID();
+ fOrgDateTime = rCal.getDateTime();
+ }
+ rCal.loadCalendar( rInfo.sStrArray[i], rLoc().getLocale() );
+ rCal.setDateTime( fOrgDateTime );
+ ImpFallBackToGregorianCalendar( aOrgCalendar, fOrgDateTime );
+ break;
+ case NF_SYMBOLTYPE_STAR:
+ if( bStarFlag )
+ {
+ OutString += (sal_Unicode) 0x1B;
+ OutString += rInfo.sStrArray[i].GetChar(1);
+ bRes = TRUE;
+ }
+ break;
+ case NF_SYMBOLTYPE_BLANK:
+ InsertBlanks( OutString, OutString.Len(),
+ rInfo.sStrArray[i].GetChar(1) );
+ break;
+ case NF_SYMBOLTYPE_STRING:
+ case NF_SYMBOLTYPE_CURRENCY:
+ case NF_SYMBOLTYPE_DATESEP:
+ case NF_SYMBOLTYPE_TIMESEP:
+ case NF_SYMBOLTYPE_TIME100SECSEP:
+ OutString += rInfo.sStrArray[i];
+ break;
+ case NF_KEY_M: // M
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::SHORT_MONTH, nNatNum );
+ break;
+ case NF_KEY_MM: // MM
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_MONTH, nNatNum );
+ break;
+ case NF_KEY_MMM: // MMM
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::SHORT_MONTH_NAME, nNatNum );
+ break;
+ case NF_KEY_MMMM: // MMMM
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_MONTH_NAME, nNatNum );
+ break;
+ case NF_KEY_MMMMM: // MMMMM
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_MONTH_NAME, nNatNum ).GetChar(0);
+ break;
+ case NF_KEY_Q: // Q
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::SHORT_QUARTER, nNatNum );
+ break;
+ case NF_KEY_QQ: // QQ
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_QUARTER, nNatNum );
+ break;
+ case NF_KEY_D: // D
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::SHORT_DAY, nNatNum );
+ break;
+ case NF_KEY_DD: // DD
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_DAY, nNatNum );
+ break;
+ case NF_KEY_DDD: // DDD
+ {
+ if ( bOtherCalendar )
+ SwitchToGregorianCalendar( aOrgCalendar, fOrgDateTime );
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::SHORT_DAY_NAME, nNatNum );
+ if ( bOtherCalendar )
+ SwitchToOtherCalendar( aOrgCalendar, fOrgDateTime );
+ }
+ break;
+ case NF_KEY_DDDD: // DDDD
+ {
+ if ( bOtherCalendar )
+ SwitchToGregorianCalendar( aOrgCalendar, fOrgDateTime );
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_DAY_NAME, nNatNum );
+ if ( bOtherCalendar )
+ SwitchToOtherCalendar( aOrgCalendar, fOrgDateTime );
+ }
+ break;
+ case NF_KEY_YY: // YY
+ {
+ if ( bOtherCalendar )
+ SwitchToGregorianCalendar( aOrgCalendar, fOrgDateTime );
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::SHORT_YEAR, nNatNum );
+ if ( bOtherCalendar )
+ SwitchToOtherCalendar( aOrgCalendar, fOrgDateTime );
+ }
+ break;
+ case NF_KEY_YYYY: // YYYY
+ {
+ if ( bOtherCalendar )
+ SwitchToGregorianCalendar( aOrgCalendar, fOrgDateTime );
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_YEAR, nNatNum );
+ if ( bOtherCalendar )
+ SwitchToOtherCalendar( aOrgCalendar, fOrgDateTime );
+ }
+ break;
+ case NF_KEY_EC: // E
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::SHORT_YEAR, nNatNum );
+ break;
+ case NF_KEY_EEC: // EE
+ case NF_KEY_R: // R
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_YEAR, nNatNum );
+ break;
+ case NF_KEY_NN: // NN
+ case NF_KEY_AAA: // AAA
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::SHORT_DAY_NAME, nNatNum );
+ break;
+ case NF_KEY_NNN: // NNN
+ case NF_KEY_AAAA: // AAAA
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_DAY_NAME, nNatNum );
+ break;
+ case NF_KEY_NNNN: // NNNN
+ {
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_DAY_NAME, nNatNum );
+ OutString += rLoc().getLongDateDayOfWeekSep();
+ }
+ break;
+ case NF_KEY_WW : // WW
+ {
+ sal_Int16 nVal = rCal.getValue( CalendarFieldIndex::WEEK_OF_YEAR );
+ OutString += ImpIntToString( nIx, nVal );
+ }
+ break;
+ case NF_KEY_G: // G
+ ImpAppendEraG( OutString, rCal, nNatNum );
+ break;
+ case NF_KEY_GG: // GG
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::SHORT_ERA, nNatNum );
+ break;
+ case NF_KEY_GGG: // GGG
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_ERA, nNatNum );
+ break;
+ case NF_KEY_RR: // RR => GGGEE
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_YEAR_AND_ERA, nNatNum );
+ break;
+ }
+ }
+ if ( aOrgCalendar.Len() )
+ rCal.loadCalendar( aOrgCalendar, rLoc().getLocale() ); // restore calendar
+ return bRes;
+}
+
+BOOL SvNumberformat::ImpGetDateTimeOutput(double fNumber,
+ USHORT nIx,
+ String& OutString)
+{
+ using namespace ::com::sun::star::i18n;
+ BOOL bRes = FALSE;
+
+ CalendarWrapper& rCal = GetCal();
+ double fDiff = DateTime(*(rScan.GetNullDate())) - rCal.getEpochStart();
+ fNumber += fDiff;
+
+ const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info();
+ BOOL bInputLine;
+ xub_StrLen nCntPost;
+ if ( rScan.GetStandardPrec() == 300 &&
+ 0 < rInfo.nCntPost && rInfo.nCntPost < 7 )
+ { // round at 7 decimals (+5 of 86400 == 12 significant digits)
+ bInputLine = TRUE;
+ nCntPost = 7;
+ }
+ else
+ {
+ bInputLine = FALSE;
+ nCntPost = xub_StrLen(rInfo.nCntPost);
+ }
+ double fTime = (fNumber - floor( fNumber )) * 86400.0;
+ fTime = ::rtl::math::round( fTime, int(nCntPost) );
+ if (fTime >= 86400.0)
+ {
+ // result of fNumber==x.999999999... rounded up, use correct date/time
+ fTime -= 86400.0;
+ fNumber = floor( fNumber + 0.5) + fTime;
+ }
+ rCal.setLocalDateTime( fNumber );
+
+ String aOrgCalendar; // empty => not changed yet
+ double fOrgDateTime;
+ BOOL bOtherCalendar = ImpIsOtherCalendar( NumFor[nIx] );
+ if ( bOtherCalendar )
+ SwitchToOtherCalendar( aOrgCalendar, fOrgDateTime );
+ if ( ImpFallBackToGregorianCalendar( aOrgCalendar, fOrgDateTime ) )
+ bOtherCalendar = FALSE;
+ sal_Int16 nNatNum = NumFor[nIx].GetNatNum().GetNatNum();
+
+ ULONG nSeconds = (ULONG)floor( fTime );
+ String sSecStr( ::rtl::math::doubleToUString( fTime-nSeconds,
+ rtl_math_StringFormat_F, int(nCntPost), '.'));
+ sSecStr.EraseLeadingChars('0');
+ sSecStr.EraseLeadingChars('.');
+ if ( bInputLine )
+ {
+ sSecStr.EraseTrailingChars('0');
+ if ( sSecStr.Len() < xub_StrLen(rInfo.nCntPost) )
+ sSecStr.Expand( xub_StrLen(rInfo.nCntPost), '0' );
+ ImpTransliterate( sSecStr, NumFor[nIx].GetNatNum() );
+ nCntPost = sSecStr.Len();
+ }
+ else
+ ImpTransliterate( sSecStr, NumFor[nIx].GetNatNum() );
+
+ xub_StrLen nSecPos = 0; // Zum Ziffernweisen
+ // abarbeiten
+ ULONG nHour, nMin, nSec;
+ if (!rInfo.bThousand) // [] Format
+ {
+ nHour = (nSeconds/3600) % 24;
+ nMin = (nSeconds%3600) / 60;
+ nSec = nSeconds%60;
+ }
+ else if (rInfo.nThousand == 3) // [ss]
+ {
+ nHour = 0;
+ nMin = 0;
+ nSec = nSeconds;
+ }
+ else if (rInfo.nThousand == 2) // [mm]:ss
+ {
+ nHour = 0;
+ nMin = nSeconds / 60;
+ nSec = nSeconds % 60;
+ }
+ else if (rInfo.nThousand == 1) // [hh]:mm:ss
+ {
+ nHour = nSeconds / 3600;
+ nMin = (nSeconds%3600) / 60;
+ nSec = nSeconds%60;
+ }
+ else {
+ nHour = 0; // TODO What should these values be?
+ nMin = 0;
+ nSec = 0;
+ }
+ sal_Unicode cAmPm = ' '; // a oder p
+ if (rInfo.nCntExp) // AM/PM
+ {
+ if (nHour == 0)
+ {
+ nHour = 12;
+ cAmPm = 'a';
+ }
+ else if (nHour < 12)
+ cAmPm = 'a';
+ else
+ {
+ cAmPm = 'p';
+ if (nHour > 12)
+ nHour -= 12;
+ }
+ }
+ const USHORT nAnz = NumFor[nIx].GetnAnz();
+ for (USHORT i = 0; i < nAnz; i++)
+ {
+ switch (rInfo.nTypeArray[i])
+ {
+ case NF_SYMBOLTYPE_CALENDAR :
+ if ( !aOrgCalendar.Len() )
+ {
+ aOrgCalendar = rCal.getUniqueID();
+ fOrgDateTime = rCal.getDateTime();
+ }
+ rCal.loadCalendar( rInfo.sStrArray[i], rLoc().getLocale() );
+ rCal.setDateTime( fOrgDateTime );
+ ImpFallBackToGregorianCalendar( aOrgCalendar, fOrgDateTime );
+ break;
+ case NF_SYMBOLTYPE_STAR:
+ if( bStarFlag )
+ {
+ OutString += (sal_Unicode) 0x1B;
+ OutString += rInfo.sStrArray[i].GetChar(1);
+ bRes = TRUE;
+ }
+ break;
+ case NF_SYMBOLTYPE_BLANK:
+ InsertBlanks( OutString, OutString.Len(),
+ rInfo.sStrArray[i].GetChar(1) );
+ break;
+ case NF_SYMBOLTYPE_STRING:
+ case NF_SYMBOLTYPE_CURRENCY:
+ case NF_SYMBOLTYPE_DATESEP:
+ case NF_SYMBOLTYPE_TIMESEP:
+ case NF_SYMBOLTYPE_TIME100SECSEP:
+ OutString += rInfo.sStrArray[i];
+ break;
+ case NF_SYMBOLTYPE_DIGIT:
+ {
+ xub_StrLen nLen = ( bInputLine && i > 0 &&
+ (rInfo.nTypeArray[i-1] == NF_SYMBOLTYPE_STRING ||
+ rInfo.nTypeArray[i-1] == NF_SYMBOLTYPE_TIME100SECSEP) ?
+ nCntPost : rInfo.sStrArray[i].Len() );
+ for (xub_StrLen j = 0; j < nLen && nSecPos < nCntPost; j++)
+ {
+ OutString += sSecStr.GetChar(nSecPos);
+ nSecPos++;
+ }
+ }
+ break;
+ case NF_KEY_AMPM: // AM/PM
+ {
+ if (cAmPm == 'a')
+ OutString += rCal.getDisplayName( CalendarDisplayIndex::AM_PM,
+ AmPmValue::AM, 0 );
+ else
+ OutString += rCal.getDisplayName( CalendarDisplayIndex::AM_PM,
+ AmPmValue::PM, 0 );
+ }
+ break;
+ case NF_KEY_AP: // A/P
+ {
+ if (cAmPm == 'a')
+ OutString += 'a';
+ else
+ OutString += 'p';
+ }
+ break;
+ case NF_KEY_MI: // M
+ OutString += ImpIntToString( nIx, nMin );
+ break;
+ case NF_KEY_MMI: // MM
+ OutString += ImpIntToString( nIx, nMin, 2 );
+ break;
+ case NF_KEY_H: // H
+ OutString += ImpIntToString( nIx, nHour );
+ break;
+ case NF_KEY_HH: // HH
+ OutString += ImpIntToString( nIx, nHour, 2 );
+ break;
+ case NF_KEY_S: // S
+ OutString += ImpIntToString( nIx, nSec );
+ break;
+ case NF_KEY_SS: // SS
+ OutString += ImpIntToString( nIx, nSec, 2 );
+ break;
+ case NF_KEY_M: // M
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::SHORT_MONTH, nNatNum );
+ break;
+ case NF_KEY_MM: // MM
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_MONTH, nNatNum );
+ break;
+ case NF_KEY_MMM: // MMM
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::SHORT_MONTH_NAME, nNatNum );
+ break;
+ case NF_KEY_MMMM: // MMMM
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_MONTH_NAME, nNatNum );
+ break;
+ case NF_KEY_MMMMM: // MMMMM
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_MONTH_NAME, nNatNum ).GetChar(0);
+ break;
+ case NF_KEY_Q: // Q
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::SHORT_QUARTER, nNatNum );
+ break;
+ case NF_KEY_QQ: // QQ
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_QUARTER, nNatNum );
+ break;
+ case NF_KEY_D: // D
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::SHORT_DAY, nNatNum );
+ break;
+ case NF_KEY_DD: // DD
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_DAY, nNatNum );
+ break;
+ case NF_KEY_DDD: // DDD
+ {
+ if ( bOtherCalendar )
+ SwitchToGregorianCalendar( aOrgCalendar, fOrgDateTime );
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::SHORT_DAY_NAME, nNatNum );
+ if ( bOtherCalendar )
+ SwitchToOtherCalendar( aOrgCalendar, fOrgDateTime );
+ }
+ break;
+ case NF_KEY_DDDD: // DDDD
+ {
+ if ( bOtherCalendar )
+ SwitchToGregorianCalendar( aOrgCalendar, fOrgDateTime );
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_DAY_NAME, nNatNum );
+ if ( bOtherCalendar )
+ SwitchToOtherCalendar( aOrgCalendar, fOrgDateTime );
+ }
+ break;
+ case NF_KEY_YY: // YY
+ {
+ if ( bOtherCalendar )
+ SwitchToGregorianCalendar( aOrgCalendar, fOrgDateTime );
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::SHORT_YEAR, nNatNum );
+ if ( bOtherCalendar )
+ SwitchToOtherCalendar( aOrgCalendar, fOrgDateTime );
+ }
+ break;
+ case NF_KEY_YYYY: // YYYY
+ {
+ if ( bOtherCalendar )
+ SwitchToGregorianCalendar( aOrgCalendar, fOrgDateTime );
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_YEAR, nNatNum );
+ if ( bOtherCalendar )
+ SwitchToOtherCalendar( aOrgCalendar, fOrgDateTime );
+ }
+ break;
+ case NF_KEY_EC: // E
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::SHORT_YEAR, nNatNum );
+ break;
+ case NF_KEY_EEC: // EE
+ case NF_KEY_R: // R
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_YEAR, nNatNum );
+ break;
+ case NF_KEY_NN: // NN
+ case NF_KEY_AAA: // AAA
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::SHORT_DAY_NAME, nNatNum );
+ break;
+ case NF_KEY_NNN: // NNN
+ case NF_KEY_AAAA: // AAAA
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_DAY_NAME, nNatNum );
+ break;
+ case NF_KEY_NNNN: // NNNN
+ {
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_DAY_NAME, nNatNum );
+ OutString += rLoc().getLongDateDayOfWeekSep();
+ }
+ break;
+ case NF_KEY_WW : // WW
+ {
+ sal_Int16 nVal = rCal.getValue( CalendarFieldIndex::WEEK_OF_YEAR );
+ OutString += ImpIntToString( nIx, nVal );
+ }
+ break;
+ case NF_KEY_G: // G
+ ImpAppendEraG( OutString, rCal, nNatNum );
+ break;
+ case NF_KEY_GG: // GG
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::SHORT_ERA, nNatNum );
+ break;
+ case NF_KEY_GGG: // GGG
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_ERA, nNatNum );
+ break;
+ case NF_KEY_RR: // RR => GGGEE
+ OutString += rCal.getDisplayString(
+ CalendarDisplayCode::LONG_YEAR_AND_ERA, nNatNum );
+ break;
+ }
+ }
+ if ( aOrgCalendar.Len() )
+ rCal.loadCalendar( aOrgCalendar, rLoc().getLocale() ); // restore calendar
+ return bRes;
+}
+
+BOOL SvNumberformat::ImpGetNumberOutput(double fNumber,
+ USHORT nIx,
+ String& OutString)
+{
+ BOOL bRes = FALSE;
+ BOOL bSign;
+ if (fNumber < 0.0)
+ {
+ if (nIx == 0) // nicht in hinteren
+ bSign = TRUE; // Formaten
+ else
+ bSign = FALSE;
+ fNumber = -fNumber;
+ }
+ else
+ {
+ bSign = FALSE;
+ if ( ::rtl::math::isSignBitSet( fNumber ) )
+ fNumber = -fNumber; // yes, -0.0 is possible, eliminate '-'
+ }
+ const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info();
+ if (rInfo.eScannedType == NUMBERFORMAT_PERCENT)
+ {
+ if (fNumber < _D_MAX_D_BY_100)
+ fNumber *= 100.0;
+ else
+ {
+ OutString = rScan.GetErrorString();
+ return FALSE;
+ }
+ }
+ USHORT i, j;
+ xub_StrLen k;
+ String sStr;
+ long nPrecExp;
+ BOOL bInteger = FALSE;
+ if ( rInfo.nThousand != FLAG_STANDARD_IN_FORMAT )
+ { // special formatting only if no GENERAL keyword in format code
+ const USHORT nThousand = rInfo.nThousand;
+ for (i = 0; i < nThousand; i++)
+ {
+ if (fNumber > _D_MIN_M_BY_1000)
+ fNumber /= 1000.0;
+ else
+ fNumber = 0.0;
+ }
+ if (fNumber > 0.0)
+ nPrecExp = GetPrecExp( fNumber );
+ else
+ nPrecExp = 0;
+ if (rInfo.nCntPost) // NachkommaStellen
+ {
+ if (rInfo.nCntPost + nPrecExp > 15 && nPrecExp < 15)
+ {
+ sStr = ::rtl::math::doubleToUString( fNumber,
+ rtl_math_StringFormat_F, 15-nPrecExp, '.');
+ for (long l = 15-nPrecExp; l < (long) rInfo.nCntPost; l++)
+ sStr += '0';
+ }
+ else
+ sStr = ::rtl::math::doubleToUString( fNumber,
+ rtl_math_StringFormat_F, rInfo.nCntPost, '.' );
+ sStr.EraseLeadingChars('0'); // fuehrende Nullen weg
+ }
+ else if (fNumber == 0.0) // Null
+ {
+ // nothing to be done here, keep empty string sStr,
+ // ImpNumberFillWithThousands does the rest
+ }
+ else // Integer
+ {
+ sStr = ::rtl::math::doubleToUString( fNumber,
+ rtl_math_StringFormat_F, 0, '.');
+ sStr.EraseLeadingChars('0'); // fuehrende Nullen weg
+ }
+ xub_StrLen nPoint = sStr.Search( '.' );
+ if ( nPoint != STRING_NOTFOUND )
+ {
+ register const sal_Unicode* p = sStr.GetBuffer() + nPoint;
+ while ( *++p == '0' )
+ ;
+ if ( !*p )
+ bInteger = TRUE;
+ sStr.Erase( nPoint, 1 ); // . herausnehmen
+ }
+ if (bSign &&
+ (sStr.Len() == 0 || sStr.GetTokenCount('0') == sStr.Len()+1)) // nur 00000
+ bSign = FALSE; // nicht -0.00
+ } // End of != FLAG_STANDARD_IN_FORMAT
+
+ // von hinten nach vorn
+ // editieren:
+ k = sStr.Len(); // hinter letzter Ziffer
+ j = NumFor[nIx].GetnAnz()-1; // letztes Symbol
+ // Nachkommastellen:
+ if (rInfo.nCntPost > 0)
+ {
+ BOOL bTrailing = TRUE; // ob Endnullen?
+ BOOL bFilled = FALSE; // ob aufgefuellt wurde ?
+ short nType;
+ while (j > 0 && // rueckwaerts
+ (nType = rInfo.nTypeArray[j]) != NF_SYMBOLTYPE_DECSEP)
+ {
+ switch ( nType )
+ {
+ case NF_SYMBOLTYPE_STAR:
+ if( bStarFlag )
+ {
+ sStr.Insert( (sal_Unicode) 0x1B, k /*++*/ );
+ sStr.Insert(rInfo.sStrArray[j].GetChar(1),k);
+ bRes = TRUE;
+ }
+ break;
+ case NF_SYMBOLTYPE_BLANK:
+ /*k = */ InsertBlanks( sStr,k,rInfo.sStrArray[j].GetChar(1) );
+ break;
+ case NF_SYMBOLTYPE_STRING:
+ case NF_SYMBOLTYPE_CURRENCY:
+ case NF_SYMBOLTYPE_PERCENT:
+ sStr.Insert(rInfo.sStrArray[j],k);
+ break;
+ case NF_SYMBOLTYPE_THSEP:
+ if (rInfo.nThousand == 0)
+ sStr.Insert(rInfo.sStrArray[j],k);
+ break;
+ case NF_SYMBOLTYPE_DIGIT:
+ {
+ const String& rStr = rInfo.sStrArray[j];
+ const sal_Unicode* p1 = rStr.GetBuffer();
+ register const sal_Unicode* p = p1 + rStr.Len();
+ while ( p1 < p-- )
+ {
+ const sal_Unicode c = *p;
+ k--;
+ if ( sStr.GetChar(k) != '0' )
+ bTrailing = FALSE;
+ if (bTrailing)
+ {
+ if ( c == '0' )
+ bFilled = TRUE;
+ else if ( c == '-' )
+ {
+ if ( bInteger )
+ sStr.SetChar( k, '-' );
+ bFilled = TRUE;
+ }
+ else if ( c == '?' )
+ {
+ sStr.SetChar( k, ' ' );
+ bFilled = TRUE;
+ }
+ else if ( !bFilled ) // #
+ sStr.Erase(k,1);
+ }
+ } // of for
+ } // of case digi
+ break;
+ case NF_KEY_CCC: // CCC-Waehrung
+ sStr.Insert(rScan.GetCurAbbrev(), k);
+ break;
+ case NF_KEY_GENERAL: // Standard im String
+ {
+ String sNum;
+ ImpGetOutputStandard(fNumber, sNum);
+ sNum.EraseLeadingChars('-');
+ sStr.Insert(sNum, k);
+ }
+ break;
+ default:
+ break;
+ } // of switch
+ j--;
+ } // of while
+ } // of Nachkomma
+
+ bRes |= ImpNumberFillWithThousands(sStr, fNumber, k, j, nIx, // ggfs Auffuellen mit .
+ rInfo.nCntPre);
+ if ( rInfo.nCntPost > 0 )
+ {
+ const String& rDecSep = GetFormatter().GetNumDecimalSep();
+ xub_StrLen nLen = rDecSep.Len();
+ if ( sStr.Len() > nLen && sStr.Equals( rDecSep, sStr.Len() - nLen, nLen ) )
+ sStr.Erase( sStr.Len() - nLen ); // no decimals => strip DecSep
+ }
+ if (bSign)
+ sStr.Insert('-',0);
+ ImpTransliterate( sStr, NumFor[nIx].GetNatNum() );
+ OutString = sStr;
+ return bRes;
+}
+
+BOOL SvNumberformat::ImpNumberFillWithThousands(
+ String& sStr, // number string
+ double& rNumber, // number
+ xub_StrLen k, // position within string
+ USHORT j, // position of format code string
+ USHORT nIx, // subformat index
+ USHORT nDigCnt) // count of digits in format
+{
+ BOOL bRes = FALSE;
+ BOOL bLeading = FALSE; // leading characters
+ xub_StrLen nAnzLeadingChars = 0; // count of leading zeros or blanks
+ USHORT nThousandCnt = 0; // count of digits before leftmost separator
+ xub_StrLen nLeadingStringChars = 0; // inserted StringChars before number
+ USHORT nDigitCount = 0; // count of integer digits
+ BOOL bStop = FALSE;
+ const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info();
+ // no normal thousands separators if number divided by thousands
+ BOOL bDoThousands = (rInfo.nThousand == 0);
+ const String& rThousandSep = GetFormatter().GetNumThousandSep();
+ while (!bStop) // backwards
+ {
+ if (j == 0)
+ bStop = TRUE;
+ switch (rInfo.nTypeArray[j])
+ {
+ case NF_SYMBOLTYPE_DECSEP:
+ case NF_SYMBOLTYPE_STRING:
+ case NF_SYMBOLTYPE_CURRENCY:
+ case NF_SYMBOLTYPE_PERCENT:
+ sStr.Insert(rInfo.sStrArray[j],k);
+ if ( k == 0 )
+ nLeadingStringChars =
+ nLeadingStringChars + rInfo.sStrArray[j].Len();
+ break;
+ case NF_SYMBOLTYPE_STAR:
+ if( bStarFlag )
+ {
+ sStr.Insert( (sal_Unicode) 0x1B, k/*++*/ );
+ sStr.Insert(rInfo.sStrArray[j].GetChar(1),k);
+ bRes = TRUE;
+ }
+ break;
+ case NF_SYMBOLTYPE_BLANK:
+ /*k = */ InsertBlanks( sStr,k,rInfo.sStrArray[j].GetChar(1) );
+ break;
+ case NF_SYMBOLTYPE_THSEP:
+ {
+ // #i7284# #102685# Insert separator also if number is divided
+ // by thousands and the separator is specified somewhere in
+ // between and not only at the end.
+ // #i12596# But do not insert if it's a parenthesized negative
+ // format like (#,)
+ // In fact, do not insert if divided and regex [0#],[^0#] and
+ // no other digit symbol follows (which was already detected
+ // during scan of format code, otherwise there would be no
+ // division), else do insert.
+ if ( !bDoThousands && j < NumFor[nIx].GetnAnz()-1 )
+ bDoThousands = ((j == 0) ||
+ (rInfo.nTypeArray[j-1] != NF_SYMBOLTYPE_DIGIT) ||
+ (rInfo.nTypeArray[j+1] == NF_SYMBOLTYPE_DIGIT));
+ if ( bDoThousands && k > 0 )
+ {
+ sStr.Insert(rInfo.sStrArray[j],k);
+ nThousandCnt = 0;
+ }
+ }
+ break;
+ case NF_SYMBOLTYPE_DIGIT:
+ {
+ const String& rStr = rInfo.sStrArray[j];
+ const sal_Unicode* p1 = rStr.GetBuffer();
+ register const sal_Unicode* p = p1 + rStr.Len();
+ while ( p1 < p-- )
+ {
+ nDigitCount++;
+ const sal_Unicode c = *p;
+//! TODO: what if rThousandSep is more than one charater? => change this damned backward loop
+ if ( c == rThousandSep.GetChar(0) && rThousandSep.Len() == 1 )
+ {
+ nDigitCount--;
+ if (k > 0)
+ {
+ sStr.Insert(c,k);
+ nThousandCnt = 0;
+ }
+ }
+ else if (k > 0)
+ {
+ k--;
+ nThousandCnt++;
+ }
+ else
+ bLeading = TRUE;
+ if (bLeading)
+ {
+ if (c == '?')
+ {
+ sStr.Insert(' ',0);
+ nAnzLeadingChars++;
+ }
+ else if (c == '0')
+ {
+ sStr.Insert('0',0);
+ nAnzLeadingChars++;
+ }
+ }
+ if (nDigitCount == nDigCnt && k > 0)
+ { // more digits than specified
+ ImpDigitFill(sStr, 0, k, nIx, nThousandCnt);
+ }
+ }
+ }
+ break;
+ case NF_KEY_CCC: // CCC currency
+ sStr.Insert(rScan.GetCurAbbrev(), k);
+ break;
+ case NF_KEY_GENERAL: // "General" in string
+ {
+ String sNum;
+ ImpGetOutputStandard(rNumber, sNum);
+ sNum.EraseLeadingChars('-');
+ sStr.Insert(sNum, k);
+ }
+ break;
+
+ default:
+ break;
+ } // switch
+ j--; // next format code string
+ } // while
+ k += nLeadingStringChars + nAnzLeadingChars;
+ if (k > nLeadingStringChars)
+ ImpDigitFill(sStr, nLeadingStringChars, k, nIx, nThousandCnt);
+ return bRes;
+}
+
+void SvNumberformat::ImpDigitFill(
+ String& sStr, // number string
+ xub_StrLen nStart, // start of digits
+ xub_StrLen& k, // position within string
+ USHORT nIx, // subformat index
+ USHORT nThousandCnt ) // count of digits before leftmost separator
+{
+ if (NumFor[nIx].Info().bThousand) // noch Ziffern da
+ { // Aufuellen mit .
+ const String& rThousandSep = GetFormatter().GetNumThousandSep();
+ while (k > nStart)
+ {
+ if (nThousandCnt == 3)
+ { // hier muss . dazwischen
+ sStr.Insert( rThousandSep, k );
+ nThousandCnt = 1;
+ }
+ else
+ nThousandCnt++;
+ k--;
+ }
+ }
+ else // einfach ueberspringen
+ k = nStart;
+}
+
+BOOL SvNumberformat::ImpNumberFill(String& sStr, // Zahlstring
+ double& rNumber, // Zahl fuer Standard
+ xub_StrLen& k, // Zeigen darin
+ USHORT& j, // Symbolzeiger
+ USHORT nIx, // Teilformatstring
+ short eSymbolType ) // Abbruchtyp
+{
+ BOOL bRes = FALSE;
+ k = sStr.Len(); // hinter letzter Ziffer
+ BOOL bLeading = FALSE; // fuehrende ? oder 0
+ const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info();
+ const String& rThousandSep = GetFormatter().GetNumThousandSep();
+ short nType;
+ while (j > 0 && (nType = rInfo.nTypeArray[j]) != eSymbolType )
+ { // rueckwaerts:
+ switch ( nType )
+ {
+ case NF_SYMBOLTYPE_STAR:
+ if( bStarFlag )
+ {
+ sStr.Insert( sal_Unicode(0x1B), k++ );
+ sStr.Insert(rInfo.sStrArray[j].GetChar(1),k);
+ bRes = TRUE;
+ }
+ break;
+ case NF_SYMBOLTYPE_BLANK:
+ k = InsertBlanks( sStr,k,rInfo.sStrArray[j].GetChar(1) );
+ break;
+ case NF_SYMBOLTYPE_DIGIT:
+ {
+ const String& rStr = rInfo.sStrArray[j];
+ const sal_Unicode* p1 = rStr.GetBuffer();
+ register const sal_Unicode* p = p1 + rStr.Len();
+ while ( p1 < p-- )
+ {
+ const sal_Unicode c = *p;
+//! TODO: what if rThousandSep is more than one charater? => change this damned backward loop
+ if ( c == rThousandSep.GetChar(0) && rThousandSep.Len() == 1 )
+ {
+ if (k > 0)
+ sStr.Insert(c,k);
+ }
+ else if (k > 0)
+ k--;
+ else
+ bLeading = TRUE;
+ if (bLeading)
+ {
+ if (c == '?')
+ sStr.Insert(' ',0);
+ else if (c == '0')
+ sStr.Insert('0',0);
+ } // of if
+ } // of for
+ } // of case digi
+ break;
+ case NF_KEY_CCC: // CCC-Waehrung
+ sStr.Insert(rScan.GetCurAbbrev(), k);
+ break;
+ case NF_KEY_GENERAL: // Standard im String
+ {
+ String sNum;
+ ImpGetOutputStandard(rNumber, sNum);
+ sNum.EraseLeadingChars('-'); // Vorzeichen weg!!
+ sStr.Insert(sNum, k);
+ }
+ break;
+
+ default:
+ sStr.Insert(rInfo.sStrArray[j],k);
+ break;
+ } // of switch
+ j--; // naechster String
+ } // of while
+ return bRes;
+}
+
+void SvNumberformat::GetFormatSpecialInfo(BOOL& bThousand,
+ BOOL& IsRed,
+ USHORT& nPrecision,
+ USHORT& nAnzLeading) const
+{
+ // as before: take info from nNumFor=0 for whole format (for dialog etc.)
+
+ short nDummyType;
+ GetNumForInfo( 0, nDummyType, bThousand, nPrecision, nAnzLeading );
+
+ // "negative in red" is only useful for the whole format
+
+ const Color* pColor = NumFor[1].GetColor();
+ if (fLimit1 == 0.0 && fLimit2 == 0.0 && pColor
+ && (*pColor == rScan.GetRedColor()))
+ IsRed = TRUE;
+ else
+ IsRed = FALSE;
+}
+
+void SvNumberformat::GetNumForInfo( USHORT nNumFor, short& rScannedType,
+ BOOL& bThousand, USHORT& nPrecision, USHORT& nAnzLeading ) const
+{
+ // take info from a specified sub-format (for XML export)
+
+ if ( nNumFor > 3 )
+ return; // invalid
+
+ const ImpSvNumberformatInfo& rInfo = NumFor[nNumFor].Info();
+ rScannedType = rInfo.eScannedType;
+ bThousand = rInfo.bThousand;
+ nPrecision = rInfo.nCntPost;
+ if (bStandard && rInfo.eScannedType == NUMBERFORMAT_NUMBER)
+ // StandardFormat
+ nAnzLeading = 1;
+ else
+ {
+ nAnzLeading = 0;
+ BOOL bStop = FALSE;
+ USHORT i = 0;
+ const USHORT nAnz = NumFor[nNumFor].GetnAnz();
+ while (!bStop && i < nAnz)
+ {
+ short nType = rInfo.nTypeArray[i];
+ if ( nType == NF_SYMBOLTYPE_DIGIT)
+ {
+ register const sal_Unicode* p = rInfo.sStrArray[i].GetBuffer();
+ while ( *p == '#' )
+ p++;
+ while ( *p++ == '0' )
+ nAnzLeading++;
+ }
+ else if (nType == NF_SYMBOLTYPE_DECSEP || nType == NF_SYMBOLTYPE_EXP)
+ bStop = TRUE;
+ i++;
+ }
+ }
+}
+
+const String* SvNumberformat::GetNumForString( USHORT nNumFor, USHORT nPos,
+ BOOL bString /* = FALSE */ ) const
+{
+ if ( nNumFor > 3 )
+ return NULL;
+ USHORT nAnz = NumFor[nNumFor].GetnAnz();
+ if ( !nAnz )
+ return NULL;
+ if ( nPos == 0xFFFF )
+ {
+ nPos = nAnz - 1;
+ if ( bString )
+ { // rueckwaerts
+ short* pType = NumFor[nNumFor].Info().nTypeArray + nPos;
+ while ( nPos > 0 && (*pType != NF_SYMBOLTYPE_STRING) &&
+ (*pType != NF_SYMBOLTYPE_CURRENCY) )
+ {
+ pType--;
+ nPos--;
+ }
+ if ( (*pType != NF_SYMBOLTYPE_STRING) && (*pType != NF_SYMBOLTYPE_CURRENCY) )
+ return NULL;
+ }
+ }
+ else if ( nPos > nAnz - 1 )
+ return NULL;
+ else if ( bString )
+ { // vorwaerts
+ short* pType = NumFor[nNumFor].Info().nTypeArray + nPos;
+ while ( nPos < nAnz && (*pType != NF_SYMBOLTYPE_STRING) &&
+ (*pType != NF_SYMBOLTYPE_CURRENCY) )
+ {
+ pType++;
+ nPos++;
+ }
+ if ( nPos >= nAnz || ((*pType != NF_SYMBOLTYPE_STRING) &&
+ (*pType != NF_SYMBOLTYPE_CURRENCY)) )
+ return NULL;
+ }
+ return &NumFor[nNumFor].Info().sStrArray[nPos];
+}
+
+
+short SvNumberformat::GetNumForType( USHORT nNumFor, USHORT nPos,
+ BOOL bString /* = FALSE */ ) const
+{
+ if ( nNumFor > 3 )
+ return 0;
+ USHORT nAnz = NumFor[nNumFor].GetnAnz();
+ if ( !nAnz )
+ return 0;
+ if ( nPos == 0xFFFF )
+ {
+ nPos = nAnz - 1;
+ if ( bString )
+ { // rueckwaerts
+ short* pType = NumFor[nNumFor].Info().nTypeArray + nPos;
+ while ( nPos > 0 && (*pType != NF_SYMBOLTYPE_STRING) &&
+ (*pType != NF_SYMBOLTYPE_CURRENCY) )
+ {
+ pType--;
+ nPos--;
+ }
+ if ( (*pType != NF_SYMBOLTYPE_STRING) && (*pType != NF_SYMBOLTYPE_CURRENCY) )
+ return 0;
+ }
+ }
+ else if ( nPos > nAnz - 1 )
+ return 0;
+ else if ( bString )
+ { // vorwaerts
+ short* pType = NumFor[nNumFor].Info().nTypeArray + nPos;
+ while ( nPos < nAnz && (*pType != NF_SYMBOLTYPE_STRING) &&
+ (*pType != NF_SYMBOLTYPE_CURRENCY) )
+ {
+ pType++;
+ nPos++;
+ }
+ if ( (*pType != NF_SYMBOLTYPE_STRING) && (*pType != NF_SYMBOLTYPE_CURRENCY) )
+ return 0;
+ }
+ return NumFor[nNumFor].Info().nTypeArray[nPos];
+}
+
+
+BOOL SvNumberformat::IsNegativeWithoutSign() const
+{
+ if ( IsNegativeRealNegative() )
+ {
+ const String* pStr = GetNumForString( 1, 0, TRUE );
+ if ( pStr )
+ return !HasStringNegativeSign( *pStr );
+ }
+ return FALSE;
+}
+
+
+DateFormat SvNumberformat::GetDateOrder() const
+{
+ if ( (eType & NUMBERFORMAT_DATE) == NUMBERFORMAT_DATE )
+ {
+ short const * const pType = NumFor[0].Info().nTypeArray;
+ USHORT nAnz = NumFor[0].GetnAnz();
+ for ( USHORT j=0; j<nAnz; j++ )
+ {
+ switch ( pType[j] )
+ {
+ case NF_KEY_D :
+ case NF_KEY_DD :
+ return DMY;
+ case NF_KEY_M :
+ case NF_KEY_MM :
+ case NF_KEY_MMM :
+ case NF_KEY_MMMM :
+ case NF_KEY_MMMMM :
+ return MDY;
+ case NF_KEY_YY :
+ case NF_KEY_YYYY :
+ case NF_KEY_EC :
+ case NF_KEY_EEC :
+ case NF_KEY_R :
+ case NF_KEY_RR :
+ return YMD;
+ }
+ }
+ }
+ else
+ {
+ DBG_ERROR( "SvNumberformat::GetDateOrder: no date" );
+ }
+ return rLoc().getDateFormat();
+}
+
+
+sal_uInt32 SvNumberformat::GetExactDateOrder() const
+{
+ sal_uInt32 nRet = 0;
+ if ( (eType & NUMBERFORMAT_DATE) != NUMBERFORMAT_DATE )
+ {
+ DBG_ERROR( "SvNumberformat::GetExactDateOrder: no date" );
+ return nRet;
+ }
+ short const * const pType = NumFor[0].Info().nTypeArray;
+ USHORT nAnz = NumFor[0].GetnAnz();
+ int nShift = 0;
+ for ( USHORT j=0; j<nAnz && nShift < 3; j++ )
+ {
+ switch ( pType[j] )
+ {
+ case NF_KEY_D :
+ case NF_KEY_DD :
+ nRet = (nRet << 8) | 'D';
+ ++nShift;
+ break;
+ case NF_KEY_M :
+ case NF_KEY_MM :
+ case NF_KEY_MMM :
+ case NF_KEY_MMMM :
+ case NF_KEY_MMMMM :
+ nRet = (nRet << 8) | 'M';
+ ++nShift;
+ break;
+ case NF_KEY_YY :
+ case NF_KEY_YYYY :
+ case NF_KEY_EC :
+ case NF_KEY_EEC :
+ case NF_KEY_R :
+ case NF_KEY_RR :
+ nRet = (nRet << 8) | 'Y';
+ ++nShift;
+ break;
+ }
+ }
+ return nRet;
+}
+
+
+void SvNumberformat::GetConditions( SvNumberformatLimitOps& rOper1, double& rVal1,
+ SvNumberformatLimitOps& rOper2, double& rVal2 ) const
+{
+ rOper1 = eOp1;
+ rOper2 = eOp2;
+ rVal1 = fLimit1;
+ rVal2 = fLimit2;
+}
+
+
+Color* SvNumberformat::GetColor( USHORT nNumFor ) const
+{
+ if ( nNumFor > 3 )
+ return NULL;
+
+ return NumFor[nNumFor].GetColor();
+}
+
+String SvNumberformat::ImpGetNatNumString( const SvNumberNatNum& rNum,
+ sal_Int32 nVal, USHORT nMinDigits ) const
+{
+ String aStr;
+ if ( nMinDigits )
+ {
+ if ( nMinDigits == 2 )
+ { // speed up the most common case
+ if ( 0 <= nVal && nVal < 10 )
+ {
+ sal_Unicode* p = aStr.AllocBuffer( 2 );
+ *p++ = '0';
+ *p = sal_Unicode( '0' + nVal );
+ }
+ else
+ aStr = String::CreateFromInt32( nVal );
+ }
+ else
+ {
+ String aValStr( String::CreateFromInt32( nVal ) );
+ if ( aValStr.Len() >= nMinDigits )
+ aStr = aValStr;
+ else
+ {
+ aStr.Fill( nMinDigits - aValStr.Len(), '0' );
+ aStr += aValStr;
+ }
+ }
+ }
+ else
+ aStr = String::CreateFromInt32( nVal );
+ ImpTransliterate( aStr, rNum );
+ return aStr;
+}
+
+
+void SvNumberformat::ImpTransliterateImpl( String& rStr,
+ const SvNumberNatNum& rNum ) const
+{
+ com::sun::star::lang::Locale aLocale(
+ MsLangId::convertLanguageToLocale( rNum.GetLang() ) );
+ rStr = GetFormatter().GetNatNum()->getNativeNumberString( rStr,
+ aLocale, rNum.GetNatNum() );
+}
+
+
+void SvNumberformat::GetNatNumXml(
+ com::sun::star::i18n::NativeNumberXmlAttributes& rAttr,
+ USHORT nNumFor ) const
+{
+ if ( nNumFor <= 3 )
+ {
+ const SvNumberNatNum& rNum = NumFor[nNumFor].GetNatNum();
+ if ( rNum.IsSet() )
+ {
+ com::sun::star::lang::Locale aLocale(
+ MsLangId::convertLanguageToLocale( rNum.GetLang() ) );
+ rAttr = GetFormatter().GetNatNum()->convertToXmlAttributes(
+ aLocale, rNum.GetNatNum() );
+ }
+ else
+ rAttr = com::sun::star::i18n::NativeNumberXmlAttributes();
+ }
+ else
+ rAttr = com::sun::star::i18n::NativeNumberXmlAttributes();
+}
+
+// static
+BOOL SvNumberformat::HasStringNegativeSign( const String& rStr )
+{
+ // fuer Sign muss '-' am Anfang oder am Ende des TeilStrings sein (Blanks ignored)
+ xub_StrLen nLen = rStr.Len();
+ if ( !nLen )
+ return FALSE;
+ const sal_Unicode* const pBeg = rStr.GetBuffer();
+ const sal_Unicode* const pEnd = pBeg + nLen;
+ register const sal_Unicode* p = pBeg;
+ do
+ { // Anfang
+ if ( *p == '-' )
+ return TRUE;
+ } while ( *p == ' ' && ++p < pEnd );
+ p = pEnd - 1;
+ do
+ { // Ende
+ if ( *p == '-' )
+ return TRUE;
+ } while ( *p == ' ' && pBeg < --p );
+ return FALSE;
+}
+
+// static
+void SvNumberformat::EraseCommentBraces( String& rStr )
+{
+ xub_StrLen nLen = rStr.Len();
+ if ( nLen && rStr.GetChar(0) == '{' )
+ {
+ rStr.Erase( 0, 1 );
+ --nLen;
+ }
+ if ( nLen && rStr.GetChar(0) == ' ' )
+ {
+ rStr.Erase( 0, 1 );
+ --nLen;
+ }
+ if ( nLen && rStr.GetChar( nLen-1 ) == '}' )
+ rStr.Erase( --nLen, 1 );
+ if ( nLen && rStr.GetChar( nLen-1 ) == ' ' )
+ rStr.Erase( --nLen, 1 );
+}
+
+
+// static
+BOOL SvNumberformat::IsInQuote( const String& rStr, xub_StrLen nPos,
+ sal_Unicode cQuote, sal_Unicode cEscIn, sal_Unicode cEscOut )
+{
+ xub_StrLen nLen = rStr.Len();
+ if ( nPos >= nLen )
+ return FALSE;
+ register const sal_Unicode* p0 = rStr.GetBuffer();
+ register const sal_Unicode* p = p0;
+ register const sal_Unicode* p1 = p0 + nPos;
+ BOOL bQuoted = FALSE;
+ while ( p <= p1 )
+ {
+ if ( *p == cQuote )
+ {
+ if ( p == p0 )
+ bQuoted = TRUE;
+ else if ( bQuoted )
+ {
+ if ( *(p-1) != cEscIn )
+ bQuoted = FALSE;
+ }
+ else
+ {
+ if ( *(p-1) != cEscOut )
+ bQuoted = TRUE;
+ }
+ }
+ p++;
+ }
+ return bQuoted;
+}
+
+
+// static
+xub_StrLen SvNumberformat::GetQuoteEnd( const String& rStr, xub_StrLen nPos,
+ sal_Unicode cQuote, sal_Unicode cEscIn, sal_Unicode cEscOut )
+{
+ xub_StrLen nLen = rStr.Len();
+ if ( nPos >= nLen )
+ return STRING_NOTFOUND;
+ if ( !IsInQuote( rStr, nPos, cQuote, cEscIn, cEscOut ) )
+ {
+ if ( rStr.GetChar( nPos ) == cQuote )
+ return nPos; // schliessendes cQuote
+ return STRING_NOTFOUND;
+ }
+ register const sal_Unicode* p0 = rStr.GetBuffer();
+ register const sal_Unicode* p = p0 + nPos;
+ register const sal_Unicode* p1 = p0 + nLen;
+ while ( p < p1 )
+ {
+ if ( *p == cQuote && p > p0 && *(p-1) != cEscIn )
+ return sal::static_int_cast< xub_StrLen >(p - p0);
+ p++;
+ }
+ return nLen; // String Ende
+}
+
+
+USHORT SvNumberformat::ImpGetNumForStringElementCount( USHORT nNumFor ) const
+{
+ USHORT nCnt = 0;
+ USHORT nAnz = NumFor[nNumFor].GetnAnz();
+ short const * const pType = NumFor[nNumFor].Info().nTypeArray;
+ for ( USHORT j=0; j<nAnz; ++j )
+ {
+ switch ( pType[j] )
+ {
+ case NF_SYMBOLTYPE_STRING:
+ case NF_SYMBOLTYPE_CURRENCY:
+ case NF_SYMBOLTYPE_DATESEP:
+ case NF_SYMBOLTYPE_TIMESEP:
+ case NF_SYMBOLTYPE_TIME100SECSEP:
+ case NF_SYMBOLTYPE_PERCENT:
+ ++nCnt;
+ break;
+ }
+ }
+ return nCnt;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/numbers/svt_zforscan.cxx b/binfilter/bf_svtools/source/numbers/svt_zforscan.cxx
new file mode 100644
index 000000000000..b906626ab2e5
--- /dev/null
+++ b/binfilter/bf_svtools/source/numbers/svt_zforscan.cxx
@@ -0,0 +1,2778 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <stdlib.h>
+
+#include <tools/debug.hxx>
+#include <i18npool/mslangid.hxx>
+#include <unotools/charclass.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <unotools/numberformatcodewrapper.hxx>
+#include <rtl/instance.hxx>
+
+#include <bf_svtools/zforlist.hxx>
+#include <bf_svtools/zformat.hxx>
+
+#define _ZFORSCAN_CXX
+#include "zforscan.hxx"
+#undef _ZFORSCAN_CXX
+
+#include "nfsymbol.hxx"
+
+namespace binfilter
+{
+
+const sal_Unicode cNonBreakingSpace = 0xA0;
+
+namespace
+{
+ struct ImplEnglishColors
+ {
+ const String* operator()()
+ {
+ static const String aEnglishColors[NF_MAX_DEFAULT_COLORS] =
+ {
+ String( RTL_CONSTASCII_USTRINGPARAM( "BLACK" ) ),
+ String( RTL_CONSTASCII_USTRINGPARAM( "BLUE" ) ),
+ String( RTL_CONSTASCII_USTRINGPARAM( "GREEN" ) ),
+ String( RTL_CONSTASCII_USTRINGPARAM( "CYAN" ) ),
+ String( RTL_CONSTASCII_USTRINGPARAM( "RED" ) ),
+ String( RTL_CONSTASCII_USTRINGPARAM( "MAGENTA" ) ),
+ String( RTL_CONSTASCII_USTRINGPARAM( "BROWN" ) ),
+ String( RTL_CONSTASCII_USTRINGPARAM( "GREY" ) ),
+ String( RTL_CONSTASCII_USTRINGPARAM( "YELLOW" ) ),
+ String( RTL_CONSTASCII_USTRINGPARAM( "WHITE" ) )
+ };
+ return &aEnglishColors[0];
+ }
+ };
+
+ struct theEnglishColors
+ : public rtl::StaticAggregate< const String, ImplEnglishColors> {};
+
+}
+
+ImpSvNumberformatScan::ImpSvNumberformatScan( SvNumberFormatter* pFormatterP )
+{
+ pFormatter = pFormatterP;
+ bConvertMode = FALSE;
+ //! All keywords MUST be UPPERCASE!
+ sKeyword[NF_KEY_E].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "E" ) ); // Exponent
+ sKeyword[NF_KEY_AMPM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "AM/PM" ) ); // AM/PM
+ sKeyword[NF_KEY_AP].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "A/P" ) ); // AM/PM short
+ sKeyword[NF_KEY_MI].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "M" ) ); // Minute
+ sKeyword[NF_KEY_MMI].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MM" ) ); // Minute 02
+ sKeyword[NF_KEY_S].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "S" ) ); // Second
+ sKeyword[NF_KEY_SS].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "SS" ) ); // Second 02
+ sKeyword[NF_KEY_Q].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Q" ) ); // Quarter short 'Q'
+ sKeyword[NF_KEY_QQ].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "QQ" ) ); // Quarter long
+ sKeyword[NF_KEY_NN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "NN" ) ); // Day of week short
+ sKeyword[NF_KEY_NNN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "NNN" ) ); // Day of week long
+ sKeyword[NF_KEY_NNNN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "NNNN" ) ); // Day of week long incl. separator
+ sKeyword[NF_KEY_WW].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "WW" ) ); // Week of year
+ sKeyword[NF_KEY_CCC].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "CCC" ) ); // Currency abbreviation
+ bKeywordsNeedInit = TRUE; // locale dependent keywords
+ bCompatCurNeedInit = TRUE; // locale dependent compatibility currency strings
+
+ StandardColor[0] = Color(COL_BLACK);
+ StandardColor[1] = Color(COL_LIGHTBLUE);
+ StandardColor[2] = Color(COL_LIGHTGREEN);
+ StandardColor[3] = Color(COL_LIGHTCYAN);
+ StandardColor[4] = Color(COL_LIGHTRED);
+ StandardColor[5] = Color(COL_LIGHTMAGENTA);
+ StandardColor[6] = Color(COL_BROWN);
+ StandardColor[7] = Color(COL_GRAY);
+ StandardColor[8] = Color(COL_YELLOW);
+ StandardColor[9] = Color(COL_WHITE);
+
+ pNullDate = new Date(30,12,1899);
+ nStandardPrec = 2;
+
+ sErrStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "###" ) );
+ Reset();
+}
+
+ImpSvNumberformatScan::~ImpSvNumberformatScan()
+{
+ delete pNullDate;
+ Reset();
+}
+
+
+void ImpSvNumberformatScan::ChangeIntl()
+{
+ bKeywordsNeedInit = TRUE;
+ bCompatCurNeedInit = TRUE;
+ // may be initialized by InitSpecialKeyword()
+ sKeyword[NF_KEY_TRUE].Erase();
+ sKeyword[NF_KEY_FALSE].Erase();
+}
+
+
+void ImpSvNumberformatScan::InitSpecialKeyword( NfKeywordIndex eIdx ) const
+{
+ switch ( eIdx )
+ {
+ case NF_KEY_TRUE :
+ ((ImpSvNumberformatScan*)this)->sKeyword[NF_KEY_TRUE] =
+ pFormatter->GetCharClass()->upper(
+ pFormatter->GetLocaleData()->getTrueWord() );
+ if ( !sKeyword[NF_KEY_TRUE].Len() )
+ {
+ DBG_ERRORFILE( "InitSpecialKeyword: TRUE_WORD?" );
+ ((ImpSvNumberformatScan*)this)->sKeyword[NF_KEY_TRUE].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "TRUE" ) );
+ }
+ break;
+ case NF_KEY_FALSE :
+ ((ImpSvNumberformatScan*)this)->sKeyword[NF_KEY_FALSE] =
+ pFormatter->GetCharClass()->upper(
+ pFormatter->GetLocaleData()->getFalseWord() );
+ if ( !sKeyword[NF_KEY_FALSE].Len() )
+ {
+ DBG_ERRORFILE( "InitSpecialKeyword: FALSE_WORD?" );
+ ((ImpSvNumberformatScan*)this)->sKeyword[NF_KEY_FALSE].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "FALSE" ) );
+ }
+ break;
+ default:
+ DBG_ERRORFILE( "InitSpecialKeyword: unknown request" );
+ }
+}
+
+
+void ImpSvNumberformatScan::InitCompatCur() const
+{
+ ImpSvNumberformatScan* pThis = (ImpSvNumberformatScan*)this;
+ // currency symbol for old style ("automatic") compatibility format codes
+ pFormatter->GetCompatibilityCurrency( pThis->sCurSymbol, pThis->sCurAbbrev );
+ // currency symbol upper case
+ pThis->sCurString = pFormatter->GetCharClass()->upper( sCurSymbol );
+ bCompatCurNeedInit = FALSE;
+}
+
+
+void ImpSvNumberformatScan::InitKeywords() const
+{
+ if ( !bKeywordsNeedInit )
+ return ;
+ ((ImpSvNumberformatScan*)this)->SetDependentKeywords();
+ bKeywordsNeedInit = FALSE;
+}
+
+
+void ImpSvNumberformatScan::SetDependentKeywords()
+{
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+
+ const CharClass* pCharClass = pFormatter->GetCharClass();
+ const LocaleDataWrapper* pLocaleData = pFormatter->GetLocaleData();
+ // #80023# be sure to generate keywords for the loaded Locale, not for the
+ // requested Locale, otherwise number format codes might not match
+ lang::Locale aLoadedLocale = pLocaleData->getLoadedLocale();
+ LanguageType eLang = MsLangId::convertLocaleToLanguage( aLoadedLocale );
+ NumberFormatCodeWrapper aNumberFormatCode( pFormatter->GetServiceManager(), aLoadedLocale );
+
+ i18n::NumberFormatCode aFormat = aNumberFormatCode.getFormatCode( NF_NUMBER_STANDARD );
+ sNameStandardFormat = aFormat.Code;
+ sKeyword[NF_KEY_GENERAL] = pCharClass->upper( sNameStandardFormat );
+
+ // preset new calendar keywords
+ sKeyword[NF_KEY_AAA].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "AAA" ) );
+ sKeyword[NF_KEY_AAAA].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "AAAA" ) );
+ sKeyword[NF_KEY_EC].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "E" ) );
+ sKeyword[NF_KEY_EEC].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "EE" ) );
+ sKeyword[NF_KEY_G].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "G" ) );
+ sKeyword[NF_KEY_GG].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GG" ) );
+ sKeyword[NF_KEY_GGG].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GGG" ) );
+ sKeyword[NF_KEY_R].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "R" ) );
+ sKeyword[NF_KEY_RR].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "RR" ) );
+
+ // Thai T NatNum special. Other locale's small letter 't' results in upper
+ // case comparison not matching but length does in conversion mode. Ugly.
+ if (eLang == LANGUAGE_THAI)
+ sKeyword[NF_KEY_THAI_T].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "T"));
+ else
+ sKeyword[NF_KEY_THAI_T].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "t"));
+
+ switch ( eLang )
+ {
+ case LANGUAGE_GERMAN:
+ case LANGUAGE_GERMAN_SWISS:
+ case LANGUAGE_GERMAN_AUSTRIAN:
+ case LANGUAGE_GERMAN_LUXEMBOURG:
+ case LANGUAGE_GERMAN_LIECHTENSTEIN:
+ {
+ //! all capital letters
+ sKeyword[NF_KEY_M].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "M" ) ); // month 1
+ sKeyword[NF_KEY_MM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MM" ) ); // month 01
+ sKeyword[NF_KEY_MMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MMM" ) ); // month Jan
+ sKeyword[NF_KEY_MMMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MMMM" ) ); // month Januar
+ sKeyword[NF_KEY_MMMMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MMMMM" ) );// month J
+ sKeyword[NF_KEY_H].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "H" ) ); // hour 2
+ sKeyword[NF_KEY_HH].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "HH" ) ); // hour 02
+ sKeyword[NF_KEY_D].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "T" ) );
+ sKeyword[NF_KEY_DD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "TT" ) );
+ sKeyword[NF_KEY_DDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "TTT" ) );
+ sKeyword[NF_KEY_DDDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "TTTT" ) );
+ sKeyword[NF_KEY_YY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJ" ) );
+ sKeyword[NF_KEY_YYYY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJJJ" ) );
+ sKeyword[NF_KEY_BOOLEAN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "LOGISCH" ) );
+ sKeyword[NF_KEY_COLOR].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "FARBE" ) );
+ sKeyword[NF_KEY_BLACK].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "SCHWARZ" ) );
+ sKeyword[NF_KEY_BLUE].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "BLAU" ) );
+ sKeyword[NF_KEY_GREEN] = UniString( "GR" "\xDC" "N", RTL_TEXTENCODING_ISO_8859_1 );
+ sKeyword[NF_KEY_CYAN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "CYAN" ) );
+ sKeyword[NF_KEY_RED].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "ROT" ) );
+ sKeyword[NF_KEY_MAGENTA].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MAGENTA" ) );
+ sKeyword[NF_KEY_BROWN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "BRAUN" ) );
+ sKeyword[NF_KEY_GREY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GRAU" ) );
+ sKeyword[NF_KEY_YELLOW].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GELB" ) );
+ sKeyword[NF_KEY_WHITE].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "WEISS" ) );
+ }
+ break;
+ default:
+ {
+ // day
+ switch ( eLang )
+ {
+ case LANGUAGE_ITALIAN :
+ case LANGUAGE_ITALIAN_SWISS :
+ sKeyword[NF_KEY_D].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "G" ) );
+ sKeyword[NF_KEY_DD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GG" ) );
+ sKeyword[NF_KEY_DDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GGG" ) );
+ sKeyword[NF_KEY_DDDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GGGG" ) );
+ // must exchange the era code, same as Xcl
+ sKeyword[NF_KEY_G].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "X" ) );
+ sKeyword[NF_KEY_GG].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "XX" ) );
+ sKeyword[NF_KEY_GGG].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "XXX" ) );
+ break;
+ case LANGUAGE_FRENCH :
+ case LANGUAGE_FRENCH_BELGIAN :
+ case LANGUAGE_FRENCH_CANADIAN :
+ case LANGUAGE_FRENCH_SWISS :
+ case LANGUAGE_FRENCH_LUXEMBOURG :
+ case LANGUAGE_FRENCH_MONACO :
+ sKeyword[NF_KEY_D].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "J" ) );
+ sKeyword[NF_KEY_DD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJ" ) );
+ sKeyword[NF_KEY_DDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJJ" ) );
+ sKeyword[NF_KEY_DDDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJJJ" ) );
+ break;
+ case LANGUAGE_FINNISH :
+ sKeyword[NF_KEY_D].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "P" ) );
+ sKeyword[NF_KEY_DD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "PP" ) );
+ sKeyword[NF_KEY_DDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "PPP" ) );
+ sKeyword[NF_KEY_DDDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "PPPP" ) );
+ break;
+ default:
+ sKeyword[NF_KEY_D].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "D" ) );
+ sKeyword[NF_KEY_DD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "DD" ) );
+ sKeyword[NF_KEY_DDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "DDD" ) );
+ sKeyword[NF_KEY_DDDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "DDDD" ) );
+ }
+ // month
+ switch ( eLang )
+ {
+ case LANGUAGE_FINNISH :
+ sKeyword[NF_KEY_M].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "K" ) );
+ sKeyword[NF_KEY_MM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "KK" ) );
+ sKeyword[NF_KEY_MMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "KKK" ) );
+ sKeyword[NF_KEY_MMMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "KKKK" ) );
+ sKeyword[NF_KEY_MMMMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "KKKKK" ) );
+ break;
+ default:
+ sKeyword[NF_KEY_M].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "M" ) );
+ sKeyword[NF_KEY_MM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MM" ) );
+ sKeyword[NF_KEY_MMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MMM" ) );
+ sKeyword[NF_KEY_MMMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MMMM" ) );
+ sKeyword[NF_KEY_MMMMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MMMMM" ) );
+ }
+ // year
+ switch ( eLang )
+ {
+ case LANGUAGE_ITALIAN :
+ case LANGUAGE_ITALIAN_SWISS :
+ case LANGUAGE_FRENCH :
+ case LANGUAGE_FRENCH_BELGIAN :
+ case LANGUAGE_FRENCH_CANADIAN :
+ case LANGUAGE_FRENCH_SWISS :
+ case LANGUAGE_FRENCH_LUXEMBOURG :
+ case LANGUAGE_FRENCH_MONACO :
+ case LANGUAGE_PORTUGUESE :
+ case LANGUAGE_PORTUGUESE_BRAZILIAN :
+ case LANGUAGE_SPANISH_MODERN :
+ case LANGUAGE_SPANISH_DATED :
+ case LANGUAGE_SPANISH_MEXICAN :
+ case LANGUAGE_SPANISH_GUATEMALA :
+ case LANGUAGE_SPANISH_COSTARICA :
+ case LANGUAGE_SPANISH_PANAMA :
+ case LANGUAGE_SPANISH_DOMINICAN_REPUBLIC :
+ case LANGUAGE_SPANISH_VENEZUELA :
+ case LANGUAGE_SPANISH_COLOMBIA :
+ case LANGUAGE_SPANISH_PERU :
+ case LANGUAGE_SPANISH_ARGENTINA :
+ case LANGUAGE_SPANISH_ECUADOR :
+ case LANGUAGE_SPANISH_CHILE :
+ case LANGUAGE_SPANISH_URUGUAY :
+ case LANGUAGE_SPANISH_PARAGUAY :
+ case LANGUAGE_SPANISH_BOLIVIA :
+ case LANGUAGE_SPANISH_EL_SALVADOR :
+ case LANGUAGE_SPANISH_HONDURAS :
+ case LANGUAGE_SPANISH_NICARAGUA :
+ case LANGUAGE_SPANISH_PUERTO_RICO :
+ sKeyword[NF_KEY_YY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "AA" ) );
+ sKeyword[NF_KEY_YYYY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "AAAA" ) );
+ // must exchange the day of week name code, same as Xcl
+ sKeyword[NF_KEY_AAA].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "OOO" ) );
+ sKeyword[NF_KEY_AAAA].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "OOOO" ) );
+ break;
+ case LANGUAGE_DUTCH :
+ case LANGUAGE_DUTCH_BELGIAN :
+ sKeyword[NF_KEY_YY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJ" ) );
+ sKeyword[NF_KEY_YYYY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJJJ" ) );
+ break;
+ case LANGUAGE_FINNISH :
+ sKeyword[NF_KEY_YY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "VV" ) );
+ sKeyword[NF_KEY_YYYY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "VVVV" ) );
+ break;
+ default:
+ sKeyword[NF_KEY_YY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "YY" ) );
+ sKeyword[NF_KEY_YYYY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "YYYY" ) );
+ }
+ // hour
+ switch ( eLang )
+ {
+ case LANGUAGE_DUTCH :
+ case LANGUAGE_DUTCH_BELGIAN :
+ sKeyword[NF_KEY_H].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "U" ) );
+ sKeyword[NF_KEY_HH].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "UU" ) );
+ break;
+ case LANGUAGE_FINNISH :
+ case LANGUAGE_SWEDISH :
+ case LANGUAGE_SWEDISH_FINLAND :
+ case LANGUAGE_DANISH :
+ case LANGUAGE_NORWEGIAN :
+ case LANGUAGE_NORWEGIAN_BOKMAL :
+ case LANGUAGE_NORWEGIAN_NYNORSK :
+ sKeyword[NF_KEY_H].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "T" ) );
+ sKeyword[NF_KEY_HH].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "TT" ) );
+ break;
+ default:
+ sKeyword[NF_KEY_H].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "H" ) );
+ sKeyword[NF_KEY_HH].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "HH" ) );
+ }
+ // boolean
+ sKeyword[NF_KEY_BOOLEAN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "BOOLEAN" ) );
+ // colours
+ sKeyword[NF_KEY_COLOR].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "COLOR" ) );
+ sKeyword[NF_KEY_BLACK].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "BLACK" ) );
+ sKeyword[NF_KEY_BLUE].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "BLUE" ) );
+ sKeyword[NF_KEY_GREEN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GREEN" ) );
+ sKeyword[NF_KEY_CYAN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "CYAN" ) );
+ sKeyword[NF_KEY_RED].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "RED" ) );
+ sKeyword[NF_KEY_MAGENTA].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MAGENTA" ) );
+ sKeyword[NF_KEY_BROWN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "BROWN" ) );
+ sKeyword[NF_KEY_GREY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GREY" ) );
+ sKeyword[NF_KEY_YELLOW].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "YELLOW" ) );
+ sKeyword[NF_KEY_WHITE].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "WHITE" ) );
+ }
+ break;
+ }
+
+ // boolean keyords
+ InitSpecialKeyword( NF_KEY_TRUE );
+ InitSpecialKeyword( NF_KEY_FALSE );
+
+ // compatibility currency strings
+ InitCompatCur();
+}
+
+
+void ImpSvNumberformatScan::ChangeNullDate(USHORT nDay, USHORT nMonth, USHORT nYear)
+{
+ if ( pNullDate )
+ *pNullDate = Date(nDay, nMonth, nYear);
+ else
+ pNullDate = new Date(nDay, nMonth, nYear);
+}
+
+void ImpSvNumberformatScan::ChangeStandardPrec(short nPrec)
+{
+ nStandardPrec = nPrec;
+}
+
+Color* ImpSvNumberformatScan::GetColor(String& sStr)
+{
+ String sString = pFormatter->GetCharClass()->upper(sStr);
+ const String* pKeyword = GetKeywords();
+ size_t i = 0;
+ while (i < NF_MAX_DEFAULT_COLORS &&
+ sString != pKeyword[NF_KEY_FIRSTCOLOR+i] )
+ i++;
+ if ( i >= NF_MAX_DEFAULT_COLORS )
+ {
+ const String* pEnglishColors = theEnglishColors::get();
+ size_t j = 0;
+ while ( j < NF_MAX_DEFAULT_COLORS &&
+ sString != pEnglishColors[j] )
+ ++j;
+ if ( j < NF_MAX_DEFAULT_COLORS )
+ i = j;
+ }
+ if (i >= NF_MAX_DEFAULT_COLORS)
+ {
+ const String& rColorWord = pKeyword[NF_KEY_COLOR];
+ xub_StrLen nPos = sString.Match(rColorWord);
+ if (nPos > 0)
+ {
+ sStr.Erase(0, nPos);
+ sStr.EraseLeadingChars();
+ sStr.EraseTrailingChars();
+ if (bConvertMode)
+ {
+ pFormatter->ChangeIntl(eNewLnge);
+ sStr.Insert( GetKeywords()[NF_KEY_COLOR], 0 ); // Color -> FARBE
+ pFormatter->ChangeIntl(eTmpLnge);
+ }
+ else
+ sStr.Insert(rColorWord,0);
+ sString.Erase(0, nPos);
+ sString.EraseLeadingChars();
+ sString.EraseTrailingChars();
+
+ if ( CharClass::isAsciiNumeric( sString ) )
+ {
+ long nIndex = sString.ToInt32();
+ if (nIndex > 0 && nIndex <= 64)
+ return pFormatter->GetUserDefColor((USHORT)nIndex-1);
+ else
+ return NULL;
+ }
+ else
+ return NULL;
+ }
+ else
+ return NULL;
+ }
+ else
+ {
+ sStr.Erase();
+ if (bConvertMode)
+ {
+ pFormatter->ChangeIntl(eNewLnge);
+ sStr = GetKeywords()[NF_KEY_FIRSTCOLOR+i]; // red -> rot
+ pFormatter->ChangeIntl(eTmpLnge);
+ }
+ else
+ sStr = pKeyword[NF_KEY_FIRSTCOLOR+i];
+
+ return &(StandardColor[i]);
+ }
+}
+
+
+short ImpSvNumberformatScan::GetKeyWord( const String& sSymbol, xub_StrLen nPos )
+{
+ String sString = pFormatter->GetCharClass()->toUpper( sSymbol, nPos, sSymbol.Len() - nPos );
+ const String* pKeyword = GetKeywords();
+ // #77026# for the Xcl perverts: the GENERAL keyword is recognized anywhere
+ if ( sString.Search( pKeyword[NF_KEY_GENERAL] ) == 0 )
+ return NF_KEY_GENERAL;
+ //! MUST be a reverse search to find longer strings first
+ short i = NF_KEYWORD_ENTRIES_COUNT-1;
+ BOOL bFound = FALSE;
+ for ( ; i > NF_KEY_LASTKEYWORD_SO5; --i )
+ {
+ bFound = sString.Search(pKeyword[i]) == 0;
+ if ( bFound )
+ {
+ break;
+ }
+ }
+ // new keywords take precedence over old keywords
+ if ( !bFound )
+ { // skip the gap of colors et al between new and old keywords and search on
+ i = NF_KEY_LASTKEYWORD;
+ while ( i > 0 && sString.Search(pKeyword[i]) != 0 )
+ i--;
+ if ( i > NF_KEY_LASTOLDKEYWORD && sString != pKeyword[i] )
+ { // found something, but maybe it's something else?
+ // e.g. new NNN is found in NNNN, for NNNN we must search on
+ short j = i - 1;
+ while ( j > 0 && sString.Search(pKeyword[j]) != 0 )
+ j--;
+ if ( j && pKeyword[j].Len() > pKeyword[i].Len() )
+ return j;
+ }
+ }
+ // The Thai T NatNum modifier during Xcl import.
+ if (i == 0 && bConvertMode && sString.GetChar(0) == 'T' && eTmpLnge ==
+ LANGUAGE_ENGLISH_US && MsLangId::getRealLanguage( eNewLnge) ==
+ LANGUAGE_THAI)
+ i = NF_KEY_THAI_T;
+ return i; // 0 => not found
+}
+
+//---------------------------------------------------------------------------
+// Next_Symbol
+//---------------------------------------------------------------------------
+// Zerlegt die Eingabe in Symbole fuer die weitere
+// Verarbeitung (Turing-Maschine).
+//---------------------------------------------------------------------------
+// Ausgangs Zustand = SsStart
+//---------------+-------------------+-----------------------+---------------
+// Alter Zustand | gelesenes Zeichen | Aktion | Neuer Zustand
+//---------------+-------------------+-----------------------+---------------
+// SsStart | Buchstabe | Symbol=Zeichen | SsGetWord
+// | " | Typ = String | SsGetString
+// | \ | Typ = String | SsGetChar
+// | * | Typ = Star | SsGetStar
+// | _ | Typ = Blank | SsGetBlank
+// | @ # 0 ? / . , % [ | Symbol = Zeichen; |
+// | ] ' Blank | Typ = Steuerzeichen | SsStop
+// | $ - + ( ) : | Typ = String; |
+// | | | Typ = Comment | SsStop
+// | Sonst | Symbol = Zeichen | SsStop
+//---------------|-------------------+-----------------------+---------------
+// SsGetChar | Sonst | Symbol=Zeichen | SsStop
+//---------------+-------------------+-----------------------+---------------
+// GetString | " | | SsStop
+// | Sonst | Symbol+=Zeichen | GetString
+//---------------+-------------------+-----------------------+---------------
+// SsGetWord | Buchstabe | Symbol += Zeichen |
+// | + - (E+ E-)| Symbol += Zeichen | SsStop
+// | / (AM/PM)| Symbol += Zeichen |
+// | Sonst | Pos--, if Key Typ=Word| SsStop
+//---------------+-------------------+-----------------------+---------------
+// SsGetStar | Sonst | Symbol+=Zeichen | SsStop
+// | | markiere Sonderfall * |
+//---------------+-------------------+-----------------------+---------------
+// SsGetBlank | Sonst | Symbol+=Zeichen | SsStop
+// | | markiere Sonderfall _ |
+//---------------+-------------------+-----------------------+---------------
+// Wurde im State SsGetWord ein Schluesselwort erkannt (auch als
+// Anfangsteilwort des Symbols)
+// so werden die restlichen Buchstaben zurueckgeschrieben !!
+
+enum ScanState
+{
+ SsStop = 0,
+ SsStart = 1,
+ SsGetChar = 2,
+ SsGetString = 3,
+ SsGetWord = 4,
+ SsGetStar = 5,
+ SsGetBlank = 6
+};
+
+short ImpSvNumberformatScan::Next_Symbol( const String& rStr,
+ xub_StrLen& nPos, String& sSymbol )
+{
+ if ( bKeywordsNeedInit )
+ InitKeywords();
+ const CharClass* pChrCls = pFormatter->GetCharClass();
+ const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData();
+ const xub_StrLen nStart = nPos;
+ short eType = 0;
+ ScanState eState = SsStart;
+ sSymbol.Erase();
+ while ( nPos < rStr.Len() && eState != SsStop )
+ {
+ sal_Unicode cToken = rStr.GetChar( nPos++ );
+ switch (eState)
+ {
+ case SsStart:
+ {
+ // Fetch any currency longer than one character and don't get
+ // confused later on by "E/" or other combinations of letters
+ // and meaningful symbols. Necessary for old automatic currency.
+ // #96158# But don't do it if we're starting a "[...]" section,
+ // for example a "[$...]" new currency symbol to not parse away
+ // "$U" (symbol) of "[$UYU]" (abbreviation).
+ if ( nCurrPos != STRING_NOTFOUND && sCurString.Len() > 1 &&
+ nPos-1 + sCurString.Len() <= rStr.Len() &&
+ !(nPos > 1 && rStr.GetChar( nPos-2 ) == '[') )
+ {
+ String aTest( rStr.Copy( nPos-1, sCurString.Len() ) );
+ pChrCls->toUpper( aTest );
+ if ( aTest == sCurString )
+ {
+ sSymbol = rStr.Copy( --nPos, sCurString.Len() );
+ nPos = nPos + sSymbol.Len();
+ eState = SsStop;
+ eType = NF_SYMBOLTYPE_STRING;
+ return eType;
+ }
+ }
+ switch (cToken)
+ {
+ case '#':
+ case '0':
+ case '?':
+ case '%':
+ case '@':
+ case '[':
+ case ']':
+ case ',':
+ case '.':
+ case '/':
+ case '\'':
+ case ' ':
+ case ':':
+ case '-':
+ {
+ eType = NF_SYMBOLTYPE_DEL;
+ sSymbol += cToken;
+ eState = SsStop;
+ }
+ break;
+ case '*':
+ {
+ eType = NF_SYMBOLTYPE_STAR;
+ sSymbol += cToken;
+ eState = SsGetStar;
+ }
+ break;
+ case '_':
+ {
+ eType = NF_SYMBOLTYPE_BLANK;
+ sSymbol += cToken;
+ eState = SsGetBlank;
+ }
+ break;
+#if NF_COMMENT_IN_FORMATSTRING
+ case '{':
+ eType = NF_SYMBOLTYPE_COMMENT;
+ eState = SsStop;
+ sSymbol.Append( rStr.GetBuffer() + (nPos-1), rStr.Len() - (nPos-1) );
+ nPos = rStr.Len();
+ break;
+#endif
+ case '"':
+ eType = NF_SYMBOLTYPE_STRING;
+ eState = SsGetString;
+ sSymbol += cToken;
+ break;
+ case '\\':
+ eType = NF_SYMBOLTYPE_STRING;
+ eState = SsGetChar;
+ sSymbol += cToken;
+ break;
+ case '$':
+ case '+':
+ case '(':
+ case ')':
+ eType = NF_SYMBOLTYPE_STRING;
+ eState = SsStop;
+ sSymbol += cToken;
+ break;
+ default :
+ {
+ if (StringEqualsChar( pFormatter->GetNumDecimalSep(), cToken) ||
+ StringEqualsChar( pFormatter->GetNumThousandSep(), cToken) ||
+ StringEqualsChar( pFormatter->GetDateSep(), cToken) ||
+ StringEqualsChar( pLoc->getTimeSep(), cToken) ||
+ StringEqualsChar( pLoc->getTime100SecSep(), cToken))
+ {
+ // Another separator than pre-known ASCII
+ eType = NF_SYMBOLTYPE_DEL;
+ sSymbol += cToken;
+ eState = SsStop;
+ }
+ else if ( pChrCls->isLetter( rStr, nPos-1 ) )
+ {
+ short nTmpType = GetKeyWord( rStr, nPos-1 );
+ if ( nTmpType )
+ {
+ BOOL bCurrency = FALSE;
+ // "Automatic" currency may start with keyword,
+ // like "R" (Rand) and 'R' (era)
+ if ( nCurrPos != STRING_NOTFOUND &&
+ nPos-1 + sCurString.Len() <= rStr.Len() &&
+ sCurString.Search( sKeyword[nTmpType] ) == 0 )
+ {
+ String aTest( rStr.Copy( nPos-1, sCurString.Len() ) );
+ pChrCls->toUpper( aTest );
+ if ( aTest == sCurString )
+ bCurrency = TRUE;
+ }
+ if ( bCurrency )
+ {
+ eState = SsGetWord;
+ sSymbol += cToken;
+ }
+ else
+ {
+ eType = nTmpType;
+ xub_StrLen nLen = sKeyword[eType].Len();
+ sSymbol = rStr.Copy( nPos-1, nLen );
+ if ( eType == NF_KEY_E || IsAmbiguousE( eType ) )
+ {
+ sal_Unicode cNext = rStr.GetChar(nPos);
+ switch ( cNext )
+ {
+ case '+' :
+ case '-' : // E+ E- combine to one symbol
+ sSymbol += cNext;
+ eType = NF_KEY_E;
+ nPos++;
+ break;
+ case '0' :
+ case '#' : // scientific E without sign
+ eType = NF_KEY_E;
+ break;
+ }
+ }
+ nPos--;
+ nPos = nPos + nLen;
+ eState = SsStop;
+ }
+ }
+ else
+ {
+ eState = SsGetWord;
+ sSymbol += cToken;
+ }
+ }
+ else
+ {
+ eType = NF_SYMBOLTYPE_STRING;
+ eState = SsStop;
+ sSymbol += cToken;
+ }
+ }
+ break;
+ }
+ }
+ break;
+ case SsGetChar:
+ {
+ sSymbol += cToken;
+ eState = SsStop;
+ }
+ break;
+ case SsGetString:
+ {
+ if (cToken == '"')
+ eState = SsStop;
+ sSymbol += cToken;
+ }
+ break;
+ case SsGetWord:
+ {
+ if ( pChrCls->isLetter( rStr, nPos-1 ) )
+ {
+ short nTmpType = GetKeyWord( rStr, nPos-1 );
+ if ( nTmpType )
+ { // beginning of keyword, stop scan and put back
+ eType = NF_SYMBOLTYPE_STRING;
+ eState = SsStop;
+ nPos--;
+ }
+ else
+ sSymbol += cToken;
+ }
+ else
+ {
+ BOOL bDontStop = FALSE;
+ switch (cToken)
+ {
+ case '/': // AM/PM, A/P
+ {
+ sal_Unicode cNext = rStr.GetChar(nPos);
+ if ( cNext == 'P' || cNext == 'p' )
+ {
+ xub_StrLen nLen = sSymbol.Len();
+ if ( 1 <= nLen
+ && (sSymbol.GetChar(0) == 'A' || sSymbol.GetChar(0) == 'a')
+ && (nLen == 1 || (nLen == 2
+ && (sSymbol.GetChar(1) == 'M' || sSymbol.GetChar(1) == 'm')
+ && (rStr.GetChar(nPos+1) == 'M' || rStr.GetChar(nPos+1) == 'm'))) )
+ {
+ sSymbol += cToken;
+ bDontStop = TRUE;
+ }
+ }
+ }
+ break;
+ }
+ // anything not recognized will stop the scan
+ if ( eState != SsStop && !bDontStop )
+ {
+ eState = SsStop;
+ nPos--;
+ eType = NF_SYMBOLTYPE_STRING;
+ }
+ }
+ }
+ break;
+ case SsGetStar:
+ {
+ eState = SsStop;
+ sSymbol += cToken;
+ nRepPos = (nPos - nStart) - 1; // everytime > 0!!
+ }
+ break;
+ case SsGetBlank:
+ {
+ eState = SsStop;
+ sSymbol += cToken;
+ }
+ break;
+ default:
+ break;
+ } // of switch
+ } // of while
+ if (eState == SsGetWord)
+ eType = NF_SYMBOLTYPE_STRING;
+ return eType;
+}
+
+xub_StrLen ImpSvNumberformatScan::Symbol_Division(const String& rString)
+{
+ nCurrPos = STRING_NOTFOUND;
+ // Ist Waehrung im Spiel?
+ String sString = pFormatter->GetCharClass()->upper(rString);
+ xub_StrLen nCPos = 0;
+ while (nCPos != STRING_NOTFOUND)
+ {
+ nCPos = sString.Search(GetCurString(),nCPos);
+ if (nCPos != STRING_NOTFOUND)
+ {
+ // in Quotes?
+ xub_StrLen nQ = SvNumberformat::GetQuoteEnd( sString, nCPos );
+ if ( nQ == STRING_NOTFOUND )
+ {
+ sal_Unicode c;
+ if ( nCPos == 0 ||
+ ((c = sString.GetChar(xub_StrLen(nCPos-1))) != '"'
+ && c != '\\') ) // dm kann durch "dm
+ { // \d geschuetzt werden
+ nCurrPos = nCPos;
+ nCPos = STRING_NOTFOUND; // Abbruch
+ }
+ else
+ nCPos++; // weitersuchen
+ }
+ else
+ nCPos = nQ + 1; // weitersuchen
+ }
+ }
+ nAnzStrings = 0;
+ BOOL bStar = FALSE; // wird bei '*'Detektion gesetzt
+ Reset();
+
+ xub_StrLen nPos = 0;
+ const xub_StrLen nLen = rString.Len();
+ while (nPos < nLen && nAnzStrings < NF_MAX_FORMAT_SYMBOLS)
+ {
+ nTypeArray[nAnzStrings] = Next_Symbol(rString, nPos, sStrArray[nAnzStrings]);
+ if (nTypeArray[nAnzStrings] == NF_SYMBOLTYPE_STAR)
+ { // Ueberwachung des '*'
+ if (bStar)
+ return nPos; // Fehler: doppelter '*'
+ else
+ bStar = TRUE;
+ }
+ nAnzStrings++;
+ }
+
+ return 0; // 0 => ok
+}
+
+void ImpSvNumberformatScan::SkipStrings(USHORT& i, xub_StrLen& nPos)
+{
+ while (i < nAnzStrings && ( nTypeArray[i] == NF_SYMBOLTYPE_STRING
+ || nTypeArray[i] == NF_SYMBOLTYPE_BLANK
+ || nTypeArray[i] == NF_SYMBOLTYPE_STAR) )
+ {
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+}
+
+
+USHORT ImpSvNumberformatScan::PreviousKeyword(USHORT i)
+{
+ short res = 0;
+ if (i > 0 && i < nAnzStrings)
+ {
+ i--;
+ while (i > 0 && nTypeArray[i] <= 0)
+ i--;
+ if (nTypeArray[i] > 0)
+ res = nTypeArray[i];
+ }
+ return res;
+}
+
+USHORT ImpSvNumberformatScan::NextKeyword(USHORT i)
+{
+ short res = 0;
+ if (i < nAnzStrings-1)
+ {
+ i++;
+ while (i < nAnzStrings-1 && nTypeArray[i] <= 0)
+ i++;
+ if (nTypeArray[i] > 0)
+ res = nTypeArray[i];
+ }
+ return res;
+}
+
+short ImpSvNumberformatScan::PreviousType( USHORT i )
+{
+ if ( i > 0 && i < nAnzStrings )
+ {
+ do
+ {
+ i--;
+ } while ( i > 0 && nTypeArray[i] == NF_SYMBOLTYPE_EMPTY );
+ return nTypeArray[i];
+ }
+ return 0;
+}
+
+sal_Unicode ImpSvNumberformatScan::PreviousChar(USHORT i)
+{
+ sal_Unicode res = ' ';
+ if (i > 0 && i < nAnzStrings)
+ {
+ i--;
+ while (i > 0 && ( nTypeArray[i] == NF_SYMBOLTYPE_EMPTY
+ || nTypeArray[i] == NF_SYMBOLTYPE_STRING
+ || nTypeArray[i] == NF_SYMBOLTYPE_STAR
+ || nTypeArray[i] == NF_SYMBOLTYPE_BLANK ) )
+ i--;
+ if (sStrArray[i].Len() > 0)
+ res = sStrArray[i].GetChar(xub_StrLen(sStrArray[i].Len()-1));
+ }
+ return res;
+}
+
+sal_Unicode ImpSvNumberformatScan::NextChar(USHORT i)
+{
+ sal_Unicode res = ' ';
+ if (i < nAnzStrings-1)
+ {
+ i++;
+ while (i < nAnzStrings-1 &&
+ ( nTypeArray[i] == NF_SYMBOLTYPE_EMPTY
+ || nTypeArray[i] == NF_SYMBOLTYPE_STRING
+ || nTypeArray[i] == NF_SYMBOLTYPE_STAR
+ || nTypeArray[i] == NF_SYMBOLTYPE_BLANK))
+ i++;
+ if (sStrArray[i].Len() > 0)
+ res = sStrArray[i].GetChar(0);
+ }
+ return res;
+}
+
+BOOL ImpSvNumberformatScan::IsLastBlankBeforeFrac(USHORT i)
+{
+ BOOL res = TRUE;
+ if (i < nAnzStrings-1)
+ {
+ BOOL bStop = FALSE;
+ i++;
+ while (i < nAnzStrings-1 && !bStop)
+ {
+ i++;
+ if ( nTypeArray[i] == NF_SYMBOLTYPE_DEL &&
+ sStrArray[i].GetChar(0) == '/')
+ bStop = TRUE;
+ else if ( nTypeArray[i] == NF_SYMBOLTYPE_DEL &&
+ sStrArray[i].GetChar(0) == ' ')
+ res = FALSE;
+ }
+ if (!bStop) // kein '/'
+ res = FALSE;
+ }
+ else
+ res = FALSE; // kein '/' mehr
+
+ return res;
+}
+
+void ImpSvNumberformatScan::Reset()
+{
+ nAnzStrings = 0;
+ nAnzResStrings = 0;
+#if 0
+// ER 20.06.97 14:05 nicht noetig, wenn nAnzStrings beachtet wird
+ for (size_t i = 0; i < NF_MAX_FORMAT_SYMBOLS; i++)
+ {
+ sStrArray[i].Erase();
+ nTypeArray[i] = 0;
+ }
+#endif
+ eScannedType = NUMBERFORMAT_UNDEFINED;
+ nRepPos = 0;
+ bExp = FALSE;
+ bThousand = FALSE;
+ nThousand = 0;
+ bDecSep = FALSE;
+ nDecPos = -1;
+ nExpPos = (USHORT) -1;
+ nBlankPos = (USHORT) -1;
+ nCntPre = 0;
+ nCntPost = 0;
+ nCntExp = 0;
+ bFrac = FALSE;
+ bBlank = FALSE;
+ nNatNumModifier = 0;
+}
+
+
+BOOL ImpSvNumberformatScan::Is100SecZero( USHORT i, BOOL bHadDecSep )
+{
+ USHORT nIndexPre = PreviousKeyword( i );
+ return (nIndexPre == NF_KEY_S || nIndexPre == NF_KEY_SS)
+ && (bHadDecSep // S, SS ','
+ || (i>0 && nTypeArray[i-1] == NF_SYMBOLTYPE_STRING));
+ // SS"any"00 take "any" as a valid decimal separator
+}
+
+
+xub_StrLen ImpSvNumberformatScan::ScanType(const String&)
+{
+ const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData();
+
+ xub_StrLen nPos = 0;
+ USHORT i = 0;
+ short eNewType;
+ BOOL bMatchBracket = FALSE;
+
+ SkipStrings(i, nPos);
+ while (i < nAnzStrings)
+ {
+ if (nTypeArray[i] > 0)
+ { // keyword
+ switch (nTypeArray[i])
+ {
+ case NF_KEY_E: // E
+ eNewType = NUMBERFORMAT_SCIENTIFIC;
+ break;
+ case NF_KEY_AMPM: // AM,A,PM,P
+ case NF_KEY_AP:
+ case NF_KEY_H: // H
+ case NF_KEY_HH: // HH
+ case NF_KEY_S: // S
+ case NF_KEY_SS: // SS
+ eNewType = NUMBERFORMAT_TIME;
+ break;
+ case NF_KEY_M: // M
+ case NF_KEY_MM: // MM
+ { // minute or month
+ USHORT nIndexPre = PreviousKeyword(i);
+ USHORT nIndexNex = NextKeyword(i);
+ sal_Unicode cChar = PreviousChar(i);
+ if (nIndexPre == NF_KEY_H || // H
+ nIndexPre == NF_KEY_HH || // HH
+ nIndexNex == NF_KEY_S || // S
+ nIndexNex == NF_KEY_SS || // SS
+ cChar == '[' ) // [M
+ {
+ eNewType = NUMBERFORMAT_TIME;
+ nTypeArray[i] -= 2; // 6 -> 4, 7 -> 5
+ }
+ else
+ eNewType = NUMBERFORMAT_DATE;
+ }
+ break;
+ case NF_KEY_MMM: // MMM
+ case NF_KEY_MMMM: // MMMM
+ case NF_KEY_MMMMM: // MMMMM
+ case NF_KEY_Q: // Q
+ case NF_KEY_QQ: // QQ
+ case NF_KEY_D: // D
+ case NF_KEY_DD: // DD
+ case NF_KEY_DDD: // DDD
+ case NF_KEY_DDDD: // DDDD
+ case NF_KEY_YY: // YY
+ case NF_KEY_YYYY: // YYYY
+ case NF_KEY_NN: // NN
+ case NF_KEY_NNN: // NNN
+ case NF_KEY_NNNN: // NNNN
+ case NF_KEY_WW : // WW
+ case NF_KEY_AAA : // AAA
+ case NF_KEY_AAAA : // AAAA
+ case NF_KEY_EC : // E
+ case NF_KEY_EEC : // EE
+ case NF_KEY_G : // G
+ case NF_KEY_GG : // GG
+ case NF_KEY_GGG : // GGG
+ case NF_KEY_R : // R
+ case NF_KEY_RR : // RR
+ eNewType = NUMBERFORMAT_DATE;
+ break;
+ case NF_KEY_CCC: // CCC
+ eNewType = NUMBERFORMAT_CURRENCY;
+ break;
+ case NF_KEY_GENERAL: // Standard
+ eNewType = NUMBERFORMAT_NUMBER;
+ break;
+ default:
+ eNewType = NUMBERFORMAT_UNDEFINED;
+ break;
+ }
+ }
+ else
+ { // control character
+ switch ( sStrArray[i].GetChar(0) )
+ {
+ case '#':
+ case '?':
+ eNewType = NUMBERFORMAT_NUMBER;
+ break;
+ case '0':
+ {
+ if ( (eScannedType & NUMBERFORMAT_TIME) == NUMBERFORMAT_TIME )
+ {
+ if ( Is100SecZero( i, bDecSep ) )
+ {
+ bDecSep = TRUE; // subsequent 0's
+ eNewType = NUMBERFORMAT_TIME;
+ }
+ else
+ return nPos; // Error
+ }
+ else
+ eNewType = NUMBERFORMAT_NUMBER;
+ }
+ break;
+ case '%':
+ eNewType = NUMBERFORMAT_PERCENT;
+ break;
+ case '/':
+ eNewType = NUMBERFORMAT_FRACTION;
+ break;
+ case '[':
+ {
+ if ( i < nAnzStrings-1 &&
+ nTypeArray[i+1] == NF_SYMBOLTYPE_STRING &&
+ sStrArray[i+1].GetChar(0) == '$' )
+ { // as of SV_NUMBERFORMATTER_VERSION_NEW_CURR
+ eNewType = NUMBERFORMAT_CURRENCY;
+ bMatchBracket = TRUE;
+ }
+ else if ( i < nAnzStrings-1 &&
+ nTypeArray[i+1] == NF_SYMBOLTYPE_STRING &&
+ sStrArray[i+1].GetChar(0) == '~' )
+ { // as of SV_NUMBERFORMATTER_VERSION_CALENDAR
+ eNewType = NUMBERFORMAT_DATE;
+ bMatchBracket = TRUE;
+ }
+ else
+ {
+ USHORT nIndexNex = NextKeyword(i);
+ if (nIndexNex == NF_KEY_H || // H
+ nIndexNex == NF_KEY_HH || // HH
+ nIndexNex == NF_KEY_M || // M
+ nIndexNex == NF_KEY_MM || // MM
+ nIndexNex == NF_KEY_S || // S
+ nIndexNex == NF_KEY_SS ) // SS
+ eNewType = NUMBERFORMAT_TIME;
+ else
+ return nPos; // Error
+ }
+ }
+ break;
+ case '@':
+ eNewType = NUMBERFORMAT_TEXT;
+ break;
+ default:
+ if ( sStrArray[i] == pLoc->getTime100SecSep() )
+ bDecSep = TRUE; // for SS,0
+ eNewType = NUMBERFORMAT_UNDEFINED;
+ break;
+ }
+ }
+ if (eScannedType == NUMBERFORMAT_UNDEFINED)
+ eScannedType = eNewType;
+ else if (eScannedType == NUMBERFORMAT_TEXT || eNewType == NUMBERFORMAT_TEXT)
+ eScannedType = NUMBERFORMAT_TEXT; // Text bleibt immer Text
+ else if (eNewType == NUMBERFORMAT_UNDEFINED)
+ { // bleibt wie bisher
+ }
+ else if (eScannedType != eNewType)
+ {
+ switch (eScannedType)
+ {
+ case NUMBERFORMAT_DATE:
+ {
+ switch (eNewType)
+ {
+ case NUMBERFORMAT_TIME:
+ eScannedType = NUMBERFORMAT_DATETIME;
+ break;
+ case NUMBERFORMAT_FRACTION: // DD/MM
+ break;
+ default:
+ {
+ if (nCurrPos != STRING_NOTFOUND)
+ eScannedType = NUMBERFORMAT_UNDEFINED;
+ else if ( sStrArray[i] != pFormatter->GetDateSep() )
+ return nPos;
+ }
+ }
+ }
+ break;
+ case NUMBERFORMAT_TIME:
+ {
+ switch (eNewType)
+ {
+ case NUMBERFORMAT_DATE:
+ eScannedType = NUMBERFORMAT_DATETIME;
+ break;
+ case NUMBERFORMAT_FRACTION: // MM/SS
+ break;
+ default:
+ {
+ if (nCurrPos != STRING_NOTFOUND)
+ eScannedType = NUMBERFORMAT_UNDEFINED;
+ else if ( sStrArray[i] != pLoc->getTimeSep() )
+ return nPos;
+ }
+ }
+ }
+ break;
+ case NUMBERFORMAT_DATETIME:
+ {
+ switch (eNewType)
+ {
+ case NUMBERFORMAT_TIME:
+ case NUMBERFORMAT_DATE:
+ break;
+ case NUMBERFORMAT_FRACTION: // DD/MM
+ break;
+ default:
+ {
+ if (nCurrPos != STRING_NOTFOUND)
+ eScannedType = NUMBERFORMAT_UNDEFINED;
+ else if ( sStrArray[i] != pFormatter->GetDateSep()
+ && sStrArray[i] != pLoc->getTimeSep() )
+ return nPos;
+ }
+ }
+ }
+ break;
+ case NUMBERFORMAT_PERCENT:
+ {
+ switch (eNewType)
+ {
+ case NUMBERFORMAT_NUMBER: // nur Zahl nach Prozent
+ break;
+ default:
+ return nPos;
+ }
+ }
+ break;
+ case NUMBERFORMAT_SCIENTIFIC:
+ {
+ switch (eNewType)
+ {
+ case NUMBERFORMAT_NUMBER: // nur Zahl nach E
+ break;
+ default:
+ return nPos;
+ }
+ }
+ break;
+ case NUMBERFORMAT_NUMBER:
+ {
+ switch (eNewType)
+ {
+ case NUMBERFORMAT_SCIENTIFIC:
+ case NUMBERFORMAT_PERCENT:
+ case NUMBERFORMAT_FRACTION:
+ case NUMBERFORMAT_CURRENCY:
+ eScannedType = eNewType;
+ break;
+ default:
+ if (nCurrPos != STRING_NOTFOUND)
+ eScannedType = NUMBERFORMAT_UNDEFINED;
+ else
+ return nPos;
+ }
+ }
+ break;
+ case NUMBERFORMAT_FRACTION:
+ {
+ switch (eNewType)
+ {
+ case NUMBERFORMAT_NUMBER: // nur Zahl nach Bruch
+ break;
+ default:
+ return nPos;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ nPos = nPos + sStrArray[i].Len(); // Korrekturposition
+ i++;
+ if ( bMatchBracket )
+ { // no type detection inside of matching brackets if [$...], [~...]
+ while ( bMatchBracket && i < nAnzStrings )
+ {
+ if ( nTypeArray[i] == NF_SYMBOLTYPE_DEL
+ && sStrArray[i].GetChar(0) == ']' )
+ bMatchBracket = FALSE;
+ else
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ if ( bMatchBracket )
+ return nPos; // missing closing bracket at end of code
+ }
+ SkipStrings(i, nPos);
+ }
+
+ if ((eScannedType == NUMBERFORMAT_NUMBER || eScannedType == NUMBERFORMAT_UNDEFINED)
+ && nCurrPos != STRING_NOTFOUND)
+ eScannedType = NUMBERFORMAT_CURRENCY; // old "automatic" currency
+ if (eScannedType == NUMBERFORMAT_UNDEFINED)
+ eScannedType = NUMBERFORMAT_DEFINED;
+ return 0; // Alles ok
+}
+
+
+int ImpSvNumberformatScan::FinalScanGetCalendar( xub_StrLen& nPos, USHORT& i,
+ USHORT& rAnzResStrings )
+{
+ if ( sStrArray[i].GetChar(0) == '[' &&
+ i < nAnzStrings-1 &&
+ nTypeArray[i+1] == NF_SYMBOLTYPE_STRING &&
+ sStrArray[i+1].GetChar(0) == '~' )
+ { // [~calendarID]
+ // as of SV_NUMBERFORMATTER_VERSION_CALENDAR
+ nPos = nPos + sStrArray[i].Len(); // [
+ nTypeArray[i] = NF_SYMBOLTYPE_CALDEL;
+ nPos = nPos + sStrArray[++i].Len(); // ~
+ sStrArray[i-1] += sStrArray[i]; // [~
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ rAnzResStrings--;
+ if ( ++i >= nAnzStrings )
+ return -1; // error
+ nPos = nPos + sStrArray[i].Len(); // calendarID
+ String& rStr = sStrArray[i];
+ nTypeArray[i] = NF_SYMBOLTYPE_CALENDAR; // convert
+ i++;
+ while ( i < nAnzStrings &&
+ sStrArray[i].GetChar(0) != ']' )
+ {
+ nPos = nPos + sStrArray[i].Len();
+ rStr += sStrArray[i];
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ rAnzResStrings--;
+ i++;
+ }
+ if ( rStr.Len() && i < nAnzStrings &&
+ sStrArray[i].GetChar(0) == ']' )
+ {
+ nTypeArray[i] = NF_SYMBOLTYPE_CALDEL;
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ else
+ return -1; // error
+ return 1;
+ }
+ return 0;
+}
+
+xub_StrLen ImpSvNumberformatScan::FinalScan( String& rString, String& rComment )
+{
+ const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData();
+
+ // save values for convert mode
+ String sOldDecSep = pFormatter->GetNumDecimalSep();
+ String sOldThousandSep = pFormatter->GetNumThousandSep();
+ String sOldDateSep = pFormatter->GetDateSep();
+ String sOldTimeSep = pLoc->getTimeSep();
+ String sOldTime100SecSep= pLoc->getTime100SecSep();
+ String sOldCurSymbol = GetCurSymbol();
+ String sOldCurString = GetCurString();
+ sal_Unicode cOldKeyH = sKeyword[NF_KEY_H].GetChar(0);
+ sal_Unicode cOldKeyMI = sKeyword[NF_KEY_MI].GetChar(0);
+ sal_Unicode cOldKeyS = sKeyword[NF_KEY_S].GetChar(0);
+
+ // If the group separator is a Non-Breaking Space (French) continue with a
+ // normal space instead so queries on space work correctly.
+ // The format string is adjusted to allow both.
+ // For output of the format code string the LocaleData characters are used.
+ if ( sOldThousandSep.GetChar(0) == cNonBreakingSpace && sOldThousandSep.Len() == 1 )
+ sOldThousandSep = ' ';
+
+ // change locale data et al
+ if (bConvertMode)
+ {
+ pFormatter->ChangeIntl(eNewLnge);
+ //! pointer may have changed
+ pLoc = pFormatter->GetLocaleData();
+ //! init new keywords
+ InitKeywords();
+ }
+ const CharClass* pChrCls = pFormatter->GetCharClass();
+
+ xub_StrLen nPos = 0; // error correction position
+ USHORT i = 0; // symbol loop counter
+ USHORT nCounter = 0; // counts digits
+ nAnzResStrings = nAnzStrings; // counts remaining symbols
+ bDecSep = FALSE; // reset in case already used in TypeCheck
+ bool bThaiT = false; // Thai T NatNum modifier present
+
+ switch (eScannedType)
+ {
+ case NUMBERFORMAT_TEXT:
+ case NUMBERFORMAT_DEFINED:
+ {
+ while (i < nAnzStrings)
+ {
+ switch (nTypeArray[i])
+ {
+ case NF_SYMBOLTYPE_BLANK:
+ case NF_SYMBOLTYPE_STAR:
+ break;
+ case NF_SYMBOLTYPE_COMMENT:
+ {
+ String& rStr = sStrArray[i];
+ nPos = nPos + rStr.Len();
+ SvNumberformat::EraseCommentBraces( rStr );
+ rComment += rStr;
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ }
+ break;
+ case NF_KEY_GENERAL : // #77026# "General" is the same as "@"
+ break;
+ default:
+ {
+ if ( nTypeArray[i] != NF_SYMBOLTYPE_DEL ||
+ sStrArray[i].GetChar(0) != '@' )
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ }
+ break;
+ }
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ } // of while
+ }
+ break;
+ case NUMBERFORMAT_NUMBER:
+ case NUMBERFORMAT_PERCENT:
+ case NUMBERFORMAT_CURRENCY:
+ case NUMBERFORMAT_SCIENTIFIC:
+ case NUMBERFORMAT_FRACTION:
+ {
+ sal_Unicode cThousandFill = ' ';
+ while (i < nAnzStrings)
+ {
+ if (eScannedType == NUMBERFORMAT_FRACTION && // special case
+ nTypeArray[i] == NF_SYMBOLTYPE_DEL && // # ### #/#
+ StringEqualsChar( sOldThousandSep, ' ' ) && // e.g. France or Sweden
+ StringEqualsChar( sStrArray[i], ' ' ) &&
+ !bFrac &&
+ IsLastBlankBeforeFrac(i) )
+ {
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING; // del->string
+ } // kein Taus.p.
+
+
+ if (nTypeArray[i] == NF_SYMBOLTYPE_BLANK ||
+ nTypeArray[i] == NF_SYMBOLTYPE_STAR ||
+ nTypeArray[i] == NF_KEY_CCC || // CCC
+ nTypeArray[i] == NF_KEY_GENERAL ) // Standard
+ {
+ if (nTypeArray[i] == NF_KEY_GENERAL)
+ {
+ nThousand = FLAG_STANDARD_IN_FORMAT;
+ if ( bConvertMode )
+ sStrArray[i] = sNameStandardFormat;
+ }
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ else if (nTypeArray[i] == NF_SYMBOLTYPE_STRING || // Strings oder
+ nTypeArray[i] > 0) // Keywords
+ {
+ if (eScannedType == NUMBERFORMAT_SCIENTIFIC &&
+ nTypeArray[i] == NF_KEY_E) // E+
+ {
+ if (bExp) // doppelt
+ return nPos;
+ bExp = TRUE;
+ nExpPos = i;
+ if (bDecSep)
+ nCntPost = nCounter;
+ else
+ nCntPre = nCounter;
+ nCounter = 0;
+ nTypeArray[i] = NF_SYMBOLTYPE_EXP;
+ }
+ else if (eScannedType == NUMBERFORMAT_FRACTION &&
+ sStrArray[i].GetChar(0) == ' ')
+ {
+ if (!bBlank && !bFrac) // nicht doppelt oder hinter /
+ {
+ if (bDecSep && nCounter > 0) // Nachkommastellen
+ return nPos; // Fehler
+ bBlank = TRUE;
+ nBlankPos = i;
+ nCntPre = nCounter;
+ nCounter = 0;
+ }
+ nTypeArray[i] = NF_SYMBOLTYPE_FRACBLANK;
+ }
+ else if (nTypeArray[i] == NF_KEY_THAI_T)
+ {
+ bThaiT = true;
+ sStrArray[i] = sKeyword[nTypeArray[i]];
+ }
+ else
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ else if (nTypeArray[i] == NF_SYMBOLTYPE_DEL)
+ {
+ sal_Unicode cHere = sStrArray[i].GetChar(0);
+ // Handle not pre-known separators in switch.
+ sal_Unicode cSimplified;
+ if (StringEqualsChar( pFormatter->GetNumThousandSep(), cHere))
+ cSimplified = ',';
+ else if (StringEqualsChar( pFormatter->GetNumDecimalSep(), cHere))
+ cSimplified = '.';
+ else
+ cSimplified = cHere;
+ switch ( cSimplified )
+ {
+ case '#':
+ case '0':
+ case '?':
+ {
+ if (nThousand > 0) // #... #
+ return nPos; // Fehler
+ else if (bFrac && cHere == '0')
+ return nPos; // 0 im Nenner
+ nTypeArray[i] = NF_SYMBOLTYPE_DIGIT;
+ String& rStr = sStrArray[i];
+ nPos = nPos + rStr.Len();
+ i++;
+ nCounter++;
+ while (i < nAnzStrings &&
+ (sStrArray[i].GetChar(0) == '#' ||
+ sStrArray[i].GetChar(0) == '0' ||
+ sStrArray[i].GetChar(0) == '?')
+ )
+ {
+ rStr += sStrArray[i];
+ nPos = nPos + sStrArray[i].Len();
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ nCounter++;
+ i++;
+ }
+ }
+ break;
+ case '-':
+ {
+ if ( bDecSep && nDecPos+1 == i &&
+ nTypeArray[nDecPos] == NF_SYMBOLTYPE_DECSEP )
+ { // "0.--"
+ nTypeArray[i] = NF_SYMBOLTYPE_DIGIT;
+ String& rStr = sStrArray[i];
+ nPos = nPos + rStr.Len();
+ i++;
+ nCounter++;
+ while (i < nAnzStrings &&
+ (sStrArray[i].GetChar(0) == '-') )
+ {
+ // If more than two dashes are present in
+ // currency formats the last dash will be
+ // interpreted literally as a minus sign.
+ // Has to be this ugly. Period.
+ if ( eScannedType == NUMBERFORMAT_CURRENCY
+ && rStr.Len() >= 2 &&
+ (i == nAnzStrings-1 ||
+ sStrArray[i+1].GetChar(0) != '-') )
+ break;
+ rStr += sStrArray[i];
+ nPos = nPos + sStrArray[i].Len();
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ nCounter++;
+ i++;
+ }
+ }
+ else
+ {
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ }
+ break;
+ case '.':
+ case ',':
+ case '\'':
+ case ' ':
+ {
+ sal_Unicode cSep = cHere; // remember
+ if ( StringEqualsChar( sOldThousandSep, cSep ) )
+ {
+ // previous char with skip empty
+ sal_Unicode cPre = PreviousChar(i);
+ sal_Unicode cNext;
+ if (bExp || bBlank || bFrac)
+ { // after E, / or ' '
+ if ( !StringEqualsChar( sOldThousandSep, ' ' ) )
+ {
+ nPos = nPos + sStrArray[i].Len();
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ i++; // eat it
+ }
+ else
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ }
+ else if (i > 0 && i < nAnzStrings-1 &&
+ (cPre == '#' || cPre == '0') &&
+ ((cNext = NextChar(i)) == '#' || cNext == '0')
+ ) // #,#
+ {
+ nPos = nPos + sStrArray[i].Len();
+ if (!bThousand) // only once
+ { // set hard, in case of Non-Breaking Space or ConvertMode
+ sStrArray[i] = pFormatter->GetNumThousandSep();
+ nTypeArray[i] = NF_SYMBOLTYPE_THSEP;
+ bThousand = TRUE;
+ cThousandFill = sStrArray[i+1].GetChar(0);
+ }
+ else // eat it
+ {
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ }
+ i++;
+ }
+ else if (i > 0 && (cPre == '#' || cPre == '0')
+ && PreviousType(i) == NF_SYMBOLTYPE_DIGIT
+ && nThousand < FLAG_STANDARD_IN_FORMAT )
+ { // #,,,,
+ if ( StringEqualsChar( sOldThousandSep, ' ' ) )
+ { // strange, those French..
+ BOOL bFirst = TRUE;
+ String& rStr = sStrArray[i];
+ // set a hard Non-Breaking Space or ConvertMode
+ const String& rSepF = pFormatter->GetNumThousandSep();
+ while ( i < nAnzStrings
+ && sStrArray[i] == sOldThousandSep
+ && StringEqualsChar( sOldThousandSep, NextChar(i) ) )
+ { // last was a space or another space
+ // is following => separator
+ nPos = nPos + sStrArray[i].Len();
+ if ( bFirst )
+ {
+ bFirst = FALSE;
+ rStr = rSepF;
+ nTypeArray[i] = NF_SYMBOLTYPE_THSEP;
+ }
+ else
+ {
+ rStr += rSepF;
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ }
+ nThousand++;
+ i++;
+ }
+ if ( i < nAnzStrings-1
+ && sStrArray[i] == sOldThousandSep )
+ { // something following last space
+ // => space if currency contained,
+ // else separator
+ nPos = nPos + sStrArray[i].Len();
+ if ( (nPos <= nCurrPos &&
+ nCurrPos < nPos + sStrArray[i+1].Len())
+ || nTypeArray[i+1] == NF_KEY_CCC
+ || (i < nAnzStrings-2 &&
+ sStrArray[i+1].GetChar(0) == '[' &&
+ sStrArray[i+2].GetChar(0) == '$') )
+ {
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ }
+ else
+ {
+ if ( bFirst )
+ {
+ bFirst = FALSE;
+ rStr = rSepF;
+ nTypeArray[i] = NF_SYMBOLTYPE_THSEP;
+ }
+ else
+ {
+ rStr += rSepF;
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ }
+ nThousand++;
+ }
+ i++;
+ }
+ }
+ else
+ {
+ do
+ {
+ nThousand++;
+ nTypeArray[i] = NF_SYMBOLTYPE_THSEP;
+ nPos = nPos + sStrArray[i].Len();
+ sStrArray[i] = pFormatter->GetNumThousandSep();
+ i++;
+ } while (i < nAnzStrings &&
+ sStrArray[i] == sOldThousandSep);
+ }
+ }
+ else // any grsep
+ {
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ String& rStr = sStrArray[i];
+ nPos = nPos + rStr.Len();
+ i++;
+ while ( i < nAnzStrings &&
+ sStrArray[i] == sOldThousandSep )
+ {
+ rStr += sStrArray[i];
+ nPos = nPos + sStrArray[i].Len();
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ i++;
+ }
+ }
+ }
+ else if ( StringEqualsChar( sOldDecSep, cSep ) )
+ {
+ if (bBlank || bFrac) // . behind / or ' '
+ return nPos; // error
+ else if (bExp) // behind E
+ {
+ nPos = nPos + sStrArray[i].Len();
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ i++; // eat it
+ }
+ else if (bDecSep) // any .
+ {
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ String& rStr = sStrArray[i];
+ nPos = nPos + rStr.Len();
+ i++;
+ while ( i < nAnzStrings &&
+ sStrArray[i] == sOldDecSep )
+ {
+ rStr += sStrArray[i];
+ nPos = nPos + sStrArray[i].Len();
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ i++;
+ }
+ }
+ else
+ {
+ nPos = nPos + sStrArray[i].Len();
+ nTypeArray[i] = NF_SYMBOLTYPE_DECSEP;
+ sStrArray[i] = pFormatter->GetNumDecimalSep();
+ bDecSep = TRUE;
+ nDecPos = i;
+ nCntPre = nCounter;
+ nCounter = 0;
+
+ i++;
+ }
+ } // of else = DecSep
+ else // . without meaning
+ {
+ if (cSep == ' ' &&
+ eScannedType == NUMBERFORMAT_FRACTION &&
+ StringEqualsChar( sStrArray[i], ' ' ) )
+ {
+ if (!bBlank && !bFrac) // no dups
+ { // or behind /
+ if (bDecSep && nCounter > 0)// dec.
+ return nPos; // error
+ bBlank = TRUE;
+ nBlankPos = i;
+ nCntPre = nCounter;
+ nCounter = 0;
+ }
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ nPos = nPos + sStrArray[i].Len();
+ }
+ else
+ {
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ String& rStr = sStrArray[i];
+ nPos = nPos + rStr.Len();
+ i++;
+ while (i < nAnzStrings &&
+ StringEqualsChar( sStrArray[i], cSep ) )
+ {
+ rStr += sStrArray[i];
+ nPos = nPos + sStrArray[i].Len();
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ i++;
+ }
+ }
+ }
+ }
+ break;
+ case '/':
+ {
+ if (eScannedType == NUMBERFORMAT_FRACTION)
+ {
+ if ( i == 0 ||
+ (nTypeArray[i-1] != NF_SYMBOLTYPE_DIGIT &&
+ nTypeArray[i-1] != NF_SYMBOLTYPE_EMPTY) )
+ return nPos ? nPos : 1; // /? not allowed
+ else if (!bFrac || (bDecSep && nCounter > 0))
+ {
+ bFrac = TRUE;
+ nCntPost = nCounter;
+ nCounter = 0;
+ nTypeArray[i] = NF_SYMBOLTYPE_FRAC;
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ else // / doppelt od. , imZaehl
+ return nPos; // Fehler
+ }
+ else
+ {
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ }
+ break;
+ case '[' :
+ {
+ if ( eScannedType == NUMBERFORMAT_CURRENCY &&
+ i < nAnzStrings-1 &&
+ nTypeArray[i+1] == NF_SYMBOLTYPE_STRING &&
+ sStrArray[i+1].GetChar(0) == '$' )
+ { // [$DM-xxx]
+ // ab SV_NUMBERFORMATTER_VERSION_NEW_CURR
+ nPos = nPos + sStrArray[i].Len(); // [
+ nTypeArray[i] = NF_SYMBOLTYPE_CURRDEL;
+ nPos = nPos + sStrArray[++i].Len(); // $
+ sStrArray[i-1] += sStrArray[i]; // [$
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ if ( ++i >= nAnzStrings )
+ return nPos; // Fehler
+ nPos = nPos + sStrArray[i].Len(); // DM
+ String& rStr = sStrArray[i];
+ String* pStr = &sStrArray[i];
+ nTypeArray[i] = NF_SYMBOLTYPE_CURRENCY; // wandeln
+ BOOL bHadDash = FALSE;
+ i++;
+ while ( i < nAnzStrings &&
+ sStrArray[i].GetChar(0) != ']' )
+ {
+ nPos = nPos + sStrArray[i].Len();
+ if ( bHadDash )
+ {
+ *pStr += sStrArray[i];
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ }
+ else
+ {
+ if ( sStrArray[i].GetChar(0) == '-' )
+ {
+ bHadDash = TRUE;
+ pStr = &sStrArray[i];
+ nTypeArray[i] = NF_SYMBOLTYPE_CURREXT;
+ }
+ else
+ {
+ *pStr += sStrArray[i];
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ }
+ }
+ i++;
+ }
+ if ( rStr.Len() && i < nAnzStrings &&
+ sStrArray[i].GetChar(0) == ']' )
+ {
+ nTypeArray[i] = NF_SYMBOLTYPE_CURRDEL;
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ else
+ return nPos; // Fehler
+ }
+ else
+ {
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ }
+ break;
+ default: // andere Dels
+ {
+ if (eScannedType == NUMBERFORMAT_PERCENT &&
+ cHere == '%')
+ nTypeArray[i] = NF_SYMBOLTYPE_PERCENT;
+ else
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ break;
+ } // of switch (Del)
+ } // of else Del
+ else if ( nTypeArray[i] == NF_SYMBOLTYPE_COMMENT )
+ {
+ String& rStr = sStrArray[i];
+ nPos = nPos + rStr.Len();
+ SvNumberformat::EraseCommentBraces( rStr );
+ rComment += rStr;
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ i++;
+ }
+ else
+ {
+ DBG_ERRORFILE( "unknown NF_SYMBOLTYPE_..." );
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ } // of while
+ if (eScannedType == NUMBERFORMAT_FRACTION)
+ {
+ if (bFrac)
+ nCntExp = nCounter;
+ else if (bBlank)
+ nCntPost = nCounter;
+ else
+ nCntPre = nCounter;
+ }
+ else
+ {
+ if (bExp)
+ nCntExp = nCounter;
+ else if (bDecSep)
+ nCntPost = nCounter;
+ else
+ nCntPre = nCounter;
+ }
+ if (nThousand == 0 && bThousand) // Expansion Tausenderpunkt:
+ {
+ USHORT nMaxPos;
+ if (bFrac)
+ {
+ if (bBlank)
+ nMaxPos = nBlankPos;
+ else
+ nMaxPos = 0; // keine Expansion
+ }
+ else if (bDecSep) // , vorhanden
+ nMaxPos = nDecPos;
+ else if (bExp) // E vorhanden
+ nMaxPos = nExpPos;
+ else // sonst bis Ende
+ nMaxPos = i;
+ i = 0;
+ long nCount = nCntPre;
+ while (i < nMaxPos && nTypeArray[i] != NF_SYMBOLTYPE_THSEP) // nur bis zum ,
+ {
+ if (nTypeArray[i] == NF_SYMBOLTYPE_DIGIT)
+ nCount -= sStrArray[i].Len();
+ i++;
+ }
+ USHORT nPosThSep = i; // Position merken
+ i++; // Ziffern hinter .
+ xub_StrLen nFill = 0;
+ if (nCount > 0) // muesste immer sein
+ nFill = xub_StrLen(nCount % 3);
+ if (nFill)
+ {
+ nFill = 3 - nFill;
+ if (i < nMaxPos)
+ for (xub_StrLen k = 0; k < nFill; k++)
+ sStrArray[i].Insert(cThousandFill,0);
+ nCntPre = nCntPre + USHORT(nFill);
+ }
+ nCount = 0; // Aufuellen mit .
+ while (i < nMaxPos) // nach hinten
+ {
+ if (nTypeArray[i] == NF_SYMBOLTYPE_DIGIT)
+ {
+ xub_StrLen nLen = sStrArray[i].Len();
+ if (nCount+nLen > 3)
+ { // hier muss . dazwischen
+ xub_StrLen nAnz =
+ sal::static_int_cast< xub_StrLen >(
+ (nLen+nCount-4)/3+1);
+ xub_StrLen InPos =
+ sal::static_int_cast< xub_StrLen >(3-nCount);
+ for (xub_StrLen k = 0; k < nAnz; k++)
+ {
+ sStrArray[i].Insert(
+ pFormatter->GetNumThousandSep(),InPos);
+ InPos += 4;
+ }
+ nCount = sStrArray[i].Len() - InPos + 3;
+ }
+ else
+ nCount += sStrArray[i].Len();
+ }
+ i++;
+ }
+ nCount = 0; // Aufuellen mit .
+ i = nPosThSep; // nach vorn
+ while (i > 0)
+ {
+ i--;
+ if (nTypeArray[i] == NF_SYMBOLTYPE_DIGIT)
+ {
+ xub_StrLen nLen = sStrArray[i].Len();
+ if (nCount+nLen > 3)
+ { // hier muss . dazwischen
+ xub_StrLen nAnz =
+ sal::static_int_cast< xub_StrLen >(
+ (nLen+nCount-4)/3+1);
+ xub_StrLen InPos =
+ sal::static_int_cast< xub_StrLen >(
+ nLen + nCount - 3);
+ for (xub_StrLen k = 0; k < nAnz; k++)
+ {
+ sStrArray[i].Insert(
+ pFormatter->GetNumThousandSep(),InPos);
+ InPos -= 3;
+ }
+ nCount = InPos + 3;
+ }
+ else
+ nCount += sStrArray[i].Len();
+ }
+ }
+ }
+ }
+ break; // of NUMBERFORMAT_NUMBER
+ case NUMBERFORMAT_DATE:
+ {
+ while (i < nAnzStrings)
+ {
+ switch (nTypeArray[i])
+ {
+ case NF_SYMBOLTYPE_BLANK:
+ case NF_SYMBOLTYPE_STAR:
+ case NF_SYMBOLTYPE_STRING:
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ break;
+ case NF_SYMBOLTYPE_COMMENT:
+ {
+ String& rStr = sStrArray[i];
+ nPos = nPos + rStr.Len();
+ SvNumberformat::EraseCommentBraces( rStr );
+ rComment += rStr;
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ i++;
+ }
+ break;
+ case NF_SYMBOLTYPE_DEL:
+ {
+ int nCalRet;
+ if (sStrArray[i] == sOldDateSep)
+ {
+ nTypeArray[i] = NF_SYMBOLTYPE_DATESEP;
+ nPos = nPos + sStrArray[i].Len();
+ if (bConvertMode)
+ sStrArray[i] = pFormatter->GetDateSep();
+ i++;
+ }
+ else if ( (nCalRet = FinalScanGetCalendar( nPos, i, nAnzResStrings )) != 0 )
+ {
+ if ( nCalRet < 0 )
+ return nPos; // error
+ }
+ else
+ {
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ }
+ break;
+ case NF_KEY_THAI_T :
+ bThaiT = true;
+ // fall thru
+ case NF_KEY_M: // M
+ case NF_KEY_MM: // MM
+ case NF_KEY_MMM: // MMM
+ case NF_KEY_MMMM: // MMMM
+ case NF_KEY_MMMMM: // MMMMM
+ case NF_KEY_Q: // Q
+ case NF_KEY_QQ: // QQ
+ case NF_KEY_D: // D
+ case NF_KEY_DD: // DD
+ case NF_KEY_DDD: // DDD
+ case NF_KEY_DDDD: // DDDD
+ case NF_KEY_YY: // YY
+ case NF_KEY_YYYY: // YYYY
+ case NF_KEY_NN: // NN
+ case NF_KEY_NNN: // NNN
+ case NF_KEY_NNNN: // NNNN
+ case NF_KEY_WW : // WW
+ case NF_KEY_AAA : // AAA
+ case NF_KEY_AAAA : // AAAA
+ case NF_KEY_EC : // E
+ case NF_KEY_EEC : // EE
+ case NF_KEY_G : // G
+ case NF_KEY_GG : // GG
+ case NF_KEY_GGG : // GGG
+ case NF_KEY_R : // R
+ case NF_KEY_RR : // RR
+ sStrArray[i] = sKeyword[nTypeArray[i]]; // tTtT -> TTTT
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ break;
+ default: // andere Keywords
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ break;
+ }
+ } // of while
+ }
+ break; // of NUMBERFORMAT_DATE
+ case NUMBERFORMAT_TIME:
+ {
+ while (i < nAnzStrings)
+ {
+ switch (nTypeArray[i])
+ {
+ case NF_SYMBOLTYPE_BLANK:
+ case NF_SYMBOLTYPE_STAR:
+ {
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ break;
+ case NF_SYMBOLTYPE_DEL:
+ {
+ switch( sStrArray[i].GetChar(0) )
+ {
+ case '0':
+ {
+ if ( Is100SecZero( i, bDecSep ) )
+ {
+ bDecSep = TRUE;
+ nTypeArray[i] = NF_SYMBOLTYPE_DIGIT;
+ String& rStr = sStrArray[i];
+ i++;
+ nPos = nPos + sStrArray[i].Len();
+ nCounter++;
+ while (i < nAnzStrings &&
+ sStrArray[i].GetChar(0) == '0')
+ {
+ rStr += sStrArray[i];
+ nPos = nPos + sStrArray[i].Len();
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ nCounter++;
+ i++;
+ }
+ }
+ else
+ return nPos;
+ }
+ break;
+ case '#':
+ case '?':
+ return nPos;
+ case '[':
+ {
+ if (bThousand) // doppelt
+ return nPos;
+ bThousand = TRUE; // bei Time frei
+ sal_Unicode cChar = pChrCls->upper( NextChar(i) ).GetChar(0);
+ if ( cChar == cOldKeyH )
+ nThousand = 1; // H
+ else if ( cChar == cOldKeyMI )
+ nThousand = 2; // M
+ else if ( cChar == cOldKeyS )
+ nThousand = 3; // S
+ else
+ return nPos;
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ break;
+ case ']':
+ {
+ if (!bThousand) // kein [ vorher
+ return nPos;
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ break;
+ default:
+ {
+ nPos = nPos + sStrArray[i].Len();
+ if ( sStrArray[i] == sOldTimeSep )
+ {
+ nTypeArray[i] = NF_SYMBOLTYPE_TIMESEP;
+ if ( bConvertMode )
+ sStrArray[i] = pLoc->getTimeSep();
+ }
+ else if ( sStrArray[i] == sOldTime100SecSep )
+ {
+ bDecSep = TRUE;
+ nTypeArray[i] = NF_SYMBOLTYPE_TIME100SECSEP;
+ if ( bConvertMode )
+ sStrArray[i] = pLoc->getTime100SecSep();
+ }
+ else
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ i++;
+ }
+ break;
+ }
+ }
+ break;
+ case NF_SYMBOLTYPE_STRING:
+ {
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ break;
+ case NF_SYMBOLTYPE_COMMENT:
+ {
+ String& rStr = sStrArray[i];
+ nPos = nPos + rStr.Len();
+ SvNumberformat::EraseCommentBraces( rStr );
+ rComment += rStr;
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ i++;
+ }
+ break;
+ case NF_KEY_AMPM: // AM/PM
+ case NF_KEY_AP: // A/P
+ {
+ bExp = TRUE; // missbraucht fuer A/P
+ sStrArray[i] = sKeyword[nTypeArray[i]]; // tTtT -> TTTT
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ break;
+ case NF_KEY_THAI_T :
+ bThaiT = true;
+ // fall thru
+ case NF_KEY_MI: // M
+ case NF_KEY_MMI: // MM
+ case NF_KEY_H: // H
+ case NF_KEY_HH: // HH
+ case NF_KEY_S: // S
+ case NF_KEY_SS: // SS
+ {
+ sStrArray[i] = sKeyword[nTypeArray[i]]; // tTtT -> TTTT
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ break;
+ default: // andere Keywords
+ {
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ break;
+ }
+ } // of while
+ nCntPost = nCounter; // Zaehler der Nullen
+ if (bExp)
+ nCntExp = 1; // merkt AM/PM
+ }
+ break; // of NUMBERFORMAT_TIME
+ case NUMBERFORMAT_DATETIME:
+ {
+ BOOL bTimePart = FALSE;
+ while (i < nAnzStrings)
+ {
+ switch (nTypeArray[i])
+ {
+ case NF_SYMBOLTYPE_BLANK:
+ case NF_SYMBOLTYPE_STAR:
+ case NF_SYMBOLTYPE_STRING:
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ break;
+ case NF_SYMBOLTYPE_COMMENT:
+ {
+ String& rStr = sStrArray[i];
+ nPos = nPos + rStr.Len();
+ SvNumberformat::EraseCommentBraces( rStr );
+ rComment += rStr;
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ i++;
+ }
+ break;
+ case NF_SYMBOLTYPE_DEL:
+ {
+ int nCalRet;
+ if ( (nCalRet = FinalScanGetCalendar( nPos, i, nAnzResStrings )) != 0 )
+ {
+ if ( nCalRet < 0 )
+ return nPos; // error
+ }
+ else
+ {
+ switch( sStrArray[i].GetChar(0) )
+ {
+ case '0':
+ {
+ if ( bTimePart && Is100SecZero( i, bDecSep ) )
+ {
+ bDecSep = TRUE;
+ nTypeArray[i] = NF_SYMBOLTYPE_DIGIT;
+ String& rStr = sStrArray[i];
+ i++;
+ nPos = nPos + sStrArray[i].Len();
+ nCounter++;
+ while (i < nAnzStrings &&
+ sStrArray[i].GetChar(0) == '0')
+ {
+ rStr += sStrArray[i];
+ nPos = nPos + sStrArray[i].Len();
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ nCounter++;
+ i++;
+ }
+ }
+ else
+ return nPos;
+ }
+ break;
+ case '#':
+ case '?':
+ return nPos;
+ default:
+ {
+ nPos = nPos + sStrArray[i].Len();
+ if (bTimePart)
+ {
+ if ( sStrArray[i] == sOldTimeSep )
+ {
+ nTypeArray[i] = NF_SYMBOLTYPE_TIMESEP;
+ if ( bConvertMode )
+ sStrArray[i] = pLoc->getTimeSep();
+ }
+ else if ( sStrArray[i] == sOldTime100SecSep )
+ {
+ bDecSep = TRUE;
+ nTypeArray[i] = NF_SYMBOLTYPE_TIME100SECSEP;
+ if ( bConvertMode )
+ sStrArray[i] = pLoc->getTime100SecSep();
+ }
+ else
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ }
+ else
+ {
+ if ( sStrArray[i] == sOldDateSep )
+ {
+ nTypeArray[i] = NF_SYMBOLTYPE_DATESEP;
+ if (bConvertMode)
+ sStrArray[i] = pFormatter->GetDateSep();
+ }
+ else
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ }
+ i++;
+ }
+ }
+ }
+ }
+ break;
+ case NF_KEY_AMPM: // AM/PM
+ case NF_KEY_AP: // A/P
+ {
+ bTimePart = TRUE;
+ bExp = TRUE; // missbraucht fuer A/P
+ sStrArray[i] = sKeyword[nTypeArray[i]]; // tTtT -> TTTT
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ }
+ break;
+ case NF_KEY_MI: // M
+ case NF_KEY_MMI: // MM
+ case NF_KEY_H: // H
+ case NF_KEY_HH: // HH
+ case NF_KEY_S: // S
+ case NF_KEY_SS: // SS
+ bTimePart = TRUE;
+ sStrArray[i] = sKeyword[nTypeArray[i]]; // tTtT -> TTTT
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ break;
+ case NF_KEY_M: // M
+ case NF_KEY_MM: // MM
+ case NF_KEY_MMM: // MMM
+ case NF_KEY_MMMM: // MMMM
+ case NF_KEY_MMMMM: // MMMMM
+ case NF_KEY_Q: // Q
+ case NF_KEY_QQ: // QQ
+ case NF_KEY_D: // D
+ case NF_KEY_DD: // DD
+ case NF_KEY_DDD: // DDD
+ case NF_KEY_DDDD: // DDDD
+ case NF_KEY_YY: // YY
+ case NF_KEY_YYYY: // YYYY
+ case NF_KEY_NN: // NN
+ case NF_KEY_NNN: // NNN
+ case NF_KEY_NNNN: // NNNN
+ case NF_KEY_WW : // WW
+ case NF_KEY_AAA : // AAA
+ case NF_KEY_AAAA : // AAAA
+ case NF_KEY_EC : // E
+ case NF_KEY_EEC : // EE
+ case NF_KEY_G : // G
+ case NF_KEY_GG : // GG
+ case NF_KEY_GGG : // GGG
+ case NF_KEY_R : // R
+ case NF_KEY_RR : // RR
+ bTimePart = FALSE;
+ sStrArray[i] = sKeyword[nTypeArray[i]]; // tTtT -> TTTT
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ break;
+ case NF_KEY_THAI_T :
+ bThaiT = true;
+ sStrArray[i] = sKeyword[nTypeArray[i]];
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ break;
+ default: // andere Keywords
+ nTypeArray[i] = NF_SYMBOLTYPE_STRING;
+ nPos = nPos + sStrArray[i].Len();
+ i++;
+ break;
+ }
+ } // of while
+ nCntPost = nCounter; // decimals (100th seconds)
+ if (bExp)
+ nCntExp = 1; // merkt AM/PM
+ }
+ break; // of NUMBERFORMAT_DATETIME
+ default:
+ break;
+ }
+ if (eScannedType == NUMBERFORMAT_SCIENTIFIC &&
+ (nCntPre + nCntPost == 0 || nCntExp == 0))
+ return nPos;
+ else if (eScannedType == NUMBERFORMAT_FRACTION && (nCntExp > 8 || nCntExp == 0))
+ return nPos;
+
+ if (bThaiT && !GetNatNumModifier())
+ SetNatNumModifier(1);
+
+ if ( bConvertMode )
+ { // strings containing keywords of the target locale must be quoted, so
+ // the user sees the difference and is able to edit the format string
+ for ( i=0; i < nAnzStrings; i++ )
+ {
+ if ( nTypeArray[i] == NF_SYMBOLTYPE_STRING &&
+ sStrArray[i].GetChar(0) != '\"' )
+ {
+ if ( bConvertSystemToSystem && eScannedType == NUMBERFORMAT_CURRENCY )
+ { // don't stringize automatic currency, will be converted
+ if ( sStrArray[i] == sOldCurSymbol )
+ continue; // for
+ // DM might be splitted into D and M
+ if ( sStrArray[i].Len() < sOldCurSymbol.Len() &&
+ pChrCls->toUpper( sStrArray[i], 0, 1 ).GetChar(0) ==
+ sOldCurString.GetChar(0) )
+ {
+ String aTmp( sStrArray[i] );
+ USHORT j = i + 1;
+ while ( aTmp.Len() < sOldCurSymbol.Len() &&
+ j < nAnzStrings &&
+ nTypeArray[j] == NF_SYMBOLTYPE_STRING )
+ {
+ aTmp += sStrArray[j++];
+ }
+ if ( pChrCls->upper( aTmp ) == sOldCurString )
+ {
+ sStrArray[i++] = aTmp;
+ for ( ; i<j; i++ )
+ {
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ }
+ i = j - 1;
+ continue; // for
+ }
+ }
+ }
+ String& rStr = sStrArray[i];
+ xub_StrLen nLen = rStr.Len();
+ for ( xub_StrLen j=0; j<nLen; j++ )
+ {
+ if ( (j == 0 || rStr.GetChar(j-1) != '\\') && GetKeyWord( rStr, j ) )
+ {
+ rStr.Insert( '\"', 0 );
+ rStr += '\"';
+ break; // for
+ }
+ }
+ }
+ }
+ }
+ // concatenate strings, remove quotes for output, and rebuild the format string
+ rString.Erase();
+ i = 0;
+ while (i < nAnzStrings)
+ {
+ switch ( nTypeArray[i] )
+ {
+ case NF_SYMBOLTYPE_STRING :
+ {
+ xub_StrLen nStringPos = rString.Len();
+ xub_StrLen nArrPos = 0;
+ USHORT iPos = i;
+ do
+ {
+ if (sStrArray[i].Len() == 2 &&
+ sStrArray[i].GetChar(0) == '\\')
+ {
+ // Unescape some simple forms of symbols even in the UI
+ // visible string to prevent duplicates that differ
+ // only in notation, originating from import.
+ // e.g. YYYY-MM-DD and YYYY\-MM\-DD are identical,
+ // but 0\ 000 0 and 0 000 0 in a French locale are not.
+ sal_Unicode c = sStrArray[i].GetChar(1);
+ switch (c)
+ {
+ case '+':
+ case '-':
+ rString += c;
+ break;
+ case ' ':
+ case '.':
+ case '/':
+ if (((eScannedType & NUMBERFORMAT_DATE) == 0)
+ && (StringEqualsChar(
+ pFormatter->GetNumThousandSep(),
+ c) || StringEqualsChar(
+ pFormatter->GetNumDecimalSep(),
+ c) || (c == ' ' &&
+ StringEqualsChar(
+ pFormatter->GetNumThousandSep(),
+ cNonBreakingSpace))))
+ rString += sStrArray[i];
+ else if ((eScannedType & NUMBERFORMAT_DATE) &&
+ StringEqualsChar(
+ pFormatter->GetDateSep(), c))
+ rString += sStrArray[i];
+ else if ((eScannedType & NUMBERFORMAT_TIME) &&
+ (StringEqualsChar( pLoc->getTimeSep(),
+ c) ||
+ StringEqualsChar(
+ pLoc->getTime100SecSep(), c)))
+ rString += sStrArray[i];
+ else if (eScannedType & NUMBERFORMAT_FRACTION)
+ rString += sStrArray[i];
+ else
+ rString += c;
+ break;
+ default:
+ rString += sStrArray[i];
+ }
+ }
+ else
+ rString += sStrArray[i];
+ if ( RemoveQuotes( sStrArray[i] ) > 0 )
+ { // update currency up to quoted string
+ if ( eScannedType == NUMBERFORMAT_CURRENCY )
+ { // dM -> DM or DM -> $ in old automatic
+ // currency formats, oh my ..., why did we ever
+ // introduce them?
+ String aTmp( pChrCls->toUpper(
+ sStrArray[iPos], nArrPos,
+ sStrArray[iPos].Len()-nArrPos ) );
+ xub_StrLen nCPos = aTmp.Search( sOldCurString );
+ if ( nCPos != STRING_NOTFOUND )
+ {
+ const String& rCur =
+ bConvertMode && bConvertSystemToSystem ?
+ GetCurSymbol() : sOldCurSymbol;
+ sStrArray[iPos].Replace( nArrPos+nCPos,
+ sOldCurString.Len(), rCur );
+ rString.Replace( nStringPos+nCPos,
+ sOldCurString.Len(), rCur );
+ }
+ nStringPos = rString.Len();
+ if ( iPos == i )
+ nArrPos = sStrArray[iPos].Len();
+ else
+ nArrPos = sStrArray[iPos].Len() + sStrArray[i].Len();
+ }
+ }
+ if ( iPos != i )
+ {
+ sStrArray[iPos] += sStrArray[i];
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ }
+ i++;
+ } while ( i < nAnzStrings && nTypeArray[i] == NF_SYMBOLTYPE_STRING );
+ if ( i < nAnzStrings )
+ i--; // enter switch on next symbol again
+ if ( eScannedType == NUMBERFORMAT_CURRENCY && nStringPos < rString.Len() )
+ { // same as above, since last RemoveQuotes
+ String aTmp( pChrCls->toUpper(
+ sStrArray[iPos], nArrPos,
+ sStrArray[iPos].Len()-nArrPos ) );
+ xub_StrLen nCPos = aTmp.Search( sOldCurString );
+ if ( nCPos != STRING_NOTFOUND )
+ {
+ const String& rCur =
+ bConvertMode && bConvertSystemToSystem ?
+ GetCurSymbol() : sOldCurSymbol;
+ sStrArray[iPos].Replace( nArrPos+nCPos,
+ sOldCurString.Len(), rCur );
+ rString.Replace( nStringPos+nCPos,
+ sOldCurString.Len(), rCur );
+ }
+ }
+ }
+ break;
+ case NF_SYMBOLTYPE_CURRENCY :
+ {
+ rString += sStrArray[i];
+ RemoveQuotes( sStrArray[i] );
+ }
+ break;
+ case NF_KEY_THAI_T:
+ if (bThaiT && GetNatNumModifier() == 1)
+ { // Remove T from format code, will be replaced with a [NatNum1] prefix.
+ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
+ nAnzResStrings--;
+ }
+ else
+ rString += sStrArray[i];
+ break;
+ case NF_SYMBOLTYPE_EMPTY :
+ // nothing
+ break;
+ default:
+ rString += sStrArray[i];
+ }
+ i++;
+ }
+ return 0;
+}
+
+
+xub_StrLen ImpSvNumberformatScan::RemoveQuotes( String& rStr )
+{
+ if ( rStr.Len() > 1 )
+ {
+ sal_Unicode c = rStr.GetChar(0);
+ xub_StrLen n;
+ if ( c == '"' && rStr.GetChar( (n = xub_StrLen(rStr.Len()-1)) ) == '"' )
+ {
+ rStr.Erase(n,1);
+ rStr.Erase(0,1);
+ return 2;
+ }
+ else if ( c == '\\' )
+ {
+ rStr.Erase(0,1);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+
+xub_StrLen ImpSvNumberformatScan::ScanFormat( String& rString, String& rComment )
+{
+ xub_StrLen res = Symbol_Division(rString); //lexikalische Analyse
+ if (!res)
+ res = ScanType(rString); // Erkennung des Formattyps
+ if (!res)
+ res = FinalScan( rString, rComment ); // Typabhaengige Endanalyse
+ return res; // res = Kontrollposition
+ // res = 0 => Format ok
+}
+
+void ImpSvNumberformatScan::CopyInfo(ImpSvNumberformatInfo* pInfo, USHORT nAnz)
+{
+ size_t i,j;
+ j = 0;
+ i = 0;
+ while (i < nAnz && j < NF_MAX_FORMAT_SYMBOLS)
+ {
+ if (nTypeArray[j] != NF_SYMBOLTYPE_EMPTY)
+ {
+ pInfo->sStrArray[i] = sStrArray[j];
+ pInfo->nTypeArray[i] = nTypeArray[j];
+ i++;
+ }
+ j++;
+ }
+ pInfo->eScannedType = eScannedType;
+ pInfo->bThousand = bThousand;
+ pInfo->nThousand = nThousand;
+ pInfo->nCntPre = nCntPre;
+ pInfo->nCntPost = nCntPost;
+ pInfo->nCntExp = nCntExp;
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/numbers/zforscan.hxx b/binfilter/bf_svtools/source/numbers/zforscan.hxx
new file mode 100644
index 000000000000..64e75f839050
--- /dev/null
+++ b/binfilter/bf_svtools/source/numbers/zforscan.hxx
@@ -0,0 +1,276 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 _ZFORSCAN_HXX
+#define _ZFORSCAN_HXX
+
+#include <tools/string.hxx>
+#include <tools/date.hxx>
+#include <i18npool/lang.h>
+#include <tools/color.hxx>
+
+#include <bf_svtools/nfkeytab.hxx>
+
+namespace binfilter
+{
+
+class SvNumberFormatter;
+struct ImpSvNumberformatInfo;
+
+
+const size_t NF_MAX_FORMAT_SYMBOLS = 100;
+const size_t NF_MAX_DEFAULT_COLORS = 10;
+
+// Hack: nThousand==1000 => "Default" occurs in format string
+const USHORT FLAG_STANDARD_IN_FORMAT = 1000;
+
+class ImpSvNumberformatScan
+{
+public:
+
+ ImpSvNumberformatScan( SvNumberFormatter* pFormatter );
+ ~ImpSvNumberformatScan();
+ void ChangeIntl(); // tauscht Keywords aus
+
+ void ChangeNullDate(USHORT nDay, USHORT nMonth, USHORT nYear);
+ // tauscht Referenzdatum aus
+ void ChangeStandardPrec(short nPrec); // tauscht Standardprecision aus
+
+ xub_StrLen ScanFormat( String& rString, String& rComment ); // Aufruf der Scan-Analyse
+
+ void CopyInfo(ImpSvNumberformatInfo* pInfo,
+ USHORT nAnz); // Kopiert die FormatInfo
+ USHORT GetAnzResStrings() const { return nAnzResStrings; }
+
+ const CharClass& GetChrCls() const { return *pFormatter->GetCharClass(); }
+ const LocaleDataWrapper& GetLoc() const { return *pFormatter->GetLocaleData(); }
+ CalendarWrapper& GetCal() const { return *pFormatter->GetCalendar(); }
+
+ const String* GetKeywords() const
+ {
+ if ( bKeywordsNeedInit )
+ InitKeywords();
+ return sKeyword;
+ }
+ // Keywords used in output like TRUE and FALSE
+ const String& GetSpecialKeyword( NfKeywordIndex eIdx ) const
+ {
+ if ( !sKeyword[eIdx].Len() )
+ InitSpecialKeyword( eIdx );
+ return sKeyword[eIdx];
+ }
+ const String& GetTrueString() const { return GetSpecialKeyword( NF_KEY_TRUE ); }
+ const String& GetFalseString() const { return GetSpecialKeyword( NF_KEY_FALSE ); }
+ const String& GetColorString() const { return GetKeywords()[NF_KEY_COLOR]; }
+ const String& GetRedString() const { return GetKeywords()[NF_KEY_RED]; }
+ const String& GetBooleanString() const { return GetKeywords()[NF_KEY_BOOLEAN]; }
+ const String& GetErrorString() const { return sErrStr; }
+
+ Date* GetNullDate() const { return pNullDate; }
+ const String& GetStandardName() const
+ {
+ if ( bKeywordsNeedInit )
+ InitKeywords();
+ return sNameStandardFormat;
+ }
+ short GetStandardPrec() const { return nStandardPrec; }
+ const Color& GetRedColor() const { return StandardColor[4]; }
+ Color* GetColor(String& sStr); // Setzt Hauptfarben oder
+ // definierte Farben
+
+ // the compatibility currency symbol for old automatic currency formats
+ const String& GetCurSymbol() const
+ {
+ if ( bCompatCurNeedInit )
+ InitCompatCur();
+ return sCurSymbol;
+ }
+
+ // the compatibility currency abbreviation for CCC format code
+ const String& GetCurAbbrev() const
+ {
+ if ( bCompatCurNeedInit )
+ InitCompatCur();
+ return sCurAbbrev;
+ }
+
+ // the compatibility currency symbol upper case for old automatic currency formats
+ const String& GetCurString() const
+ {
+ if ( bCompatCurNeedInit )
+ InitCompatCur();
+ return sCurString;
+ }
+
+ void SetConvertMode(LanguageType eTmpLge, LanguageType eNewLge,
+ BOOL bSystemToSystem = FALSE )
+ {
+ bConvertMode = TRUE;
+ eNewLnge = eNewLge;
+ eTmpLnge = eTmpLge;
+ bConvertSystemToSystem = bSystemToSystem;
+ }
+ void SetConvertMode(BOOL bMode) { bConvertMode = bMode; }
+ // Veraendert nur die Bool-Variable
+ // (zum temporaeren Unterbrechen des
+ // Convert-Modus)
+ BOOL GetConvertMode() const { return bConvertMode; }
+ LanguageType GetNewLnge() const { return eNewLnge; }
+ // Lesezugriff auf ConvertMode
+ // und Konvertierungsland/Spr.
+ LanguageType GetTmpLnge() const { return eTmpLnge; }
+ // Lesezugriff auf
+ // und Ausgangsland/Spr.
+
+ /// get Thai T speciality
+ BYTE GetNatNumModifier() const { return nNatNumModifier; }
+ /// set Thai T speciality
+ void SetNatNumModifier( BYTE n ) { nNatNumModifier = n; }
+
+ SvNumberFormatter* GetNumberformatter() { return pFormatter; }
+ // Zugriff auf Formatierer
+ // (fuer zformat.cxx)
+
+
+private: // ---- privater Teil
+ NfKeywordTable sKeyword; // Schluesselworte der Syntax
+ Color StandardColor[NF_MAX_DEFAULT_COLORS];
+ // Array der Standardfarben
+ Date* pNullDate; // 30Dec1899
+ String sNameStandardFormat; // "Standard"
+ short nStandardPrec; // default Precision fuer Standardformat (2)
+ SvNumberFormatter* pFormatter; // Pointer auf die Formatliste
+
+ String sStrArray[NF_MAX_FORMAT_SYMBOLS]; // Array der Symbole
+ short nTypeArray[NF_MAX_FORMAT_SYMBOLS]; // Array der Infos
+ // externe Infos:
+ USHORT nAnzResStrings; // Anzahl der Ergebnissymbole
+#if !(defined SOLARIS && defined X86)
+ short eScannedType; // Typ gemaess Scan
+#else
+ int eScannedType; // wg. Optimierung
+#endif
+ BOOL bThousand; // Mit Tausenderpunkt
+ USHORT nThousand; // Zaehlt ....-Folgen
+ USHORT nCntPre; // Zaehlt Vorkommastellen
+ USHORT nCntPost; // Zaehlt Nachkommastellen
+ USHORT nCntExp; // Zaehlt Exp.Stellen, AM/PM
+ // interne Infos:
+ USHORT nAnzStrings; // Anzahl der Symbole
+ USHORT nRepPos; // Position eines '*'
+ USHORT nExpPos; // interne Position des E
+ USHORT nBlankPos; // interne Position des Blank
+ short nDecPos; // interne Pos. des ,
+ BOOL bExp; // wird bei Lesen des E gesetzt
+ BOOL bFrac; // wird bei Lesen des / gesetzt
+ BOOL bBlank; // wird bei ' '(Fraction) ges.
+ BOOL bDecSep; // Wird beim ersten , gesetzt
+ mutable BOOL bKeywordsNeedInit; // Locale dependent keywords need to be initialized
+ mutable BOOL bCompatCurNeedInit; // Locale dependent compatibility currency need to be initialized
+ String sCurSymbol; // Currency symbol for compatibility format codes
+ String sCurString; // Currency symbol in upper case
+ String sCurAbbrev; // Currency abbreviation
+ String sErrStr; // String fuer Fehlerausgaben
+
+ BOOL bConvertMode; // Wird im Convert-Mode gesetzt
+ // Land/Sprache, in die der
+ LanguageType eNewLnge; // gescannte String konvertiert
+ // wird (fuer Excel Filter)
+ // Land/Sprache, aus der der
+ LanguageType eTmpLnge; // gescannte String konvertiert
+ // wird (fuer Excel Filter)
+ BOOL bConvertSystemToSystem; // Whether the conversion is
+ // from one system locale to
+ // another system locale (in
+ // this case the automatic
+ // currency symbol is converted
+ // too).
+
+ xub_StrLen nCurrPos; // Position des Waehrungssymbols
+
+ BYTE nNatNumModifier; // Thai T speciality
+
+ void InitKeywords() const;
+ void InitSpecialKeyword( NfKeywordIndex eIdx ) const;
+ void InitCompatCur() const;
+
+#ifdef _ZFORSCAN_CXX // ----- private Methoden -----
+ void SetDependentKeywords();
+ // Setzt die Sprachabh. Keyw.
+ void SkipStrings(USHORT& i,xub_StrLen& nPos);// Ueberspringt StringSymbole
+ USHORT PreviousKeyword(USHORT i); // Gibt Index des vorangeh.
+ // Schluesselworts oder 0
+ USHORT NextKeyword(USHORT i); // Gibt Index des naechsten
+ // Schluesselworts oder 0
+ sal_Unicode PreviousChar(USHORT i); // Gibt letzten Buchstaben
+ // vor der Position,
+ // skipt EMPTY, STRING, STAR, BLANK
+ sal_Unicode NextChar(USHORT i); // Gibt ersten Buchst. danach
+ short PreviousType( USHORT i ); // Gibt Typ vor Position,
+ // skipt EMPTY
+ BOOL IsLastBlankBeforeFrac(USHORT i); // True <=> es kommt kein ' '
+ // mehr bis zum '/'
+ void Reset(); // Reset aller Variablen
+ // vor Analysestart
+ short GetKeyWord( const String& sSymbol, // determine keyword at nPos
+ xub_StrLen nPos ); // return 0 <=> not found
+
+ inline BOOL IsAmbiguousE( short nKey ) // whether nKey is ambiguous E of NF_KEY_E/NF_KEY_EC
+ {
+ return (nKey == NF_KEY_EC || nKey == NF_KEY_E) &&
+ (GetKeywords()[NF_KEY_EC] == GetKeywords()[NF_KEY_E]);
+ }
+
+ // if 0 at strArray[i] is of S,00 or SS,00 or SS"any"00 in ScanType() or FinalScan()
+ BOOL Is100SecZero( USHORT i, BOOL bHadDecSep );
+
+ short Next_Symbol(const String& rStr,
+ xub_StrLen& nPos,
+ String& sSymbol); // Naechstes Symbol
+ xub_StrLen Symbol_Division(const String& rString);// lexikalische Voranalyse
+ xub_StrLen ScanType(const String& rString); // Analyse des Formattyps
+ xub_StrLen FinalScan( String& rString, String& rComment ); // Endanalyse mit Vorgabe
+ // des Typs
+ // -1:= error, return nPos in FinalScan; 0:= no calendar, 1:= calendar found
+ int FinalScanGetCalendar( xub_StrLen& nPos, USHORT& i, USHORT& nAnzResStrings );
+
+ static inline BOOL StringEqualsChar( const String& rStr, sal_Unicode ch )
+ { return rStr.GetChar(0) == ch && rStr.Len() == 1; }
+ // Yes, for efficiency get the character first and then compare length
+ // because in most places where this is used the string is one char.
+
+ // remove "..." and \... quotes from rStr, return how many chars removed
+ static xub_StrLen RemoveQuotes( String& rStr );
+
+#endif //_ZFORSCAN_CXX
+};
+
+}
+
+#endif // _ZFORSCAN_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/svdde/ddeimp.hxx b/binfilter/bf_svtools/source/svdde/ddeimp.hxx
new file mode 100644
index 000000000000..17e5ae1eb037
--- /dev/null
+++ b/binfilter/bf_svtools/source/svdde/ddeimp.hxx
@@ -0,0 +1,186 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 _DDEIMP_HXX
+#define _DDEIMP_HXX
+
+#ifdef OS2
+
+#include "ddemlos2.h"
+
+#define WORD USHORT
+#define DWORD ULONG
+#define LPBYTE BYTE*
+#define LPWORD USHORT*
+#define LPDWORD ULONG*
+#define LPCTSTR PCSZ
+
+#else
+
+#include <tools/prewin.h>
+#include <ddeml.h>
+#include <tools/postwin.h>
+#include "ddewrap.hxx"
+
+/*
+extern "C"
+{
+#define BOOL WIN_BOOL
+#define BYTE WIN_BYTE
+#undef BOOL
+#undef BYTE
+};
+*/
+
+#endif
+
+#include <tools/string.hxx>
+#include <tools/list.hxx>
+#include <tools/shl.hxx>
+
+namespace binfilter
+{
+
+class DdeService;
+class DdeTopic;
+class DdeItem;
+class DdeTopics;
+class DdeItems;
+
+// ----------------
+// - Conversation -
+// ----------------
+
+struct Conversation
+{
+ HCONV hConv;
+ DdeTopic* pTopic;
+};
+
+DECLARE_LIST( ConvList, Conversation* );
+
+// ---------------
+// - DdeInternal -
+// ---------------
+
+class DdeInternal
+{
+public:
+#ifdef WNT
+ static HDDEDATA CALLBACK CliCallback
+ ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD );
+ static HDDEDATA CALLBACK SvrCallback
+ ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD );
+ static HDDEDATA CALLBACK InfCallback
+ ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD );
+#else
+#if defined ( MTW ) || ( defined ( GCC ) && defined ( OS2 )) || defined( ICC )
+ static HDDEDATA CALLBACK __EXPORT CliCallback
+ ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD );
+ static HDDEDATA CALLBACK __EXPORT SvrCallback
+ ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD );
+ static HDDEDATA CALLBACK __EXPORT InfCallback
+ ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD );
+#else
+ static HDDEDATA CALLBACK _export CliCallback
+ ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD );
+ static HDDEDATA CALLBACK _export SvrCallback
+ ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD );
+ static HDDEDATA CALLBACK _export InfCallback
+ ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD );
+#endif
+#endif
+ static DdeService* FindService( HSZ );
+ static DdeTopic* FindTopic( DdeService&, HSZ );
+ static DdeItem* FindItem( DdeTopic&, HSZ );
+};
+
+// -------------
+// - DdeString -
+// -------------
+
+class DdeString : public String
+{
+protected:
+ HSZ hString;
+ DWORD hInst;
+
+public:
+ DdeString( DWORD, const sal_Unicode* );
+ DdeString( DWORD, const String& );
+ ~DdeString();
+
+ int operator==( HSZ );
+ operator HSZ();
+};
+
+// --------------
+// - DdeDataImp -
+// --------------
+
+struct DdeDataImp
+{
+ HDDEDATA hData;
+ LPBYTE pData;
+ long nData;
+ ULONG nFmt;
+};
+
+class DdeConnections;
+class DdeServices;
+
+struct DdeInstData
+{
+ USHORT nRefCount;
+ DdeConnections* pConnections;
+ // Server
+ long hCurConvSvr;
+ ULONG hDdeInstSvr;
+ short nInstanceSvr;
+ DdeServices* pServicesSvr;
+ // Client
+ ULONG hDdeInstCli;
+ short nInstanceCli;
+};
+
+#ifndef SHL_SVDDE
+#define SHL_SVDDE SHL_SHL2
+#endif
+
+inline DdeInstData* ImpGetInstData()
+{
+ return (DdeInstData*)(*GetAppData( SHL_SVDDE ));
+}
+DdeInstData* ImpInitInstData();
+void ImpDeinitInstData();
+
+}
+
+#endif // _DDEIMP_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/svdde/ddemldeb.hxx b/binfilter/bf_svtools/source/svdde/ddemldeb.hxx
new file mode 100644
index 000000000000..7bf9429961d2
--- /dev/null
+++ b/binfilter/bf_svtools/source/svdde/ddemldeb.hxx
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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.
+ *
+ ************************************************************************/
+
+namespace binfilter
+{
+
+#if defined(OV_DEBUG)
+
+void ImpWriteLogFile(char*,char*);
+void ImpAddHSZ( HSZ, String& );
+void ImpWriteDdeStatus(char*, char* );
+void ImpWriteDdeData(char*, DDESTRUCT*);
+
+#ifdef LOGFILE
+#define WRITELOG(aString) ImpWriteLogFile("\\ddeml.log",aString);
+#else
+#define WRITELOG(bla)
+#endif
+#ifdef STATUSFILE
+#define WRITESTATUS(aContext) ImpWriteDdeStatus("\\ddeml.sts",aContext);
+#else
+#define WRITESTATUS(bla)
+#endif
+#ifdef DDEDATAFILE
+#define WRITEDATA(data) ImpWriteDdeData("\\ddeml.dat",data);
+#else
+#define WRITEDATA(bla)
+#endif
+
+#else
+
+#define WRITELOG(bla)
+#define WRITESTATUS(bla)
+#define WRITEDATA(bla)
+
+#endif
+
+APIRET MyDosAllocSharedMem(void** ppBaseAddress, char* pszName, unsigned long ulObjectSize,
+ unsigned long ulFlags, char* pContextStr );
+
+APIRET MyDosAllocMem(void** ppBaseAddress, unsigned long ulObjectSize,
+ unsigned long ulFlags, char* pContextStr );
+
+APIRET MyDosFreeMem( void* pBaseAddress, char* pContextStr );
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/svdde/ddemlimp.hxx b/binfilter/bf_svtools/source/svdde/ddemlimp.hxx
new file mode 100644
index 000000000000..775f3a7df34f
--- /dev/null
+++ b/binfilter/bf_svtools/source/svdde/ddemlimp.hxx
@@ -0,0 +1,438 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 _DDEMLIMP_HXX
+#define _DDEMLIMP_HXX
+
+
+#include <string.h>
+#include <ctype.h>
+#include "ddemlos2.h"
+
+namespace binfilter
+{
+
+#define DDEMLSERVICETABLE_INISIZE 8
+
+// Bezeichner der systemglobalen DDEML-Tabelle
+#define DDEMLDATA "\\SHAREMEM\\OV_DDEML.DAT"
+
+// vorlaeufig konstante Tabellengroessen
+#define CONVTABLECOUNT 2048 /* max count conversations */
+#define TRANSTABLECOUNT 2048 /* transactions */
+#define DDEMLAPPCOUNT 16 /* max count simultaniously running */
+ /* ddeml (StarDivision) applications */
+
+#define ST_TERMACKREC 0x8000 /* wird im Conversationhandle gesetzt, */
+ /* wenn die Partner-App DDE_TERMINATE */
+ /* bestaetigt hat */
+
+#define XST_TIMEOUT 17 /* Trans. hat Timeout ueberschritten */
+#define XST_WAITING_ACK 18 /* Trans. wartet auf Acknowledge */
+#define XST_WAITING_ADVDATA 19 /* Trans. wartet auf Advise-Daten */
+#define XST_WAITING_REQDATA 20 /* Trans. wartet auf angeforderte Daten */
+
+
+/* User-Flags DDESTRUCT */
+#define IMP_HDATAAPPOWNED 0x8000
+
+#define CONVLISTNAME "DdeConvListId"
+
+#define XTYPF_MASK (XTYPF_NOBLOCK | XTYPF_NODATA | XTYPF_ACKREQ)
+
+//
+// DDEML-Messages; werden nur an registrierte DDEML-Apps gesendet
+//
+
+// Msg: WM_DDEML_REGISTER
+// Empfaenger: wird allen DDEML-Applikationen nach Registrierung
+// eines neuen Services gesendet
+// Params: nPar1: hszBaseServName
+// nPar2: hszInstServName
+#define WM_DDEML_REGISTER WM_USER+1
+
+// Msg: WM_DDEML_UNREGISTER
+// Empfaenger: wird allen DDEML-Applikationen nach Deregistrierung
+// eines Services gesendet
+// Params: nPar1: hszBaseServName
+// nPar2: hszInstServName
+#define WM_DDEML_UNREGISTER WM_USER+2
+
+//
+//
+//
+
+struct ImpHCONV
+{
+ HCONV hConvPartner;
+ HSZ hszPartner; // Name of partner application
+ HSZ hszServiceReq; // Service name
+ HSZ hszTopic; // Topic name
+ USHORT nStatus; // ST_* of conversation
+ HCONVLIST hConvList; // ConvListId , wenn in ConvList
+ CONVCONTEXT aConvContext; // Conversation context
+
+ // private
+ HWND hWndThis; // 0 == Handle not used
+ HWND hWndPartner;
+ PID pidOwner; // PID des DdeManagers, der
+ // den Conv-Handle erzeugt hat.
+ USHORT nPrevHCONV; // 0 == no previous hConv or not in list
+ USHORT nNextHCONV; // 0 == no next hconv or not in list
+};
+
+struct Transaction
+{
+ HSZ hszItem; // Item name
+ USHORT nFormat; // Data format
+ USHORT nType; // Transaction type (XTYP_*)
+ // XTYP_ADVREQ [|XTYPF_NODATA] == Advise-Loop
+ // [|XTYPF_ACKREQ]
+ // XTYP_EXECUTE == laufendes Execute
+ // XTYP_REQUEST
+ // XTYP_POKE
+ // XTYP_ADVSTOP
+ // XTYP_ADVSTART
+ USHORT nConvst; // Conversation state (XST_*)
+ // 0 == idle
+ // XST_REQSENT (fuer XTYP_ADVREQ)
+ // XST_TIMEOUT (fuer alle Typen!)
+ // XST_WAITING (alle ausser XTYP_ADVREQ)
+ USHORT nLastError; // last err in transaction
+ ULONG nUser; // Userhandle
+ // private
+ HCONV hConvOwner; // 0 == Transaction not used
+};
+
+
+struct ImpWndProcParams
+{
+ HWND hWndReceiver;
+ MPARAM nPar1;
+ MPARAM nPar2;
+};
+
+struct ImpService
+{
+ HSZ hBaseServName; // Basis-Name des Service
+ HSZ hInstServName; // Basis-Name + DDEML-Server-HWND der App
+};
+
+class ImpDdeMgr;
+
+// Daten eines Conversation-Windows
+struct ImpConvWndData
+{
+ ImpDdeMgr* pThis;
+ USHORT nRefCount; // Zahl Conversations auf diesem Window
+};
+
+
+// systemglobale Daten der Library (liegen in named shared memory)
+struct ImpDdeMgrData
+{
+ ULONG nTotalSize;
+ ULONG nOffsAppTable;
+ ULONG nOffsConvTable;
+ ULONG nOffsTransTable;
+ USHORT nMaxAppCount;
+ USHORT nMaxConvCount;
+ USHORT nMaxTransCount;
+ USHORT nLastErr;
+ USHORT nReserved;
+ USHORT nCurTransCount;
+ USHORT nCurConvCount;
+ HWND aAppTable[ 1 ]; // fuer Broadcast-Messages
+ ImpHCONV aConvTable[ 1 ];
+ Transaction aTransTable[ 1 ];
+};
+
+
+
+class ImpDdeMgr
+{
+ friend MRESULT EXPENTRY ConvWndProc(HWND hWnd,ULONG nMsg,MPARAM nPar1,MPARAM nPar2);
+ friend MRESULT EXPENTRY ServerWndProc(HWND hWnd,ULONG nMsg,MPARAM nPar1,MPARAM nPar2);
+ friend void ImpWriteDdeStatus(char*,char*);
+ friend void ImpAddHSZ( HSZ, String& );
+
+ static PSZ AllocAtomName( ATOM hString, ULONG& rBufLen );
+ static PDDESTRUCT MakeDDEObject( HWND hwnd, ATOM hItemName,
+ USHORT fsStatus, USHORT usFormat, PVOID pabData, ULONG usDataLen );
+ static APIRET AllocNamedSharedMem( PPVOID ppBaseAddress, PSZ pName,
+ ULONG nElementSize, ULONG nElementCount );
+
+ HWND hWndServer;
+ PID pidThis;
+ PFNCALLBACK pCallback;
+ ULONG nTransactFilter;
+ CONVCONTEXT aDefaultContext;
+ ImpDdeMgrData* pData;
+ ImpService* pServices;
+ USHORT nServiceCount;
+
+ ImpHCONV* pConvTable; // liegt in pData (nicht deleten!)
+ Transaction* pTransTable; // liegt in pData (nicht deleten!)
+ HWND* pAppTable; // liegt in pData (nicht deleten!)
+
+ static ImpHCONV* GetConvTable( ImpDdeMgrData* );
+ static Transaction* GetTransTable( ImpDdeMgrData* );
+ static HWND* GetAppTable( ImpDdeMgrData* );
+
+
+ static HWND NextFrameWin( HENUM hEnum );
+ void CreateServerWnd();
+ void DestroyServerWnd();
+ HWND CreateConversationWnd();
+ // Fktn. duerfen nur fuer HCONVs aufgerufen werden, die
+ // in der eigenen Applikation erzeugt wurden
+ static void DestroyConversationWnd( HWND hWndConv );
+ static USHORT GetConversationWndRefCount( HWND hWndConv );
+ static USHORT IncConversationWndRefCount( HWND hWndConv );
+
+ MRESULT SrvWndProc(HWND hWnd,ULONG nMsg,MPARAM nPar1,MPARAM nPar2);
+ MRESULT ConvWndProc(HWND hWnd,ULONG nMsg,MPARAM nPar1,MPARAM nPar2);
+ void RegisterDDEMLApp();
+ void UnregisterDDEMLApp();
+ void CleanUp();
+ ImpDdeMgrData* InitAll();
+ static BOOL MyWinDdePostMsg( HWND, HWND, USHORT, PDDESTRUCT, ULONG );
+ void MyInitiateDde( HWND hWndServer, HWND hWndClient,
+ HSZ hszService, HSZ hszTopic, CONVCONTEXT* pCC );
+ DDEINIT* CreateDDEInitData( HWND hWndDest, HSZ hszService,
+ HSZ hszTopic, CONVCONTEXT* pCC );
+ // wenn pDDEData==0, muss pCC gesetzt sein
+ HCONV ConnectWithClient( HWND hWndClient, HSZ hszPartner,
+ HSZ hszService, HSZ hszTopic, BOOL bSameInst,
+ DDEINIT* pDDEData, CONVCONTEXT* pCC = 0);
+
+ HCONV CheckIncoming( ImpWndProcParams*, ULONG nTransMask,
+ HSZ& rhszItem );
+ // fuer Serverbetrieb. Ruft Callback-Fkt fuer alle offenen Advises
+ // auf, deren Owner der uebergebene HCONV ist.
+ // bFreeTransactions==TRUE: loescht die Transaktionen
+ // gibt Anzahl der getrennten Transaktionen zurueck
+ USHORT SendUnadvises( HCONV hConv,
+ USHORT nFormat, // 0==alle
+ BOOL bFreeTransactions );
+
+ BOOL WaitTransState(
+ Transaction* pTrans, ULONG nTransId,
+ USHORT nNewState,
+ ULONG nTimeout );
+
+ // DDEML ruft Callback mit XTYP_CONNECT-Transaction nur auf,
+ // wenn die App den angeforderten Service registriert hat
+ // Standardeinstellung: TRUE
+ BOOL bServFilterOn;
+
+ // Fehlercode muss noch systemglobal werden (Atom o. ae.)
+ static USHORT nLastErrInstance; // wenn 0, dann gilt globaler Fehlercode
+
+ static ImpDdeMgrData* AccessMgrData();
+
+ static HCONV CreateConvHandle( ImpDdeMgrData* pBase,
+ PID pidOwner,
+ HWND hWndThis, HWND hWndPartner,
+ HSZ hszPartner, HSZ hszServiceReq, HSZ hszTopic,
+ HCONV hPrevHCONV = 0 );
+
+ static HCONV IsConvHandleAvailable( ImpDdeMgrData* pBase );
+ static HCONV GetConvHandle( ImpDdeMgrData* pBase,
+ HWND hWndThis, HWND hWndPartner );
+ static void FreeConvHandle( ImpDdeMgrData*, HCONV,
+ BOOL bDestroyHWndThis = TRUE );
+
+ static ULONG CreateTransaction( ImpDdeMgrData* pBase,
+ HCONV hOwner, HSZ hszItem, USHORT nFormat,
+ USHORT nTransactionType );
+ static ULONG GetTransaction( ImpDdeMgrData* pBase,
+ HCONV hOwner, HSZ hszItem, USHORT nFormat );
+
+ static void FreeTransaction( ImpDdeMgrData*, ULONG nTransId );
+
+ BOOL DisconnectAll();
+ // Transaktionen muessen _vor_ den Konversationen geloescht werden!
+ static void FreeTransactions( ImpDdeMgrData*, HWND hWndThis,
+ HWND hWndPartner );
+ static void FreeTransactions( ImpDdeMgrData*, HCONV hConvOwner );
+
+ static void FreeConversations( ImpDdeMgrData*,HWND hWndThis,
+ HWND hWndPartner );
+
+ ImpService* GetService( HSZ hszService );
+ ImpService* PutService( HSZ hszService );
+ void BroadcastService( ImpService*, BOOL bRegistered );
+
+ // rh: Startposition(!) & gefundener Handle
+ static ImpHCONV* GetFirstServer( ImpDdeMgrData*, HCONVLIST, HCONV& rh);
+ static ImpHCONV* GetLastServer( ImpDdeMgrData*, HCONVLIST, HCONV& );
+ static BOOL CheckConvListId( HCONVLIST hConvListId );
+
+ BOOL IsSameInstance( HWND hWnd );
+ HSZ GetAppName( HWND hWnd );
+
+
+ // Transactions
+ MRESULT DdeAck( ImpWndProcParams* pParams );
+ MRESULT DdeAdvise( ImpWndProcParams* pParams );
+ MRESULT DdeData( ImpWndProcParams* pParams );
+ MRESULT DdeExecute( ImpWndProcParams* pParams );
+ MRESULT DdeInitiate( ImpWndProcParams* pParams );
+ MRESULT DdeInitiateAck( ImpWndProcParams* pParams );
+ MRESULT DdePoke( ImpWndProcParams* pParams );
+ MRESULT DdeRequest( ImpWndProcParams* pParams );
+ MRESULT DdeTerminate( ImpWndProcParams* pParams );
+ MRESULT DdeUnadvise( ImpWndProcParams* pParams );
+ MRESULT DdeRegister( ImpWndProcParams* pParams );
+ MRESULT DdeUnregister( ImpWndProcParams* pParams );
+ MRESULT DdeTimeout( ImpWndProcParams* pParams );
+
+ HDDEDATA Callback(
+ USHORT nTransactionType,
+ USHORT nClipboardFormat,
+ HCONV hConversationHandle,
+ HSZ hsz1,
+ HSZ hsz2,
+ HDDEDATA hData,
+ ULONG nData1,
+ ULONG nData2 );
+
+ HCONV DdeConnectImp( HSZ hszService,HSZ hszTopic,CONVCONTEXT* pCC);
+
+ // connection data
+ HCONV hCurConv; // wird im DdeInitiateAck gesetzt
+ HCONVLIST hCurListId; // fuer DdeConnectList
+ USHORT nPrevConv; // .... "" ....
+ BOOL bListConnect;
+
+ // synchr. transaction data
+ BOOL bInSyncTrans;
+ ULONG nSyncTransId;
+ HDDEDATA hSyncResponseData;
+ ULONG nSyncResponseMsg; // WM_DDE_ACK, WM_DDE_DATA, WM_TIMER
+ // TRUE==nach Ende der synchronen Transaktion eine evtl. benutzte
+ // asynchrone Transaktion beenden (typisch synchroner Request auf
+ // Advise-Loop)
+ BOOL bSyncAbandonTrans;
+
+public:
+ ImpDdeMgr();
+ ~ImpDdeMgr();
+
+ USHORT DdeInitialize( PFNCALLBACK pCallbackProc, ULONG nTransactionFilter );
+ USHORT DdeGetLastError();
+
+ HCONV DdeConnect( HSZ hszService, HSZ hszTopic, CONVCONTEXT* );
+ HCONVLIST DdeConnectList( HSZ hszService, HSZ hszTopic,
+ HCONVLIST hConvList, CONVCONTEXT* );
+ static BOOL DdeDisconnect( HCONV hConv );
+ static BOOL DdeDisconnectList( HCONVLIST hConvList );
+ static HCONV DdeReconnect(HCONV hConv);
+ static HCONV DdeQueryNextServer(HCONVLIST hConvList, HCONV hConvPrev);
+ static USHORT DdeQueryConvInfo(HCONV hConv, ULONG idTrans,CONVINFO* pCI);
+ static BOOL DdeSetUserHandle(HCONV hConv, ULONG id, ULONG hUser);
+ BOOL DdeAbandonTransaction( HCONV hConv, ULONG idTransaction);
+
+ BOOL DdePostAdvise( HSZ hszTopic, HSZ hszItem);
+ BOOL DdeEnableCallback( HCONV hConv, USHORT wCmd);
+
+ HDDEDATA DdeNameService( HSZ hszService, USHORT afCmd);
+
+ static HDDEDATA DdeClientTransaction(void* pData, ULONG cbData,
+ HCONV hConv, HSZ hszItem, USHORT wFmt, USHORT wType,
+ ULONG dwTimeout, ULONG* pdwResult);
+
+ // Data handles
+
+ HDDEDATA DdeCreateDataHandle( void* pSrc, ULONG cb, ULONG cbOff,
+ HSZ hszItem, USHORT wFmt, USHORT afCmd);
+ static BYTE* DdeAccessData(HDDEDATA hData, ULONG* pcbDataSize);
+ static BOOL DdeUnaccessData(HDDEDATA hData);
+ static BOOL DdeFreeDataHandle(HDDEDATA hData);
+ static HDDEDATA DdeAddData(HDDEDATA hData,void* pSrc,ULONG cb,ULONG cbOff);
+ static ULONG DdeGetData(HDDEDATA hData,void* pDst,ULONG cbMax,ULONG cbOff);
+
+ // String handles
+
+ static HSZ DdeCreateStringHandle( PSZ pStr, int iCodePage);
+ static ULONG DdeQueryString(HSZ hsz,PSZ pStr,ULONG cchMax,int iCPage);
+ static BOOL DdeFreeStringHandle( HSZ hsz );
+ static BOOL DdeKeepStringHandle( HSZ hsz );
+ static int DdeCmpStringHandles(HSZ hsz1, HSZ hsz2);
+
+ // mit dieser Funktion kann geprueft werden, ob eine
+ // Applikation schon eine DDEML-Instanz angelegt hat.
+ // Die aktuelle Impl. unterstuetzt nur eine DDEML-Instanz
+ // pro Applikation (wg. synchroner Transaktionen)
+ static ImpDdeMgr* GetImpDdeMgrInstance( HWND hWnd );
+
+ // gibt TRUE zurueck, wenn mind. ein lebender HCONV
+ // von diesem DdeMgr erzeugt wurde
+ BOOL OwnsConversationHandles();
+};
+
+// static
+inline ImpHCONV* ImpDdeMgr::GetConvTable( ImpDdeMgrData* pData )
+{
+ ImpHCONV* pRet;
+ if( pData )
+ pRet = (ImpHCONV*)((ULONG)(pData) + pData->nOffsConvTable);
+ else
+ pRet = 0;
+ return pRet;
+}
+
+// static
+inline Transaction* ImpDdeMgr::GetTransTable( ImpDdeMgrData* pData )
+{
+ Transaction* pRet;
+ if( pData )
+ pRet = (Transaction*)((ULONG)(pData) + pData->nOffsTransTable);
+ else
+ pRet = 0;
+ return pRet;
+}
+
+// static
+inline HWND* ImpDdeMgr::GetAppTable( ImpDdeMgrData* pData )
+{
+ HWND* pRet;
+ if( pData )
+ pRet = (HWND*)((ULONG)(pData) + pData->nOffsAppTable);
+ else
+ pRet = 0;
+ return pRet;
+}
+
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/svdde/ddemlos2.h b/binfilter/bf_svtools/source/svdde/ddemlos2.h
new file mode 100644
index 000000000000..1c017ac21540
--- /dev/null
+++ b/binfilter/bf_svtools/source/svdde/ddemlos2.h
@@ -0,0 +1,381 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 _DDEML_H
+#define _DDEML_H
+
+#define INCL_OS2
+#define INCL_WIN
+
+#include <tools/svpm.h>
+#include <tools/solar.h>
+#include <tools/debug.hxx>
+#include <tools/stream.hxx>
+
+namespace binfilter
+{
+
+typedef LHANDLE HSTR;
+
+#ifndef CALLBACK
+#define CALLBACK
+#endif
+
+
+typedef ULONG HCONVLIST;
+typedef ULONG HCONV;
+typedef ATOM HSZ;
+typedef DDESTRUCT* HDDEDATA;
+
+struct CONVINFO
+{
+ USHORT nSize; // sizeof(CONVINFO)
+ ULONG nUser; // Userhandle
+ HCONV hConvPartner; //
+ HSZ hszPartner; // Name der Partnerapp
+ HSZ hszServiceReq; // Name des angeforderten Services
+ HSZ hszTopic; // -- " -- Topics
+ HSZ hszItem; // -- " -- Items
+ USHORT nFormat; // Datenformat der akt. Transaktion
+ USHORT nType; // Typ der akt. Transaktion (XTYP_*)
+ USHORT nStatus; // ST_* der Konversation
+ USHORT nConvst; // XST_* der akt. Transaktion
+ USHORT nLastError; // letzter Fehler der Transaktion
+ HCONVLIST hConvList; // ConvListId , wenn in ConvList
+ CONVCONTEXT aConvCtxt; // conversation context
+};
+
+/* the following structure is for use with XTYP_WILDCONNECT processing. */
+
+struct HSZPAIR
+{
+ HSZ hszSvc;
+ HSZ hszTopic;
+};
+typedef HSZPAIR *PHSZPAIR;
+
+/***** conversation states (usState) *****/
+
+#define XST_NULL 0 /* quiescent states */
+#define XST_INCOMPLETE 1
+#define XST_CONNECTED 2
+#define XST_INIT1 3 /* mid-initiation states */
+#define XST_INIT2 4
+#define XST_REQSENT 5 /* active conversation states */
+#define XST_DATARCVD 6
+#define XST_POKESENT 7
+#define XST_POKEACKRCVD 8
+#define XST_EXECSENT 9
+#define XST_EXECACKRCVD 10
+#define XST_ADVSENT 11
+#define XST_UNADVSENT 12
+#define XST_ADVACKRCVD 13
+#define XST_UNADVACKRCVD 14
+#define XST_ADVDATASENT 15
+#define XST_ADVDATAACKRCVD 16
+
+/* used in LOWORD(dwData1) of XTYP_ADVREQ callbacks... */
+#define CADV_LATEACK 0xFFFF
+
+/***** conversation status bits (fsStatus) *****/
+
+#define ST_CONNECTED 0x0001
+#define ST_ADVISE 0x0002
+#define ST_ISLOCAL 0x0004
+#define ST_BLOCKED 0x0008
+#define ST_CLIENT 0x0010
+#define ST_TERMINATED 0x0020
+#define ST_INLIST 0x0040
+#define ST_BLOCKNEXT 0x0080
+#define ST_ISSELF 0x0100
+
+
+/* DDE constants for wStatus field */
+
+//#define DDE_FACK 0x8000
+//#define DDE_FBUSY 0x4000
+//#define DDE_FDEFERUPD 0x4000
+//#define DDE_FACKREQ 0x8000
+//#define DDE_FRELEASE 0x2000
+//#define DDE_FREQUESTED 0x1000
+//#define DDE_FACKRESERVED 0x3ff0
+//#define DDE_FADVRESERVED 0x3fff
+//#define DDE_FDATRESERVED 0x4fff
+//#define DDE_FPOKRESERVED 0xdfff
+//#define DDE_FAPPSTATUS 0x00ff
+#define DDE_FNOTPROCESSED 0x0000
+
+/***** message filter hook types *****/
+
+#define MSGF_DDEMGR 0x8001
+
+/***** codepage constants ****/
+
+#define CP_WINANSI 1004 /* default codepage for windows & old DDE convs. */
+
+/***** transaction types *****/
+
+#define XTYPF_NOBLOCK 0x0002 /* CBR_BLOCK will not work */
+#define XTYPF_NODATA 0x0004 /* DDE_FDEFERUPD */
+#define XTYPF_ACKREQ 0x0008 /* DDE_FACKREQ */
+
+#define XCLASS_MASK 0xFC00
+#define XCLASS_BOOL 0x1000
+#define XCLASS_DATA 0x2000
+#define XCLASS_FLAGS 0x4000
+#define XCLASS_NOTIFICATION 0x8000
+
+#define XTYP_ERROR (0x0000 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK )
+#define XTYP_ADVDATA (0x0010 | XCLASS_FLAGS )
+#define XTYP_ADVREQ (0x0020 | XCLASS_DATA | XTYPF_NOBLOCK )
+#define XTYP_ADVSTART (0x0030 | XCLASS_BOOL )
+#define XTYP_ADVSTOP (0x0040 | XCLASS_NOTIFICATION)
+#define XTYP_EXECUTE (0x0050 | XCLASS_FLAGS )
+#define XTYP_CONNECT (0x0060 | XCLASS_BOOL | XTYPF_NOBLOCK)
+#define XTYP_CONNECT_CONFIRM (0x0070 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK)
+#define XTYP_XACT_COMPLETE (0x0080 | XCLASS_NOTIFICATION )
+#define XTYP_POKE (0x0090 | XCLASS_FLAGS )
+#define XTYP_REGISTER (0x00A0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK)
+#define XTYP_REQUEST (0x00B0 | XCLASS_DATA )
+#define XTYP_DISCONNECT (0x00C0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK)
+#define XTYP_UNREGISTER (0x00D0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK)
+#define XTYP_WILDCONNECT (0x00E0 | XCLASS_DATA | XTYPF_NOBLOCK)
+
+#define XTYP_MASK 0x00F0
+#define XTYP_SHIFT 4 /* shift to turn XTYP_ into an index */
+
+/***** Timeout constants *****/
+
+#define TIMEOUT_ASYNC -1L
+
+/***** Transaction ID constants *****/
+
+#define QID_SYNC -1L
+
+/****** public strings used in DDE ******/
+
+#define SZDDESYS_TOPIC "System"
+#define SZDDESYS_ITEM_TOPICS "Topics"
+#define SZDDESYS_ITEM_SYSITEMS "SysItems"
+#define SZDDESYS_ITEM_RTNMSG "ReturnMessage"
+#define SZDDESYS_ITEM_STATUS "Status"
+#define SZDDESYS_ITEM_FORMATS "Formats"
+#define SZDDESYS_ITEM_HELP "Help"
+#define SZDDE_ITEM_ITEMLIST "TopicItemList"
+
+
+/****** API entry points ******/
+
+typedef HDDEDATA CALLBACK FNCALLBACK(USHORT wType, USHORT wFmt, HCONV hConv,
+ HSZ hsz1, HSZ hsz2, HDDEDATA hData, ULONG dwData1, ULONG dwData2);
+typedef FNCALLBACK* PFNCALLBACK;
+
+#define CBR_BLOCK 0xffffffffL
+
+/* DLL registration functions */
+
+USHORT DdeInitialize(ULONG* pidInst, PFNCALLBACK pfnCallback,
+ ULONG afCmd, ULONG ulRes);
+
+/*
+ * Callback filter flags for use with standard apps.
+ */
+
+#define CBF_FAIL_SELFCONNECTIONS 0x00001000
+#define CBF_FAIL_CONNECTIONS 0x00002000
+#define CBF_FAIL_ADVISES 0x00004000
+#define CBF_FAIL_EXECUTES 0x00008000
+#define CBF_FAIL_POKES 0x00010000
+#define CBF_FAIL_REQUESTS 0x00020000
+#define CBF_FAIL_ALLSVRXACTIONS 0x0003f000
+
+#define CBF_SKIP_CONNECT_CONFIRMS 0x00040000
+#define CBF_SKIP_REGISTRATIONS 0x00080000
+#define CBF_SKIP_UNREGISTRATIONS 0x00100000
+#define CBF_SKIP_DISCONNECTS 0x00200000
+#define CBF_SKIP_ALLNOTIFICATIONS 0x003c0000
+
+/*
+ * Application command flags
+ */
+#define APPCMD_CLIENTONLY 0x00000010L
+#define APPCMD_FILTERINITS 0x00000020L
+#define APPCMD_MASK 0x00000FF0L
+
+/*
+ * Application classification flags
+ */
+#define APPCLASS_STANDARD 0x00000000L
+#define APPCLASS_MASK 0x0000000FL
+
+
+BOOL DdeUninitialize(ULONG idInst);
+
+/* conversation enumeration functions */
+
+HCONVLIST DdeConnectList(ULONG idInst, HSZ hszService, HSZ hszTopic,
+ HCONVLIST hConvList, CONVCONTEXT* pCC);
+HCONV DdeQueryNextServer(HCONVLIST hConvList, HCONV hConvPrev);
+BOOL DdeDisconnectList(HCONVLIST hConvList);
+
+/* conversation control functions */
+
+HCONV DdeConnect(ULONG idInst, HSZ hszService, HSZ hszTopic,
+ CONVCONTEXT* pCC);
+BOOL DdeDisconnect(HCONV hConv);
+HCONV DdeReconnect(HCONV hConv);
+
+USHORT DdeQueryConvInfo(HCONV hConv, ULONG idTransaction, CONVINFO* pConvInfo);
+BOOL DdeSetUserHandle(HCONV hConv, ULONG id, ULONG hUser);
+
+BOOL DdeAbandonTransaction(ULONG idInst, HCONV hConv, ULONG idTransaction);
+
+
+/* app server interface functions */
+
+BOOL DdePostAdvise(ULONG idInst, HSZ hszTopic, HSZ hszItem);
+BOOL DdeEnableCallback(ULONG idInst, HCONV hConv, USHORT wCmd);
+
+#define EC_ENABLEALL 0
+#define EC_ENABLEONE ST_BLOCKNEXT
+#define EC_DISABLE ST_BLOCKED
+#define EC_QUERYWAITING 2
+
+HDDEDATA DdeNameService(ULONG idInst, HSZ hsz1, HSZ hsz2, USHORT afCmd);
+
+#define DNS_REGISTER 0x0001
+#define DNS_UNREGISTER 0x0002
+#define DNS_FILTERON 0x0004
+#define DNS_FILTEROFF 0x0008
+
+/* app client interface functions */
+
+HDDEDATA DdeClientTransaction(void* pData, ULONG cbData,
+ HCONV hConv, HSZ hszItem, USHORT wFmt, USHORT wType,
+ ULONG dwTimeout, ULONG* pdwResult);
+
+/* data transfer functions */
+
+HDDEDATA DdeCreateDataHandle(ULONG idInst, void* pSrc, ULONG cb,
+ ULONG cbOff, HSZ hszItem, USHORT wFmt, USHORT afCmd);
+// HDDEDATA DdeAddData(HDDEDATA hData, void* pSrc, ULONG cb, ULONG cbOff);
+ULONG DdeGetData(HDDEDATA hData, void* pDst, ULONG cbMax, ULONG cbOff);
+BYTE* DdeAccessData(HDDEDATA hData, ULONG* pcbDataSize);
+BOOL DdeUnaccessData(HDDEDATA hData);
+BOOL DdeFreeDataHandle(HDDEDATA hData);
+
+#define HDATA_APPOWNED 0x0001
+
+USHORT DdeGetLastError(ULONG idInst);
+
+#define DMLERR_NO_ERROR 0 /* must be 0 */
+
+#define DMLERR_FIRST 0x4000
+
+#define DMLERR_ADVACKTIMEOUT 0x4000
+#define DMLERR_BUSY 0x4001
+#define DMLERR_DATAACKTIMEOUT 0x4002
+#define DMLERR_DLL_NOT_INITIALIZED 0x4003
+#define DMLERR_DLL_USAGE 0x4004
+#define DMLERR_EXECACKTIMEOUT 0x4005
+#define DMLERR_INVALIDPARAMETER 0x4006
+#define DMLERR_LOW_MEMORY 0x4007
+#define DMLERR_MEMORY_ERROR 0x4008
+#define DMLERR_NOTPROCESSED 0x4009
+#define DMLERR_NO_CONV_ESTABLISHED 0x400a
+#define DMLERR_POKEACKTIMEOUT 0x400b
+#define DMLERR_POSTMSG_FAILED 0x400c
+#define DMLERR_REENTRANCY 0x400d
+#define DMLERR_SERVER_DIED 0x400e
+#define DMLERR_SYS_ERROR 0x400f
+#define DMLERR_UNADVACKTIMEOUT 0x4010
+#define DMLERR_UNFOUND_QUEUE_ID 0x4011
+
+#define DMLERR_LAST 0x4011
+
+HSZ DdeCreateStringHandle(ULONG idInst, PSZ pStr, int iCodePage);
+ULONG DdeQueryString(ULONG idInst, HSZ hsz, PSZ pStr, ULONG cchMax,
+ int iCodePage);
+BOOL DdeFreeStringHandle(ULONG idInst, HSZ hsz);
+BOOL DdeKeepStringHandle(ULONG idInst, HSZ hsz);
+int DdeCmpStringHandles(HSZ hsz1, HSZ hsz2);
+
+
+
+/* von OS/2 nicht unterstuetzte Win3.1 Clipboard-Formate */
+
+#define CF_NOTSUPPORTED_BASE 0xff00
+
+#ifndef CF_DIB
+#define CF_DIB CF_NOTSUPPORTED_BASE+1
+#endif
+
+#ifndef CF_DIF
+#define CF_DIF CF_NOTSUPPORTED_BASE+2
+#endif
+
+#ifndef CF_DSPMETAFILEPICT
+#define CF_DSPMETAFILEPICT CF_NOTSUPPORTED_BASE+3
+#endif
+
+#ifndef CF_METAFILEPICT
+#define CF_METAFILEPICT CF_NOTSUPPORTED_BASE+4
+#endif
+
+#ifndef CF_OEMTEXT
+#define CF_OEMTEXT CF_NOTSUPPORTED_BASE+5
+#endif
+
+#ifndef CF_OWNERDISPLAY
+#define CF_OWNERDISPLAY CF_NOTSUPPORTED_BASE+6
+#endif
+
+#ifndef CF_PENDATA
+#define CF_PENDATA CF_NOTSUPPORTED_BASE+7
+#endif
+
+#ifndef CF_RIFF
+#define CF_RIFF CF_NOTSUPPORTED_BASE+8
+#endif
+
+#ifndef CF_SYLK
+#define CF_SYLK CF_NOTSUPPORTED_BASE+9
+#endif
+
+#ifndef CF_TIFF
+#define CF_TIFF CF_NOTSUPPORTED_BASE+10
+#endif
+
+#ifndef CF_WAVE
+#define CF_WAVE CF_NOTSUPPORTED_BASE+11
+#endif
+
+}
+
+#endif /* _DDEML_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/svdde/ddewrap.hxx b/binfilter/bf_svtools/source/svdde/ddewrap.hxx
new file mode 100644
index 000000000000..f15e2033bbc3
--- /dev/null
+++ b/binfilter/bf_svtools/source/svdde/ddewrap.hxx
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+#ifndef _SVTOOLS_SVDDE_DDEWRAP_HXX_
+#define _SVTOOLS_SVDDE_DDEWRAP_HXX_
+
+
+namespace binfilter
+{
+
+#define DECLARE_WAPI_FUNC(func) \
+ extern func##_PROC lpfn##func;
+
+typedef HSZ (WINAPI *DdeCreateStringHandleW_PROC)( DWORD idInst, LPCWSTR pszString, int iCodePage );
+typedef DWORD (WINAPI *DdeQueryStringW_PROC)( DWORD idInst, HSZ hsz, LPWSTR pszString, DWORD cchMax, int iCodePage );
+typedef UINT (WINAPI *DdeInitializeW_PROC)( LPDWORD pidInst, PFNCALLBACK pfnCallback, DWORD afCmd, DWORD ulRes );
+
+
+DECLARE_WAPI_FUNC( DdeCreateStringHandleW );
+DECLARE_WAPI_FUNC( DdeQueryStringW );
+DECLARE_WAPI_FUNC( DdeInitializeW );
+
+
+#ifndef _SVTOOLS_SVDDE_DDEWRAP_CXX_
+#define DdeCreateStringHandleW lpfnDdeCreateStringHandleW
+#define DdeQueryStringW lpfnDdeQueryStringW
+#define DdeInitializeW lpfnDdeInitializeW
+#endif
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/svdde/makefile.mk b/binfilter/bf_svtools/source/svdde/makefile.mk
new file mode 100644
index 000000000000..7bc9f01ae7e6
--- /dev/null
+++ b/binfilter/bf_svtools/source/svdde/makefile.mk
@@ -0,0 +1,59 @@
+#*************************************************************************
+#
+# DO NOT ALTER 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=binfilter
+TARGET=svdde
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+.IF "$(GUIBASE)"=="WIN"
+
+SLOFILES= $(SLO)$/svt_ddecli.obj \
+ $(SLO)$/svt_ddesvr.obj \
+ $(SLO)$/svt_ddedata.obj \
+ $(SLO)$/svt_ddestrg.obj \
+ $(SLO)$/svt_ddewrap.obj \
+ $(SLO)$/svt_ddeinf.obj
+.ELSE
+
+SLOFILES= $(SLO)$/svt_ddedummy.obj \
+
+.ENDIF
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/binfilter/bf_svtools/source/svdde/svt_ddecli.cxx b/binfilter/bf_svtools/source/svdde/svt_ddecli.cxx
new file mode 100644
index 000000000000..fd1922f156ee
--- /dev/null
+++ b/binfilter/bf_svtools/source/svdde/svt_ddecli.cxx
@@ -0,0 +1,479 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+#define UNICODE
+#include <string.h> // memset
+#include "ddeimp.hxx"
+#include <bf_svtools/svdde.hxx>
+
+#include <osl/thread.h>
+
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+
+namespace binfilter
+{
+
+// static DWORD hDdeInst = NULL;
+// static short nInstance = 0;
+
+// DdeConnections* DdeConnection::pConnections = NULL;
+
+DdeInstData* ImpInitInstData()
+{
+ DdeInstData* pData = new DdeInstData;
+ memset( pData,0,sizeof(DdeInstData) );
+ DdeInstData** ppInst = (DdeInstData**)GetAppData( BF_SHL_SVDDE );
+ *ppInst = pData;
+ return pData;
+}
+
+void ImpDeinitInstData()
+{
+ DdeInstData** ppInst = (DdeInstData**)GetAppData( BF_SHL_SVDDE );
+ delete (*ppInst);
+ *ppInst = 0;
+}
+
+
+struct DdeImp
+{
+ HCONV hConv;
+ long nStatus;
+};
+
+// --- DdeInternat::CliCallback() ----------------------------------
+
+HDDEDATA CALLBACK DdeInternal::CliCallback(
+ WORD nCode, WORD nCbType, HCONV hConv, HSZ, HSZ hText2,
+ HDDEDATA hData, DWORD nInfo1, DWORD )
+{
+ HDDEDATA nRet = DDE_FNOTPROCESSED;
+ DdeConnections& rAll = (DdeConnections&)DdeConnection::GetConnections();
+ DdeConnection* self = 0;
+
+ DdeInstData* pInst = ImpGetInstData();
+ DBG_ASSERT(pInst,"SVDDE:No instance data");
+
+ for ( self = rAll.First(); self; self = rAll.Next() )
+ if ( self->pImp->hConv == hConv )
+ break;
+
+ if( self )
+ {
+ DdeTransaction* t;
+ BOOL bFound = FALSE;
+ for( t = self->aTransactions.First(); t; t = self->aTransactions.Next() )
+ {
+ switch( nCode )
+ {
+ case XTYP_XACT_COMPLETE:
+ if( (DWORD)t->nId == nInfo1 )
+ {
+ nCode = t->nType & (XCLASS_MASK | XTYP_MASK);
+ t->bBusy = FALSE;
+ t->Done( 0 != hData );
+ bFound = TRUE;
+ }
+ break;
+
+ case XTYP_DISCONNECT:
+ self->pImp->hConv = DdeReconnect( hConv );
+ self->pImp->nStatus = self->pImp->hConv
+ ? DMLERR_NO_ERROR
+ : DdeGetLastError( pInst->hDdeInstCli );
+ t = 0;
+ nRet = 0;
+ bFound = TRUE;
+ break;
+
+ case XTYP_ADVDATA:
+ bFound = BOOL( *t->pName == hText2 );
+ break;
+ }
+ if( bFound )
+ break;
+ }
+
+ if( t )
+ {
+ switch( nCode )
+ {
+ case XTYP_ADVDATA:
+ if( !hData )
+ {
+ ((DdeLink*) t)->Notify();
+ nRet = (HDDEDATA)DDE_FACK;
+ break;
+ }
+ // kein break;
+
+ case XTYP_REQUEST:
+ if( !hData && XTYP_REQUEST == nCode )
+ {
+
+ }
+
+ DdeData d;
+ d.pImp->hData = hData;
+ d.pImp->nFmt = DdeData::GetInternalFormat( nCbType );
+ d.Lock();
+ t->Data( &d );
+ nRet = (HDDEDATA)DDE_FACK;
+ break;
+ }
+ }
+ }
+ return nRet;
+}
+
+// --- DdeConnection::DdeConnection() ------------------------------
+
+DdeConnection::DdeConnection( const String& rService, const String& rTopic )
+{
+ pImp = new DdeImp;
+ pImp->nStatus = DMLERR_NO_ERROR;
+ pImp->hConv = NULL;
+
+ DdeInstData* pInst = ImpGetInstData();
+ if( !pInst )
+ pInst = ImpInitInstData();
+ pInst->nRefCount++;
+ pInst->nInstanceCli++;
+ if ( !pInst->hDdeInstCli )
+ {
+ pImp->nStatus = DdeInitialize( &pInst->hDdeInstCli,
+ (PFNCALLBACK)DdeInternal::CliCallback,
+ APPCLASS_STANDARD | APPCMD_CLIENTONLY |
+ CBF_FAIL_ALLSVRXACTIONS |
+ CBF_SKIP_REGISTRATIONS |
+ CBF_SKIP_UNREGISTRATIONS, 0L );
+ pInst->pConnections = new DdeConnections;
+ }
+
+ pService = new DdeString( pInst->hDdeInstCli, rService );
+ pTopic = new DdeString( pInst->hDdeInstCli, rTopic );
+
+ if ( pImp->nStatus == DMLERR_NO_ERROR )
+ {
+ pImp->hConv = DdeConnect( pInst->hDdeInstCli,*pService,*pTopic, NULL);
+ if( !pImp->hConv )
+ pImp->nStatus = DdeGetLastError( pInst->hDdeInstCli );
+ }
+
+ if ( pInst->pConnections )
+ pInst->pConnections->Insert( this );
+}
+
+// --- DdeConnection::~DdeConnection() -----------------------------
+
+DdeConnection::~DdeConnection()
+{
+ if ( pImp->hConv )
+ DdeDisconnect( pImp->hConv );
+
+ delete pService;
+ delete pTopic;
+
+ DdeInstData* pInst = ImpGetInstData();
+ DBG_ASSERT(pInst,"SVDDE:No instance data");
+ if ( pInst->pConnections )
+ pInst->pConnections->Remove( this );
+
+ pInst->nInstanceCli--;
+ pInst->nRefCount--;
+ if ( !pInst->nInstanceCli && pInst->hDdeInstCli )
+ {
+ if( DdeUninitialize( pInst->hDdeInstCli ) )
+ {
+ pInst->hDdeInstCli = NULL;
+ delete pInst->pConnections;
+ pInst->pConnections = NULL;
+ if( pInst->nRefCount == 0 )
+ ImpDeinitInstData();
+ }
+ }
+ delete pImp;
+}
+
+// --- DdeConnection::IsConnected() --------------------------------
+
+BOOL DdeConnection::IsConnected()
+{
+ CONVINFO c;
+#ifdef OS2
+ c.nSize = sizeof( c );
+#else
+ c.cb = sizeof( c );
+#endif
+ if ( DdeQueryConvInfo( pImp->hConv, QID_SYNC, &c ) )
+ return TRUE;
+ else
+ {
+ DdeInstData* pInst = ImpGetInstData();
+ pImp->hConv = DdeReconnect( pImp->hConv );
+ pImp->nStatus = pImp->hConv ? DMLERR_NO_ERROR : DdeGetLastError( pInst->hDdeInstCli );
+ return BOOL( pImp->nStatus == DMLERR_NO_ERROR );
+ }
+}
+
+// --- DdeConnection::GetServiceName() -----------------------------
+
+const String& DdeConnection::GetServiceName()
+{
+ return (const String&)*pService;
+}
+
+// --- DdeConnection::GetTopicName() -------------------------------
+
+const String& DdeConnection::GetTopicName()
+{
+ return (const String&)*pTopic;
+}
+
+// --- DdeConnection::GetConvId() ----------------------------------
+
+long DdeConnection::GetConvId()
+{
+ return (long)pImp->hConv;
+}
+
+const DdeConnections& DdeConnection::GetConnections()
+{
+ DdeInstData* pInst = ImpGetInstData();
+ DBG_ASSERT(pInst,"SVDDE:No instance data");
+ return *(pInst->pConnections);
+}
+
+// --- DdeTransaction::DdeTransaction() ----------------------------
+
+DdeTransaction::DdeTransaction( DdeConnection& d, const String& rItemName,
+ long n ) :
+ rDde( d )
+{
+ DdeInstData* pInst = ImpGetInstData();
+ pName = new DdeString( pInst->hDdeInstCli, rItemName );
+ nTime = n;
+ nId = 0;
+ nType = 0;
+ bBusy = FALSE;
+
+ rDde.aTransactions.Insert( this );
+}
+
+// --- DdeTransaction::~DdeTransaction() ---------------------------
+
+DdeTransaction::~DdeTransaction()
+{
+ if ( nId && rDde.pImp->hConv )
+ {
+ DdeInstData* pInst = ImpGetInstData();
+ DdeAbandonTransaction( pInst->hDdeInstCli, rDde.pImp->hConv, nId );
+ }
+
+ delete pName;
+ rDde.aTransactions.Remove( this );
+}
+
+// --- DdeTransaction::Execute() -----------------------------------
+
+void DdeTransaction::Execute()
+{
+ HSZ hItem = *pName;
+ void* pData = (void*)(const void *)aDdeData;
+ DWORD nData = (DWORD)(long)aDdeData;
+ ULONG nIntFmt = aDdeData.pImp->nFmt;
+ UINT nExtFmt = DdeData::GetExternalFormat( nIntFmt );
+ DdeInstData* pInst = ImpGetInstData();
+
+ if ( nType == XTYP_EXECUTE )
+ hItem = NULL;
+ if ( nType != XTYP_EXECUTE && nType != XTYP_POKE )
+ {
+ pData = NULL;
+ nData = 0L;
+ }
+ if ( nTime )
+ {
+ HDDEDATA hData = DdeClientTransaction( (unsigned char*)pData,
+ nData, rDde.pImp->hConv,
+ hItem, nExtFmt, (UINT)nType,
+ (DWORD)nTime, (DWORD FAR*)NULL );
+
+ rDde.pImp->nStatus = DdeGetLastError( pInst->hDdeInstCli );
+ if( hData && nType == XTYP_REQUEST )
+ {
+ {
+ DdeData d;
+ d.pImp->hData = hData;
+ d.pImp->nFmt = nIntFmt;
+ d.Lock();
+ Data( &d );
+ }
+ DdeFreeDataHandle( hData );
+ }
+ }
+ else
+ {
+ if ( nId && rDde.pImp->hConv )
+ DdeAbandonTransaction( pInst->hDdeInstCli, rDde.pImp->hConv, nId);
+ nId = 0;
+ bBusy = TRUE;
+ HDDEDATA hRet = DdeClientTransaction( (unsigned char*)pData, nData,
+ rDde.pImp->hConv, hItem, nExtFmt,
+ (UINT)nType, TIMEOUT_ASYNC,
+ (DWORD FAR *) ((long*) &nId) );
+ rDde.pImp->nStatus = hRet ? DMLERR_NO_ERROR
+ : DdeGetLastError( pInst->hDdeInstCli );
+ }
+}
+
+// --- DdeTransaction::GetName() -----------------------------------
+
+const String& DdeTransaction::GetName() const
+{
+ return *pName;
+}
+
+// --- DdeTransaction::Data() --------------------------------------
+
+
+void __EXPORT DdeTransaction::Data( const DdeData* p )
+{
+ SolarMutexGuard aSolarGuard;
+
+ aData.Call( (void*)p );
+}
+
+// --- DdeTransaction::Done() --------------------------------------
+
+void __EXPORT DdeTransaction::Done( BOOL bDataValid )
+{
+ aDone.Call( (void*)bDataValid );
+}
+
+// --- DdeLink::DdeLink() ------------------------------------------
+
+DdeLink::DdeLink( DdeConnection& d, const String& aItemName, long n ) :
+ DdeTransaction (d, aItemName, n)
+{
+}
+
+// --- DdeLink::~DdeLink() -----------------------------------------
+
+DdeLink::~DdeLink()
+{
+ nType = (USHORT)XTYP_ADVSTOP;
+ nTime = 0;
+}
+
+// --- DdeLink::Notify() -----------------------------------------
+
+void __EXPORT DdeLink::Notify()
+{
+ aNotify.Call( NULL );
+}
+
+// --- DdeRequest::DdeRequest() ------------------------------------
+
+DdeRequest::DdeRequest( DdeConnection& d, const String& i, long n ) :
+ DdeTransaction( d, i, n )
+{
+ nType = XTYP_REQUEST;
+}
+
+// --- DdeWarmLink::DdeWarmLink() ----------------------------------
+
+DdeWarmLink::DdeWarmLink( DdeConnection& d, const String& i, long n ) :
+ DdeLink( d, i, n )
+{
+ nType = XTYP_ADVSTART | XTYPF_NODATA;
+}
+
+// --- DdeHotLink::DdeHotLink() ------------------------------------
+
+DdeHotLink::DdeHotLink( DdeConnection& d, const String& i, long n ) :
+ DdeLink( d, i, n )
+{
+ nType = XTYP_ADVSTART;
+}
+
+// --- DdePoke::DdePoke() ------------------------------------------
+
+DdePoke::DdePoke( DdeConnection& d, const String& i, const char* p,
+ long l, ULONG f, long n ) :
+ DdeTransaction( d, i, n )
+{
+ aDdeData = DdeData( p, l, f );
+ nType = XTYP_POKE;
+}
+
+// --- DdePoke::DdePoke() ------------------------------------------
+
+DdePoke::DdePoke( DdeConnection& d, const String& i, const String& rData,
+ long n ) :
+ DdeTransaction( d, i, n )
+{
+// ByteString aByteStr( rData, osl_getThreadTextEncoding() );
+ aDdeData = DdeData( (void*) rData.GetBuffer(), sizeof(sal_Unicode) * (rData.Len()), CF_TEXT );
+ nType = XTYP_POKE;
+}
+
+// --- DdePoke::DdePoke() ------------------------------------------
+
+DdePoke::DdePoke( DdeConnection& d, const String& i, const DdeData& rData,
+ long n ) :
+ DdeTransaction( d, i, n )
+{
+ aDdeData = rData;
+ nType = XTYP_POKE;
+}
+
+// --- DdeExecute::DdeExecute() ------------------------------------
+
+DdeExecute::DdeExecute( DdeConnection& d, const String& rData, long n ) :
+ DdeTransaction( d, String(), n )
+{
+// ByteString aByteStr( rData, osl_getThreadTextEncoding() );
+ aDdeData = DdeData( (void*)rData.GetBuffer(), sizeof(sal_Unicode) * (rData.Len() + 1), CF_TEXT );
+ nType = XTYP_EXECUTE;
+}
+
+// --- DdeConnection::GetError() -----------------------------------
+
+long DdeConnection::GetError()
+{
+ return pImp->nStatus;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/svdde/svt_ddedata.cxx b/binfilter/bf_svtools/source/svdde/svt_ddedata.cxx
new file mode 100644
index 000000000000..202625a9d772
--- /dev/null
+++ b/binfilter/bf_svtools/source/svdde/svt_ddedata.cxx
@@ -0,0 +1,236 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+// ACHTUNG: es wird angenommen, dass StarView-Clipboard-Foamatnummern
+// und Windows-Formatnummern identisch sind! Ist dies einmal nicht der
+// Fall, muessen die Routinen hier angepasst werden. Die Implementation
+// verwendet die hier defineirten Konversionen.
+
+#define UNICODE
+
+#include <string.h>
+#include "ddeimp.hxx"
+#include <bf_svtools/svdde.hxx>
+
+#include <osl/thread.h>
+
+#if defined( WIN ) && defined( MSC )
+#pragma code_seg( "SVDDE_MISC_CODE" )
+#endif
+
+namespace binfilter
+{
+
+// --- DdeData::DdeData() ------------------------------------------
+
+DdeData::DdeData()
+{
+ pImp = new DdeDataImp;
+ pImp->hData = NULL;
+ pImp->nData = 0;
+ pImp->pData = NULL;
+ pImp->nFmt = CF_TEXT;
+}
+
+// --- DdeData::DdeData() ------------------------------------------
+
+DdeData::DdeData( const void* p, long n, ULONG f )
+{
+ pImp = new DdeDataImp;
+ pImp->hData = NULL;
+ pImp->pData = (LPBYTE)p;
+ pImp->nData = n;
+ pImp->nFmt = f;
+}
+
+// --- DdeData::DdeData() ------------------------------------------
+
+DdeData::DdeData( const String& s )
+{
+ pImp = new DdeDataImp;
+ pImp->hData = NULL;
+ pImp->pData = (LPBYTE)s.GetBuffer();
+ pImp->nData = s.Len()+1;
+ pImp->nFmt = CF_TEXT;
+}
+
+// --- DdeData::DdeData() ------------------------------------------
+
+DdeData::DdeData( const DdeData& rData )
+{
+ pImp = new DdeDataImp;
+ pImp->hData = rData.pImp->hData;
+ pImp->nData = rData.pImp->nData;
+ pImp->pData = rData.pImp->pData;
+ pImp->nFmt = rData.pImp->nFmt;
+ Lock();
+}
+
+// --- DdeData::~DdeData() -----------------------------------------
+
+DdeData::~DdeData()
+{
+ if ( pImp && pImp->hData )
+ DdeUnaccessData( pImp->hData );
+ delete pImp;
+}
+
+// --- DdeData::Lock() ---------------------------------------------
+
+void DdeData::Lock()
+{
+ if ( pImp->hData )
+ pImp->pData = DdeAccessData( pImp->hData, (LPDWORD) &pImp->nData );
+}
+
+// --- DdeData::GetFormat() ----------------------------------------
+
+ULONG DdeData::GetFormat() const
+{
+ return pImp->nFmt;
+}
+
+void DdeData::SetFormat( ULONG nFmt )
+{
+ pImp->nFmt = nFmt;
+}
+
+// --- DdeData::operator const char*() -----------------------------
+
+DdeData::operator const void*() const
+{
+ return pImp->pData;
+}
+
+// --- DdeData::operator long() ------------------------------------
+
+DdeData::operator long() const
+{
+ return pImp->nData;
+}
+
+// --- DdeData::operator =() ---------------------------------------
+
+DdeData& DdeData::operator = ( const DdeData& rData )
+{
+ if ( &rData != this )
+ {
+ DdeData tmp( rData );
+ delete pImp;
+ pImp = tmp.pImp;
+ tmp.pImp = NULL;
+ }
+
+ return *this;
+}
+
+ULONG DdeData::GetExternalFormat( ULONG nFmt )
+{
+ switch( nFmt )
+ {
+ case FORMAT_STRING:
+ nFmt = CF_TEXT;
+ break;
+ case FORMAT_BITMAP:
+ nFmt = CF_BITMAP;
+ break;
+ case FORMAT_GDIMETAFILE:
+ nFmt = CF_METAFILEPICT;
+ break;
+
+ default:
+ {
+#if defined(WNT) || defined(WIN) || defined( PM2 )
+ String aName( SotExchange::GetFormatName( nFmt ) );
+
+#if defined(WNT) || defined(WIN)
+
+ if( aName.Len() )
+ nFmt = RegisterClipboardFormat( reinterpret_cast<LPCWSTR>(aName.GetBuffer()) );
+#endif
+#if defined( PM2 )
+
+ if( aName.Len() )
+ {
+ HATOMTBL hSysTable = WinQuerySystemAtomTable();
+ nFmt = (ULONG)WinAddAtom( hSysTable, (PSZ)aName.GetBuffer() );
+ }
+#endif
+#endif
+ }
+ }
+ return nFmt;
+}
+
+ULONG DdeData::GetInternalFormat( ULONG nFmt )
+{
+ switch( nFmt )
+ {
+ case CF_TEXT:
+ nFmt = FORMAT_STRING;
+ break;
+
+ case CF_BITMAP:
+ nFmt = FORMAT_BITMAP;
+ break;
+
+ case CF_METAFILEPICT:
+ nFmt = FORMAT_GDIMETAFILE;
+ break;
+
+ default:
+#if defined(WIN) || defined(WNT)
+ if( nFmt >= CF_MAX )
+ {
+ TCHAR szName[ 256 ];
+
+ if( GetClipboardFormatName( nFmt, szName, sizeof(szName) ) )
+ nFmt = SotExchange::RegisterFormatName( String(reinterpret_cast<const sal_Unicode*>(szName)) );
+ }
+#endif
+#if defined(PM2)
+ if( nFmt > CF_PALETTE )
+ {
+ char szName[ 256 ];
+
+ HATOMTBL hSysTable = WinQuerySystemAtomTable();
+ WinQueryAtomName( hSysTable, (ATOM)nFmt, (PSZ)szName,
+ sizeof( szName ) );
+ nFmt = SotExchange::RegisterFormatName( String( szName ) );
+ }
+#endif
+ break;
+ }
+ return nFmt;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/svdde/svt_ddedll.cxx b/binfilter/bf_svtools/source/svdde/svt_ddedll.cxx
new file mode 100644
index 000000000000..c03a39139fdb
--- /dev/null
+++ b/binfilter/bf_svtools/source/svdde/svt_ddedll.cxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+#ifdef WIN
+
+namespace binfilter
+{
+
+#include <sysdep.hxx> // included svwin.h
+
+// Statische DLL-Verwaltungs-Variablen
+static HINSTANCE hDLLInst = 0; // HANDLE der DLL
+
+/***************************************************************************
+|* LibMain()
+|* Beschreibung Initialisierungsfunktion der DLL
+***************************************************************************/
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+/***************************************************************************
+|* WEP()
+|* Beschreibung DLL-Deinitialisierung
+***************************************************************************/
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/svdde/svt_ddedummy.cxx b/binfilter/bf_svtools/source/svdde/svt_ddedummy.cxx
new file mode 100644
index 000000000000..17bbd256b07c
--- /dev/null
+++ b/binfilter/bf_svtools/source/svdde/svt_ddedummy.cxx
@@ -0,0 +1,144 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/svdde.hxx>
+#include <rtl/instance.hxx>
+
+namespace binfilter
+{
+
+DdeData::DdeData()
+{
+}
+
+DdeData::DdeData( const DdeData& )
+{
+}
+
+DdeData::~DdeData( void )
+{
+}
+
+void DdeData::SetFormat( ULONG )
+{
+}
+
+ULONG DdeData::GetFormat() const
+{
+ return 0L;
+}
+
+DdeData& DdeData::operator = ( const DdeData& )
+{
+ return *this;
+}
+
+DdeData::operator long() const
+{
+ return 0L;
+}
+
+DdeData::operator const void*() const
+{
+ return NULL;
+}
+
+long DdeConnection::GetError()
+{
+ return 0L;
+}
+
+DdeConnection::DdeConnection( const String&, const String& )
+{
+}
+
+DdeConnection::~DdeConnection( void )
+{
+}
+
+const String& DdeConnection::GetServiceName()
+{
+ return String::EmptyString();
+}
+
+const String& DdeConnection::GetTopicName()
+{
+ return String::EmptyString();
+}
+
+DdeTransaction::DdeTransaction( DdeConnection& rConnection, const String&, long ) :
+ rDde( rConnection )
+{
+}
+
+DdeTransaction::DdeTransaction( const DdeTransaction& rTransaction ) :
+ rDde( rTransaction.rDde )
+{
+}
+
+void DdeTransaction::Execute(void)
+{
+}
+
+void DdeTransaction::Done( BOOL )
+{
+}
+
+void DdeTransaction::Data( const DdeData* )
+{
+}
+
+DdeTransaction::~DdeTransaction(void)
+{
+}
+
+DdeRequest::DdeRequest(DdeConnection& rConnection, const String& rString, long lLong ) :
+ DdeTransaction( rConnection, rString, lLong )
+{
+}
+
+DdeLink::DdeLink( DdeConnection& rConnection, const String& rString, long l ) :
+DdeTransaction( rConnection, rString, l )
+{
+}
+
+DdeLink::~DdeLink()
+{
+}
+
+void DdeLink::Notify()
+{
+}
+
+DdeHotLink::DdeHotLink( DdeConnection& rConnection, const String& rString, long l ) :
+DdeLink( rConnection, rString, l )
+{
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/svdde/svt_ddeinf.cxx b/binfilter/bf_svtools/source/svdde/svt_ddeinf.cxx
new file mode 100644
index 000000000000..445cb5565492
--- /dev/null
+++ b/binfilter/bf_svtools/source/svdde/svt_ddeinf.cxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+#define UNICODE
+
+#include <string.h>
+#include "ddeimp.hxx"
+#include <bf_svtools/svdde.hxx>
+
+namespace binfilter
+{
+
+// --- DdeInternal::InfCallback() ----------------------------------
+
+#ifdef WNT
+HDDEDATA CALLBACK DdeInternal::InfCallback(
+ WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD )
+#else
+#if defined ( MTW ) || ( defined ( GCC ) && defined ( OS2 )) || defined( ICC )
+HDDEDATA CALLBACK __EXPORT DdeInternal::InfCallback(
+ WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD )
+#else
+HDDEDATA CALLBACK _export DdeInternal::InfCallback(
+ WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD )
+#endif
+#endif
+{
+ return (HDDEDATA)DDE_FNOTPROCESSED;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/svdde/svt_ddeml1.cxx b/binfilter/bf_svtools/source/svdde/svt_ddeml1.cxx
new file mode 100644
index 000000000000..ae2a9e8835f1
--- /dev/null
+++ b/binfilter/bf_svtools/source/svdde/svt_ddeml1.cxx
@@ -0,0 +1,2662 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+/*
+ ToDo / Bugs:
+
+ - DdeInitiate: Eigener Thread?
+ - Timeout bei Disconnects (IBM:nicht auf Ack warten!)
+ - Konzept Errorhandling (globale/lokale Fehler)
+ - Bedeutung/Anwendung Conversation-Contexte
+ - Bei Zugriffen auf ConversationHandles WindowHandles checken
+ - Namen der Partner-App ermitteln
+ - Codepage-Geraffel
+*/
+#define INCL_DOSPROCESS
+
+#include "ddemlimp.hxx"
+
+#define LOGFILE
+#define STATUSFILE
+#define DDEDATAFILE
+#include "ddemldeb.hxx"
+
+
+#if defined (OS2) && defined (__BORLANDC__)
+#pragma option -w-par
+#endif
+
+namespace binfilter
+{
+
+// static
+inline BOOL ImpDdeMgr::MyWinDdePostMsg( HWND hWndTo, HWND hWndFrom,
+ USHORT nMsg, PDDESTRUCT pData, ULONG nFlags )
+{
+ BOOL bSuccess = WinDdePostMsg( hWndTo,hWndFrom,nMsg,pData,nFlags);
+ if( !bSuccess )
+ {
+ WRITELOG("WinDdePostMsg:Failed!")
+ if ( !(nFlags & DDEPM_NOFREE) )
+ {
+ MyDosFreeMem( pData,"MyWinDdePostMsg" );
+ }
+ }
+ return bSuccess;
+}
+
+
+// *********************************************************************
+// ImpDdeMgr
+// *********************************************************************
+
+USHORT ImpDdeMgr::nLastErrInstance = 0;
+
+//
+// Conversation-WndProc
+// Steuert Transaktionen eines Conversationhandles
+//
+MRESULT EXPENTRY ConvWndProc(HWND hWnd,ULONG nMsg,MPARAM nPar1,MPARAM nPar2)
+{
+#if defined(DBG_UTIL) && defined(OV_DEBUG)
+ if( nMsg >= WM_DDE_FIRST && nMsg <= WM_DDE_LAST)
+ {
+ ////WRITELOG("::ConvWndProc:DDE-Msg received")
+ }
+#endif
+ ImpConvWndData* pObj = (ImpConvWndData*)WinQueryWindowULong( hWnd, 0 );
+ return pObj->pThis->ConvWndProc( hWnd, nMsg, nPar1, nPar2 );
+}
+
+//
+// Server-WndProc
+// DDE-Server-Window der App
+//
+MRESULT EXPENTRY ServerWndProc(HWND hWnd,ULONG nMsg,MPARAM nPar1,MPARAM nPar2)
+{
+#if defined(DBG_UTIL) && defined(OV_DEBUG)
+ if( nMsg >= WM_DDE_FIRST && nMsg <= WM_DDE_LAST)
+ {
+ ////WRITELOG("::ServerWndProc:DDE-Msg received")
+ }
+#endif
+ ImpDdeMgr* pObj = (ImpDdeMgr*)WinQueryWindowULong( hWnd, 0 );
+ return pObj->SrvWndProc( hWnd, nMsg, nPar1, nPar2 );
+}
+
+
+inline HDDEDATA ImpDdeMgr::Callback( USHORT nTransactionType,
+ USHORT nClipboardFormat, HCONV hConversationHandle, HSZ hsz1,
+ HSZ hsz2, HDDEDATA hData, ULONG nData1, ULONG nData2 )
+{
+ HDDEDATA hRet = (HDDEDATA)0;
+ if( pCallback )
+ hRet = (*pCallback)(nTransactionType, nClipboardFormat,
+ hConversationHandle, hsz1, hsz2, hData, nData1, nData2);
+ return hRet;
+}
+
+
+
+ImpDdeMgr::ImpDdeMgr()
+{
+ nLastErrInstance = DMLERR_NO_ERROR;
+ pCallback = 0;
+ nTransactFilter = 0;
+ nServiceCount = 0;
+ pServices = 0;
+ pAppTable = 0;
+ pConvTable = 0;
+ pTransTable = 0;
+ bServFilterOn = TRUE;
+ bInSyncTrans = FALSE;
+
+ CreateServerWnd();
+ pData = InitAll();
+ if ( !pData )
+ nLastErrInstance = DMLERR_MEMORY_ERROR;
+ else
+ RegisterDDEMLApp();
+}
+
+ImpDdeMgr::~ImpDdeMgr()
+{
+ CleanUp();
+ DestroyServerWnd();
+// Named Shared Mem vom BS loeschen lassen, da nicht bekannt ist,
+// wieviele DDEML-Instanzen die App erzeugt hat, und OS/2
+// keinen App-Referenzzaehler fuer shared mem fuehrt.
+// if ( pData )
+// DosFreeMem( pData );
+}
+
+
+BOOL ImpDdeMgr::IsSameInstance( HWND hWnd )
+{
+ TID tid; PID pid;
+ WinQueryWindowProcess( hWnd, &pid, &tid );
+ return (BOOL)(pid == pidThis);
+}
+
+HSZ ImpDdeMgr::GetAppName( HWND hWnd )
+{
+ return 0;
+}
+
+// static
+ImpDdeMgr* ImpDdeMgr::GetImpDdeMgrInstance( HWND hWnd )
+{
+ ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData();
+ if( !pData )
+ return 0;
+
+ ImpDdeMgr* pResult = 0;
+ TID tid; PID pidApp;
+ WinQueryWindowProcess( hWnd, &pidApp, &tid );
+ HWND* pApp = ImpDdeMgr::GetAppTable( pData );
+ USHORT nCurApp = 0;
+ while( nCurApp < pData->nMaxAppCount )
+ {
+ HWND hCurWin = *pApp;
+ if( hCurWin )
+ {
+ PID pidCurApp;
+ WinQueryWindowProcess( hCurWin, &pidCurApp, &tid );
+ if( pidCurApp == pidApp )
+ {
+ pResult = (ImpDdeMgr*)WinQueryWindowULong( hCurWin, 0 );
+ break;
+ }
+ }
+ pApp++;
+ nCurApp++;
+ }
+ return pResult;
+}
+
+
+
+
+
+void ImpDdeMgr::CleanUp()
+{
+ DisconnectAll();
+ ImpService* pPtr = pServices;
+ if( pPtr )
+ {
+ for( USHORT nIdx = 0; nIdx < nServiceCount; nIdx++, pPtr++ )
+ {
+ HSZ hStr = pPtr->hBaseServName;
+ if( hStr )
+ DdeFreeStringHandle( hStr );
+ hStr = pPtr->hInstServName;
+ if( hStr )
+ DdeFreeStringHandle( hStr );
+ }
+ nServiceCount = 0;
+ delete pServices;
+ pServices = 0;
+ }
+ bServFilterOn = TRUE; // default setting DDEML
+ UnregisterDDEMLApp();
+}
+
+void ImpDdeMgr::RegisterDDEMLApp()
+{
+ HWND* pPtr = pAppTable;
+ HWND hCur;
+ USHORT nPos = 0;
+ while( nPos < pData->nMaxAppCount )
+ {
+ hCur = *pPtr;
+ if (hCur == (HWND)0 )
+ {
+ // in Tabelle stellen
+ *pPtr = hWndServer;
+ break;
+ }
+ nPos++;
+ pPtr++;
+ }
+}
+
+void ImpDdeMgr::UnregisterDDEMLApp()
+{
+ HWND* pPtr = pAppTable;
+ USHORT nPos = 0;
+ while( nPos < pData->nMaxAppCount )
+ {
+ if (*pPtr == hWndServer )
+ {
+ *pPtr = 0;
+ break;
+ }
+ nPos++;
+ pPtr++;
+ }
+}
+
+// static
+ImpDdeMgrData* ImpDdeMgr::AccessMgrData()
+{
+ ImpDdeMgrData* pData = 0;
+ APIRET nRet = DosGetNamedSharedMem((PPVOID)&pData,DDEMLDATA,PAG_READ|PAG_WRITE);
+ DBG_ASSERT(!nRet,"DDE:AccessMgrData failed");
+ return pData;
+}
+
+USHORT ImpDdeMgr::DdeGetLastError()
+{
+ USHORT nErr;
+ if ( !pData )
+ nErr = DMLERR_DLL_NOT_INITIALIZED;
+ else if ( nLastErrInstance )
+ nErr = nLastErrInstance;
+ else
+ nErr = pData->nLastErr;
+
+ nLastErrInstance = 0;
+ pData->nLastErr = 0;
+ return nErr;
+}
+
+
+
+USHORT ImpDdeMgr::DdeInitialize( PFNCALLBACK pCallbackProc, ULONG nTransactionFilter )
+{
+ if ( !nLastErrInstance )
+ {
+ if ( !pCallbackProc )
+ {
+ nLastErrInstance = DMLERR_INVALIDPARAMETER;
+ return nLastErrInstance;
+ }
+ pCallback = pCallbackProc;
+ nTransactFilter = nTransactionFilter;
+ nTransactFilter |= CBF_FAIL_SELFCONNECTIONS;
+ }
+ return nLastErrInstance;
+}
+
+
+// static
+HWND ImpDdeMgr::NextFrameWin( HENUM hEnum )
+{
+ char aBuf[ 10 ];
+
+ HWND hWnd = WinGetNextWindow( hEnum );
+ while( hWnd )
+ {
+ WinQueryClassName( hWnd, sizeof(aBuf)-1, (PCH)aBuf );
+ // Frame-Window ?
+ if( !strcmp( aBuf, "#1" ) ) // #define WC_FRAME ((PSZ)0xffff0001L)
+ break;
+ hWnd = WinGetNextWindow( hEnum );
+ }
+ return hWnd;
+}
+
+
+HCONV ImpDdeMgr::DdeConnectImp( HSZ hszService,HSZ hszTopic,CONVCONTEXT* pCC)
+{
+ hCurConv = 0;
+ if( !pCC )
+ pCC = &aDefaultContext;
+
+ ULONG nBufLen;
+ PSZ pService = AllocAtomName( (ATOM)hszService, nBufLen );
+ PSZ pTopic = AllocAtomName( (ATOM)hszTopic, nBufLen );
+#if 0 && defined(OV_DEBUG)
+ String aStr("DdeConnectImp Service:");
+ aStr += pService;
+ aStr += " Topic:";
+ aStr += pTopic;
+ WRITELOG((char*)(const char*)aStr)
+#endif
+
+#if defined(OV_DEBUG)
+ if( !strcmp(pService,"oliver voeltz") )
+ {
+ WRITESTATUS("Table of connections");
+ MyDosFreeMem( pTopic,"DdeConnectImp" );
+ MyDosFreeMem( pService,"DdeConnectImp" );
+ return 0;
+ }
+#endif
+
+#if 0
+ // original pm-fkt benutzen
+ HWND hWndCurClient = CreateConversationWnd();
+ WinDdeInitiate( hWndCurClient, pService, pTopic, pCC );
+ if( GetConversationWndRefCount(hWndCurClient) == 0)
+ DestroyConversationWnd( hWndCurClient );
+#else
+ // eigener Verbindungsaufbau
+ HENUM hEnum = WinBeginEnumWindows( HWND_DESKTOP );
+ HWND hWndCurSrv = NextFrameWin( hEnum );
+ HWND hWndCurClient = CreateConversationWnd();
+ while( hWndCurSrv && !hCurConv )
+ {
+ if( hWndCurSrv != hWndServer ||
+ ((nTransactFilter & CBF_FAIL_SELFCONNECTIONS)==0 ))
+ {
+ // pro DDE-Server ein Conversation-Window erzeugen
+ if( GetConversationWndRefCount(hWndCurClient) >= 2)
+ {
+ DestroyConversationWnd( hWndCurClient );
+ hWndCurClient = CreateConversationWnd();
+ }
+ MyInitiateDde(hWndCurSrv,hWndCurClient,hszService,hszTopic,pCC);
+ if( !bListConnect && hCurConv )
+ break;
+ }
+ hWndCurSrv = NextFrameWin( hEnum );
+ }
+
+ if( GetConversationWndRefCount(hWndCurClient) == 0)
+ DestroyConversationWnd( hWndCurClient );
+ WinEndEnumWindows( hEnum );
+#endif
+
+ if( !hCurConv )
+ nLastErrInstance = DMLERR_NO_CONV_ESTABLISHED;
+
+#if 0 && defined(OV_DEBUG)
+ String aCStr( "DdeConnectImp:End ");
+ if( nLastErrInstance != DMLERR_NO_CONV_ESTABLISHED )
+ aCStr += "(Success)";
+ else
+ aCStr += "(Failed)";
+ WRITELOG((char*)aCStr.GetStr())
+#endif
+
+ MyDosFreeMem( pTopic,"DdeConnectImp" );
+ MyDosFreeMem( pService,"DdeConnectImp" );
+ return hCurConv;
+}
+
+HCONV ImpDdeMgr::DdeConnect( HSZ hszService, HSZ hszTopic, CONVCONTEXT* pCC)
+{
+ ////WRITELOG("DdeConnect:Start")
+ bListConnect = FALSE;
+ HCONV hResult = DdeConnectImp( hszService, hszTopic, pCC );
+ ////WRITELOG("DdeConnect:End")
+ ////WRITESTATUS("DdeConnect:End")
+ return hResult;
+}
+
+
+HCONVLIST ImpDdeMgr::DdeConnectList( HSZ hszService, HSZ hszTopic,
+ HCONVLIST hConvList, CONVCONTEXT* pCC )
+{
+ nPrevConv = 0;
+ ////WRITESTATUS("Before DdeConnectList")
+ if( hConvList )
+ {
+ HCONV hLastConvInList;
+
+ hCurListId = hConvList;
+ ImpHCONV* pConv = pConvTable;
+ pConv += (USHORT)hConvList;
+ if( (USHORT)hConvList >= pData->nMaxConvCount ||pConv->hWndThis==0 )
+ {
+ nLastErrInstance = DMLERR_INVALIDPARAMETER;
+ return 0;
+ }
+ GetLastServer(pData, hConvList, hLastConvInList);
+ nPrevConv = (USHORT)hLastConvInList;
+ }
+ else
+ hCurListId = (HCONVLIST)WinCreateWindow( HWND_OBJECT, WC_FRAME,
+ CONVLISTNAME, 0,0,0,0,0, HWND_DESKTOP, HWND_BOTTOM, 0,0,0);
+
+ bListConnect = TRUE;
+ DdeConnectImp( hszService, hszTopic, pCC );
+#if 0 && defined(OV_DEBUG)
+ WRITELOG("DdeConnectList:ConnectionList:")
+ HCONV hDebug = 0;
+ do
+ {
+ hDebug = DdeQueryNextServer( hCurListId, hDebug);
+ String aStr( (ULONG)hDebug );
+ WRITELOG((char*)(const char*)aStr)
+ } while( hDebug );
+#endif
+ ////WRITESTATUS("After DdeConnectList")
+ return (HCONVLIST)hCurListId;
+}
+
+DDEINIT* ImpDdeMgr::CreateDDEInitData( HWND hWndDestination, HSZ hszService,
+ HSZ hszTopic, CONVCONTEXT* pCC )
+{
+ ULONG nLen1 = 0, nLen2 = 0;
+ HATOMTBL hAtomTable = WinQuerySystemAtomTable();
+
+ if( hszService )
+ nLen1 = WinQueryAtomLength( hAtomTable, hszService );
+ if( hszTopic )
+ nLen2 = WinQueryAtomLength( hAtomTable, hszTopic );
+ nLen1++; nLen2++;
+
+ DDEINIT* pBuf = 0;
+
+ ULONG nLen = sizeof(DDEINIT) + nLen1+ nLen2 + sizeof(CONVCONTEXT);
+ if( !(MyDosAllocSharedMem((PPVOID)&pBuf, NULL, nLen,
+ PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_GIVEABLE | OBJ_ANY,
+ "CreateDDEInitData")))
+ {
+ memset( pBuf, 0, nLen );
+
+ /*
+ PID pid; TID tid;
+ WinQueryWindowProcess( hWndDestination, &pid, &tid );
+ APIRET nRet = DosGiveSharedMem( pBuf, pid, PAG_READ | PAG_WRITE );
+ */
+
+ pBuf->cb = nLen;
+ pBuf->offConvContext = sizeof( DDEINIT );
+ char* pBase = (char*)pBuf;
+ pBase += sizeof(DDEINIT);
+ if( pCC )
+ memcpy( pBase, pCC, sizeof(CONVCONTEXT) );
+ pBase += sizeof(CONVCONTEXT);
+ pBuf->pszAppName = pBase;
+ if( hszService )
+ WinQueryAtomName( hAtomTable, hszService, pBase, nLen1 );
+ pBase += nLen1;
+ pBuf->pszTopic = pBase;
+ if( hszTopic )
+ WinQueryAtomName( hAtomTable, hszTopic, pBase, nLen2 );
+ }
+ return pBuf;
+}
+
+
+
+void ImpDdeMgr::MyInitiateDde( HWND hWndSrv, HWND hWndClient,
+ HSZ hszService, HSZ hszTopic, CONVCONTEXT* pCC )
+{
+ DDEINIT* pBuf = CreateDDEInitData( hWndSrv, hszService, hszTopic, pCC );
+ if( pBuf )
+ {
+ PID pid; TID tid;
+ WinQueryWindowProcess( hWndSrv, &pid, &tid );
+ APIRET nRet = DosGiveSharedMem( pBuf, pid, PAG_READ | PAG_WRITE );
+ WinSendMsg( hWndSrv,WM_DDE_INITIATE,(MPARAM)hWndClient,(MPARAM)pBuf);
+ MyDosFreeMem( pBuf,"MyInitiateDde" );
+ }
+}
+
+// static
+ImpHCONV* ImpDdeMgr::GetFirstServer(ImpDdeMgrData* pData, HCONVLIST hConvList,
+ HCONV& rhConv )
+{
+ ImpHCONV* pPtr = GetConvTable( pData );
+ HCONV hConv;
+ if( !rhConv )
+ {
+ pPtr++;
+ hConv = 1;
+ }
+ else
+ {
+ // Startposition
+ pPtr += (USHORT)rhConv;
+ hConv = rhConv;
+ pPtr++; hConv++; // auf den naechsten
+ }
+ while( hConv < pData->nMaxConvCount )
+ {
+ if( pPtr->hConvList == hConvList )
+ {
+ rhConv = hConv;
+ return pPtr;
+ }
+ pPtr++;
+ hConv++;
+ }
+ rhConv = 0;
+ return 0;
+}
+
+// static
+ImpHCONV* ImpDdeMgr::GetLastServer(ImpDdeMgrData* pData, HCONVLIST hConvList,
+ HCONV& rhConv )
+{
+ ImpHCONV* pPtr = GetConvTable( pData );
+ pPtr += pData->nMaxConvCount;
+ pPtr--;
+ HCONV hConv = pData->nMaxConvCount;
+ hConv--;
+ while( hConv > 0 )
+ {
+ if( pPtr->hConvList == hConvList )
+ {
+ rhConv = hConv;
+ return pPtr;
+ }
+ pPtr--;
+ hConv--;
+ }
+ rhConv = 0;
+ return 0;
+}
+
+// static
+BOOL ImpDdeMgr::CheckConvListId( HCONVLIST hConvListId )
+{
+ HAB hAB = WinQueryAnchorBlock( (HWND)hConvListId );
+ if( hAB )
+ return WinIsWindow( hAB, (HWND)hConvListId );
+ return FALSE;
+ /*
+ HAB hAB = WinQueryAnchorBlock( (HWND)hConvListId );
+ if( hAB )
+ {
+ char aBuf[ 16 ];
+ WinQueryWindowText( (HWND)hConvListId, sizeof(aBuf), aBuf );
+ if( strcmp(aBuf, CONVLISTNAME ) == 0 )
+ return TRUE;
+ }
+ return FALSE;
+ */
+}
+
+// static
+HCONV ImpDdeMgr::DdeQueryNextServer(HCONVLIST hConvList, HCONV hConvPrev)
+{
+ if( !CheckConvListId( hConvList ) )
+ return (HCONV)0;
+ ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData();
+ GetFirstServer( pData, hConvList, hConvPrev );
+ return hConvPrev;
+}
+
+// static
+
+// Idee: DisconnectAll uebergibt das ServerWindow. Zu jedem HCONV
+// wird das Creator-Server-Wnd gespeichert. Disconnect braucht
+// dann nur noch die Window-Handles zu vergleichen
+BOOL ImpDdeMgr::DdeDisconnect( HCONV hConv )
+{
+ WRITELOG("DdeDisconnect:Start")
+ ////WRITESTATUS("DdeDisconnect:Start")
+
+ ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData();
+ if ( !pData )
+ {
+ ImpDdeMgr::nLastErrInstance = DMLERR_DLL_NOT_INITIALIZED;
+ return FALSE;
+ }
+ ImpHCONV* pConv = GetConvTable(pData) + (USHORT)hConv;
+
+ if( (USHORT)hConv >= pData->nMaxConvCount || pConv->hWndThis==0 )
+ {
+ nLastErrInstance = DMLERR_NO_CONV_ESTABLISHED;
+ return FALSE;
+ }
+
+ PID pidApp; TID tid;
+ HWND hWndDummy = WinCreateWindow( HWND_OBJECT, WC_FRAME,
+ "Bla", 0, 0,0,0,0, HWND_DESKTOP, HWND_BOTTOM, 0, 0, 0 );
+ WinQueryWindowProcess( hWndDummy, &pidApp, &tid );
+ WinDestroyWindow( hWndDummy );
+ PID pidThis; PID pidPartner;
+
+ HWND hWndThis = pConv->hWndThis;
+ HWND hWndPartner = pConv->hWndPartner;
+
+ WinQueryWindowProcess( hWndThis, &pidThis, &tid );
+ WinQueryWindowProcess( hWndPartner, &pidPartner, &tid );
+ if( pidApp != pidThis && pidApp != pidPartner )
+ return TRUE; // gehoert nicht der App -> ueberspringen
+
+ HCONV hConvPartner = pConv->hConvPartner;
+
+ // die App benachrichtigen, dass alle offenen Advise-Loops
+ // beendet werden, egal ob sie vom Server oder Client
+ // initiiert wurden. Die Dinger aber nicht loeschen, da sie evtl.
+ // noch vom Partner gebraucht werden.
+ ImpConvWndData* pObj =
+ (ImpConvWndData*)WinQueryWindowULong( pConv->hWndThis, 0 );
+ ImpDdeMgr* pThis = pObj->pThis;
+ pThis->SendUnadvises( hConv, 0, FALSE ); // alle Formate & NICHT loeschen
+ pThis->SendUnadvises( hConvPartner, 0, FALSE ); // alle Formate & NICHT loeschen
+
+ pConv->nStatus |= ST_TERMINATED;
+
+ HAB hAB = WinQueryAnchorBlock( pConv->hWndThis );
+ // um die MessageQueue inne Gaenge zu halten
+ ULONG nTimerId = WinStartTimer( hAB, 0, 0, 50 );
+
+ /*
+ Die Partner-App muss ein DDE_TERMINATE posten, auf das
+ wir warten muessen, um alle Messages zu bearbeiten, die
+ _vor_ dem DdeDisconnect von der Partner-App gepostet
+ wurden.
+ */
+ WRITELOG("DdeDisconnect:Waiting for acknowledge...")
+ WinDdePostMsg( hWndPartner, hWndThis, WM_DDE_TERMINATE,
+ (PDDESTRUCT)0,DDEPM_RETRY);
+
+ QMSG aQueueMsg;
+ BOOL bContinue = TRUE;
+ while( bContinue )
+ {
+ if( WinGetMsg( hAB, &aQueueMsg, 0, 0, 0 ))
+ {
+ WinDispatchMsg( hAB, &aQueueMsg );
+ if( (!WinIsWindow( hAB, hWndPartner)) ||
+ (pConv->nStatus & ST_TERMACKREC) )
+ {
+ bContinue = FALSE;
+ if( pConv->nStatus & ST_TERMACKREC )
+ {
+ WRITELOG("DdeDisconnect: TermAck received")
+ }
+ else
+ {
+ WRITELOG("DdeDisconnect: Partner died")
+ }
+ }
+ }
+ else
+ bContinue = FALSE;
+ }
+
+ WinStopTimer( hAB, 0, nTimerId );
+
+ // WRITELOG("DdeDisconnect:Freeing data")
+ // Transaktionstabelle aufraeumen
+ FreeTransactions( pData, hConv );
+ if( hConvPartner )
+ FreeTransactions( pData, hConvPartner );
+
+ FreeConvHandle( pData, hConv );
+
+ WRITELOG("DdeDisconnect:End")
+ //WRITESTATUS("DdeDisconnect:End")
+ return TRUE;
+}
+
+// static
+BOOL ImpDdeMgr::DdeDisconnectList( HCONVLIST hConvList )
+{
+ if( !CheckConvListId( hConvList ) )
+ {
+ ImpDdeMgr::nLastErrInstance = DMLERR_INVALIDPARAMETER;
+ return FALSE;
+ }
+
+ ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData();
+ if ( !pData )
+ {
+ ImpDdeMgr::nLastErrInstance = DMLERR_DLL_NOT_INITIALIZED;
+ return FALSE;
+ }
+ HCONV hConv = 0;
+ GetFirstServer( pData, hConvList, hConv );
+ while( hConv )
+ {
+ DdeDisconnect( hConv );
+ GetFirstServer( pData, hConvList, hConv );
+ }
+ WinDestroyWindow( (HWND)hConvList );
+ return TRUE;
+}
+
+
+
+// static
+HCONV ImpDdeMgr::DdeReconnect(HCONV hConv)
+{
+ ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData();
+ if ( !pData )
+ {
+ ImpDdeMgr::nLastErrInstance = DMLERR_DLL_NOT_INITIALIZED;
+ return 0;
+ }
+ return 0;
+}
+
+// static
+USHORT ImpDdeMgr::DdeQueryConvInfo(HCONV hConv, ULONG nTransId, CONVINFO* pCI)
+{
+ if( !pCI || pCI->nSize == 0)
+ return 0;
+ ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData();
+ if ( !pData )
+ {
+ ImpDdeMgr::nLastErrInstance = DMLERR_DLL_NOT_INITIALIZED;
+ return 0;
+ }
+ Transaction* pTrans;
+ if( nTransId != QID_SYNC )
+ {
+ pTrans = ImpDdeMgr::GetTransTable( pData );
+ pTrans += nTransId;
+ if( nTransId >= pData->nMaxTransCount || pTrans->hConvOwner == 0 )
+ {
+ ImpDdeMgr::nLastErrInstance = DMLERR_UNFOUND_QUEUE_ID;
+ return 0;
+ }
+ }
+ else
+ pTrans = 0;
+
+ ImpHCONV* pConv = ImpDdeMgr::GetConvTable( pData );
+ pConv += (ULONG)hConv;
+ if( hConv >= pData->nMaxConvCount || pConv->hWndThis == 0 )
+ {
+ ImpDdeMgr::nLastErrInstance = DMLERR_NO_CONV_ESTABLISHED;
+ return 0;
+ }
+
+ USHORT nSize = pCI->nSize;
+ if( nSize > sizeof(CONVINFO) )
+ nSize = sizeof(CONVINFO);
+ CONVINFO aTempInfo;
+ memset( &aTempInfo, 0, sizeof(CONVINFO) );
+ aTempInfo.nSize = pCI->nSize;
+ aTempInfo.hConvPartner = pConv->hConvPartner;
+ aTempInfo.hszPartner = pConv->hszPartner;
+ aTempInfo.hszServiceReq = pConv->hszServiceReq;
+ aTempInfo.hszTopic = pConv->hszTopic;
+ aTempInfo.nStatus = pConv->nStatus;
+ aTempInfo.hConvList = pConv->hConvList;
+ aTempInfo.aConvCtxt = pConv->aConvContext;
+ if( pTrans )
+ {
+ aTempInfo.nUser = pTrans->nUser;
+ aTempInfo.hszItem = pTrans->hszItem;
+ aTempInfo.nFormat = pTrans->nFormat;
+ aTempInfo.nType = pTrans->nType;
+ aTempInfo.nConvst = pTrans->nConvst;
+ aTempInfo.nLastError= pTrans->nLastError;
+ }
+ memcpy( pCI, &aTempInfo, nSize );
+
+ return nSize;
+}
+
+// static
+BOOL ImpDdeMgr::DdeSetUserHandle(HCONV hConv, ULONG nTransId, ULONG hUser)
+{
+ ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData();
+ if ( !pData )
+ {
+ ImpDdeMgr::nLastErrInstance = DMLERR_DLL_NOT_INITIALIZED;
+ return FALSE;
+ }
+ Transaction* pTrans = GetTransTable( pData );
+ pTrans += nTransId;
+ if( !nTransId || !hConv || nTransId >= pData->nMaxTransCount ||
+ pTrans->hConvOwner != hConv )
+ {
+ ImpDdeMgr::nLastErrInstance = DMLERR_INVALIDPARAMETER;
+ return FALSE;
+ }
+ if( !pTrans->hConvOwner)
+ {
+ ImpDdeMgr::nLastErrInstance = DMLERR_UNFOUND_QUEUE_ID;
+ return FALSE;
+ }
+ pTrans->nUser = hUser;
+ return TRUE;
+}
+
+BOOL ImpDdeMgr::DdeAbandonTransaction( HCONV hConv, ULONG nTransId )
+{
+ ////WRITELOG("DdeAbandonTransaction:Start")
+ if( !pData )
+ {
+ nLastErrInstance = DMLERR_DLL_NOT_INITIALIZED;
+ return FALSE;
+ }
+ ImpHCONV* pConv = pConvTable;
+ pConv += (USHORT)hConv;
+ if( nTransId < 1 || nTransId >= pData->nMaxTransCount ||
+ hConv < 1 || hConv >= pData->nMaxConvCount || !pConv->hWndThis)
+ {
+ nLastErrInstance = DMLERR_INVALIDPARAMETER;
+ return FALSE;
+ }
+ if( !hConv )
+ {
+ DBG_ASSERT(0,"DdeAbandonTransaction:NULL-hConv not supported");
+ nLastErrInstance = DMLERR_INVALIDPARAMETER;
+ return FALSE;
+ }
+ Transaction* pTrans = pTransTable;
+ pTrans += (USHORT)nTransId;
+ if( pTrans->hConvOwner != hConv )
+ {
+ nLastErrInstance = DMLERR_UNFOUND_QUEUE_ID;
+ return FALSE;
+ }
+
+ if( bInSyncTrans && nTransId == nSyncTransId )
+ {
+ bSyncAbandonTrans = TRUE;
+ return TRUE;
+ }
+ USHORT nTempType = pTrans->nType;
+ nTempType &= (~XTYPF_MASK);
+ if( nTempType == (XTYP_ADVREQ & ~(XTYPF_NOBLOCK)))
+ {
+ ////WRITELOG("DdeAbandTrans:Advise Loop")
+
+// ----------------------------------------------------------------------
+// Der von der Deutschen Bank eingesetzte DDE-Server
+// "Invision V2.71 Build 36 Mar 12 1999 V4.8.2" hat einen Bug, der
+// dazu fuehrt, dass auf per WM_DDE_TERMINATE geschlossene Verbindungen
+// nicht mit einem WM_DDE_TERMINATE geantwortet wird, wenn der
+// entsprechende Link vorher per WM_DDE_UNADVISE beendet wurde. Dieser
+// Bug tritt ab zwei parallel laufenden Links auf. Auf Wunsch der DB
+// wurde das folgende Workaround eingebaut.
+// ----------------------------------------------------------------------
+#define DEUTSCHE_BANK
+#ifndef DEUTSCHE_BANK
+
+// Acknowledge ist beim Unadvise nicht ueblich
+//#define SO_DDE_ABANDON_TRANSACTION_WAIT_ACK
+#ifdef SO_DDE_ABANDON_TRANSACTION_WAIT_ACK
+ DDESTRUCT* pOutDDEData = MakeDDEObject( pConv->hWndPartner,
+ pTrans->hszItem, DDE_FACKREQ, 0 /*pTrans->nFormat*/, 0, 0);
+#else
+ DDESTRUCT* pOutDDEData = MakeDDEObject( pConv->hWndPartner,
+ pTrans->hszItem, 0, 0 /*pTrans->nFormat*/, 0, 0);
+#endif
+ WRITELOG("DdeAbandTrans:Waiting for acknowledge...")
+ pTrans->nConvst = XST_UNADVSENT;
+ if ( !MyWinDdePostMsg( pConv->hWndPartner, pConv->hWndThis,
+ WM_DDE_UNADVISE, pOutDDEData, DDEPM_RETRY ) )
+ {
+ WRITELOG("DdeAbandTrans:PostMsg Failed")
+ return FALSE;
+ }
+#ifdef SO_DDE_ABANDON_TRANSACTION_WAIT_ACK
+ WaitTransState( pTrans, nTransId, XST_UNADVACKRCVD, 0 );
+#else
+ pTrans->nConvst = XST_UNADVACKRCVD;
+#endif
+
+#endif // DEUTSCHE_BANK
+
+ WRITELOG("DdeAbandTrans:Ack received->Freeing transaction")
+ FreeTransaction( pData, nTransId );
+ }
+ WRITELOG("DdeAbandonTransaction:End")
+ return TRUE;
+}
+
+// wird von einem Server aufgerufen, wenn sich die Daten des
+// Topic/Item-Paars geaendert haben. Diese Funktion fordert
+// dann den Server auf, die Daten zu rendern (bei Hotlinks) und
+// benachrichtigt die Clients
+BOOL ImpDdeMgr::DdePostAdvise( HSZ hszTopic, HSZ hszItem)
+{
+ ////WRITELOG("DdePostAdvise:Start")
+ ////WRITESTATUS("DdePostAdvise:Start")
+
+#if 0 && defined( OV_DEBUG )
+ String aDebStr("DdePostAdvise:Item ");
+ aDebStr += (ULONG)hszItem;
+ WRITELOG((char*)(const char*)aDebStr)
+#endif
+
+ Transaction* pTrans = pTransTable;
+ pTrans++;
+ USHORT nCurTrans = 1;
+ USHORT nUsedTransactions = pData->nCurTransCount;
+ while( nUsedTransactions && nCurTrans < pData->nMaxTransCount )
+ {
+ HCONV hOwner = pTrans->hConvOwner;
+ if( hOwner )
+ {
+ nUsedTransactions--;
+ USHORT nTempType = pTrans->nType;
+ nTempType &= (~XTYPF_MASK);
+ if( nTempType == (XTYP_ADVREQ & (~XTYPF_NOBLOCK) ) )
+ {
+ ImpHCONV* pConv = pConvTable;
+ pConv += (USHORT)hOwner;
+ if(hszItem == pTrans->hszItem && pConv->hszTopic == hszTopic)
+ {
+ if( pConv->hConvPartner )
+ {
+ // Transaktionen werden immer vom Client erzeugt
+ // -> auf Server-HCONV umschalten
+ hOwner = pConv->hConvPartner;
+ pConv = pConvTable;
+ pConv += (USHORT)hOwner;
+ }
+ HWND hWndClient = pConv->hWndPartner;
+ HWND hWndServer = pConv->hWndThis;
+#if 0 && defined( OV_DEBUG )
+ String aDebStr("DdePostAdvise: Server:");
+ aDebStr += (ULONG)hWndServer;
+ aDebStr += " Client:";
+ aDebStr += (ULONG)hWndClient;
+ WRITELOG((char*)(const char*)aDebStr)
+#endif
+ DDESTRUCT* pOutDDEData;
+ if ( pTrans->nType & XTYPF_NODATA )
+ {
+ // Warm link
+ ////WRITELOG("DdePostAdvise:Warm link found")
+ pOutDDEData = MakeDDEObject( hWndClient, hszItem,
+ DDE_FNODATA, pTrans->nFormat, 0, 0 );
+ }
+ else
+ {
+ // Hot link
+ ////WRITELOG("DdePostAdvise:Hot link found")
+ pOutDDEData = Callback( XTYP_ADVREQ,
+ pTrans->nFormat, hOwner, hszTopic,
+ hszItem, (HDDEDATA)0, 1, 0 );
+ }
+ if( pOutDDEData )
+ {
+ // todo: FACK_REQ in Out-Data setzen, wenn pTrans->nType & XTYPF_ACKREQ
+ ////WRITELOG("DdePostAdvise:Sending data/notification")
+ BOOL bSuccess = MyWinDdePostMsg( hWndClient,
+ hWndServer,WM_DDE_DATA, pOutDDEData, DDEPM_RETRY);
+ if( bSuccess )
+ {
+ // auf Acknowledge des Partners warten ?
+ if( pTrans->nType & XTYPF_ACKREQ )
+ {
+ pTrans->nConvst = XST_ADVDATASENT;
+ // Impl. ist falsch! => korrekt: XST_ADVDATAACKRCVD
+ WaitTransState(pTrans, nCurTrans,
+ XST_UNADVACKRCVD, 0);
+ }
+ }
+ else
+ {
+ ////WRITELOG("DdePostAdvise:PostMsg failed")
+ nLastErrInstance = DMLERR_POSTMSG_FAILED;
+ }
+ }
+ else
+ {
+ ////WRITELOG("DdePostAdvise:No data to send")
+ }
+ }
+ }
+ }
+ nCurTrans++;
+ pTrans++;
+ }
+ ////WRITELOG("DdePostAdvise:End")
+ return TRUE;
+}
+
+BOOL ImpDdeMgr::DdeEnableCallback( HCONV hConv, USHORT wCmd)
+{
+ return FALSE;
+}
+
+// Rueckgabe: 0==Service nicht registriert; sonst Pointer auf Service-Eintrag
+ImpService* ImpDdeMgr::GetService( HSZ hszService )
+{
+ ImpService* pPtr = pServices;
+ if( !pPtr || !hszService )
+ return 0;
+ for( ULONG nIdx = 0; nIdx < nServiceCount; nIdx++, pPtr++ )
+ {
+ if(( hszService == pPtr->hBaseServName ) ||
+ ( hszService == pPtr->hInstServName ) )
+ return pPtr;
+ }
+ return 0;
+}
+
+
+// legt Service in Service-Tabelle ab. Tabelle wird ggf. expandiert
+ImpService* ImpDdeMgr::PutService( HSZ hszService )
+{
+ if( !pServices )
+ {
+ DBG_ASSERT(nServiceCount==0,"DDE:Bad ServiceCount");
+ pServices = new ImpService[ DDEMLSERVICETABLE_INISIZE ];
+ memset( pServices, 0, DDEMLSERVICETABLE_INISIZE* sizeof(ImpService));
+ nServiceCount = DDEMLSERVICETABLE_INISIZE;
+ }
+ ImpService* pPtr = pServices;
+ USHORT nCurPos = 0;
+ while( pPtr )
+ {
+ if( pPtr->hBaseServName == 0 )
+ break;
+ nCurPos++;
+ if( nCurPos < nServiceCount )
+ pPtr++;
+ else
+ pPtr = 0;
+ }
+ if( !pPtr )
+ {
+ // Tabelle vergroessern
+ pPtr = new ImpService[ nServiceCount + DDEMLSERVICETABLE_INISIZE ];
+ memset( pPtr, 0, DDEMLSERVICETABLE_INISIZE* sizeof(ImpService));
+ memcpy( pPtr, pServices, nServiceCount * sizeof(ImpService) );
+#ifdef DBG_UTIL
+ memset( pServices, 0, nServiceCount * sizeof(ImpService) );
+#endif
+ delete pServices;
+ pServices = pPtr;
+ pPtr += nServiceCount; // zeigt auf erste neue Position
+ nServiceCount += DDEMLSERVICETABLE_INISIZE;
+ }
+ DBG_ASSERT(pPtr->hBaseServName==0,"DDE:Service not empty");
+ DBG_ASSERT(pPtr->hInstServName==0,"DDE:Service not empty");
+
+ DdeKeepStringHandle( hszService );
+
+ USHORT nStrLen = (USHORT)DdeQueryString( hszService, 0, 0, 0);
+ char* pBuf = new char[ nStrLen + 1 ];
+ DdeQueryString(hszService, pBuf, nStrLen, 850 /* CodePage*/ );
+ pBuf[ nStrLen ] = 0;
+ String aStr( (ULONG)hWndServer );
+ aStr += pBuf;
+ HSZ hszInstServ = DdeCreateStringHandle( (PSZ)(const char*)pBuf, 850 );
+ delete[] pBuf;
+
+ pPtr->hBaseServName = hszService;
+ pPtr->hInstServName = hszInstServ;
+ return pPtr;
+}
+
+void ImpDdeMgr::BroadcastService( ImpService* pService, BOOL bRegistered )
+{
+ DBG_ASSERT(pService,"DDE:No Service");
+ if( !pService )
+ return;
+ MPARAM aMp1 = (MPARAM)(pService->hBaseServName);
+ MPARAM aMp2 = (MPARAM)(pService->hInstServName);
+ ULONG nMsg;
+ if( bRegistered )
+ nMsg = WM_DDEML_REGISTER;
+ else
+ nMsg = WM_DDEML_UNREGISTER;
+
+ HWND* pPtr = pAppTable;
+ for( USHORT nPos = 0; nPos < pData->nMaxAppCount; nPos++, pPtr++ )
+ {
+ HWND hWndCurWin = *pPtr;
+ if ( hWndCurWin && hWndCurWin != hWndServer )
+ WinSendMsg( hWndCurWin, nMsg, aMp1, aMp2 );
+ }
+}
+
+HDDEDATA ImpDdeMgr::DdeNameService( HSZ hszService, USHORT afCmd )
+{
+ HDDEDATA hRet = (HDDEDATA)1;
+
+ if( afCmd & DNS_FILTERON )
+ bServFilterOn = TRUE;
+ else if( afCmd & DNS_FILTEROFF )
+ bServFilterOn = FALSE;
+ ImpService* pService = GetService( hszService );
+ BOOL bRegister = (BOOL)(afCmd & DNS_REGISTER);
+ if( bRegister )
+ {
+ if( !pService )
+ {
+ pService = PutService( hszService );
+ BroadcastService( pService, TRUE );
+ }
+ }
+ else
+ {
+ if( pService )
+ {
+ BroadcastService( pService, FALSE );
+ DdeFreeStringHandle( pService->hBaseServName );
+ pService->hBaseServName = 0;
+ DdeFreeStringHandle( pService->hInstServName );
+ pService->hInstServName = 0;
+ }
+ hRet = (HDDEDATA)0; // Service nicht gefunden
+ }
+ return hRet;
+}
+
+
+// static
+HDDEDATA ImpDdeMgr::DdeClientTransaction(void* pDdeData, ULONG cbData,
+ HCONV hConv, HSZ hszItem, USHORT nFormat, USHORT nType,
+ ULONG nTimeout, ULONG* pResult)
+{
+ //WRITELOG("DdeClientTransaction:Start")
+
+#if 0 && defined(OV_DEBUG)
+ if( nType == XTYP_REQUEST )
+ {
+ WRITELOG("Start XTYP_REQUEST");
+ WinMessageBox(HWND_DESKTOP,HWND_DESKTOP,
+ "Start XTYP_REQUEST","DdeClientTransaction",
+ HWND_DESKTOP,MB_OK);
+ }
+#endif
+
+ if( pResult )
+ *pResult = 0;
+
+ ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData();
+ if ( !pData )
+ {
+ ImpDdeMgr::nLastErrInstance = DMLERR_DLL_NOT_INITIALIZED;
+ return (HDDEDATA)0;
+ }
+
+ BOOL bIsDdeHandle = (BOOL)(pDdeData && cbData==0xffffffff);
+ BOOL bAppOwnsHandle = (BOOL)( bIsDdeHandle &&
+ (((DDESTRUCT*)pDdeData)->fsStatus & IMP_HDATAAPPOWNED) );
+
+ BOOL bNoData = (BOOL)(nType & XTYPF_NODATA)!=0;
+ BOOL bAckReq = (BOOL)(nType & XTYPF_ACKREQ)!=0;
+ USHORT nTypeFlags = nType & XTYPF_MASK;
+ nType &= (~XTYPF_MASK);
+
+ BOOL bSync = (BOOL)( nTimeout != TIMEOUT_ASYNC ) != 0;
+ if( nType == XTYP_ADVSTART )
+ bSync = TRUE;
+
+ // Mapping transaction -> OS/2-Message
+ USHORT nTimeoutErr, nMsg;
+ switch ( nType )
+ {
+ case XTYP_ADVSTART:
+ nMsg = WM_DDE_ADVISE;
+ nTimeoutErr = DMLERR_ADVACKTIMEOUT;
+{
+ nTimeout = 60000;
+#if 0 && defined(OV_DEBUG)
+ char aBuf[ 128 ];
+ ImpDdeMgr::DdeQueryString( hszItem,aBuf,127,850);
+ String aXXStr("Establishing hotlink ");
+ aXXStr += aBuf;
+ WRITELOG((char*)aXXStr.GetStr());
+#endif
+
+}
+ break;
+
+ case XTYP_ADVSTOP:
+ nMsg = WM_DDE_UNADVISE;
+ nTimeoutErr = DMLERR_UNADVACKTIMEOUT;
+ break;
+
+ case XTYP_REQUEST:
+ nMsg = WM_DDE_REQUEST;
+ nTimeoutErr = DMLERR_DATAACKTIMEOUT;
+ break;
+
+ case XTYP_POKE:
+ nMsg = WM_DDE_POKE;
+ nTimeoutErr = DMLERR_POKEACKTIMEOUT;
+ break;
+
+ case XTYP_EXECUTE:
+ nMsg = WM_DDE_EXECUTE;
+ nTimeoutErr = DMLERR_EXECACKTIMEOUT;
+ break;
+
+ default:
+ nMsg = 0;
+ }
+ if(!hConv || (USHORT)hConv>= pData->nMaxConvCount || !nType || !nMsg ||
+ (nType != XTYP_EXECUTE && (!hszItem || !nFormat)) )
+ {
+ WRITELOG("DdeClientTransaction:Invalid parameter")
+ ImpDdeMgr::nLastErrInstance = DMLERR_INVALIDPARAMETER;
+ if( bIsDdeHandle && !bAppOwnsHandle )
+ DdeFreeDataHandle( (HDDEDATA)pDdeData );
+ return (HDDEDATA)0;
+ }
+
+ // ueber den Conversation handle das ImpDdeMgr-Objekt holen
+ ImpHCONV* pConv = GetConvTable( pData );
+ pConv += (USHORT)hConv;
+ ImpConvWndData* pObj =
+ (ImpConvWndData*)WinQueryWindowULong( pConv->hWndThis, 0 );
+ ImpDdeMgr* pThis = pObj->pThis;
+
+ if( bSync && pThis->bInSyncTrans )
+ {
+ WRITELOG("DdeClientTransaction:Already in sync. transaction")
+ ImpDdeMgr::nLastErrInstance = DMLERR_REENTRANCY;
+ if( bIsDdeHandle && !bAppOwnsHandle )
+ DdeFreeDataHandle( (HDDEDATA)pDdeData );
+ return (HDDEDATA)0;
+ }
+
+ Transaction* pTrans;
+
+ BOOL bReqOnAdvLoop = FALSE;
+ ULONG nTransId = GetTransaction( pData, hConv, hszItem, nFormat );
+ if( nTransId )
+ {
+ // WRITELOG("DdeClientTransaction:Transaction found")
+ pTrans = GetTransTable( pData );
+ pTrans += (USHORT)nTransId;
+ USHORT nTransType = pTrans->nType;
+ nTransType &= (~XTYPF_MASK);
+ if( (nType != XTYP_REQUEST && nTransType == nType) ||
+ // wird Advise-Loop schon zum requesten missbraucht ?
+ (nType == XTYP_REQUEST &&
+ nTransType == XTYP_ADVREQ &&
+ pTrans->nConvst == XST_WAITING_REQDATA))
+ {
+ // dieser Kanal ist dicht!
+ WRITELOG("DdeClientTransaction:Transaction already used")
+ ImpDdeMgr::nLastErrInstance = DMLERR_REENTRANCY;
+ if( bIsDdeHandle && !bAppOwnsHandle )
+ DdeFreeDataHandle( (HDDEDATA)pDdeData );
+ return (HDDEDATA)0;
+ }
+ else if( nTransType == XTYP_ADVREQ )
+ {
+ switch( nType )
+ {
+ case XTYP_ADVSTOP:
+ //WRITELOG("DdeClientTransaction:Stopping advise trans")
+ pTrans->nType = XTYP_ADVSTOP;
+ break;
+
+ case XTYP_ADVSTART:
+ //WRITELOG("DdeClientTransaction:Adj. Advise-Params")
+ pTrans->nType = XTYP_ADVREQ;
+ if( bNoData )
+ pTrans->nType |= XTYPF_NODATA;
+ if( bAckReq )
+ pTrans->nType |= XTYPF_ACKREQ;
+ if( pResult )
+ *pResult = nTransId;
+ return (HDDEDATA)TRUE;
+
+ case XTYP_REQUEST:
+ // WRITELOG("DdeClientTransaction:Using adv trans for req")
+ // nConvst wird unten auf XST_WAITING_REQDATA gesetzt
+ bReqOnAdvLoop = TRUE;
+ break;
+
+ default:
+ WRITELOG("DdeClientTransaction:Invalid parameter")
+ ImpDdeMgr::nLastErrInstance = DMLERR_INVALIDPARAMETER;
+ if( bIsDdeHandle && !bAppOwnsHandle )
+ DdeFreeDataHandle( (HDDEDATA)pDdeData );
+ return (HDDEDATA)FALSE;
+ }
+ }
+ }
+ else
+ {
+ // WRITELOG("DdeClientTransaction:Creating transaction")
+ nTransId = CreateTransaction(pData, hConv, hszItem, nFormat, nType);
+ }
+
+ pTrans = GetTransTable( pData );
+ pTrans += (USHORT)nTransId;
+ pTrans->nConvst = XST_WAITING_ACK;
+ if( nType == XTYP_REQUEST )
+ pTrans->nConvst = XST_WAITING_REQDATA;
+
+ HWND hWndServer = pConv->hWndPartner;
+ HWND hWndClient = pConv->hWndThis;
+
+ HDDEDATA pOutDDEData;
+ if( bIsDdeHandle )
+ {
+ if( bAppOwnsHandle )
+ {
+ // wir muessen leider leider duplizieren, da uns OS/2
+ // keine Chance laesst, diesen Status im Datenobjekt
+ // zu versenken.
+ ////WRITELOG("DdeClientTransaction:Copying handle")
+ HDDEDATA pNew;
+ HDDEDATA pData = (HDDEDATA)pDdeData;
+ if( !(MyDosAllocSharedMem((PPVOID)&pNew, NULL, pData->cbData,
+ PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_GIVEABLE | OBJ_ANY,
+ "MakeDDEObject")))
+ {
+ memcpy( pNew, pData, pData->cbData );
+ pOutDDEData = pNew;
+ }
+ else
+ {
+ WRITELOG("DdeClientTransaction:No Memory")
+ ImpDdeMgr::nLastErrInstance = DMLERR_LOW_MEMORY;
+ return (HDDEDATA)0;
+ }
+ }
+ else
+ pOutDDEData = (HDDEDATA)pDdeData;
+ }
+ else
+ pOutDDEData=MakeDDEObject(hWndServer,hszItem,0,nFormat,pDdeData,cbData);
+
+ pOutDDEData->fsStatus |= nTypeFlags;
+
+ HDDEDATA pDDEInData = 0;
+ if( bSync )
+ {
+ if( nType != XTYP_REQUEST )
+ pOutDDEData->fsStatus |= DDE_FACKREQ;
+
+ // WRITELOG("DdeClientTransaction:Starting sync. trans.")
+ pThis->hSyncResponseData = (HDDEDATA)0;
+ pThis->nSyncResponseMsg = 0;
+ pThis->bInSyncTrans = TRUE;
+ pThis->nSyncTransId = nTransId;
+ pThis->bSyncAbandonTrans = FALSE;
+
+ if ( !MyWinDdePostMsg( hWndServer, hWndClient, nMsg, pOutDDEData,
+ DDEPM_RETRY) )
+ {
+ WRITELOG("DdeClientTransaction:PostMsg failed")
+ nLastErrInstance = DMLERR_POSTMSG_FAILED;
+ if( !bReqOnAdvLoop )
+ FreeTransaction( pData, nTransId );
+ else
+ {
+ DBG_ASSERT(pTrans->nType==XTYP_ADVREQ,"DDE:Error!")
+ pTrans->nConvst = 0;
+ }
+ return FALSE;
+ }
+ HAB hAB = WinQueryAnchorBlock( hWndClient );
+ ULONG nDummyTimer = WinStartTimer( hAB, 0, 0, 50 );
+ ULONG nTimeoutId = TID_USERMAX - nTransId;
+ WinStartTimer( hAB, hWndClient, nTimeoutId, nTimeout );
+ QMSG aQueueMsg;
+ BOOL bLoop = TRUE;
+ while( bLoop )
+ {
+ if( pThis->nSyncResponseMsg )
+ bLoop = FALSE;
+ else
+ {
+ if( WinGetMsg(hAB,&aQueueMsg,0,0,0 ))
+ {
+ WinDispatchMsg( hAB, &aQueueMsg );
+ }
+ else
+ bLoop = FALSE;
+ }
+ }
+
+ WinStopTimer( hAB, hWndClient, nTimeoutId );
+ WinStopTimer( hAB, 0, nDummyTimer );
+
+ //
+ // Der Speicherblock pOutDDEData muss vom Server geloescht worden sein!
+ // Ueberlegen: Nochmal loeschen, falls Server buggy ist, ansonsten
+ // platzt uns bald der Adressraum!
+ //
+ if( !pThis->nSyncResponseMsg )
+ {
+ // unsere App wurde beendet
+ ////WRITELOG("DdeClientTransaction:App terminated")
+ return 0;
+ }
+ pDDEInData = pThis->hSyncResponseData;
+ nMsg = pThis->nSyncResponseMsg;
+ pThis->hSyncResponseData= 0;
+ pThis->nSyncResponseMsg = 0;
+ pThis->bInSyncTrans = FALSE;
+ pThis->nSyncTransId = 0;
+ if( !pDDEInData && nMsg != WM_TIMER )
+ {
+ DBG_ASSERT(0,"Dde:No data!");
+ WRITELOG("DdeClientTransaction: No Data!")
+ return (HDDEDATA)0;
+ }
+ switch( nMsg )
+ {
+ case WM_TIMER:
+ WRITELOG("DdeClientTransaction:Timeout!")
+ nLastErrInstance = nTimeoutErr;
+ if( bReqOnAdvLoop )
+ // auf normalen Loop-Betrieb zurueckschalten
+ pTrans->nConvst = XST_WAITING_ADVDATA;
+ break;
+
+ case WM_DDE_ACK:
+ {
+ // WRITELOG("DdeClientTransaction:Ack received")
+ BOOL bPositive = (BOOL)(pDDEInData->fsStatus & DDE_FACK);
+ MyDosFreeMem( pDDEInData,"DdeClientTransaction" );
+ pDDEInData = (HDDEDATA)bPositive;
+ if( nType == XTYP_ADVSTART && pDDEInData )
+ {
+
+#if 0 && defined(OV_DEBUG)
+ char aBuf[ 128 ];
+ ImpDdeMgr::DdeQueryString( pTrans->hszItem,aBuf,128,850);
+ String aXXStr("Hotlink ");
+#endif
+
+ if( bPositive )
+ {
+ pTrans->nType = XTYP_ADVREQ;
+ // Hot/Warmlink, Ack
+ pTrans->nType |= nTypeFlags;
+ // XST_WAITING_ACK ==> XST_WAITING_ADVDATA
+ pTrans->nConvst = XST_WAITING_ADVDATA;
+
+#if 0 && defined(OV_DEBUG)
+ aXXStr += "established ";
+ aXXStr += aBuf;
+#endif
+
+ }
+
+#if 0 && defined(OV_DEBUG)
+ else
+ {
+ aXXStr += "failed ";
+ aXXStr += aBuf;
+ }
+ WRITELOG((char*)aXXStr.GetStr());
+#endif
+
+ }
+ }
+ break;
+
+ case WM_DDE_DATA:
+ // WRITELOG("DdeClientTransaction:Data received")
+ // WRITEDATA(pDDEInData)
+ if( bReqOnAdvLoop )
+ {
+ DBG_ASSERT(pTrans->nConvst==XST_WAITING_REQDATA,"DDE:Bad state");
+ DBG_ASSERT(pTrans->nType==XTYP_ADVREQ,"DDE:Bad state");
+ // auf Loop-Betrieb umschalten
+ pTrans->nConvst = XST_WAITING_ADVDATA;
+ }
+ break;
+
+ default:
+ WRITELOG("DdeClientTransaction:Unexpected msg")
+ MyDosFreeMem( pDDEInData,"DdeClientTransaction" );
+ pDDEInData = 0;
+ }
+ pThis->bSyncAbandonTrans = FALSE;
+ pThis->bInSyncTrans = FALSE;
+ if( pThis->bSyncAbandonTrans && bReqOnAdvLoop )
+ pThis->DdeAbandonTransaction( hConv, nTransId );
+ }
+ else
+ {
+ // WRITELOG("DdeClientTransaction:Starting async. trans.")
+ pDDEInData = (HDDEDATA)MyWinDdePostMsg( hWndServer, hWndClient, nMsg,
+ pOutDDEData, DDEPM_RETRY);
+ if( !pDDEInData )
+ {
+ WRITELOG("DdeClientTransaction:PostMsg failed")
+ nLastErrInstance = DMLERR_POSTMSG_FAILED;
+ if( !bReqOnAdvLoop )
+ FreeTransaction( pData, nTransId );
+ else
+ {
+ DBG_ASSERT(pTrans->nType==XTYP_ADVREQ,"DDE:Error!")
+ pTrans->nConvst = 0;
+ }
+ }
+ else
+ {
+ // WRITELOG("DdeClientTransaction:Async trans. success")
+ if( pResult )
+ *pResult = nTransId;
+ }
+ }
+#if 0 && defined( OV_DEBUG )
+ if( nType == XTYP_REQUEST )
+ {
+ WRITELOG("End XTYP_REQUEST");
+ WinMessageBox(HWND_DESKTOP,HWND_DESKTOP,
+ "End XTYP_REQUEST","DdeClientTransaction",
+ HWND_DESKTOP,MB_OK);
+ }
+#endif
+ //WRITELOG("DdeClientTransaction:End")
+ //WRITESTATUS("DdeClientTransaction:End")
+ return pDDEInData;
+}
+
+MRESULT ImpDdeMgr::DdeRegister( ImpWndProcParams* pParams )
+{
+ MRESULT nRet = (MRESULT)0;
+ if ( !(nTransactFilter & CBF_SKIP_REGISTRATIONS) )
+ {
+ HSZ hSBaseName = (HSZ)pParams->nPar1;
+ HSZ hIBaseName = (HSZ)pParams->nPar2;
+ nRet=(MRESULT)Callback(XTYP_REGISTER,0,0,hSBaseName,hIBaseName,0,0,0);
+ }
+ return nRet;
+}
+
+MRESULT ImpDdeMgr::DdeUnregister( ImpWndProcParams* pParams )
+{
+ MRESULT nRet = (MRESULT)0;
+ if ( !(nTransactFilter & CBF_SKIP_UNREGISTRATIONS) )
+ {
+ HSZ hSBaseName = (HSZ)pParams->nPar1;
+ HSZ hIBaseName = (HSZ)pParams->nPar2;
+ nRet=(MRESULT)Callback(XTYP_UNREGISTER,0,0,hSBaseName,hIBaseName,0,0,0);
+ }
+ return nRet;
+}
+
+MRESULT ImpDdeMgr::DdeTimeout( ImpWndProcParams* pParams )
+{
+ ////WRITELOG("DdeTimeout:Received")
+ if( nSyncResponseMsg )
+ {
+ ////WRITELOG("DdeTimeout:Trans already processed->ignoring timeout")
+ return (MRESULT)1;
+ }
+ ULONG nTimerId = (ULONG)pParams->nPar1;
+ ULONG nTransId = TID_USERMAX - nTimerId;
+ Transaction* pTrans = pTransTable;
+ pTrans += (USHORT)nTransId;
+ if( nTransId < 1 || nTransId >= pData->nMaxTransCount ||
+ pTrans->hConvOwner == 0 )
+ {
+ DBG_ASSERT(0,"DdeTimeout:Invalid TransactionId");
+ return (MRESULT)1;
+ }
+ if( bInSyncTrans && nTransId == nSyncTransId )
+ {
+ USHORT nTempType = pTrans->nType;
+ nTempType &= (~XTYPF_MASK);
+ // advise-loops koennen nur innerhalb synchroner
+ // requests timeouts bekommen. die transaktion wird
+ // in diesem fall nicht geloescht.
+ if( nTempType != (XTYP_ADVREQ & (~XTYPF_NOBLOCK) ))
+ {
+ ////WRITELOG("DdeTimeout:Freeing transaction")
+ FreeTransaction( pData, nTransId );
+ }
+ nSyncResponseMsg = WM_TIMER;
+#if 0 && defined( OV_DEBUG )
+ String aMsg("DdeTimeout:Transaction=");
+ aMsg += nTransId;
+ WRITELOG((char*)(const char*)aMsg)
+#endif
+ }
+ else
+ {
+ ////WRITELOG("DdeTimeout:Async transaction timed out")
+ pTrans->nConvst = XST_TIMEOUT;
+ }
+ return (MRESULT)1;
+}
+
+
+
+MRESULT ImpDdeMgr::DdeTerminate( ImpWndProcParams* pParams )
+{
+ WRITELOG("DdeTerminate:Received")
+ HWND hWndThis = pParams->hWndReceiver;
+ HWND hWndPartner = (HWND)(pParams->nPar1);
+
+ HCONV hConv = GetConvHandle( pData, hWndThis, hWndPartner );
+#if 0 && defined( OV_DEBUG )
+ String strDebug("DdeTerminate:ConvHandle=");
+ strDebug += (USHORT)hConv;
+ WRITELOG((char*)(const char*)strDebug)
+#endif
+ ImpHCONV* pConv = pConvTable + (USHORT)hConv;
+ if( hConv )
+ {
+ // warten wir auf ein DDE_TERMINATE Acknowledge ?
+ if( pConv->nStatus & ST_TERMINATED )
+ {
+ ////WRITELOG("DdeTerminate:TERMINATE-Ack received")
+ pConv->nStatus |= ST_TERMACKREC;
+ return (MRESULT)0; // DdeDisconnect raeumt jetzt auf
+ }
+
+ // sind wir Server?, wenn ja: die App benachrichtigen,
+ // dass die Advise loops gestoppt wurden und die
+ // Transaktionen loeschen
+
+ // OV 26.07.96: Die das TERMINATE empfangende App muss
+ // die Transaction-Tabelle abraeumen, egal ob Server oder Client!!
+ // Es muessen alle Trans geloescht werden, die als Owner den
+ // Client oder den Server haben!
+ // if( !(pConv->nStatus & ST_CLIENT ) )
+ SendUnadvises( hConv, 0, FALSE ); // alle Formate & nicht loeschen
+ SendUnadvises( pConv->hConvPartner, 0, FALSE );
+
+ // wir werden von draussen gekillt
+ if ( !(nTransactFilter & CBF_SKIP_DISCONNECTS) )
+ {
+ Callback( XTYP_DISCONNECT, 0, hConv, 0, 0, 0,
+ 0, (ULONG)IsSameInstance(hWndPartner));
+ }
+
+ // kann unsere Partner-App DDEML ?
+ if( !(pConv->hConvPartner) )
+ {
+ // nein, deshalb Transaktionstabelle selbst loeschen
+ ////WRITELOG("DdeTerminate:Freeing transactions")
+ FreeTransactions( pData, hConv );
+ }
+ }
+ else
+ nLastErrInstance = DMLERR_NO_CONV_ESTABLISHED;
+
+#if 0 && defined(OV_DEBUG)
+ if( !WinIsWindow(0,hWndPartner))
+ {
+ WRITELOG("DdeTerminate:hWndPartner not valid")
+ }
+ if(!WinIsWindow(0,hWndThis))
+ {
+ WRITELOG("DdeTerminate:hWndThis not valid")
+ }
+#endif
+
+ if( hConv )
+ {
+ // hWndThis nicht loeschen, da wir den Handle noch fuer
+ // das Acknowledge brauchen
+ ////WRITELOG("DdeTerminate:Freeing conversation")
+ FreeConvHandle( pData, hConv, FALSE );
+ }
+
+ ////WRITELOG("DdeTerminate:Acknowledging DDE_TERMINATE")
+
+#ifdef OV_DEBUG
+ DBG_ASSERT(WinIsWindow( 0, hWndThis ),"hWndThis not valid");
+#endif
+
+ if( !WinDdePostMsg( hWndPartner, hWndThis, WM_DDE_TERMINATE, 0, DDEPM_RETRY ))
+ {
+ ////WRITELOG("DdeTerminate:Acknowledging DDE_TERMINATE failed")
+ }
+ // jetzt hWndThis loeschen
+ DestroyConversationWnd( hWndThis );
+
+ return (MRESULT)0;
+}
+
+
+/*
+ Zuordnung des Conversationhandles:
+
+ Verbindungsaufbau:
+ Client: DdeInitiate( HWNDClient )
+ Server: Post( WM_DDE_INITIATEACK( HWNDServer ))
+ Client: CreateConvHandle( HWNDClient, HWNDServer )
+
+ Datenaustausch:
+ Server: Post(WM_DDE_ACK( HWNDSender ))
+ Client: GetConvHandle( HWNDClient, HWNDSender )
+*/
+
+MRESULT ImpDdeMgr::ConvWndProc( HWND hWnd,ULONG nMsg,MPARAM nPar1,MPARAM nPar2 )
+{
+ ImpWndProcParams aParams;
+
+ MRESULT nRet = (MRESULT)0;
+ aParams.hWndReceiver= hWnd;
+ aParams.nPar1 = nPar1;
+ aParams.nPar2 = nPar2;
+
+ switch( nMsg )
+ {
+
+#ifdef DBG_UTIL
+ case WM_DDE_INITIATE :
+ DBG_ASSERT(0,"dde:unexpected msg");
+ nRet = (MRESULT)TRUE;
+ break;
+#endif
+
+ case WM_DDE_INITIATEACK : nRet = DdeInitiateAck(&aParams); break;
+ case WM_DDE_ACK : nRet = DdeAck( &aParams ); break;
+ case WM_DDE_ADVISE : nRet = DdeAdvise( &aParams ); break;
+ case WM_DDE_DATA : nRet = DdeData( &aParams ); break;
+ case WM_DDE_EXECUTE : nRet = DdeExecute( &aParams ); break;
+ case WM_DDE_POKE : nRet = DdePoke( &aParams ); break;
+ case WM_DDE_REQUEST : nRet = DdeRequest( &aParams ); break;
+ case WM_DDE_TERMINATE : nRet = DdeTerminate( &aParams ); break;
+ case WM_DDE_UNADVISE : nRet = DdeUnadvise( &aParams ); break;
+ case WM_TIMER : nRet = DdeTimeout( &aParams ); break;
+ }
+ return nRet;
+}
+
+MRESULT ImpDdeMgr::SrvWndProc( HWND hWnd,ULONG nMsg,MPARAM nPar1,MPARAM nPar2 )
+{
+ MRESULT nRet = (MRESULT)0;
+
+ ImpWndProcParams aParams;
+ aParams.hWndReceiver= hWnd;
+ aParams.nPar1 = nPar1;
+ aParams.nPar2 = nPar2;
+
+ switch( nMsg )
+ {
+#ifdef DBG_UTIL
+ case WM_DDE_ACK :
+ case WM_DDE_ADVISE :
+ case WM_DDE_EXECUTE :
+ case WM_DDE_POKE :
+ case WM_DDE_REQUEST :
+ case WM_DDE_UNADVISE :
+ case WM_DDE_DATA :
+ case WM_DDE_INITIATEACK :
+ DBG_ASSERT(0,"dde:unexpected msg");
+ nRet = (MRESULT)TRUE;
+ break;
+#endif
+
+ case WM_DDE_TERMINATE :
+ break; // DDE_INITIATE wurde im DDE_INITIATEACK terminiert
+
+ // ein Client will was von uns
+ case WM_DDE_INITIATE :
+ nRet = DdeInitiate( &aParams );
+ break;
+
+ // eine ddeml-faehige App. hat einen Service (typ. AppName) [de]reg.
+ case WM_DDEML_REGISTER :
+ nRet = DdeRegister( &aParams );
+ break;
+
+ case WM_DDEML_UNREGISTER :
+ nRet = DdeUnregister( &aParams );
+ break;
+ };
+ return nRet;
+}
+
+
+MRESULT ImpDdeMgr::DdeAck( ImpWndProcParams* pParams )
+{
+ //WRITELOG("DdeAck:Start")
+ HSZ hszItem;
+ DDESTRUCT* pInDDEData = (DDESTRUCT*)(pParams->nPar2);
+ if( pInDDEData )
+ {
+ BOOL bPositive = (BOOL)(pInDDEData->fsStatus & DDE_FACK ) != 0;
+ BOOL bBusy = bPositive ? FALSE : (BOOL)(pInDDEData->fsStatus & DDE_FBUSY ) != 0;
+ BOOL bNotProcessed = (BOOL)(pInDDEData->fsStatus & DDE_NOTPROCESSED ) != 0;
+#if 0 && defined( OV_DEBUG )
+ String aDebStr("DdeAck:Received ");
+ if( bPositive )
+ aDebStr += "(positive)";
+ else
+ aDebStr += "(negative)";
+ if( bBusy )
+ aDebStr += "(busy)";
+ if( bNotProcessed )
+ aDebStr += "(not processed)";
+ WRITELOG((char*)(const char*)aDebStr)
+#endif
+ // ein DDE_ACK niemals bestaetigen (um endlosschleifen zu vermeiden)
+ pInDDEData->fsStatus &= (~DDE_FACKREQ);
+ }
+ else
+ {
+ //WRITELOG("DdeAck:Received (no data!)")
+ return (MRESULT)0;
+ }
+
+ HCONV hConv = CheckIncoming(pParams, 0, hszItem);
+#ifdef OV_DEBUG
+ if( !hConv )
+ {
+ WRITELOG("DdeAck:HCONV not found")
+ }
+#endif
+ ULONG nTransId=GetTransaction(pData,hConv,hszItem,pInDDEData->usFormat);
+ if( !nTransId )
+ {
+ WRITELOG("DdeAck:Transaction not found")
+ MyDosFreeMem( pInDDEData,"DdeAck" );
+ return (MRESULT)0;
+ }
+
+ BOOL bThisIsSync = (BOOL)( bInSyncTrans && nTransId == nSyncTransId );
+#if 0 && defined( OV_DEBUG )
+ if( bThisIsSync)
+ WRITELOG("DdeAck: sync transaction")
+ else
+ WRITELOG("DdeAck: async transaction")
+#endif
+ // pruefen, ob die Transaktion abgeschlossen ist.
+ Transaction* pTrans = pTransTable;
+ pTrans += (USHORT)nTransId;
+ ImpHCONV* pConv = pConvTable;
+ pConv += (USHORT)hConv;
+
+ if( pTrans->nConvst == XST_UNADVSENT )
+ {
+ //WRITELOG("DdeAck:Unadvise-Ack received")
+ pTrans->nConvst = XST_UNADVACKRCVD;
+ MyDosFreeMem( pInDDEData,"DdeAck" );
+ DdeFreeStringHandle( hszItem );
+ return (MRESULT)0;
+ }
+ if( pTrans->nConvst == XST_ADVDATASENT )
+ {
+ //WRITELOG("DdeAck:AdvData-Ack received")
+ pTrans->nConvst = XST_ADVDATAACKRCVD;
+ MyDosFreeMem( pInDDEData,"DdeAck" );
+ DdeFreeStringHandle( hszItem );
+ return (MRESULT)0;
+ }
+
+ USHORT nType = pTrans->nType;
+ nType &= (~XTYPF_MASK);
+ // beginn einer advise-loop oder request auf advise-loop ?
+ // wenn ja: transaktion nicht loeschen
+ BOOL bFinished = (BOOL)(nType != XTYP_ADVSTART &&
+ nType != (XTYP_ADVREQ & (~XTYPF_NOBLOCK)) );
+ if( bFinished )
+ {
+ if( !bThisIsSync )
+ {
+ ////WRITELOG("DdeAck:Transaction completed")
+ Callback( XTYP_XACT_COMPLETE, pInDDEData->usFormat, hConv,
+ pConv->hszTopic, hszItem, (HDDEDATA)0, nTransId, 0 );
+ }
+ ////WRITELOG("DdeAck:Freeing transaction")
+ FreeTransaction( pData, nTransId );
+ }
+
+ if( bThisIsSync )
+ {
+ hSyncResponseData = pInDDEData;
+ nSyncResponseMsg = WM_DDE_ACK;
+ }
+ else
+ {
+ MyDosFreeMem( pInDDEData,"DdeAck" );
+ }
+
+ DdeFreeStringHandle( hszItem );
+
+ return (MRESULT)0;
+}
+
+
+USHORT ImpDdeMgr::SendUnadvises(HCONV hConvServer,USHORT nFormat,BOOL bFree)
+{
+ USHORT nTransFound = 0;
+ BOOL bCallApp = (BOOL)(!(nTransactFilter & CBF_FAIL_ADVISES));
+#if 0 && defined( OV_DEBUG )
+ String aStr("Unadvising transactions for HCONV=");
+ aStr += (ULONG)hConvServer;
+ aStr += " CallApp:"; aStr += (USHORT)bCallApp;
+ WRITELOG((char*)aStr.GetStr())
+#endif
+
+
+ // wenn wir weder loeschen noch die App benachrichtigen sollen,
+ // koennen wir gleich wieder returnen
+ if( !hConvServer || ( !bFree && !bCallApp ) )
+ return 0;
+
+ ImpHCONV* pConvSrv = pConvTable;
+ pConvSrv += (USHORT)hConvServer;
+ HSZ hszTopic = pConvSrv->hszTopic;
+
+ Transaction* pTrans = pTransTable;
+ pTrans++;
+ USHORT nCurTransId = 1;
+ USHORT nCurTransactions = pData->nCurTransCount;
+ while( nCurTransactions && nCurTransId < pData->nMaxTransCount )
+ {
+ if( pTrans->hConvOwner )
+ nCurTransactions--;
+ if( pTrans->hConvOwner == hConvServer &&
+ (pTrans->nType & XTYP_ADVREQ) )
+ {
+ if( !nFormat || (nFormat == pTrans->nFormat) )
+ {
+ nTransFound++;
+ if( bCallApp )
+ {
+ //WRITELOG("SendUnadvises:Notifying App")
+ Callback( XTYP_ADVSTOP, pTrans->nFormat, hConvServer,
+ hszTopic, pTrans->hszItem, 0,0,0 );
+ }
+ if( bFree )
+ FreeTransaction( pData, (ULONG)nCurTransId );
+ }
+ }
+ nCurTransId++;
+ pTrans++;
+ }
+ return nTransFound;
+}
+
+
+
+HCONV ImpDdeMgr::CheckIncoming( ImpWndProcParams* pParams, ULONG nTransMask,
+ HSZ& rhszItem )
+{
+// ////WRITELOG("CheckIncoming")
+ rhszItem = 0;
+ DDESTRUCT* pInDDEData = (DDESTRUCT*)(pParams->nPar2);
+ if( !pInDDEData )
+ {
+ // ////WRITELOG("CheckIncoming:PDDESTRUCT==0")
+ return (HCONV)0;
+ }
+
+ HWND hWndThis = pParams->hWndReceiver;
+ HWND hWndClient = (HWND)pParams->nPar1;
+
+ BOOL bReject = (BOOL)(nTransactFilter & nTransMask);
+ HCONV hConv;
+ if( !bReject )
+ hConv = GetConvHandle( pData, hWndThis, hWndClient );
+ if ( bReject || !hConv )
+ return (HCONV)0;
+
+ rhszItem = DdeCreateStringHandle(
+ ((char*)(pInDDEData)+pInDDEData->offszItemName), 850 );
+
+ // ////WRITELOG("CheckIncoming:OK");
+ return hConv;
+}
+
+
+MRESULT ImpDdeMgr::DdeAdvise( ImpWndProcParams* pParams )
+{
+ ////WRITELOG("DdeAdvise:Received")
+ HSZ hszItem;
+ HCONV hConv = CheckIncoming(pParams, CBF_FAIL_ADVISES, hszItem);
+ DDESTRUCT* pInDDEData = (DDESTRUCT*)(pParams->nPar2);
+ HWND hWndThis = pParams->hWndReceiver;
+ HWND hWndClient = (HWND)pParams->nPar1;
+ if( !hConv )
+ {
+ ////WRITELOG("DdeAdvise:Conversation not found")
+ pInDDEData->fsStatus &= (~DDE_FACK);
+ MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY);
+ DdeFreeStringHandle( hszItem );
+ return (MRESULT)0;
+ }
+
+ Transaction* pTrans = pTransTable;
+ ImpHCONV* pConv = pConvTable;
+ pConv += (USHORT)hConv;
+
+ // existiert schon ein Link auf Topic/Item/Format-Vektor ?
+
+ ULONG nTransId=GetTransaction(pData,hConv,hszItem,pInDDEData->usFormat);
+ if( nTransId )
+ {
+ ////WRITELOG("DdeAdvise:Transaction already exists")
+ pTrans += (USHORT)nTransId;
+ // ist es eine AdviseLoop ?
+ USHORT nTempType = pTrans->nType;
+ nTempType &= (~XTYPF_MASK);
+ if( nTempType == XTYP_ADVREQ )
+ {
+ // Flags der laufenden Advise-Loop aktualisieren
+ ////WRITELOG("DdeAdvise:Adjusting Advise-Params")
+ pTrans->nType = XTYP_ADVREQ;
+ if( pInDDEData->fsStatus & DDE_FNODATA )
+ pTrans->nType |= XTYPF_NODATA;
+ if( pInDDEData->fsStatus & DDE_FACKREQ )
+ pTrans->nType |= XTYPF_ACKREQ;
+ pInDDEData->fsStatus |= DDE_FACK;
+ MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY);
+ DdeFreeStringHandle( hszItem );
+ return (MRESULT)0;
+ }
+ else if( nTempType != XTYP_ADVSTART )
+ {
+ ////WRITELOG("DdeAdvise:Not a advise transaction")
+ pInDDEData->fsStatus &= (~DDE_FACK);
+ MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY);
+ DdeFreeStringHandle( hszItem );
+ return (MRESULT)0;
+ }
+ }
+
+ if( !nTransId )
+ {
+ ////WRITELOG("DdeAdvise:Creating Transaction")
+ ////WRITESTATUS("DdeAdvise:Creating Transaction")
+ nTransId = CreateTransaction( pData, hConv, hszItem,
+ pInDDEData->usFormat, XTYP_ADVREQ );
+ ////WRITESTATUS("DdeAdvise:Created Transaction")
+ }
+ if( nTransId )
+ {
+ pTrans = pTransTable;
+ pTrans += (USHORT)nTransId;
+ if( pInDDEData->fsStatus & DDE_FNODATA )
+ pTrans->nType |= XTYPF_NODATA;
+ if( pInDDEData->fsStatus & DDE_FACKREQ )
+ pTrans->nType |= XTYPF_ACKREQ;
+ }
+ else
+ {
+ ////WRITELOG("DdeAdvise:Cannot create Transaction")
+ pInDDEData->fsStatus &= (~DDE_FACK);
+ MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY);
+ DdeFreeStringHandle( hszItem );
+ return (MRESULT)0;
+ }
+
+ ////WRITELOG("DdeAdvise:Calling Server")
+
+ if ( Callback( XTYP_ADVSTART, pInDDEData->usFormat,
+ hConv, pConv->hszTopic, hszItem, (HDDEDATA)0, 0, 0 ) )
+ {
+ //
+ // ServerApp erlaubt AdviseLoop
+ //
+ ////WRITELOG("DdeAdvise:Advise loop established")
+ pInDDEData->fsStatus |= DDE_FACK;
+ MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY);
+ }
+ else
+ {
+ ////WRITELOG("DdeAdvise:Advise loop not established")
+ FreeTransaction( pData, nTransId );
+ pInDDEData->fsStatus &= (~DDE_FACK); // DDE_FNOTPROCESSED;
+ MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY);
+ }
+ ////WRITESTATUS("DdeAdvise:End")
+ ////WRITELOG("DdeAdvise:End")
+ DdeFreeStringHandle( hszItem );
+ return (MRESULT)0;
+}
+
+MRESULT ImpDdeMgr::DdeData( ImpWndProcParams* pParams )
+{
+ WRITELOG("DdeData:Received")
+ HSZ hszItem;
+ HCONV hConv = CheckIncoming(pParams, 0, hszItem);
+ HWND hWndThis = pParams->hWndReceiver;
+ HWND hWndClient = (HWND)pParams->nPar1;
+ DDESTRUCT* pInDDEData = (DDESTRUCT*)(pParams->nPar2);
+#if 0 && defined( OV_DEBUG )
+ {
+ String aStr("DdeData Address:");
+ aStr += (ULONG)pInDDEData;
+ WRITELOG((char*)aStr.GetStr())
+ }
+#endif
+
+ BOOL bSendAck;
+ if( pInDDEData && (pInDDEData->fsStatus & DDE_FACKREQ ))
+ {
+ WRITELOG("DdeData: Ackn requested")
+ bSendAck = TRUE;
+ }
+ else
+ {
+ WRITELOG("DdeData: Ackn not requested")
+ bSendAck = FALSE;
+ }
+
+ ULONG nTransId = GetTransaction(pData,hConv,hszItem,pInDDEData->usFormat);
+ if( !nTransId )
+ {
+ WRITELOG("DdeData:Transaction not found")
+ WRITEDATA(pInDDEData)
+ if( bSendAck )
+ {
+ WRITELOG("DdeData: Posting Ackn")
+ pInDDEData->fsStatus &= (~DDE_FACK); // NOTPROCESSED;
+ MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY);
+ }
+ else
+ {
+ MyDosFreeMem( pInDDEData,"DdeData" );
+ }
+ return (MRESULT)0;
+ }
+
+#if 0 && defined( OV_DEBUG )
+ if( pInDDEData )
+ {
+ WRITEDATA(pInDDEData)
+ }
+#endif
+
+ BOOL bThisIsSync = (BOOL)( bInSyncTrans && nTransId == nSyncTransId );
+
+ // pruefen, ob die Transaktion abgeschlossen ist.
+ Transaction* pTrans = pTransTable;
+ pTrans += (USHORT)nTransId;
+
+ if( pTrans->nConvst == XST_WAITING_ACK )
+ {
+ // dieser Fall kann eintreten, wenn ein Server innerhalb
+ // einer WM_DDE_ADVISE-Msg. oder bevor beim Client das
+ // Ack eintrifft, Advise-Daten sendet.
+ WRITELOG("DdeData:Ignoring unexpected data")
+ if( bSendAck )
+ {
+ WRITELOG("DdeData: Posting Ackn")
+ pInDDEData->fsStatus &= (~DDE_FACK); // NOTPROCESSED;
+ MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY);
+ }
+ else
+ {
+ MyDosFreeMem( pInDDEData,"DdeData" );
+ }
+ return (MRESULT)0;
+ }
+
+ ImpHCONV* pConv = pConvTable;
+ pConv += (USHORT)hConv;
+
+ USHORT nType = pTrans->nType;
+ nType &= (~XTYPF_MASK);
+ BOOL bNotAdviseLoop = (BOOL)(nType != (XTYP_ADVREQ & (~XTYPF_NOBLOCK)));
+ if( !bThisIsSync )
+ {
+ // WRITELOG("DdeData:Is async transaction")
+ if( bNotAdviseLoop )
+ {
+ // WRITELOG("DdeData:Transaction completed -> calling client")
+ Callback( XTYP_XACT_COMPLETE, pInDDEData->usFormat, hConv,
+ pConv->hszTopic, hszItem, pInDDEData, nTransId, 0 );
+ // WRITELOG("DdeData:Freeing transaction")
+ FreeTransaction( pData, nTransId );
+ }
+ else
+ {
+ WRITELOG("DdeData:Advise-Loop -> calling client")
+ HDDEDATA pToSend = pInDDEData;
+ if( pTrans->nType & XTYPF_NODATA )
+ {
+ pToSend = 0;
+ // WRITELOG("DdeData:Is warm link")
+ }
+ Callback( XTYP_ADVDATA, pInDDEData->usFormat, hConv,
+ pConv->hszTopic, hszItem, pToSend, nTransId, 0 );
+ }
+ if( bSendAck )
+ {
+ WRITELOG("DdeData: Posting Ackn")
+ pInDDEData->fsStatus = DDE_FACK;
+ MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY);
+ }
+ else
+ MyDosFreeMem( pInDDEData,"DdeData" );
+ }
+ else // synchrone Transaktion (Datenhandle nicht freigeben!)
+ {
+ // WRITELOG("DdeData:Is sync transaction")
+ hSyncResponseData = pInDDEData;
+ nSyncResponseMsg = WM_DDE_DATA;
+ if( bSendAck )
+ {
+ pInDDEData->fsStatus |= DDE_FACK;
+ WRITELOG("DdeData: Posting Ackn")
+ MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,
+ DDEPM_RETRY | DDEPM_NOFREE );
+ }
+ }
+
+ DdeFreeStringHandle( hszItem );
+ // WRITELOG("DdeData:End")
+ return (MRESULT)0;
+}
+
+MRESULT ImpDdeMgr::DdeExecute( ImpWndProcParams* pParams )
+{
+ ////WRITELOG("DdeExecute:Received")
+ DDESTRUCT* pInDDEData = (DDESTRUCT*)(pParams->nPar2);
+ HSZ hszItem;
+ HCONV hConv = CheckIncoming(pParams, 0, hszItem);
+ BOOL bSuccess = FALSE;
+ ImpHCONV* pConv = pConvTable;
+ pConv += (USHORT)hConv;
+ if ( hConv && !(nTransactFilter & CBF_FAIL_EXECUTES) && pInDDEData )
+ {
+ if ( Callback( XTYP_EXECUTE, pInDDEData->usFormat, hConv,
+ pConv->hszTopic, hszItem, pInDDEData, 0, 0 )
+ == (DDESTRUCT*)DDE_FACK )
+ bSuccess = TRUE;
+ }
+ else
+ {
+ ////WRITELOG("DdeExecute:Not processed")
+ }
+ if( pInDDEData )
+ {
+ if( bSuccess )
+ pInDDEData->fsStatus |= DDE_FACK;
+ else
+ pInDDEData->fsStatus &= (~DDE_FACK);
+ MyWinDdePostMsg( pConv->hWndPartner, pConv->hWndThis, WM_DDE_ACK,
+ pInDDEData, DDEPM_RETRY );
+ }
+ DdeFreeStringHandle( hszItem );
+ return (MRESULT)0;
+}
+
+HCONV ImpDdeMgr::ConnectWithClient( HWND hWndClient,
+ HSZ hszPartner, HSZ hszService, HSZ hszTopic, BOOL bSameInst,
+ DDEINIT* pDDEData, CONVCONTEXT* pCC )
+{
+ ////WRITELOG("ConnectWithClient:Start")
+ HWND hWndSrv = CreateConversationWnd();
+ IncConversationWndRefCount( hWndSrv );
+ HCONV hConv = CreateConvHandle( pData, pidThis, hWndSrv, hWndClient,
+ hszPartner, hszService, hszTopic );
+ if(!hConv )
+ return 0;
+ BOOL bFreeDdeData = FALSE;
+ if( !pDDEData )
+ {
+ bFreeDdeData = TRUE;
+ pDDEData = CreateDDEInitData( hWndClient,hszService,hszTopic, pCC );
+ PID pid; TID tid;
+ WinQueryWindowProcess( hWndClient, &pid, &tid );
+ DosGiveSharedMem( pDDEData, pid, PAG_READ | PAG_WRITE);
+ }
+ HAB hAB = WinQueryAnchorBlock( hWndSrv );
+ WinGetLastError( hAB ); // fehlercode zuruecksetzen
+ WinSendMsg(hWndClient,WM_DDE_INITIATEACK,(MPARAM)hWndSrv,(MPARAM)pDDEData);
+ if( WinGetLastError( hAB ) )
+ {
+ // ////WRITELOG("DdeConnectWithClient:Client died")
+ if( bFreeDdeData )
+ {
+ MyDosFreeMem( pDDEData,"ConnectWithClient" );
+ }
+ FreeConvHandle( pData, hConv );
+ return (HCONV)0;
+ }
+
+ if( !(nTransactFilter & CBF_SKIP_CONNECT_CONFIRMS) )
+ {
+ Callback( XTYP_CONNECT_CONFIRM, 0, hConv, hszTopic, hszService,
+ 0, 0, (ULONG)bSameInst );
+ }
+
+ if( bFreeDdeData )
+ {
+ MyDosFreeMem( pDDEData,"ConnectWithClient" );
+ }
+ // HCONV der PartnerApp suchen & bei uns eintragen
+ ImpHCONV* pConv = pConvTable;
+ pConv += (USHORT)hConv;
+ pConv->hConvPartner = GetConvHandle( pData, hWndClient, hWndSrv );
+#if 0 && defined(OV_DEBUG)
+ if( !pConv->hConvPartner )
+ {
+ WRITELOG("DdeConnectWithClient:Partner not found")
+ }
+#endif
+ pConv->nStatus = ST_CONNECTED;
+ //WRITESTATUS("Server:Connected with client")
+ //WRITELOG("ConnectWithClient:End")
+ return hConv;
+}
+
+MRESULT ImpDdeMgr::DdeInitiate( ImpWndProcParams* pParams )
+{
+ ////WRITELOG("DdeInitiate:Received")
+ HWND hWndClient = (HWND)(pParams->nPar1);
+// BOOL bSameInst = IsSameInstance( hWndClient );
+ BOOL bSameInst = (BOOL)(hWndClient==hWndServer);
+ DDEINIT* pDDEData = (DDEINIT*)pParams->nPar2;
+
+ if ( ( nTransactFilter & (CBF_FAIL_CONNECTIONS | APPCMD_CLIENTONLY)) ||
+ (( nTransactFilter & CBF_FAIL_SELFCONNECTIONS) && bSameInst )
+ )
+ {
+ MyDosFreeMem( pDDEData,"DdeInitiate" );
+ return (MRESULT)FALSE; // narda
+ }
+
+ HSZ hszService = (HSZ)0;
+ if( *(pDDEData->pszAppName) != '\0' )
+ {
+ hszService = DdeCreateStringHandle( pDDEData->pszAppName, 850 );
+ ////WRITELOG(pDDEData->pszAppName);
+ }
+ HSZ hszTopic = (HSZ)0;
+ if( *(pDDEData->pszTopic) != '\0' )
+ {
+ hszTopic = DdeCreateStringHandle( pDDEData->pszTopic, 850 );
+ ////WRITELOG(pDDEData->pszTopic);
+ }
+ HSZ hszPartner = GetAppName( hWndClient );
+
+ // nur weitermachen, wenn Service registriert oder
+ // Service-Name-Filtering ausgeschaltet.
+ if( !bServFilterOn || GetService(hszService) )
+ {
+ // XTYP_CONNECT-Transaktionen erfolgen nur mit
+ // Services & Topics ungleich 0!
+ if( hszService && hszTopic )
+ {
+ if( IsConvHandleAvailable(pData) && Callback( XTYP_CONNECT,
+ 0, 0, hszTopic,hszService, 0, 0, (ULONG)bSameInst))
+ {
+ // App erlaubt Verbindung mit Client
+ ConnectWithClient( hWndClient, hszPartner,
+ hszService, hszTopic, bSameInst, pDDEData );
+ }
+ }
+ else
+ {
+ // ** Wildcard-Connect **
+ ////WRITELOG("DdeInitiate:Wildconnect")
+ // vom Server eine Liste aller Service/Topic-Paare anfordern
+ CONVCONTEXT* pCC=(CONVCONTEXT*)(pDDEData+pDDEData->offConvContext);
+ DDESTRUCT* hList = Callback( XTYP_WILDCONNECT, 0, (HCONV)0,
+ hszTopic,hszService, (HDDEDATA)0, (ULONG)pCC, (ULONG)bSameInst );
+ if( hList )
+ {
+ HSZPAIR* pPairs = (HSZPAIR*)((char*)hList+hList->offabData);
+ while( pPairs->hszSvc )
+ {
+ ////WRITELOG("DdeInitiate:Wildconnect.Connecting")
+ ConnectWithClient( hWndClient, hszPartner,
+ pPairs->hszSvc, pPairs->hszTopic, bSameInst, 0, pCC);
+ // Stringhandles gehoeren der App! (nicht free-en)
+ pPairs++;
+ }
+ DdeFreeDataHandle( hList );
+ }
+ }
+ }
+#if 0 && defined(OV_DEBUG)
+ else
+ {
+ WRITELOG("DdeInitiate:Service filtered")
+ }
+#endif
+ DdeFreeStringHandle( hszTopic );
+ DdeFreeStringHandle( hszService );
+ DdeFreeStringHandle( hszPartner );
+ MyDosFreeMem( pDDEData,"DdeInitiate" );
+ ////WRITELOG("DdeInitiate:End")
+ return (MRESULT)TRUE;
+}
+
+MRESULT ImpDdeMgr::DdeInitiateAck( ImpWndProcParams* pParams )
+{
+ ////WRITELOG("DdeInitiateAck:Received")
+ DDEINIT* pDDEData = (DDEINIT*)(pParams->nPar2);
+
+ if( !bListConnect && hCurConv )
+ {
+ ////WRITELOG("DdeInitiateAck:Already connected")
+ MyDosFreeMem( pDDEData,"DdeInitiateAck" );
+ WinPostMsg( hWndServer, WM_DDE_TERMINATE, (MPARAM)hWndServer, 0 );
+ return (MRESULT)FALSE;
+ }
+
+ HWND hWndThis = pParams->hWndReceiver;
+ // Referenz-Count unseres Client-Windows inkrementieren
+ IncConversationWndRefCount( hWndThis );
+
+ HWND hWndSrv = (HWND)(pParams->nPar1);
+ HSZ hszService = DdeCreateStringHandle( pDDEData->pszAppName, 850 );
+ HSZ hszTopic = DdeCreateStringHandle( pDDEData->pszTopic, 850 );
+ HSZ hszPartnerApp = GetAppName( hWndSrv );
+
+ hCurConv = CreateConvHandle( pData, pidThis, hWndThis, hWndSrv,
+ hszPartnerApp, hszService, hszTopic, 0 );
+
+ ImpHCONV* pConv = pConvTable;
+ pConv += (USHORT)hCurConv;
+
+ // HCONV der PartnerApp suchen & bei uns eintragen
+ pConv->hConvPartner = GetConvHandle( pData, hWndSrv, hWndThis );
+ // nicht asserten, da ja non-ddeml-Partner moeglich
+ // DBG_ASSERT(pConv->hConvPartner,"DDE:Partner not found");
+ pConv->nStatus = ST_CONNECTED | ST_CLIENT;
+
+ if( bListConnect )
+ {
+ ////WRITELOG("DdeInitiateAck:ListConnect/Connecting hConvs")
+ // Status setzen & verketten
+ pConv->hConvList = hCurListId;
+ pConv->nPrevHCONV = nPrevConv;
+ pConv->nStatus |= ST_INLIST;
+ if( nPrevConv )
+ {
+ pConv = pConvTable;
+ pConv += nPrevConv;
+ pConv->nNextHCONV = (USHORT)hCurConv;
+ }
+ nPrevConv = (USHORT)hCurConv;
+ }
+
+ DdeFreeStringHandle( hszService );
+ DdeFreeStringHandle( hszTopic );
+ DdeFreeStringHandle( hszPartnerApp );
+ MyDosFreeMem( pDDEData,"DdeInitiateAck" );
+ ////WRITESTATUS("After DdeInitiateAck")
+ ////WRITELOG("DdeInitiateAck:End")
+ return (MRESULT)TRUE;
+}
+
+MRESULT ImpDdeMgr::DdePoke( ImpWndProcParams* pParams )
+{
+ ////WRITELOG("DdePoke:Received")
+ HSZ hszItem = 0;
+ DDESTRUCT* pInDDEData = (DDESTRUCT*)(pParams->nPar2);
+ HCONV hConv = CheckIncoming( pParams, CBF_FAIL_REQUESTS, hszItem );
+ BOOL bSuccess =FALSE;
+ ImpHCONV* pConv = pConvTable;
+ pConv += (USHORT)hConv;
+ if ( hConv && !(nTransactFilter & CBF_FAIL_POKES) && pInDDEData )
+ {
+ if( Callback( XTYP_POKE, pInDDEData->usFormat, hConv,
+ pConv->hszTopic, hszItem, pInDDEData, 0, 0 )
+ == (DDESTRUCT*)DDE_FACK )
+ bSuccess = TRUE;
+ }
+#if 0 && defined( OV_DEBUG )
+ else
+ {
+ WRITELOG("DdePoke:Not processed")
+ }
+#endif
+ if( pInDDEData )
+ {
+ if( bSuccess )
+ pInDDEData->fsStatus |= DDE_FACK;
+ else
+ pInDDEData->fsStatus &= (~DDE_FACK);
+
+ MyWinDdePostMsg( pConv->hWndPartner, pConv->hWndThis, WM_DDE_ACK,
+ pInDDEData, DDEPM_RETRY );
+ }
+ DdeFreeStringHandle( hszItem );
+ return (MRESULT)0;
+}
+
+MRESULT ImpDdeMgr::DdeRequest( ImpWndProcParams* pParams )
+{
+ ////WRITELOG("DdeRequest:Received")
+ HSZ hszItem = 0;
+ DDESTRUCT* pInDDEData = (DDESTRUCT*)(pParams->nPar2);
+ if( pInDDEData )
+ // ist fuer Requests nicht definiert
+ pInDDEData->fsStatus = 0;
+ HCONV hConv = CheckIncoming( pParams, CBF_FAIL_REQUESTS, hszItem );
+ HWND hWndThis = pParams->hWndReceiver;
+ HWND hWndClient = (HWND)pParams->nPar1;
+ if( hConv )
+ {
+ ImpHCONV* pConv = pConvTable;
+ pConv += (USHORT)hConv;
+
+ DDESTRUCT* pOutDDEData = Callback( XTYP_REQUEST, pInDDEData->usFormat,
+ hConv, pConv->hszTopic, hszItem, (HDDEDATA)0, 0, 0 );
+
+ if ( !pOutDDEData )
+ {
+ ////WRITELOG("DdeRequest:Not processed")
+ pInDDEData->fsStatus &= (~DDE_FACK);
+ MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY);
+ }
+ else
+ {
+ ////WRITELOG("DdeRequest:Success")
+ MyDosFreeMem( pInDDEData,"DdeRequest" );
+ pOutDDEData->fsStatus |= DDE_FRESPONSE;
+ MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_DATA,pOutDDEData,DDEPM_RETRY);
+ }
+ }
+ else
+ {
+ pInDDEData->fsStatus &= (~DDE_FACK);
+ MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY);
+ }
+
+ DdeFreeStringHandle( hszItem );
+ ////WRITELOG("DdeRequest:End")
+ return (MRESULT)0;
+}
+
+
+MRESULT ImpDdeMgr::DdeUnadvise( ImpWndProcParams* pParams )
+{
+ ////WRITELOG("DdeUnadvise:Received")
+
+ HSZ hszItem;
+ HCONV hConv = CheckIncoming( pParams, 0, hszItem );
+ DDESTRUCT* pInDDEData = (DDESTRUCT*)(pParams->nPar2);
+ HWND hWndThis = pParams->hWndReceiver;
+ HWND hWndClient = (HWND)pParams->nPar1;
+ USHORT nClosedTransactions = 0;
+ if( hConv )
+ {
+ USHORT nFormat = pInDDEData->usFormat;
+ // alle Transaktionen des HCONVs loeschen ?
+ if( !hszItem )
+ {
+ // App benachrichtigen & Transaktionen loeschen
+ nClosedTransactions = SendUnadvises( hConv, nFormat, TRUE );
+ }
+ else
+ {
+ ULONG nTransId = GetTransaction(pData, hConv, hszItem, nFormat);
+ if( nTransId )
+ {
+ ////WRITELOG("DdeUnadvise:Transaction found")
+ Transaction* pTrans = pTransTable;
+ pTrans += (USHORT)nTransId;
+ ImpHCONV* pConv = pConvTable;
+ pConv += (USHORT)hConv;
+ nClosedTransactions = 1;
+ if( !(nTransactFilter & CBF_FAIL_ADVISES) )
+ Callback( XTYP_ADVSTOP, nFormat, hConv,
+ pConv->hszTopic, hszItem, 0, 0, 0 );
+ if( !pConv->hConvPartner )
+ FreeTransaction( pData, nTransId );
+ }
+#if defined(OV_DEBUG)
+ else
+ {
+ WRITELOG("DdeUnadvise:Transaction not found")
+ }
+#endif
+ }
+ }
+#if defined(OV_DEBUG)
+ else
+ {
+ WRITELOG("DdeUnadvise:Conversation not found")
+ }
+#endif
+
+ if( !nClosedTransactions )
+ pInDDEData->fsStatus &= (~DDE_FACK);
+ else
+ pInDDEData->fsStatus |= DDE_FACK;
+
+ MyWinDdePostMsg(hWndClient,hWndThis,WM_DDE_ACK,pInDDEData,DDEPM_RETRY);
+ DdeFreeStringHandle( hszItem );
+ return (MRESULT)0;
+}
+
+BOOL ImpDdeMgr::WaitTransState( Transaction* pTrans, ULONG nTransId,
+ USHORT nNewState, ULONG nTimeout )
+{
+ ////WRITELOG("WaitTransState:Start")
+ ImpHCONV* pConv = pConvTable;
+ pConv += pTrans->hConvOwner;
+ HAB hAB = WinQueryAnchorBlock( pConv->hWndThis );
+ ULONG nTimerId = WinStartTimer( hAB, 0, 0, 50 );
+ QMSG aQueueMsg;
+
+// while( WinGetMsg( hAB, &aQueueMsg, 0, 0, 0 ) &&
+// WinIsWindow( hAB, pConv->hWndPartner) &&
+// pTrans->nConvst != nNewState )
+// {
+// WinDispatchMsg( hAB, &aQueueMsg );
+// }
+
+ BOOL bContinue = TRUE;
+ while( bContinue )
+ {
+ if( WinGetMsg( hAB, &aQueueMsg, 0, 0, 0 ))
+ {
+ WinDispatchMsg( hAB, &aQueueMsg );
+ if( (!WinIsWindow( hAB, pConv->hWndPartner)) ||
+ (pTrans->nConvst == nNewState) )
+ {
+ bContinue = FALSE;
+ }
+ }
+ else
+ bContinue = FALSE;
+ }
+
+ WinStopTimer( hAB, 0, nTimerId );
+ ////WRITELOG("WaitTransState:End")
+ return TRUE;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/svdde/svt_ddeml2.cxx b/binfilter/bf_svtools/source/svdde/svt_ddeml2.cxx
new file mode 100644
index 000000000000..af6242cb80ed
--- /dev/null
+++ b/binfilter/bf_svtools/source/svdde/svt_ddeml2.cxx
@@ -0,0 +1,1017 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+#define INCL_DOS
+#include <stdlib.h>
+
+#include "ddemlimp.hxx"
+#define LOGFILE
+#define STATUSFILE
+#define DDEDATAFILE
+#include "ddemldeb.hxx"
+
+#if defined (OS2) && defined (__BORLANDC__)
+#pragma option -w-par
+#endif
+
+namespace binfilter
+{
+
+// ************************************************************************
+// Hilfsfunktionen Speicherverwaltung
+// ************************************************************************
+
+//
+// AllocAtomName
+//
+
+PSZ ImpDdeMgr::AllocAtomName( ATOM hString, ULONG& rBufLen )
+{
+ HATOMTBL hAtomTable = WinQuerySystemAtomTable();
+ ULONG nLen = WinQueryAtomLength( hAtomTable, hString );
+ nLen++;
+ PSZ pBuf = 0;
+ if ( !MyDosAllocMem( (PPVOID)&pBuf, nLen, PAG_READ|PAG_WRITE|PAG_COMMIT | OBJ_ANY,"Atom" ) )
+ {
+ WinQueryAtomName( hAtomTable, hString, pBuf, nLen );
+ rBufLen = nLen;
+ }
+ return pBuf;
+}
+
+
+//
+// MakeDDEObject
+//
+
+PDDESTRUCT ImpDdeMgr::MakeDDEObject( HWND hwnd, ATOM hItemName,
+ USHORT fsStatus, USHORT usFormat, PVOID pabData, ULONG usDataLen )
+{
+ PDDESTRUCT pddes = 0;
+ ULONG usItemLen;
+ PULONG pulSharedObj;
+ //WRITELOG("MakeDDEObject: Start")
+
+ PSZ pItemName = 0;
+ if( hItemName != NULL )
+ pItemName = AllocAtomName( hItemName, usItemLen );
+ else
+ usItemLen = 1;
+
+ ULONG nTotalSize = sizeof(DDESTRUCT) + usItemLen + usDataLen;
+
+ if( !(MyDosAllocSharedMem((PPVOID)&pulSharedObj, NULL,
+ nTotalSize,
+ PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_GETTABLE | OBJ_GIVEABLE | OBJ_ANY,
+ "MakeDDEObject")))
+ {
+ pddes = (PDDESTRUCT) pulSharedObj;
+ // siehe "Glenn Puchtel, DDE for OS/2" p.60
+ pddes->cbData = (ULONG)usDataLen;
+ pddes->fsStatus = fsStatus;
+ pddes->usFormat = usFormat;
+ pddes->offszItemName = sizeof( DDESTRUCT );
+ if( (usDataLen) && (pabData != NULL ) )
+ pddes->offabData = sizeof(DDESTRUCT) + usItemLen;
+ else
+ pddes->offabData = 0;
+
+ if( pItemName != NULL )
+ memcpy(DDES_PSZITEMNAME(pddes), pItemName, usItemLen );
+ else
+ *(DDES_PSZITEMNAME(pddes)) = '\0';
+
+ if( pabData != NULL )
+ memcpy( DDES_PABDATA(pddes), pabData, usDataLen );
+ }
+
+ if ( pItemName )
+ {
+ MyDosFreeMem( pItemName,"MakeDDEObject" );
+ }
+ return pddes;
+}
+
+//
+// AllocNamedSharedMem
+//
+
+APIRET ImpDdeMgr::AllocNamedSharedMem( PPVOID ppBaseAddress, PSZ pName,
+ ULONG nElementSize, ULONG nElementCount )
+{
+ ULONG nObjSize = (ULONG)(nElementSize * nElementCount );
+ nObjSize += sizeof( ULONG ); // fuer ElementCount am Anfang des Blocks
+
+ *ppBaseAddress = 0;
+ APIRET nRet = MyDosAllocSharedMem( ppBaseAddress, pName, nObjSize,
+ PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_ANY,
+ "AllocNamedSharedMem" );
+ if ( !nRet )
+ {
+ memset( *ppBaseAddress, 0, nObjSize );
+ ULONG* pULONG = (ULONG*)*ppBaseAddress;
+ *pULONG = nObjSize;
+ }
+ return nRet;
+}
+
+void ImpDdeMgr::CreateServerWnd()
+{
+ hWndServer = WinCreateWindow( HWND_DESKTOP, WC_FRAME, "DDEServer", 0,
+ 0,0,0,0, HWND_DESKTOP, HWND_BOTTOM, 0, 0, 0 );
+ WinSetWindowULong( hWndServer, 0, (ULONG)this );
+ WinSubclassWindow( hWndServer, ::ServerWndProc );
+ TID tidDummy;
+ WinQueryWindowProcess( hWndServer, &pidThis, &tidDummy );
+}
+
+void ImpDdeMgr::DestroyServerWnd()
+{
+ WinDestroyWindow( hWndServer );
+ hWndServer = NULLHANDLE;
+}
+
+HWND ImpDdeMgr::CreateConversationWnd()
+{
+ HWND hWnd = WinCreateWindow( HWND_OBJECT, WC_FRAME, "DDEConvWnd", 0,
+ 0,0,0,0, HWND_DESKTOP, HWND_BOTTOM, 0, 0, 0 );
+ if ( hWnd )
+ {
+ ImpConvWndData* pWndData = new ImpConvWndData;
+ pWndData->pThis = this;
+ pWndData->nRefCount = 0;
+ WinSetWindowULong( hWnd, 0, (ULONG)pWndData );
+ WinSubclassWindow( hWnd, ::ConvWndProc );
+#if 0 && defined( OV_DEBUG )
+ String aStr("ConvWnd created:");
+ aStr += (ULONG)hWnd;
+ WRITELOG((char*)aStr.GetStr())
+#endif
+ }
+ else
+ nLastErrInstance = DMLERR_SYS_ERROR;
+
+ return hWnd;
+}
+
+// static
+void ImpDdeMgr::DestroyConversationWnd( HWND hWnd )
+{
+ ImpConvWndData* pObj = (ImpConvWndData*)WinQueryWindowULong( hWnd, 0 );
+ if( pObj )
+ {
+ pObj->nRefCount--;
+ if( pObj->nRefCount == 0
+ // auch Windows mit Refcount vonm loeschen, da dieser in initial
+ // auf 0 gesetzt wird
+ || pObj->nRefCount == (USHORT)-1 )
+ {
+ delete pObj;
+ WinDestroyWindow( hWnd );
+#if 0 && defined( OV_DEBUG )
+ String aStr("ConvWnd destroyed:");
+ aStr += (ULONG)hWnd;
+ WRITELOG((char*)aStr.GetStr())
+#endif
+ }
+ else
+ {
+#if 0 && defined( OV_DEBUG )
+ String aStr("ConvWnd not destroyed (Refcount=");
+ aStr += pObj->nRefCount;
+ aStr += ") "; aStr += (ULONG)hWnd;
+ WRITELOG((char*)aStr.GetStr())
+#endif
+ }
+ }
+#if defined( OV_DEBUG )
+ else
+ {
+ WRITELOG("DestroyCnvWnd:Already destroyed/No win data/Partner died")
+ }
+#endif
+}
+
+// static
+USHORT ImpDdeMgr::GetConversationWndRefCount( HWND hWnd )
+{
+ ImpConvWndData* pObj = (ImpConvWndData*)WinQueryWindowULong( hWnd, 0 );
+ DBG_ASSERT(pObj,"Dde:ConvWnd has no data");
+ if( pObj )
+ return pObj->nRefCount;
+ return 0;
+}
+
+// static
+USHORT ImpDdeMgr::IncConversationWndRefCount( HWND hWnd )
+{
+#if 0 && defined( OV_DEBUG )
+ String aStr("IncConversationWndRefCount ");
+ aStr += (ULONG)hWnd;
+ WRITELOG((char*)aStr.GetStr())
+#endif
+ ImpConvWndData* pObj = (ImpConvWndData*)WinQueryWindowULong( hWnd, 0 );
+ DBG_ASSERT(pObj,"Dde:ConvWnd has no data");
+ if( pObj )
+ {
+ pObj->nRefCount++;
+ return pObj->nRefCount;
+ }
+ return 0;
+}
+
+ImpDdeMgrData* ImpDdeMgr::InitAll()
+{
+ ImpDdeMgrData* pBase = 0;
+ // nur dann neu anlegen, wenn die Tabelle nicht existiert
+ APIRET nRet=DosGetNamedSharedMem((PPVOID)&pBase,DDEMLDATA,PAG_READ| PAG_WRITE);
+ if ( nRet )
+ {
+ if ( nRet == 2 ) // ERROR_FILE_NOT_FOUND )
+ {
+ // DDECONVERSATIONCOUNT=4096
+ USHORT nConvTransCount = 128;
+ PSZ pResult;
+ nRet = DosScanEnv( "SOMAXDDECONN", (const char**)&pResult );
+ if( !nRet )
+ {
+ int nTemp = 0;
+ nTemp = atoi( pResult );
+ nTemp++; // der nullte Eintrag wird nicht benutzt
+ if( nTemp > 128 )
+ nConvTransCount = (USHORT)nTemp;
+ }
+ ULONG nSize = sizeof(ImpDdeMgrData);
+ nSize += sizeof(ImpHCONV) * nConvTransCount;
+ nSize += sizeof(Transaction) * nConvTransCount;
+ nSize += sizeof(HWND) * DDEMLAPPCOUNT;
+
+ nRet = ImpDdeMgr::AllocNamedSharedMem( (PPVOID)&pBase,
+ DDEMLDATA, nSize, 1 );
+ if ( !nRet )
+ {
+ pBase->nTotalSize = nSize;
+ ULONG nAppTable = (ULONG)&(pBase->aAppTable);
+ ULONG nCharBase = (ULONG)pBase;
+ pBase->nOffsAppTable = nAppTable - nCharBase;
+ pBase->nOffsConvTable = pBase->nOffsAppTable;
+ pBase->nOffsConvTable += sizeof(HWND) * DDEMLAPPCOUNT;
+ pBase->nOffsTransTable = pBase->nOffsConvTable;
+ pBase->nOffsTransTable += sizeof(ImpHCONV) * nConvTransCount;
+
+ pBase->nMaxAppCount = DDEMLAPPCOUNT;
+ pBase->nMaxConvCount = nConvTransCount;
+ pBase->nMaxTransCount = nConvTransCount;
+ }
+ }
+ }
+
+ if( pBase )
+ {
+ pConvTable = ImpDdeMgr::GetConvTable( pBase );
+ pTransTable = ImpDdeMgr::GetTransTable( pBase );
+ pAppTable = ImpDdeMgr::GetAppTable( pBase );
+ }
+
+ memset( &aDefaultContext, 0, sizeof(CONVCONTEXT) );
+ aDefaultContext.cb = sizeof(CONVCONTEXT);
+ aDefaultContext.idCountry = 49; // ??
+ aDefaultContext.usCodepage = 850; // ??
+
+ return pBase;
+}
+
+// static
+HCONV ImpDdeMgr::CreateConvHandle( ImpDdeMgrData* pData,
+ PID pidOwner,
+ HWND hWndMe, HWND hWndPartner,
+ HSZ hszPartner, HSZ hszServiceReq, HSZ hszTopic,
+ HCONV hPrevHCONV )
+{
+ DBG_ASSERT(pData,"DDE:Invalid data");
+ if( !pData )
+ return (HCONV)0;
+
+ ImpHCONV* pPtr = ImpDdeMgr::GetConvTable( pData );
+ USHORT nCount = pData->nMaxConvCount;
+ pPtr++;
+ nCount--; // ersten Handle (NULLHANDLE) ueberspringen
+ USHORT nIdx = 1;
+ DBG_ASSERT(pPtr,"No ConvTable");
+ if( !pPtr )
+ return (HCONV)0;
+
+ while( nCount && pPtr->hWndThis != (HWND)NULL )
+ {
+ nCount--;
+ pPtr++;
+ nIdx++;
+ }
+ if( !nCount )
+ return (HCONV)0;
+
+ DdeKeepStringHandle( hszPartner );
+ DdeKeepStringHandle( hszServiceReq );
+ DdeKeepStringHandle( hszTopic );
+ pPtr->hszPartner = hszPartner;
+ pPtr->hszServiceReq = hszServiceReq;
+ pPtr->hszTopic = hszTopic;
+
+ pPtr->hWndThis = hWndMe;
+ pPtr->hWndPartner = hWndPartner;
+ pPtr->pidOwner = pidOwner;
+ pPtr->hConvPartner = (HCONV)0;
+ pPtr->nPrevHCONV = (USHORT)hPrevHCONV;
+ pPtr->nNextHCONV = 0;
+ pPtr->nStatus = ST_CONNECTED;
+
+ pData->nCurConvCount++;
+
+ return (HCONV)nIdx;
+}
+
+// static
+void ImpDdeMgr::FreeConvHandle( ImpDdeMgrData* pBase, HCONV hConv,
+ BOOL bDestroyHWndThis )
+{
+ DBG_ASSERT(pBase,"DDE:No data");
+#if 0 && defined( OV_DEBUG )
+ String aStr("FreeConvHandle: Start ");
+ aStr += (ULONG)hConv;
+ aStr += " Destroy: "; aStr += (USHORT)bDestroyHWndThis;
+ WRITELOG((char*)aStr.GetStr());
+ WRITESTATUS("FreeConvHandle: Start");
+#endif
+ if( !pBase )
+ {
+ WRITELOG("FreeConvHandle: FAIL");
+ return;
+ }
+ DBG_ASSERT(hConv&&hConv<pBase->nMaxConvCount,"DDE:Invalid Conv-Handle");
+ if( hConv && hConv < pBase->nMaxConvCount )
+ {
+ ImpHCONV* pTable = ImpDdeMgr::GetConvTable( pBase );
+ ImpHCONV* pPtr = pTable + (USHORT)hConv;
+ if( pPtr->nStatus & ST_INLIST )
+ {
+ // Verkettung umsetzen
+ USHORT nPrev = pPtr->nPrevHCONV;
+ USHORT nNext = pPtr->nNextHCONV;
+ if( nPrev )
+ {
+ pPtr = pTable + nPrev;
+ pPtr->nNextHCONV = nNext;
+ }
+ if( nNext )
+ {
+ pPtr = pTable + nNext;
+ pPtr->nPrevHCONV = nPrev;
+ }
+ pPtr = pTable + (USHORT)hConv;
+ }
+
+ DdeFreeStringHandle( pPtr->hszPartner );
+ DdeFreeStringHandle( pPtr->hszServiceReq );
+ DdeFreeStringHandle( pPtr->hszTopic );
+ if( bDestroyHWndThis )
+ DestroyConversationWnd( pPtr->hWndThis );
+ memset( pPtr, 0, sizeof(ImpHCONV) );
+ DBG_ASSERT(pBase->nCurConvCount,"Dde:Invalid Trans. count");
+ pBase->nCurConvCount--;
+ }
+#if defined(OV_DEBUG)
+ else
+ {
+ WRITELOG("FreeConvHandle: FAIL");
+ }
+#endif
+ //WRITELOG("FreeConvHandle: END");
+ //WRITESTATUS("FreeConvHandle: End");
+}
+
+// static
+HCONV ImpDdeMgr::IsConvHandleAvailable( ImpDdeMgrData* pBase )
+{
+ DBG_ASSERT(pBase,"DDE:No data");
+ if( !pBase )
+ return 0;
+
+ ImpHCONV* pPtr = ImpDdeMgr::GetConvTable( pBase );
+ USHORT nCurPos = pBase->nMaxConvCount - 1;
+ pPtr += nCurPos; // von hinten aufrollen
+ while( nCurPos >= 1 )
+ {
+ if( pPtr->hWndThis == 0 )
+ return TRUE;
+ pPtr--;
+ nCurPos--;
+ }
+ return FALSE;
+}
+
+// static
+HCONV ImpDdeMgr::GetConvHandle( ImpDdeMgrData* pBase, HWND hWndThis,
+ HWND hWndPartner )
+{
+ DBG_ASSERT(pBase,"DDE:No data");
+ if( !pBase )
+ return 0;
+ ImpHCONV* pPtr = ImpDdeMgr::GetConvTable( pBase );
+ USHORT nCurPos = 1;
+ pPtr++; // ersten Handle ueberspringen
+ USHORT nCurConvCount = pBase->nCurConvCount;
+ while( nCurConvCount && nCurPos < pBase->nMaxConvCount )
+ {
+ if( pPtr->hWndThis )
+ {
+ if(pPtr->hWndThis == hWndThis && pPtr->hWndPartner == hWndPartner)
+ return (HCONV)nCurPos;
+ nCurConvCount--;
+ if( !nCurConvCount )
+ return (HCONV)0;
+ }
+ nCurPos++;
+ pPtr++;
+ }
+ return (HCONV)0;
+}
+
+
+
+// static
+ULONG ImpDdeMgr::CreateTransaction( ImpDdeMgrData* pBase, HCONV hOwner,
+ HSZ hszItem, USHORT nFormat, USHORT nTransactionType )
+{
+ DBG_ASSERT(pBase,"DDE:No Data");
+ DBG_ASSERT(hOwner!=0,"DDE:No Owner");
+
+ if( pBase && hOwner )
+ {
+ Transaction* pPtr = ImpDdeMgr::GetTransTable( pBase );
+ DBG_ASSERT(pPtr->hConvOwner==0,"DDE:Data corrupted");
+ USHORT nId = 1;
+ pPtr++;
+ while( nId < pBase->nMaxTransCount )
+ {
+ if( pPtr->hConvOwner == (HCONV)0 )
+ {
+ pPtr->hConvOwner = hOwner;
+ DdeKeepStringHandle( hszItem );
+ pPtr->hszItem = hszItem;
+ pPtr->nType = nTransactionType;
+ pPtr->nConvst = XST_CONNECTED;
+ pPtr->nFormat = nFormat;
+ pBase->nCurTransCount++;
+ return (ULONG)nId;
+ }
+ nId++;
+ pPtr++;
+ }
+ }
+ return 0;
+}
+
+// static
+void ImpDdeMgr::FreeTransaction( ImpDdeMgrData* pBase, ULONG nTransId )
+{
+ DBG_ASSERT(pBase,"DDE:No Data");
+ if( !pBase )
+ return;
+
+ DBG_ASSERT(nTransId<pBase->nMaxTransCount,"DDE:Invalid TransactionId");
+ if( nTransId >= pBase->nMaxTransCount )
+ return;
+
+ Transaction* pPtr = ImpDdeMgr::GetTransTable( pBase );
+ pPtr += nTransId;
+ DBG_ASSERT(pPtr->hConvOwner!=0,"DDE:TransId has no owner");
+ if( pPtr->hConvOwner )
+ {
+ //WRITELOG("Freeing transaction");
+ DdeFreeStringHandle( pPtr->hszItem );
+ memset( pPtr, 0, sizeof(Transaction) );
+ DBG_ASSERT(pBase->nCurTransCount,"Dde:Invalid Trans. count");
+ pBase->nCurTransCount--;
+ }
+}
+
+// static
+ULONG ImpDdeMgr::GetTransaction( ImpDdeMgrData* pBase,
+ HCONV hOwner, HSZ hszItem, USHORT nFormat )
+{
+ DBG_ASSERT(pBase,"DDE:No Data");
+ if( !pBase || !hOwner )
+ return 0;
+
+ Transaction* pTrans = ImpDdeMgr::GetTransTable( pBase );
+ DBG_ASSERT(pTrans,"DDE:No TransactionTable");
+ if( !pTrans )
+ return 0;
+ pTrans++; // NULLHANDLE ueberspringen
+
+ ImpHCONV* pConv = ImpDdeMgr::GetConvTable( pBase );
+ pConv += (USHORT)hOwner;
+ HCONV hConvPartner = pConv->hConvPartner;
+
+ USHORT nCurTransCount = pBase->nCurTransCount;
+ for( USHORT nTrans=1; nTrans< pBase->nMaxTransCount; nTrans++, pTrans++ )
+ {
+ if( pTrans->hConvOwner )
+ {
+ if(( pTrans->hConvOwner == hOwner ||
+ pTrans->hConvOwner == hConvPartner) &&
+ pTrans->nFormat == nFormat &&
+ pTrans->hszItem == hszItem )
+ {
+ // gefunden!
+ return (ULONG)nTrans;
+ }
+ nCurTransCount--;
+ if( !nCurTransCount )
+ return 0;
+ }
+ }
+ return 0; // narda
+}
+
+// static
+HSZ ImpDdeMgr::DdeCreateStringHandle( PSZ pszString, int iCodePage)
+{
+ if( !pszString || *pszString == '\0' )
+ return (HSZ)0;
+ // Atom-Table beachtet Gross/Kleinschreibung, DDEML aber nicht
+
+ // OV 12.4.96: Services,Topics,Items case-sensitiv!!!
+ // (Grosskundenanforderung (Reuter-DDE))
+ //strlwr( pszString );
+ //*pszString = (char)toupper(*pszString);
+
+ HATOMTBL hAtomTable = WinQuerySystemAtomTable();
+ ATOM aAtom = WinAddAtom( hAtomTable, pszString );
+ return (HSZ)aAtom;
+}
+
+// static
+ULONG ImpDdeMgr::DdeQueryString( HSZ hszStr, PSZ pszStr, ULONG cchMax, int iCodePage)
+{
+ HATOMTBL hAtomTable = WinQuerySystemAtomTable();
+ if ( !pszStr )
+ return WinQueryAtomLength( hAtomTable, (ATOM)hszStr);
+ else
+ {
+ *pszStr = 0;
+ return WinQueryAtomName( hAtomTable, (ATOM)hszStr, pszStr, cchMax );
+ }
+}
+
+// static
+BOOL ImpDdeMgr::DdeFreeStringHandle( HSZ hsz )
+{
+ if( !hsz )
+ return FALSE;
+ ATOM aResult = WinDeleteAtom( WinQuerySystemAtomTable(),(ATOM)hsz );
+ return (BOOL)(aResult==0);
+}
+
+// static
+BOOL ImpDdeMgr::DdeKeepStringHandle( HSZ hsz )
+{
+ if( !hsz )
+ return TRUE;
+ HATOMTBL hAtomTable = WinQuerySystemAtomTable();
+#ifdef DBG_UTIL
+ ULONG nUsageCount=WinQueryAtomUsage(hAtomTable,(ATOM)hsz);
+#endif
+ ULONG nAtom = 0xFFFF0000;
+ ULONG nPar = (ULONG)hsz;
+ nAtom |= nPar;
+ ATOM aAtom = WinAddAtom( hAtomTable, (PSZ)nAtom );
+#ifdef DBG_UTIL
+ if ( aAtom )
+ DBG_ASSERT(WinQueryAtomUsage(hAtomTable,(ATOM)hsz)==nUsageCount+1,"Keep failed");
+#endif
+ return (BOOL)(aAtom!=0);
+}
+
+
+// static
+int ImpDdeMgr::DdeCmpStringHandles(HSZ hsz1, HSZ hsz2)
+{
+ if ( hsz1 == hsz2 )
+ return 0;
+ if ( hsz1 < hsz2 )
+ return -1;
+ return 1;
+}
+
+HDDEDATA ImpDdeMgr::DdeCreateDataHandle( void* pSrc, ULONG cb,
+ ULONG cbOff, HSZ hszItem, USHORT wFmt, USHORT afCmd)
+{
+ char* pData = (char*)pSrc;
+ pData += cbOff;
+ USHORT nStatus;
+ if( afCmd & HDATA_APPOWNED )
+ nStatus = IMP_HDATAAPPOWNED;
+ else
+ nStatus = 0;
+ PDDESTRUCT hData=MakeDDEObject(0,(ATOM)hszItem,nStatus,wFmt,pData,cb);
+// WRITEDATA(hData)
+ if ( !hData )
+ ImpDdeMgr::nLastErrInstance = DMLERR_INVALIDPARAMETER;
+ return (HDDEDATA)hData;
+}
+
+// static
+BYTE* ImpDdeMgr::DdeAccessData(HDDEDATA hData, ULONG* pcbDataSize)
+{
+ BYTE* pRet = 0;
+ *pcbDataSize = 0;
+ if ( hData )
+ {
+ pRet = (BYTE*)hData;
+ pRet += hData->offabData;
+ ULONG nLen = hData->cbData;
+ // nLen -= hData->offabData;
+ *pcbDataSize = nLen;
+ }
+ else
+ ImpDdeMgr::nLastErrInstance = DMLERR_INVALIDPARAMETER;
+ return pRet;
+}
+
+// static
+BOOL ImpDdeMgr::DdeUnaccessData(HDDEDATA hData)
+{
+ return TRUE; // nothing to do for us
+}
+
+// static
+BOOL ImpDdeMgr::DdeFreeDataHandle(HDDEDATA hData)
+{
+ DdeUnaccessData( hData );
+ MyDosFreeMem( (PSZ)hData, "DdeFreeDataHandle" );
+ return TRUE;
+}
+
+// static
+HDDEDATA ImpDdeMgr::DdeAddData(HDDEDATA hData,void* pSrc,ULONG cb,ULONG cbOff)
+{
+ return (HDDEDATA)0;
+}
+
+// static
+ULONG ImpDdeMgr::DdeGetData(HDDEDATA hData,void* pDst,ULONG cbMax,ULONG cbOff)
+{
+ return 0;
+}
+
+BOOL ImpDdeMgr::DisconnectAll()
+{
+ //WRITESTATUS("Before DisconnectAll()")
+ USHORT nCurConvCount = pData->nCurConvCount;
+ if( !nCurConvCount )
+ return TRUE;
+
+ BOOL bRet = TRUE;
+ ImpHCONV* pPtr = pConvTable;
+ pPtr++;
+
+ for( USHORT nPos=1; nPos < pData->nMaxConvCount; nPos++, pPtr++ )
+ {
+ if( pPtr->hWndThis )
+ {
+ if( !DdeDisconnect( (HCONV)nPos ) )
+ bRet = FALSE;
+ nCurConvCount--;
+ if( !nCurConvCount )
+ break;
+ }
+ }
+ //WRITESTATUS("After DisconnectAll()")
+ return bRet;
+}
+
+// static
+void ImpDdeMgr::FreeTransactions( ImpDdeMgrData* pData,HWND hWndThis,
+ HWND hWndPartner )
+{
+ USHORT nCurTransCount = pData->nCurTransCount;
+ if( !nCurTransCount )
+ return;
+
+ Transaction* pTrans = GetTransTable( pData );
+ ImpHCONV* pConvTable = GetConvTable( pData );
+ pTrans++;
+ for( USHORT nPos=1; nPos < pData->nMaxTransCount; nPos++, pTrans++ )
+ {
+ if( pTrans->hConvOwner )
+ {
+ ImpHCONV* pConv = pConvTable + (USHORT)(pTrans->hConvOwner);
+ if((pConv->hWndThis==hWndThis&& pConv->hWndPartner==hWndPartner)||
+ (pConv->hWndThis==hWndPartner && pConv->hWndPartner==hWndThis))
+ {
+ FreeTransaction( pData, (ULONG)nPos );
+ }
+ nCurTransCount--;
+ if( !nCurTransCount )
+ return;
+ }
+ }
+}
+
+// static
+void ImpDdeMgr::FreeTransactions( ImpDdeMgrData* pData, HCONV hConvOwner )
+{
+ USHORT nCurTransCount = pData->nCurTransCount;
+ if( !nCurTransCount )
+ return;
+
+ Transaction* pTrans = GetTransTable( pData );
+// ImpHCONV* pConvTable = GetConvTable( pData );
+ pTrans++;
+ for( USHORT nPos=1; nPos < pData->nMaxTransCount; nPos++, pTrans++ )
+ {
+ if( pTrans->hConvOwner == hConvOwner )
+ {
+ FreeTransaction( pData, (ULONG)nPos );
+ nCurTransCount--;
+ if( !nCurTransCount )
+ return;
+ }
+ }
+}
+
+// static
+void ImpDdeMgr::FreeConversations( ImpDdeMgrData* pData, HWND hWndThis,
+ HWND hWndPartner )
+{
+ USHORT nCurCount = pData->nCurConvCount;
+ if( !nCurCount )
+ return;
+
+ ImpHCONV* pPtr = GetConvTable( pData );
+ pPtr++;
+ for( USHORT nPos=1; nPos < pData->nMaxConvCount; nPos++, pPtr++ )
+ {
+ if( pPtr->hWndThis )
+ {
+ if( hWndThis && pPtr->hWndPartner==hWndPartner )
+ FreeConvHandle( pData, (HCONV)nPos );
+ nCurCount--;
+ if( !nCurCount )
+ return;
+ }
+ }
+}
+
+
+BOOL ImpDdeMgr::OwnsConversationHandles()
+{
+ //WRITESTATUS("OwnsConversationHandles()");
+#if 0 && defined( OV_DEBUG )
+ String aStr("OwnsConversationHandles Server:");
+ aStr += (ULONG)hWndServer;
+ WRITELOG((char*)aStr.GetStr())
+#endif
+ ImpHCONV* pPtr = GetConvTable( pData );
+ for( USHORT nCur = 1; nCur < pData->nMaxConvCount; nCur++, pPtr++ )
+ {
+ if( pPtr->hWndThis && pPtr->pidOwner == pidThis )
+ {
+ //WRITELOG("OwnsConversationHandles: TRUE");
+ return TRUE;
+ }
+ }
+ // WRITELOG("OwnsConversationHandles: FALSE");
+ return FALSE;
+}
+
+
+
+// *********************************************************************
+// *********************************************************************
+// *********************************************************************
+
+USHORT DdeInitialize(ULONG* pidInst, PFNCALLBACK pfnCallback,
+ ULONG afCmd, ULONG ulRes)
+{
+ if( (*pidInst)!=0 )
+ {
+ // Reinitialize wird noch nicht unterstuetzt
+ DBG_ASSERT(0,"DDEML:Reinitialize not supported");
+ return DMLERR_INVALIDPARAMETER;
+ }
+
+ ImpDdeMgr* pMgr = new ImpDdeMgr;
+ *pidInst = (ULONG)pMgr;
+ return pMgr->DdeInitialize( pfnCallback, afCmd );
+}
+
+BOOL DdeUninitialize(ULONG idInst)
+{
+ if( !idInst )
+ return FALSE;
+ ImpDdeMgr* pMgr = (ImpDdeMgr*)idInst;
+ // nur loeschen, wenn wir nicht mehr benutzt werden!
+ if( !pMgr->OwnsConversationHandles() )
+ {
+ WRITELOG("DdeUninitialize: TRUE");
+ delete pMgr;
+ return TRUE;
+ }
+ WRITELOG("DdeUninitialize: FALSE");
+ return FALSE;
+}
+
+
+HCONVLIST DdeConnectList(ULONG idInst, HSZ hszService, HSZ hszTopic,
+ HCONVLIST hConvList, CONVCONTEXT* pCC)
+{
+ if( !idInst )
+ return 0;
+ return ((ImpDdeMgr*)idInst)->DdeConnectList(hszService,hszTopic,
+ hConvList, pCC );
+}
+
+HCONV DdeQueryNextServer(HCONVLIST hConvList, HCONV hConvPrev)
+{
+ return ImpDdeMgr::DdeQueryNextServer( hConvList, hConvPrev );
+}
+
+BOOL DdeDisconnectList(HCONVLIST hConvList)
+{
+ return ImpDdeMgr::DdeDisconnectList( hConvList );
+}
+
+HCONV DdeConnect(ULONG idInst, HSZ hszService, HSZ hszTopic,
+ CONVCONTEXT* pCC)
+{
+ if( !idInst )
+ return 0;
+ return ((ImpDdeMgr*)idInst)->DdeConnect( hszService, hszTopic, pCC );
+}
+
+BOOL DdeDisconnect(HCONV hConv)
+{
+ return ImpDdeMgr::DdeDisconnect( hConv );
+}
+
+HCONV DdeReconnect(HCONV hConv)
+{
+ return ImpDdeMgr::DdeReconnect( hConv );
+}
+
+
+USHORT DdeQueryConvInfo(HCONV hConv, ULONG idTransact, CONVINFO* pCI )
+{
+ return ImpDdeMgr::DdeQueryConvInfo( hConv, idTransact, pCI );
+}
+
+BOOL DdeSetUserHandle(HCONV hConv, ULONG id, ULONG hUser)
+{
+ return ImpDdeMgr::DdeSetUserHandle( hConv, id, hUser );
+}
+
+BOOL DdeAbandonTransaction(ULONG idInst, HCONV hConv, ULONG idTransaction)
+{
+ if( !idInst )
+ return FALSE;
+ return ((ImpDdeMgr*)idInst)->DdeAbandonTransaction(hConv,idTransaction);
+}
+
+BOOL DdePostAdvise(ULONG idInst, HSZ hszTopic, HSZ hszItem)
+{
+ if( !idInst )
+ return FALSE;
+ return ((ImpDdeMgr*)idInst)->DdePostAdvise( hszTopic, hszItem );
+}
+
+BOOL DdeEnableCallback(ULONG idInst, HCONV hConv, USHORT wCmd)
+{
+ if( !idInst )
+ return FALSE;
+ return ((ImpDdeMgr*)idInst)->DdeEnableCallback( hConv, wCmd );
+}
+
+HDDEDATA DdeClientTransaction(void* pData, ULONG cbData,
+ HCONV hConv, HSZ hszItem, USHORT wFmt, USHORT wType,
+ ULONG dwTimeout, ULONG* pdwResult)
+{
+ return ImpDdeMgr::DdeClientTransaction( pData, cbData,
+ hConv, hszItem, wFmt, wType, dwTimeout, pdwResult );
+}
+
+HDDEDATA DdeCreateDataHandle(ULONG idInst, void* pSrc, ULONG cb,
+ ULONG cbOff, HSZ hszItem, USHORT wFmt, USHORT afCmd)
+{
+ if( !idInst )
+ return 0;
+ return ((ImpDdeMgr*)idInst)->DdeCreateDataHandle( pSrc, cb,
+ cbOff, hszItem, wFmt, afCmd );
+}
+
+HDDEDATA DdeAddData(HDDEDATA hData, void* pSrc, ULONG cb, ULONG cbOff)
+{
+ return ImpDdeMgr::DdeAddData( hData, pSrc, cb, cbOff );
+}
+
+ULONG DdeGetData(HDDEDATA hData, void* pDst, ULONG cbMax, ULONG cbOff)
+{
+ return ImpDdeMgr::DdeGetData( hData, pDst, cbMax, cbOff );
+}
+
+BYTE* DdeAccessData(HDDEDATA hData, ULONG* pcbDataSize)
+{
+ return ImpDdeMgr::DdeAccessData( hData, pcbDataSize );
+}
+
+BOOL DdeUnaccessData(HDDEDATA hData)
+{
+ return ImpDdeMgr::DdeUnaccessData( hData );
+}
+
+BOOL DdeFreeDataHandle(HDDEDATA hData)
+{
+ return ImpDdeMgr::DdeFreeDataHandle( hData );
+}
+
+USHORT DdeGetLastError(ULONG idInst)
+{
+ if( !idInst )
+ return DMLERR_DLL_NOT_INITIALIZED;
+ return ((ImpDdeMgr*)idInst)->DdeGetLastError();
+}
+
+HSZ DdeCreateStringHandle(ULONG idInst, PSZ pszString,int iCodePage )
+{
+ if( !idInst )
+ return 0;
+ return ((ImpDdeMgr*)idInst)->DdeCreateStringHandle(pszString,iCodePage);
+}
+
+ULONG DdeQueryString( ULONG idInst, HSZ hsz, PSZ pBuf,
+ ULONG cchMax, int iCodePage )
+{
+ if( !idInst )
+ return 0;
+ return ((ImpDdeMgr*)idInst)->DdeQueryString( hsz,pBuf,cchMax,iCodePage);
+}
+
+BOOL DdeFreeStringHandle( ULONG idInst, HSZ hsz)
+{
+ if( !idInst )
+ return FALSE;
+ return ((ImpDdeMgr*)idInst)->DdeFreeStringHandle( hsz );
+}
+
+BOOL DdeKeepStringHandle( ULONG idInst, HSZ hsz )
+{
+ if( !idInst )
+ return FALSE;
+ return ((ImpDdeMgr*)idInst)->DdeKeepStringHandle( hsz );
+}
+
+int DdeCmpStringHandles(HSZ hsz1, HSZ hsz2)
+{
+ return ImpDdeMgr::DdeCmpStringHandles( hsz1, hsz2 );
+}
+
+HDDEDATA DdeNameService( ULONG idInst, HSZ hsz1, HSZ hszRes, USHORT afCmd )
+{
+ if( !idInst )
+ return 0;
+ return ((ImpDdeMgr*)idInst)->DdeNameService( hsz1, afCmd );
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/svdde/svt_ddemldeb.cxx b/binfilter/bf_svtools/source/svdde/svt_ddemldeb.cxx
new file mode 100644
index 000000000000..78cc6ca930a2
--- /dev/null
+++ b/binfilter/bf_svtools/source/svdde/svt_ddemldeb.cxx
@@ -0,0 +1,283 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 "ddemlimp.hxx"
+
+#ifdef OV_DEBUG
+#include <svgen.hxx>
+#endif
+
+#if defined(OV_DEBUG)
+
+namespace binfilter
+{
+
+void ImpAddHSZ( HSZ hszString, String& rStr )
+{
+ char aBuf[ 128 ];
+ ImpDdeMgr::DdeQueryString( hszString,aBuf,sizeof(aBuf),850);
+ rStr += " (\""; rStr += aBuf; rStr += "\",";
+ HATOMTBL hAtomTable = WinQuerySystemAtomTable();
+ ULONG nRefCount = 0;
+ if( hszString )
+ nRefCount = WinQueryAtomUsage(hAtomTable, (ATOM)hszString );
+ rStr += nRefCount; rStr += ')';
+}
+
+
+void ImpWriteDdeStatus(char* aFilename, char* pAppContext)
+{
+ char aBuf[ 128 ];
+ USHORT nCtr;
+ HWND* pAppPtr;
+ ImpHCONV* pConvPtr;
+ Transaction* pTransPtr;
+
+ ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData();
+ if( !pData )
+ return;
+ SvFileStream aStrm(aFilename, STREAM_READWRITE );
+ String aLine;
+ aStrm.Seek( STREAM_SEEK_TO_END );
+ aStrm << endl;
+ aStrm.WriteLine("********************** DDEML-Log ***********************");
+ aStrm << endl;
+ if( pAppContext )
+ {
+ aLine = Application::GetAppName();
+ aLine += ':';
+ aLine += "App-Context:"; aLine += pAppContext;
+ aStrm.WriteLine( aLine ); aStrm << endl;
+ }
+ aStrm.WriteLine("----------------- ImpDdeMgrData -------------------");
+ aStrm << endl;
+ aLine= "TotalSize :"; aLine+= pData->nTotalSize; aStrm.WriteLine(aLine);
+ aLine= "nOffsAppTable :"; aLine+= pData->nOffsAppTable; aStrm.WriteLine(aLine);
+ aLine= "nOffsConvTable :"; aLine+= pData->nOffsConvTable; aStrm.WriteLine(aLine);
+ aLine= "nOffsTransTable:"; aLine+= pData->nOffsTransTable; aStrm.WriteLine(aLine);
+ aLine= "nMaxAppCount :"; aLine+= pData->nMaxAppCount; aStrm.WriteLine(aLine);
+ aLine= "nMaxConvCount :"; aLine+= pData->nMaxConvCount; aStrm.WriteLine(aLine);
+ aLine= "nMaxTransCount :"; aLine+= pData->nMaxTransCount; aStrm.WriteLine(aLine);
+ aLine= "nLastErr :"; aLine+= pData->nLastErr; aStrm.WriteLine(aLine);
+ aLine= "nCurConvCount :"; aLine+= pData->nCurConvCount; aStrm.WriteLine(aLine);
+ aLine= "nCurTransCount :"; aLine+= pData->nCurTransCount; aStrm.WriteLine(aLine);
+ aStrm << endl;
+ aStrm.WriteLine("---------- Registered DDEML-Applications -----------");
+ aStrm << endl;
+ pAppPtr = ImpDdeMgr::GetAppTable( pData );
+ for( nCtr = 0; nCtr < pData->nMaxAppCount; nCtr++, pAppPtr++ )
+ {
+ if( *pAppPtr )
+ {
+ aLine = "App."; aLine += nCtr; aLine += " HWND:";
+ aLine += (ULONG)*pAppPtr; aStrm.WriteLine(aLine);
+ }
+ }
+
+ aStrm << endl;
+ aStrm.WriteLine("-------------- Conversation handles ----------------");
+ aStrm << endl;
+
+ USHORT nCurCount = pData->nCurConvCount;
+
+ if( nCurCount )
+ {
+ pConvPtr = ImpDdeMgr::GetConvTable( pData );
+ for( nCtr = 0; nCtr < pData->nMaxConvCount; nCtr++, pConvPtr++ )
+ {
+ if( pConvPtr->hWndThis )
+ {
+ aLine = "HCONV:"; aLine += nCtr;
+ aLine += " HCONVpartner: "; aLine += (USHORT)pConvPtr->hConvPartner;
+ if( !pConvPtr->hConvPartner ) aLine += "(Non-DDEML-App)";
+ aLine += " hszPartner: "; aLine += (USHORT)pConvPtr->hszPartner;
+ ImpAddHSZ( pConvPtr->hszPartner, aLine );
+ aStrm.WriteLine( aLine );
+
+ aLine = "hszService: "; aLine += (USHORT)pConvPtr->hszServiceReq;
+ ImpAddHSZ( pConvPtr->hszServiceReq, aLine );
+ aLine += " hszTopic: "; aLine += (USHORT)pConvPtr->hszTopic;
+ ImpAddHSZ( pConvPtr->hszTopic, aLine );
+ aStrm.WriteLine( aLine );
+
+ aLine= "Status: "; aLine+= pConvPtr->nStatus;
+ if( pConvPtr->nStatus & ST_CLIENT ) aLine += " (Client)";
+ if( pConvPtr->nStatus & ST_INLIST ) aLine += " (Inlist)";
+ aStrm.WriteLine(aLine);
+
+ aLine = "pidOwner: "; aLine += (ULONG)pConvPtr->pidOwner;
+ aStrm.WriteLine( aLine );
+ aLine = "hWndThis: "; aLine += (ULONG)pConvPtr->hWndThis;
+ aStrm.WriteLine( aLine );
+ aLine = "hWndPartner: "; aLine += (ULONG)pConvPtr->hWndPartner;
+ aStrm.WriteLine( aLine );
+
+ aLine = "hConvList: "; aLine += (ULONG)pConvPtr->hConvList;
+ aLine += " Prev: "; aLine += pConvPtr->nPrevHCONV;
+ aLine += " Next: "; aLine += pConvPtr->nNextHCONV;
+ aStrm.WriteLine( aLine );
+ aStrm.WriteLine("----------------------------------------------------");
+
+ nCurCount--;
+ if( !nCurCount )
+ break;
+ }
+ }
+ }
+
+ aStrm.WriteLine("----------------- Transaction Ids ------------------");
+
+ nCurCount = pData->nCurTransCount;
+ if( nCurCount )
+ {
+ pTransPtr = ImpDdeMgr::GetTransTable( pData );
+ for( nCtr = 0; nCtr < pData->nMaxTransCount; nCtr++, pTransPtr++ )
+ {
+
+ if( pTransPtr->hConvOwner )
+ {
+ aLine = "TransactionId:"; aLine += nCtr;
+ aLine += " hConvOwner: "; aLine += (USHORT)pTransPtr->hConvOwner;
+ aStrm.WriteLine( aLine );
+ aLine = "Item: "; aLine += (USHORT)pTransPtr->hszItem;
+ ImpAddHSZ( pTransPtr->hszItem, aLine );
+ aLine += " Format: "; aLine += pTransPtr->nFormat;
+ aStrm.WriteLine( aLine );
+ aLine = "TransactionType: "; aLine += pTransPtr->nType;
+ aLine += " Convst: "; aLine += pTransPtr->nConvst;
+ aLine += " LastErr: "; aLine += pTransPtr->nLastError;
+ aLine += " Userhandle: "; aLine += pTransPtr->nUser;
+ aStrm.WriteLine( aLine );
+ aStrm.WriteLine("--------------------------------------------------");
+
+ nCurCount--;
+ if( !nCurCount )
+ break;
+ }
+ }
+ }
+ aStrm << endl;
+ aStrm.WriteLine("******************* End of DDEML-Log *******************");
+}
+
+void ImpWriteDdeData(char* aFilename, DDESTRUCT* pData)
+{
+ char aBuf[ 128 ];
+ USHORT nCtr;
+ SvFileStream aStrm(aFilename, STREAM_READWRITE );
+ aStrm.Seek( STREAM_SEEK_TO_END );
+ String aLine;
+ aStrm << endl;
+ aLine = "cbData:"; aLine += pData->cbData; aStrm.WriteLine( aLine );
+ aLine = "fsStatus:"; aLine += pData->fsStatus; aStrm.WriteLine( aLine );
+ aLine = "usFormat:"; aLine += pData->usFormat; aStrm.WriteLine( aLine );
+ aLine = "ItemName:"; aLine += (char*)((char*)pData+pData->offszItemName);
+ aStrm.WriteLine( aLine );
+ aLine = "offabData:"; aLine += pData->offabData; aStrm.WriteLine(aLine);
+ char* pBuf = (char*)pData+pData->offabData;
+ USHORT nLen = pData->cbData; // - pData->offabData;
+ while( nLen )
+ {
+ aStrm << *pBuf;
+ nLen--;
+ pBuf++;
+ }
+ aStrm << endl;
+}
+
+void ImpWriteLogFile(char* pFilename, char* pStr)
+{
+ SvFileStream aStrm(pFilename, STREAM_READWRITE );
+ aStrm.Seek( STREAM_SEEK_TO_END );
+ String aStr( Application::GetAppName() );
+ aStr += ':'; aStr += pStr;
+ aStrm.WriteLine( (char*)aStr.GetStr() );
+}
+
+#else
+
+void ImpWriteDdeStatus(char*, char* ) {}
+void ImpWriteDdeData(char*, DDESTRUCT*) {}
+void ImpWriteLogFile(char*, char*) {}
+
+#endif
+
+APIRET MyDosAllocSharedMem(void** ppBaseAddress, char* pszName, unsigned long ulObjectSize,
+ unsigned long ulFlags, char* pContextStr )
+{
+ APIRET nRet = DosAllocSharedMem(ppBaseAddress,pszName,ulObjectSize,ulFlags );
+#if 0 && defined(OV_DEBUG) && defined(LOGFILE)
+ String aStr("DosAllocSharedMem:");
+ aStr += pContextStr;
+ aStr += ": ";
+ aStr += ulObjectSize;
+ aStr += " (";
+ aStr += (ULONG)*((char**)ppBaseAddress);
+ aStr += ')';
+ ImpWriteLogFile("\\ddeml.mem", (char*)aStr.GetStr() );
+#endif
+ return nRet;
+}
+
+APIRET MyDosAllocMem(void** ppBaseAddress, unsigned long ulObjectSize,
+ unsigned long ulFlags, char* pContextStr )
+{
+ APIRET nRet = DosAllocMem(ppBaseAddress, ulObjectSize,ulFlags );
+#if 0 && defined(OV_DEBUG) && defined(LOGFILE)
+ String aStr("DosAllocMem:");
+ aStr += pContextStr;
+ aStr += ": ";
+ aStr += ulObjectSize;
+ aStr += " (";
+ aStr += (ULONG)*((char**)ppBaseAddress);
+ aStr += ')';
+ ImpWriteLogFile("\\ddeml.mem", (char*)aStr.GetStr() );
+#endif
+ return nRet;
+}
+
+
+APIRET MyDosFreeMem( void* pBaseAddress, char* pContextStr )
+{
+ APIRET nRet = DosFreeMem( pBaseAddress );
+#if 0 && defined(OV_DEBUG) && defined(LOGFILE)
+ String aStr("DosFreeMem:");
+ aStr += pContextStr;
+ aStr += ": ";
+ aStr += (ULONG)pBaseAddress;
+ ImpWriteLogFile("\\ddeml.mem", (char*)aStr.GetStr());
+#endif
+ return nRet;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/svdde/svt_ddestrg.cxx b/binfilter/bf_svtools/source/svdde/svt_ddestrg.cxx
new file mode 100644
index 000000000000..51b573e29988
--- /dev/null
+++ b/binfilter/bf_svtools/source/svdde/svt_ddestrg.cxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+#define UNICODE
+
+#include "ddeimp.hxx"
+#include <bf_svtools/svdde.hxx>
+
+#if defined( WIN ) && defined( MSC )
+#pragma code_seg( "SVDDE_MISC_CODE" )
+#endif
+
+namespace binfilter
+{
+
+// --- DdeString::DdeString() --------------------------------------
+
+DdeString::DdeString( DWORD hDdeInst, const sal_Unicode* p ) :
+ String( p )
+{
+ hString = DdeCreateStringHandle( hDdeInst, (LPTSTR)p, CP_WINUNICODE );
+ hInst = hDdeInst;
+}
+
+// --- DdeString::DdeString() --------------------------------------
+
+DdeString::DdeString( DWORD hDdeInst, const String& r) :
+ String( r )
+{
+ hString = DdeCreateStringHandle( hDdeInst, (LPTSTR)r.GetBuffer(), CP_WINUNICODE );
+ hInst = hDdeInst;
+}
+
+// --- DdeString::~DdeString() -------------------------------------
+
+DdeString::~DdeString()
+{
+ if ( hString )
+ DdeFreeStringHandle( hInst, hString );
+}
+
+// --- DdeString::operator==() -------------------------------------
+
+int DdeString::operator==( HSZ h )
+{
+ return( !DdeCmpStringHandles( hString, h ) );
+}
+
+// --- DdeString::operator HSZ() -----------------------------------
+
+DdeString::operator HSZ()
+{
+ return hString;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/svdde/svt_ddesvr.cxx b/binfilter/bf_svtools/source/svdde/svt_ddesvr.cxx
new file mode 100644
index 000000000000..dab139f42419
--- /dev/null
+++ b/binfilter/bf_svtools/source/svdde/svt_ddesvr.cxx
@@ -0,0 +1,1083 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+
+#define UNICODE
+#include "ddeimp.hxx"
+#include <bf_svtools/svdde.hxx>
+#include <bf_svtools/svarray.hxx>
+
+#include <tools/debug.hxx>
+
+#include <osl/thread.h>
+
+namespace binfilter
+{
+
+//static long hCurConv = 0;
+//static DWORD hDdeInst = NULL;
+//static short nInstance = 0;
+//static DdeServices* pServices;
+
+enum DdeItemType
+{
+ DDEITEM,
+ DDEGETPUTITEM
+};
+
+struct DdeItemImpData
+{
+ ULONG nHCnv;
+ USHORT nCnt;
+
+ DdeItemImpData( ULONG nH ) : nHCnv( nH ), nCnt( 1 ) {}
+};
+
+SV_DECL_VARARR( DdeItemImp, DdeItemImpData, 1, 1 )
+SV_IMPL_VARARR( DdeItemImp, DdeItemImpData )
+
+// --- DdeInternat::SvrCallback() ----------------------------------
+
+#ifdef WNT
+HDDEDATA CALLBACK DdeInternal::SvrCallback(
+ WORD nCode, WORD nCbType, HCONV hConv, HSZ hText1, HSZ hText2,
+ HDDEDATA hData, DWORD, DWORD )
+#else
+#if defined ( MTW ) || ( defined ( GCC ) && defined ( OS2 )) || defined( ICC )
+HDDEDATA CALLBACK __EXPORT DdeInternal::SvrCallback(
+ WORD nCode, WORD nCbType, HCONV hConv, HSZ hText1, HSZ hText2,
+ HDDEDATA hData, DWORD, DWORD )
+#else
+HDDEDATA CALLBACK _export DdeInternal::SvrCallback(
+ WORD nCode, WORD nCbType, HCONV hConv, HSZ hText1, HSZ hText2,
+ HDDEDATA hData, DWORD, DWORD )
+#endif
+#endif
+{
+ DdeServices& rAll = DdeService::GetServices();
+ DdeService* pService;
+ DdeTopic* pTopic;
+ DdeItem* pItem;
+ DdeData* pData;
+ Conversation* pC;
+
+ DdeInstData* pInst = ImpGetInstData();
+ DBG_ASSERT(pInst,"SVDDE:No instance data");
+
+ switch( nCode )
+ {
+ case XTYP_WILDCONNECT:
+ {
+ int nTopics = 0;
+
+#if 1
+ TCHAR chTopicBuf[250];
+ if( hText1 )
+ DdeQueryString( pInst->hDdeInstSvr, hText1, chTopicBuf,
+ sizeof(chTopicBuf)/sizeof(TCHAR), CP_WINUNICODE );
+
+ for( pService = rAll.First();pService;pService = rAll.Next() )
+ {
+ if ( !hText2 || ( *pService->pName == hText2 ) )
+ {
+ String sTopics( pService->Topics() );
+ if( sTopics.Len() )
+ {
+ if( hText1 )
+ {
+ USHORT n = 0;
+ while( STRING_NOTFOUND != n )
+ {
+ String s( sTopics.GetToken( 0, '\t', n ));
+ if( s == reinterpret_cast<const sal_Unicode*>(chTopicBuf) )
+ ++nTopics;
+ }
+ }
+ else
+ nTopics += sTopics.GetTokenCount( '\t' );
+ }
+ }
+ }
+
+#else
+ for( pService = rAll.First();pService;pService = rAll.Next() )
+ {
+ if ( !hText2 || ( *pService->pName == hText2 ) )
+ {
+ for( pTopic = pService->aTopics.First(); pTopic;
+ pTopic = pService->aTopics.Next() )
+ {
+ if ( !hText1 || (*pTopic->pName == hText1) )
+ nTopics++;
+ }
+ }
+ }
+#endif
+ if( !nTopics )
+ return (HDDEDATA)NULL;
+
+ HSZPAIR* pPairs = new HSZPAIR [nTopics + 1];
+ if ( !pPairs )
+ return (HDDEDATA)NULL;
+
+ HSZPAIR* q = pPairs;
+ for( pService = rAll.First(); pService; pService = rAll.Next() )
+ {
+ if ( !hText2 || (*pService->pName == hText2 ) )
+ {
+#if 0
+ for ( pTopic = pService->aTopics.First(); pTopic;
+ pTopic = pService->aTopics.Next() )
+ {
+ if ( !hText1 || (*pTopic->pName == hText1) )
+ {
+ q->hszSvc = *pService->pName;
+ q->hszTopic = *pTopic->pName;
+ q++;
+ }
+ }
+#else
+ String sTopics( pService->Topics() );
+ USHORT n = 0;
+ while( STRING_NOTFOUND != n )
+ {
+ String s( sTopics.GetToken( 0, '\t', n ));
+ s.EraseAllChars( '\n' ).EraseAllChars( '\r' );
+ if( !hText1 || s == reinterpret_cast<const sal_Unicode*>(chTopicBuf) )
+ {
+ DdeString aDStr( pInst->hDdeInstSvr, s );
+ pTopic = FindTopic( *pService, (HSZ)aDStr );
+ if( pTopic )
+ {
+ q->hszSvc = *pService->pName;
+ q->hszTopic = *pTopic->pName;
+ q++;
+ }
+ }
+ }
+
+#endif
+ }
+ }
+
+ q->hszSvc = NULL;
+ q->hszTopic = NULL;
+ HDDEDATA h = DdeCreateDataHandle(
+ pInst->hDdeInstSvr, (LPBYTE) pPairs,
+ sizeof(HSZPAIR) * (nTopics+1),
+ 0, NULL, nCbType, 0);
+ delete[] pPairs;
+ return h;
+ }
+
+ case XTYP_CONNECT:
+ pService = FindService( hText2 );
+ if ( pService)
+ pTopic = FindTopic( *pService, hText1 );
+ else
+ pTopic = NULL;
+ if ( pTopic )
+ return (HDDEDATA)DDE_FACK;
+ else
+ return (HDDEDATA) NULL;
+
+ case XTYP_CONNECT_CONFIRM:
+ pService = FindService( hText2 );
+ if ( pService )
+ {
+ pTopic = FindTopic( *pService, hText1 );
+ if ( pTopic )
+ {
+ pTopic->Connect( (long) hConv );
+ pC = new Conversation;
+ pC->hConv = hConv;
+ pC->pTopic = pTopic;
+ pService->pConv->Insert( pC );
+ }
+ }
+ return (HDDEDATA)NULL;
+ }
+
+ for ( pService = rAll.First(); pService; pService = rAll.Next() )
+ {
+ for( pC = pService->pConv->First(); pC;
+ pC = pService->pConv->Next() )
+ {
+ if ( pC->hConv == hConv )
+ goto found;
+ }
+ }
+
+ return (HDDEDATA) DDE_FNOTPROCESSED;
+
+found:
+ if ( nCode == XTYP_DISCONNECT)
+ {
+ pC->pTopic->_Disconnect( (long) hConv );
+ pService->pConv->Remove( pC );
+ delete pC;
+ return (HDDEDATA)NULL;
+ }
+
+ BOOL bExec = BOOL(nCode == XTYP_EXECUTE);
+ pTopic = pC->pTopic;
+ if ( pTopic && !bExec )
+ pItem = FindItem( *pTopic, hText2 );
+ else
+ pItem = NULL;
+
+ if ( !bExec && !pService->HasCbFormat( nCbType ) )
+ pItem = NULL;
+ if ( !pItem && !bExec )
+ return (HDDEDATA)DDE_FNOTPROCESSED;
+ if ( pItem )
+ pTopic->aItem = pItem->GetName();
+ else
+ pTopic->aItem.Erase();
+
+ BOOL bRes = FALSE;
+ pInst->hCurConvSvr = (long)hConv;
+ switch( nCode )
+ {
+ case XTYP_REQUEST:
+ case XTYP_ADVREQ:
+ {
+ String aRes; // darf erst am Ende freigegeben werden!!
+ if ( pTopic->IsSystemTopic() )
+ {
+ if ( pTopic->aItem == reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_TOPICS) )
+ aRes = pService->Topics();
+ else if ( pTopic->aItem == reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_SYSITEMS) )
+ aRes = pService->SysItems();
+ else if ( pTopic->aItem == reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_STATUS) )
+ aRes = pService->Status();
+ else if ( pTopic->aItem == reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_FORMATS) )
+ aRes = pService->Formats();
+ else if ( pTopic->aItem == reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_HELP) )
+ aRes = pService->GetHelp();
+ else
+ aRes = pService->SysTopicGet( pTopic->aItem );
+
+ if ( aRes.Len() )
+ pData = new DdeData( aRes );
+ else
+ pData = NULL;
+ }
+ else if( DDEGETPUTITEM == pItem->nType )
+ pData = ((DdeGetPutItem*)pItem)->Get(
+ DdeData::GetInternalFormat( nCbType ) );
+ else
+ pData = pTopic->Get( DdeData::GetInternalFormat( nCbType ));
+
+ if ( pData )
+ return DdeCreateDataHandle( pInst->hDdeInstSvr,
+ (LPBYTE)pData->pImp->pData,
+ pData->pImp->nData,
+ 0, hText2,
+ DdeData::GetExternalFormat(
+ pData->pImp->nFmt ),
+ 0 );
+ }
+ break;
+
+ case XTYP_POKE:
+ if ( !pTopic->IsSystemTopic() )
+ {
+ DdeData d;
+ d.pImp->hData = hData;
+ d.pImp->nFmt = DdeData::GetInternalFormat( nCbType );
+ d.Lock();
+ if( DDEGETPUTITEM == pItem->nType )
+ bRes = ((DdeGetPutItem*)pItem)->Put( &d );
+ else
+ bRes = pTopic->Put( &d );
+ }
+ pInst->hCurConvSvr = NULL;
+ if ( bRes )
+ return (HDDEDATA)DDE_FACK;
+ else
+ return (HDDEDATA) DDE_FNOTPROCESSED;
+
+ case XTYP_ADVSTART:
+ {
+ // wird das Item zum erstenmal ein HotLink ?
+ if( !pItem->pImpData && pTopic->StartAdviseLoop() )
+ {
+ // dann wurde das Item ausgewechselt
+ pTopic->aItems.Remove( pItem );
+ DdeItem* pTmp;
+ for( pTmp = pTopic->aItems.First(); pTmp;
+ pTmp = pTopic->aItems.Next() )
+ if( *pTmp->pName == hText2 )
+ {
+ // es wurde tatsaechlich ausgewechselt
+ delete pItem;
+ pItem = 0;
+ break;
+ }
+ if( pItem )
+ // es wurde doch nicht ausgewechselt, also wieder rein
+ pTopic->aItems.Insert( pItem );
+ else
+ pItem = pTmp;
+ }
+ pItem->IncMonitor( (long)hConv );
+ pInst->hCurConvSvr = NULL;
+ }
+ return (HDDEDATA)TRUE;
+
+ case XTYP_ADVSTOP:
+ pItem->DecMonitor( (long)hConv );
+ if( !pItem->pImpData )
+ pTopic->StopAdviseLoop();
+ pInst->hCurConvSvr = NULL;
+ return (HDDEDATA)TRUE;
+
+ case XTYP_EXECUTE:
+ {
+ DdeData aExec;
+ aExec.pImp->hData = hData;
+ aExec.pImp->nFmt = DdeData::GetInternalFormat( nCbType );
+ aExec.Lock();
+ String aName;
+
+ aName = (const sal_Unicode *)aExec.pImp->pData;
+
+ if( pTopic->IsSystemTopic() )
+ bRes = pService->SysTopicExecute( &aName );
+ else
+ bRes = pTopic->Execute( &aName );
+ }
+ pInst->hCurConvSvr = NULL;
+ if ( bRes )
+ return (HDDEDATA)DDE_FACK;
+ else
+ return (HDDEDATA)DDE_FNOTPROCESSED;
+ }
+
+ return (HDDEDATA)NULL;
+}
+
+// --- DdeInternat::FindService() ----------------------------------
+
+DdeService* DdeInternal::FindService( HSZ hService )
+{
+ DdeService* s;
+ DdeServices& rSvc = DdeService::GetServices();
+ for ( s = rSvc.First(); s; s = rSvc.Next() )
+ {
+ if ( *s->pName == hService )
+ return s;
+ }
+
+ return NULL;
+}
+
+// --- DdeInternat::FindTopic() ------------------------------------
+
+DdeTopic* DdeInternal::FindTopic( DdeService& rService, HSZ hTopic )
+{
+ DdeTopic* s;
+ DdeTopics& rTopics = rService.aTopics;
+ int bWeiter = FALSE;
+ DdeInstData* pInst = ImpGetInstData();
+ DBG_ASSERT(pInst,"SVDDE:No instance data");
+
+ do { // middle check loop
+ for ( s = rTopics.First(); s; s = rTopics.Next() )
+ {
+ if ( *s->pName == hTopic )
+ return s;
+ }
+
+ bWeiter = !bWeiter;
+ if( !bWeiter )
+ break;
+
+ // dann befragen wir doch mal unsere Ableitung:
+ TCHAR chBuf[250];
+ DdeQueryString(pInst->hDdeInstSvr,hTopic,chBuf,sizeof(chBuf)/sizeof(TCHAR),CP_WINUNICODE );
+ bWeiter = rService.MakeTopic( reinterpret_cast<const sal_Unicode*>(chBuf) );
+ // dann muessen wir noch mal suchen
+ } while( bWeiter );
+
+ return 0;
+}
+
+// --- DdeInternal::FindItem() -------------------------------------
+
+DdeItem* DdeInternal::FindItem( DdeTopic& rTopic, HSZ hItem )
+{
+ DdeItem* s;
+ DdeItems& rItems = rTopic.aItems;
+ DdeInstData* pInst = ImpGetInstData();
+ DBG_ASSERT(pInst,"SVDDE:No instance data");
+ int bWeiter = FALSE;
+
+ do { // middle check loop
+
+ for ( s = rItems.First(); s; s = rItems.Next() )
+ if ( *s->pName == hItem )
+ return s;
+
+ bWeiter = !bWeiter;
+ if( !bWeiter )
+ break;
+
+ // dann befragen wir doch mal unsere Ableitung:
+ TCHAR chBuf[250];
+ DdeQueryString(pInst->hDdeInstSvr,hItem,chBuf,sizeof(chBuf)/sizeof(TCHAR),CP_WINUNICODE );
+ bWeiter = rTopic.MakeItem( reinterpret_cast<const sal_Unicode*>(chBuf) );
+ // dann muessen wir noch mal suchen
+ } while( bWeiter );
+
+ return 0;
+}
+
+// --- DdeService::DdeService() ------------------------------------
+
+DdeService::DdeService( const String& rService )
+{
+ DdeInstData* pInst = ImpGetInstData();
+ if( !pInst )
+ pInst = ImpInitInstData();
+ pInst->nRefCount++;
+ pInst->nInstanceSvr++;
+
+ if ( !pInst->hDdeInstSvr )
+ {
+ nStatus = sal::static_int_cast< short >(
+ DdeInitialize( &pInst->hDdeInstSvr,
+ (PFNCALLBACK)DdeInternal::SvrCallback,
+ APPCLASS_STANDARD |
+ CBF_SKIP_REGISTRATIONS |
+ CBF_SKIP_UNREGISTRATIONS, 0L ) );
+ pInst->pServicesSvr = new DdeServices;
+ }
+ else
+ nStatus = DMLERR_NO_ERROR;
+
+ pConv = new ConvList;
+
+ if ( pInst->pServicesSvr )
+ pInst->pServicesSvr->Insert( this );
+
+ pName = new DdeString( pInst->hDdeInstSvr, rService );
+ if ( nStatus == DMLERR_NO_ERROR )
+ if ( !DdeNameService( pInst->hDdeInstSvr, *pName, NULL,
+ DNS_REGISTER | DNS_FILTEROFF ) )
+ nStatus = DMLERR_SYS_ERROR;
+
+ AddFormat( FORMAT_STRING );
+ pSysTopic = new DdeTopic( reinterpret_cast<const sal_Unicode*>(SZDDESYS_TOPIC) );
+ pSysTopic->AddItem( DdeItem( reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_TOPICS) ) );
+ pSysTopic->AddItem( DdeItem( reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_SYSITEMS) ) );
+ pSysTopic->AddItem( DdeItem( reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_STATUS) ) );
+ pSysTopic->AddItem( DdeItem( reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_FORMATS) ) );
+ pSysTopic->AddItem( DdeItem( reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_HELP) ) );
+ AddTopic( *pSysTopic );
+}
+
+// --- DdeService::~DdeService() -----------------------------------
+
+DdeService::~DdeService()
+{
+ DdeInstData* pInst = ImpGetInstData();
+ DBG_ASSERT(pInst,"SVDDE:No instance data");
+ if ( pInst->pServicesSvr )
+ pInst->pServicesSvr->Remove( this );
+
+ // MT: Im Auftrage des Herrn (AM) auskommentiert...
+ // Grund:
+ // Bei Client/Server werden die Server nicht beendet, wenn mehr
+ // als einer gestartet.
+ // Weil keine System-Messagequeue ?!
+
+ delete pSysTopic;
+ delete pName;
+
+ pInst->nInstanceSvr--;
+ pInst->nRefCount--;
+ if ( !pInst->nInstanceSvr && pInst->hDdeInstSvr )
+ {
+ if( DdeUninitialize( pInst->hDdeInstSvr ) )
+ {
+ pInst->hDdeInstSvr = NULL;
+ delete pInst->pServicesSvr;
+ pInst->pServicesSvr = NULL;
+ if( pInst->nRefCount == 0)
+ ImpDeinitInstData();
+ }
+ }
+ delete pConv;
+}
+
+// --- DdeService::GetName() ---------------------------------------
+
+const String& DdeService::GetName() const
+{
+ return *pName;
+}
+
+// --- DdeService::GetServices() -----------------------------------
+
+DdeServices& DdeService::GetServices()
+{
+ DdeInstData* pInst = ImpGetInstData();
+ DBG_ASSERT(pInst,"SVDDE:No instance data");
+ return *(pInst->pServicesSvr);
+}
+
+// --- DdeService::AddTopic() --------------------------------------
+
+void DdeService::AddTopic( const DdeTopic& rTopic )
+{
+ RemoveTopic( rTopic );
+ aTopics.Insert( (DdeTopic*) &rTopic );
+}
+
+// --- DdeService::RemoveTopic() -----------------------------------
+
+void DdeService::RemoveTopic( const DdeTopic& rTopic )
+{
+ DdeTopic* t;
+ for ( t = aTopics.First(); t; t = aTopics.Next() )
+ {
+ if ( !DdeCmpStringHandles (*t->pName, *rTopic.pName ) )
+ {
+ aTopics.Remove( t );
+ // JP 27.07.95: und alle Conversions loeschen !!!
+ // (sonst wird auf geloeschten Topics gearbeitet!!)
+ for( ULONG n = pConv->Count(); n; )
+ {
+ Conversation* pC = pConv->GetObject( --n );
+ if( pC->pTopic == &rTopic )
+ {
+ pConv->Remove( pC );
+ delete pC;
+ }
+ }
+ break;
+ }
+ }
+}
+
+// --- DdeService::HasCbFormat() -----------------------------------
+
+BOOL DdeService::HasCbFormat( USHORT nFmt )
+{
+ return BOOL( aFormats.GetPos( nFmt ) != LIST_ENTRY_NOTFOUND );
+}
+
+// --- DdeService::HasFormat() -------------------------------------
+
+BOOL DdeService::HasFormat( ULONG nFmt )
+{
+ return HasCbFormat( (USHORT)DdeData::GetExternalFormat( nFmt ));
+}
+
+// --- DdeService::AddFormat() -------------------------------------
+
+void DdeService::AddFormat( ULONG nFmt )
+{
+ nFmt = DdeData::GetExternalFormat( nFmt );
+ aFormats.Remove( nFmt );
+ aFormats.Insert( nFmt );
+}
+
+// --- DdeService::RemoveFormat() ----------------------------------
+
+void DdeService::RemoveFormat( ULONG nFmt )
+{
+ aFormats.Remove( DdeData::GetExternalFormat( nFmt ) );
+}
+
+// --- DdeTopic::DdeTopic() ----------------------------------------
+
+DdeTopic::DdeTopic( const String& rName )
+{
+ DdeInstData* pInst = ImpGetInstData();
+ DBG_ASSERT(pInst,"SVDDE:No instance data");
+ pName = new DdeString( pInst->hDdeInstSvr, rName );
+}
+
+// --- DdeTopic::~DdeTopic() ---------------------------------------
+
+DdeTopic::~DdeTopic()
+{
+ DdeItem* t;
+ while( ( t = aItems.First() ) != NULL )
+ {
+ aItems.Remove( t );
+ t->pMyTopic = 0;
+ delete t;
+ }
+ delete pName;
+}
+
+// --- DdeTopic::GetName() -----------------------------------------
+
+const String& DdeTopic::GetName() const
+{
+ return *pName;
+}
+
+// --- DdeTopic::IsSystemTopic() -----------------------------------
+
+BOOL DdeTopic::IsSystemTopic()
+{
+ return BOOL (GetName() == reinterpret_cast<const sal_Unicode*>(SZDDESYS_TOPIC));
+}
+
+// --- DdeTopic::AddItem() -----------------------------------------
+
+DdeItem* DdeTopic::AddItem( const DdeItem& r )
+{
+ DdeItem* s;
+ if( DDEGETPUTITEM == r.nType )
+ s = new DdeGetPutItem( r );
+ else
+ s = new DdeItem( r );
+ if ( s )
+ {
+ aItems.Insert( s );
+ s->pMyTopic = this;
+ }
+ return s;
+}
+
+// --- DdeTopic::NotifyClient() ------------------------------------
+
+void DdeTopic::NotifyClient( const String& rItem )
+{
+ DdeItem* pItem;
+ DdeInstData* pInst = ImpGetInstData();
+ DBG_ASSERT(pInst,"SVDDE:No instance data");
+ for ( pItem = aItems.First(); pItem; pItem = aItems.Next() )
+ {
+ if ( pItem->GetName() == rItem )
+ {
+ if ( pItem->pImpData )
+ DdePostAdvise( pInst->hDdeInstSvr, *pName, *pItem->pName );
+ }
+ break;
+ }
+}
+
+// --- DdeTopic::Connect() -----------------------------------------
+
+void __EXPORT DdeTopic::Connect( long nId )
+{
+ aConnectLink.Call( (void*)nId );
+}
+
+// --- DdeTopic::Disconnect() --------------------------------------
+
+void __EXPORT DdeTopic::Disconnect( long nId )
+{
+ aDisconnectLink.Call( (void*)nId );
+}
+
+// --- DdeTopic::_Disconnect() --------------------------------------
+
+void __EXPORT DdeTopic::_Disconnect( long nId )
+{
+ for( DdeItem* pItem = aItems.First(); pItem; pItem = aItems.Next() )
+ pItem->DecMonitor( nId );
+
+ Disconnect( nId );
+}
+
+// --- DdeTopic::Get() ---------------------------------------------
+
+DdeData* __EXPORT DdeTopic::Get( ULONG nFmt )
+{
+ if ( aGetLink.IsSet() )
+ return (DdeData*)aGetLink.Call( (void*)nFmt );
+ else
+ return NULL;
+}
+
+// --- DdeTopic::Put() ---------------------------------------------
+
+BOOL __EXPORT DdeTopic::Put( const DdeData* r )
+{
+ if ( aPutLink.IsSet() )
+ return (BOOL)aPutLink.Call( (void*) r );
+ else
+ return FALSE;
+}
+
+// --- DdeTopic::Execute() -----------------------------------------
+
+BOOL __EXPORT DdeTopic::Execute( const String* r )
+{
+ if ( aExecLink.IsSet() )
+ return (BOOL)aExecLink.Call( (void*)r );
+ else
+ return FALSE;
+}
+
+// --- DdeTopic::GetConvId() ---------------------------------------
+
+long DdeTopic::GetConvId()
+{
+ DdeInstData* pInst = ImpGetInstData();
+ DBG_ASSERT(pInst,"SVDDE:No instance data");
+ return pInst->hCurConvSvr;
+}
+
+// --- DdeTopic::StartAdviseLoop() ---------------------------------
+
+BOOL DdeTopic::StartAdviseLoop()
+{
+ return FALSE;
+}
+
+// --- DdeTopic::StopAdviseLoop() ----------------------------------
+
+BOOL DdeTopic::StopAdviseLoop()
+{
+ return FALSE;
+}
+
+// --- DdeItem::DdeItem() ------------------------------------------
+
+DdeItem::DdeItem( const sal_Unicode* p )
+{
+ DdeInstData* pInst = ImpGetInstData();
+ DBG_ASSERT(pInst,"SVDDE:No instance data");
+ pName = new DdeString( pInst->hDdeInstSvr, p );
+ nType = DDEITEM;
+ pMyTopic = 0;
+ pImpData = 0;
+}
+
+// --- DdeItem::DdeItem() ------------------------------------------
+
+DdeItem::DdeItem( const String& r)
+{
+ DdeInstData* pInst = ImpGetInstData();
+ DBG_ASSERT(pInst,"SVDDE:No instance data");
+ pName = new DdeString( pInst->hDdeInstSvr, r );
+ nType = DDEITEM;
+ pMyTopic = 0;
+ pImpData = 0;
+}
+
+// --- DdeItem::DdeItem() ------------------------------------------
+
+DdeItem::DdeItem( const DdeItem& r)
+{
+ DdeInstData* pInst = ImpGetInstData();
+ DBG_ASSERT(pInst,"SVDDE:No instance data");
+ pName = new DdeString( pInst->hDdeInstSvr, *r.pName );
+ nType = DDEITEM;
+ pMyTopic = 0;
+ pImpData = 0;
+}
+
+// --- DdeItem::~DdeItem() -----------------------------------------
+
+DdeItem::~DdeItem()
+{
+ if( pMyTopic )
+ pMyTopic->aItems.Remove( this );
+ delete pName;
+ delete pImpData;
+}
+
+// --- DdeItem::GetName() ------------------------------------------
+
+const String& DdeItem::GetName() const
+{
+ return *pName;
+}
+
+// --- DdeItem::NotifyClient() ------------------------------------------
+
+void DdeItem::NotifyClient()
+{
+ if( pMyTopic && pImpData )
+ {
+ DdeInstData* pInst = ImpGetInstData();
+ DBG_ASSERT(pInst,"SVDDE:No instance data");
+ DdePostAdvise( pInst->hDdeInstSvr, *pMyTopic->pName, *pName );
+ }
+}
+
+// --- DdeItem::IncMonitor() ------------------------------------------
+
+void DdeItem::IncMonitor( ULONG nHCnv )
+{
+ if( !pImpData )
+ {
+ pImpData = new DdeItemImp;
+ if( DDEGETPUTITEM == nType )
+ ((DdeGetPutItem*)this)->AdviseLoop( TRUE );
+ }
+ else
+ {
+ for( USHORT n = pImpData->Count(); n; )
+ if( (*pImpData)[ --n ].nHCnv == nHCnv )
+ {
+ ++(*pImpData)[ n ].nHCnv;
+ return ;
+ }
+ }
+
+ pImpData->Insert( DdeItemImpData( nHCnv ), pImpData->Count() );
+}
+
+// --- DdeItem::DecMonitor() ------------------------------------------
+
+void DdeItem::DecMonitor( ULONG nHCnv )
+{
+ if( pImpData )
+ {
+ DdeItemImpData* pData = (DdeItemImpData*)pImpData->GetData();
+ for( USHORT n = pImpData->Count(); n; --n, ++pData )
+ if( pData->nHCnv == nHCnv )
+ {
+ if( !pData->nCnt || !--pData->nCnt )
+ {
+ if( 1 < pImpData->Count() )
+ pImpData->Remove( pImpData->Count() - n );
+ else
+ {
+ delete pImpData, pImpData = 0;
+ if( DDEGETPUTITEM == nType )
+ ((DdeGetPutItem*)this)->AdviseLoop( FALSE );
+ }
+ }
+ return ;
+ }
+ }
+}
+
+// --- DdeItem::GetLinks() ------------------------------------------
+
+short DdeItem::GetLinks()
+{
+ short nCnt = 0;
+ if( pImpData )
+ for( USHORT n = pImpData->Count(); n; )
+ nCnt = nCnt + (*pImpData)[ --n ].nCnt;
+ return nCnt;
+}
+
+// --- DdeGetPutItem::DdeGetPutItem() ------------------------------
+
+DdeGetPutItem::DdeGetPutItem( const sal_Unicode* p )
+ : DdeItem( p )
+{
+ nType = DDEGETPUTITEM;
+}
+
+// --- DdeGetPutItem::DdeGetPutItem() ------------------------------
+
+DdeGetPutItem::DdeGetPutItem( const String& rStr )
+ : DdeItem( rStr )
+{
+ nType = DDEGETPUTITEM;
+}
+
+// --- DdeGetPutItem::DdeGetPutItem() ------------------------------
+
+DdeGetPutItem::DdeGetPutItem( const DdeItem& rItem )
+ : DdeItem( rItem )
+{
+ nType = DDEGETPUTITEM;
+}
+
+
+// --- DdeGetPutData::Get() ----------------------------------------
+
+DdeData* DdeGetPutItem::Get( ULONG )
+{
+ return 0;
+}
+
+// --- DdeGetPutData::Put() ----------------------------------------
+
+BOOL DdeGetPutItem::Put( const DdeData* )
+{
+ return FALSE;
+}
+
+// --- DdeGetPutData::AdviseLoop() ---------------------------------
+
+void DdeGetPutItem::AdviseLoop( BOOL )
+{
+}
+
+
+// --- DdeService::SysItems() --------------------------------------
+
+String DdeService::SysItems()
+{
+ String s;
+ DdeTopic* t;
+ for ( t = aTopics.First(); t; t = aTopics.Next() )
+ {
+ if ( t->GetName() == reinterpret_cast<const sal_Unicode*>(SZDDESYS_TOPIC) )
+ {
+ short n = 0;
+ DdeItem* pi;
+ for ( pi = t->aItems.First(); pi; pi = t->aItems.Next(), n++ )
+ {
+ if ( n )
+ s += '\t';
+ s += pi->GetName();
+ }
+ s += String::CreateFromAscii("\r\n");
+ }
+ }
+
+ return s;
+}
+
+// --- DdeService::Topics() ----------------------------------------
+
+String DdeService::Topics()
+{
+ String s;
+ DdeTopic* t;
+ short n = 0;
+
+ for ( t = aTopics.First(); t; t = aTopics.Next(), n++ )
+ {
+ if ( n )
+ s += '\t';
+ s += t->GetName();
+ }
+ s += String::CreateFromAscii("\r\n");
+
+ return s;
+}
+
+// --- DdeService::Formats() ---------------------------------------
+
+String DdeService::Formats()
+{
+ String s;
+ long f;
+ TCHAR buf[128];
+ LPCTSTR p;
+ short n = 0;
+
+ for ( f = aFormats.First(); f; f = aFormats.Next(), n++ )
+ {
+ if ( n )
+ s += '\t';
+ p = buf;
+
+ switch( (USHORT)f )
+ {
+ case CF_TEXT:
+ p = reinterpret_cast<LPCTSTR>(String::CreateFromAscii("TEXT").GetBuffer());
+ break;
+ case CF_BITMAP:
+ p = reinterpret_cast<LPCTSTR>(String::CreateFromAscii("BITMAP").GetBuffer());
+ break;
+#ifdef OS2
+ case CF_DSPTEXT:
+ p = String::CreateFromAscii("TEXT").GetBuffer();
+ break;
+ case CF_DSPBITMAP:
+ p = String::CreateFromAscii("BITMAP").GetBuffer();
+ break;
+ case CF_METAFILE:
+ p = String::CreateFromAscii("METAFILE").GetBuffer();
+ break;
+ case CF_DSPMETAFILE:
+ p = String::CreateFromAscii("METAFILE").GetBuffer();
+ break;
+ case CF_PALETTE:
+ p = String::CreateFromAscii("PALETTE").GetBuffer();
+ break;
+ default:
+ p= String::CreateFromAscii("PRIVATE").GetBuffer();
+#else
+ default:
+ GetClipboardFormatName( (UINT)f, buf, sizeof(buf) / sizeof(TCHAR) );
+#endif
+ }
+ s += String( reinterpret_cast<const sal_Unicode*>(p) );
+ }
+ s += String::CreateFromAscii("\r\n");
+
+ return s;
+}
+
+// --- DdeService::Status() ----------------------------------------
+
+String DdeService::Status()
+{
+ return IsBusy() ? String::CreateFromAscii("Busy\r\n") : String::CreateFromAscii("Ready\r\n");
+}
+
+// --- DdeService::IsBusy() ----------------------------------------
+
+BOOL __EXPORT DdeService::IsBusy()
+{
+ return FALSE;
+}
+
+// --- DdeService::GetHelp() ----------------------------------------
+
+String __EXPORT DdeService::GetHelp()
+{
+ return String();
+}
+
+BOOL DdeTopic::MakeItem( const String& )
+{
+ return FALSE;
+}
+
+BOOL DdeService::MakeTopic( const String& )
+{
+ return FALSE;
+}
+
+String DdeService::SysTopicGet( const String& )
+{
+ return String();
+}
+
+BOOL DdeService::SysTopicExecute( const String* )
+{
+ return FALSE;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/svdde/svt_ddewrap.cxx b/binfilter/bf_svtools/source/svdde/svt_ddewrap.cxx
new file mode 100644
index 000000000000..89c73c23bfba
--- /dev/null
+++ b/binfilter/bf_svtools/source/svdde/svt_ddewrap.cxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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
+
+#define _SVTOOLS_SVDDE_DDEWRAP_CXX_
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include "ddewrap.hxx"
+
+namespace binfilter
+{
+
+//------------------------------------------------------------------------
+
+HSZ WINAPI DdeCreateStringHandleW_9x( DWORD idInst, LPCWSTR pszString, int )
+{
+ HSZ hszResult;
+ LPSTR pszANSIString;
+ int nSize;
+
+ nSize = pszString ? WideCharToMultiByte( CP_ACP, 0, pszString, -1, NULL, 0, NULL, NULL ) : 0;
+ pszANSIString = nSize ? (LPSTR)HeapAlloc( GetProcessHeap(), 0, nSize * sizeof(CHAR) ) : NULL;
+
+ if ( pszANSIString )
+ WideCharToMultiByte( CP_ACP, 0, pszString, -1, pszANSIString, nSize, NULL, NULL );
+
+ hszResult = DdeCreateStringHandleA( idInst, pszANSIString, CP_WINANSI );
+
+ if ( pszANSIString )
+ HeapFree( GetProcessHeap(), 0, pszANSIString );
+
+ return hszResult;
+}
+
+//------------------------------------------------------------------------
+
+DWORD WINAPI DdeQueryStringW_9x( DWORD idInst, HSZ hsz, LPWSTR pszString, DWORD cchMax, int )
+{
+ DWORD dwResult;
+ LPSTR pszANSIString;
+
+ pszANSIString = cchMax ? (LPSTR)HeapAlloc( GetProcessHeap(), 0, cchMax * sizeof(CHAR) ) : NULL;
+
+ dwResult = DdeQueryStringA( idInst, hsz, pszANSIString, cchMax, CP_WINANSI );
+
+ if ( dwResult && pszANSIString )
+ MultiByteToWideChar( CP_ACP, 0, pszANSIString, -1, pszString, cchMax );
+
+ if ( pszANSIString )
+ HeapFree( GetProcessHeap(), 0, pszANSIString );
+
+ return dwResult;
+}
+
+//------------------------------------------------------------------------
+
+UINT WINAPI DdeInitializeW_9x( LPDWORD pidInst, PFNCALLBACK pfnCallback, DWORD afCmd, DWORD ulRes )
+{
+ return DdeInitializeA( pidInst, pfnCallback, afCmd, ulRes );
+}
+
+//------------------------------------------------------------------------
+
+#define DEFINE_WAPI_FUNC(func) \
+func##_PROC lpfn##func = (LONG)GetVersion() >= 0 ? func : func##_9x;
+
+
+DEFINE_WAPI_FUNC( DdeCreateStringHandleW );
+DEFINE_WAPI_FUNC( DdeQueryStringW );
+DEFINE_WAPI_FUNC( DdeInitializeW );
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/syslocale/makefile.mk b/binfilter/bf_svtools/source/syslocale/makefile.mk
new file mode 100644
index 000000000000..1ecafd22262a
--- /dev/null
+++ b/binfilter/bf_svtools/source/syslocale/makefile.mk
@@ -0,0 +1,44 @@
+#*************************************************************************
+#
+# DO NOT ALTER 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=binfilter
+TARGET=syslocale
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/svt_syslocale.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/binfilter/bf_svtools/source/syslocale/svt_syslocale.cxx b/binfilter/bf_svtools/source/syslocale/svt_syslocale.cxx
new file mode 100644
index 000000000000..c0a96138f976
--- /dev/null
+++ b/binfilter/bf_svtools/source/syslocale/svt_syslocale.cxx
@@ -0,0 +1,170 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/syslocale.hxx>
+
+#include <broadcast.hxx>
+#include <listener.hxx>
+#include <bf_svtools/smplhint.hxx>
+#include <vcl/svapp.hxx>
+#include <tools/string.hxx>
+#include <bf_svtools/syslocaleoptions.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <comphelper/processfactory.hxx>
+
+
+using namespace osl;
+using namespace com::sun::star;
+
+namespace binfilter
+{
+
+
+SvtSysLocale_Impl* SvtSysLocale::pImpl = NULL;
+sal_Int32 SvtSysLocale::nRefCount = 0;
+
+
+class SvtSysLocale_Impl : public SvtListener
+{
+ friend class SvtSysLocale;
+
+ SvtSysLocaleOptions aSysLocaleOptions;
+ LocaleDataWrapper* pLocaleData;
+ CharClass* pCharClass;
+
+public:
+ SvtSysLocale_Impl();
+ virtual ~SvtSysLocale_Impl();
+
+ virtual void Notify( SvtBroadcaster& rBC, const SfxHint& rHint );
+
+};
+
+
+// -----------------------------------------------------------------------
+
+SvtSysLocale_Impl::SvtSysLocale_Impl()
+{
+ const lang::Locale& rLocale = Application::GetSettings().GetLocale();
+ pLocaleData = new LocaleDataWrapper(
+ ::comphelper::getProcessServiceFactory(), rLocale );
+ pCharClass = new CharClass(
+ ::comphelper::getProcessServiceFactory(), rLocale );
+ aSysLocaleOptions.AddListener( *this );
+}
+
+
+SvtSysLocale_Impl::~SvtSysLocale_Impl()
+{
+ aSysLocaleOptions.RemoveListener( *this );
+ delete pCharClass;
+ delete pLocaleData;
+}
+
+
+void SvtSysLocale_Impl::Notify( SvtBroadcaster&, const SfxHint& rHint )
+{
+ const SfxSimpleHint* p = PTR_CAST( SfxSimpleHint, &rHint );
+ if( p && (p->GetId() & SYSLOCALEOPTIONS_HINT_LOCALE) )
+ {
+ MutexGuard aGuard( SvtSysLocale::GetMutex() );
+ const lang::Locale& rLocale = Application::GetSettings().GetLocale();
+ pLocaleData->setLocale( rLocale );
+ pCharClass->setLocale( rLocale );
+ }
+}
+
+
+// ====================================================================
+
+SvtSysLocale::SvtSysLocale()
+{
+ MutexGuard aGuard( GetMutex() );
+ if ( !pImpl )
+ pImpl = new SvtSysLocale_Impl;
+ ++nRefCount;
+}
+
+
+SvtSysLocale::~SvtSysLocale()
+{
+ MutexGuard aGuard( GetMutex() );
+ if ( !--nRefCount )
+ {
+ delete pImpl;
+ pImpl = NULL;
+ }
+}
+
+
+// static
+Mutex& SvtSysLocale::GetMutex()
+{
+ static Mutex* pMutex = NULL;
+ if( !pMutex )
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if( !pMutex )
+ {
+ // #i77768# Due to a static reference in the toolkit lib
+ // we need a mutex that lives longer than the svtools library.
+ // Otherwise the dtor would use a destructed mutex!!
+ pMutex = new Mutex;
+ }
+ }
+ return *pMutex;
+}
+
+
+const LocaleDataWrapper& SvtSysLocale::GetLocaleData() const
+{
+ return *(pImpl->pLocaleData);
+}
+
+
+const LocaleDataWrapper* SvtSysLocale::GetLocaleDataPtr() const
+{
+ return pImpl->pLocaleData;
+}
+
+
+const CharClass& SvtSysLocale::GetCharClass() const
+{
+ return *(pImpl->pCharClass);
+}
+
+
+const CharClass* SvtSysLocale::GetCharClassPtr() const
+{
+ return pImpl->pCharClass;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/undo/makefile.mk b/binfilter/bf_svtools/source/undo/makefile.mk
new file mode 100644
index 000000000000..7ebd895b47d1
--- /dev/null
+++ b/binfilter/bf_svtools/source/undo/makefile.mk
@@ -0,0 +1,46 @@
+#*************************************************************************
+#
+# DO NOT ALTER 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=binfilter
+TARGET=undo
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/svt_undo.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/binfilter/bf_svtools/source/undo/svt_undo.cxx b/binfilter/bf_svtools/source/undo/svt_undo.cxx
new file mode 100644
index 000000000000..4a3590bf4206
--- /dev/null
+++ b/binfilter/bf_svtools/source/undo/svt_undo.cxx
@@ -0,0 +1,611 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <bf_svtools/undo.hxx>
+
+namespace binfilter
+{
+
+TYPEINIT0(SfxUndoAction);
+TYPEINIT0(SfxListUndoAction);
+TYPEINIT0(SfxLinkUndoAction);
+TYPEINIT0(SfxRepeatTarget);
+
+SfxRepeatTarget::~SfxRepeatTarget()
+{
+}
+
+BOOL SfxUndoAction::IsLinked()
+{
+ return bLinked;
+}
+
+void SfxUndoAction::SetLinked( BOOL bIsLinked )
+{
+ bLinked = bIsLinked;
+}
+
+SfxUndoAction::~SfxUndoAction()
+{
+}
+
+SfxUndoAction::SfxUndoAction()
+{
+ SetLinked( FALSE );
+}
+
+BOOL SfxUndoAction::Merge( SfxUndoAction * )
+{
+ return FALSE;
+}
+
+XubString SfxUndoAction::GetComment() const
+{
+ return XubString();
+}
+
+USHORT SfxUndoAction::GetId() const
+{
+ return 0;
+}
+
+XubString SfxUndoAction::GetRepeatComment(SfxRepeatTarget&) const
+{
+ return GetComment();
+}
+
+void SfxUndoAction::Undo()
+{
+}
+
+void SfxUndoAction::Redo()
+{
+}
+
+void SfxUndoAction::Repeat(SfxRepeatTarget&)
+{
+}
+
+BOOL SfxUndoAction::CanRepeat(SfxRepeatTarget&) const
+{
+ return TRUE;
+}
+
+SfxUndoManager::SfxUndoManager( USHORT nMaxUndoActionCount ) : pFatherUndoArray(0)
+{
+ pUndoArray=new SfxUndoArray(nMaxUndoActionCount);
+ pActUndoArray=pUndoArray;
+
+}
+
+SfxUndoManager::~SfxUndoManager()
+{
+ delete pUndoArray;
+}
+
+void SfxUndoManager::SetMaxUndoActionCount( USHORT nMaxUndoActionCount )
+{
+ // Remove entries from the pActUndoArray when we have to reduce
+ // the number of entries due to a lower nMaxUndoActionCount.
+ // Both redo and undo action entries will be removed until we reached the
+ // new nMaxUndoActionCount.
+
+ long nNumToDelete = pActUndoArray->aUndoActions.Count() - nMaxUndoActionCount;
+ if ( nNumToDelete > 0 )
+ {
+ while ( nNumToDelete > 0 )
+ {
+ USHORT nPos = pActUndoArray->aUndoActions.Count();
+ if ( nPos > pActUndoArray->nCurUndoAction )
+ {
+ if ( !pActUndoArray->aUndoActions[nPos-1]->IsLinked() )
+ {
+ delete pActUndoArray->aUndoActions[nPos-1];
+ pActUndoArray->aUndoActions.Remove( nPos-1 );
+ --nNumToDelete;
+ }
+ }
+
+ if ( nNumToDelete > 0 && pActUndoArray->nCurUndoAction > 0 )
+ {
+ if ( !pActUndoArray->aUndoActions[0]->IsLinked() )
+ {
+ delete pActUndoArray->aUndoActions[0];
+ pActUndoArray->aUndoActions.Remove(0);
+ --pActUndoArray->nCurUndoAction;
+ --nNumToDelete;
+ }
+ }
+
+ if ( nPos == pActUndoArray->aUndoActions.Count() )
+ break; // Cannot delete more entries
+ }
+ }
+
+ pActUndoArray->nMaxUndoActions = nMaxUndoActionCount;
+}
+
+//------------------------------------------------------------------------
+
+USHORT SfxUndoManager::GetMaxUndoActionCount() const
+{
+ return pActUndoArray->nMaxUndoActions;
+}
+
+//------------------------------------------------------------------------
+
+void SfxUndoManager::Clear()
+{
+ while ( pActUndoArray->aUndoActions.Count() )
+ {
+ SfxUndoAction *pAction=
+ pActUndoArray->aUndoActions[pActUndoArray->aUndoActions.Count() - 1];
+ pActUndoArray->aUndoActions.Remove( pActUndoArray->aUndoActions.Count() - 1 );
+ delete pAction;
+ }
+
+ pActUndoArray->nCurUndoAction = 0;
+}
+
+//------------------------------------------------------------------------
+
+void SfxUndoManager::ClearRedo()
+{
+ while ( pActUndoArray->aUndoActions.Count() > pActUndoArray->nCurUndoAction )
+ {
+ SfxUndoAction *pAction=
+ pActUndoArray->aUndoActions[pActUndoArray->aUndoActions.Count() - 1];
+ pActUndoArray->aUndoActions.Remove( pActUndoArray->aUndoActions.Count() - 1 );
+ delete pAction;
+ }
+}
+
+//------------------------------------------------------------------------
+
+void SfxUndoManager::AddUndoAction( SfxUndoAction *pAction, BOOL bTryMerge )
+{
+ // Redo-Actions loeschen
+ for ( USHORT nPos = pActUndoArray->aUndoActions.Count();
+ nPos > pActUndoArray->nCurUndoAction; --nPos )
+ delete pActUndoArray->aUndoActions[nPos-1];
+
+ pActUndoArray->aUndoActions.Remove(
+ pActUndoArray->nCurUndoAction,
+ pActUndoArray->aUndoActions.Count() - pActUndoArray->nCurUndoAction );
+
+ if ( pActUndoArray->nMaxUndoActions )
+ {
+ SfxUndoAction *pTmpAction = pActUndoArray->nCurUndoAction ?
+ pActUndoArray->aUndoActions[pActUndoArray->nCurUndoAction-1] : 0;
+
+ if ( !bTryMerge || !(pTmpAction && pTmpAction->Merge(pAction)) )
+ {
+ // auf Max-Anzahl anpassen
+ if( pActUndoArray == pUndoArray )
+ while( pActUndoArray->aUndoActions.Count() >=
+ pActUndoArray->nMaxUndoActions &&
+ !pActUndoArray->aUndoActions[0]->IsLinked() )
+ {
+ delete pActUndoArray->aUndoActions[0];
+ pActUndoArray->aUndoActions.Remove(0);
+ --pActUndoArray->nCurUndoAction;
+ }
+
+ // neue Action anh"angen
+ const SfxUndoAction* pTemp = pAction;
+ pActUndoArray->aUndoActions.Insert(
+ pTemp, pActUndoArray->nCurUndoAction++ );
+ return;
+ }
+ }
+
+ delete pAction;
+}
+
+//------------------------------------------------------------------------
+
+USHORT SfxUndoManager::GetUndoActionCount() const
+{
+ return pActUndoArray->nCurUndoAction;
+}
+
+//------------------------------------------------------------------------
+
+XubString SfxUndoManager::GetUndoActionComment( USHORT nNo ) const
+{
+ if( nNo < pActUndoArray->nCurUndoAction )
+ {
+ return pActUndoArray->aUndoActions[pActUndoArray->nCurUndoAction-1-nNo]->GetComment(); //!
+ }
+ else
+ {
+ XubString aEmpty;
+ return aEmpty;
+ }
+}
+
+//------------------------------------------------------------------------
+
+USHORT SfxUndoManager::GetUndoActionId( USHORT nNo ) const
+{
+ if( nNo < pActUndoArray->nCurUndoAction )
+ {
+ return pActUndoArray->aUndoActions[pActUndoArray->nCurUndoAction-1-nNo]->GetId(); //!
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+//------------------------------------------------------------------------
+
+BOOL SfxUndoManager::Undo( USHORT )
+{
+ if ( pActUndoArray->nCurUndoAction )
+ {
+ Undo( *pActUndoArray->aUndoActions[ --pActUndoArray->nCurUndoAction ] );
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//------------------------------------------------------------------------
+
+void SfxUndoManager::Undo( SfxUndoAction &rAction )
+{
+ rAction.Undo();
+}
+
+//------------------------------------------------------------------------
+
+USHORT SfxUndoManager::GetRedoActionCount() const
+{
+ return pActUndoArray->aUndoActions.Count() - pActUndoArray->nCurUndoAction; //!
+}
+
+//------------------------------------------------------------------------
+
+XubString SfxUndoManager::GetRedoActionComment( USHORT nNo ) const
+{
+ return pActUndoArray->aUndoActions[pActUndoArray->nCurUndoAction+nNo]->GetComment(); //!
+}
+
+//------------------------------------------------------------------------
+
+USHORT SfxUndoManager::GetRedoActionId( USHORT nNo ) const
+{
+ return pActUndoArray->aUndoActions[pActUndoArray->nCurUndoAction+nNo]->GetId(); //!
+}
+
+//------------------------------------------------------------------------
+
+BOOL SfxUndoManager::Redo( USHORT )
+{
+ if ( pActUndoArray->aUndoActions.Count() > pActUndoArray->nCurUndoAction )
+ {
+ Redo( *pActUndoArray->aUndoActions[pActUndoArray->nCurUndoAction++] );
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+//------------------------------------------------------------------------
+
+void SfxUndoManager::Redo( SfxUndoAction &rAction )
+{
+ rAction.Redo();
+}
+
+//------------------------------------------------------------------------
+
+USHORT SfxUndoManager::GetRepeatActionCount() const
+{
+ return pActUndoArray->aUndoActions.Count();
+}
+
+//------------------------------------------------------------------------
+
+XubString SfxUndoManager::GetRepeatActionComment( SfxRepeatTarget &rTarget, USHORT nNo ) const
+{
+ return pActUndoArray->aUndoActions[ pActUndoArray->aUndoActions.Count() - 1 - nNo ]
+ ->GetRepeatComment(rTarget);
+}
+
+//------------------------------------------------------------------------
+
+BOOL SfxUndoManager::Repeat( SfxRepeatTarget &rTarget, USHORT, USHORT )
+{
+ if ( pActUndoArray->aUndoActions.Count() )
+ {
+ Repeat( rTarget, *pActUndoArray->aUndoActions[ pActUndoArray->aUndoActions.Count() - 1 ] );
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+//------------------------------------------------------------------------
+
+void SfxUndoManager::Repeat( SfxRepeatTarget &rTarget, SfxUndoAction &rAction )
+{
+ if ( rAction.CanRepeat(rTarget) )
+ rAction.Repeat(rTarget);
+}
+
+//------------------------------------------------------------------------
+
+BOOL SfxUndoManager::CanRepeat( SfxRepeatTarget &rTarget, SfxUndoAction &rAction ) const
+{
+ return rAction.CanRepeat(rTarget);
+}
+
+//------------------------------------------------------------------------
+
+BOOL SfxUndoManager::CanRepeat( SfxRepeatTarget &rTarget, USHORT nNo ) const
+{
+ if ( pActUndoArray->aUndoActions.Count() > nNo )
+ {
+ USHORT nActionNo = pActUndoArray->aUndoActions.Count() - 1 - nNo;
+ return pActUndoArray->aUndoActions[nActionNo]->CanRepeat(rTarget);
+ }
+
+ return FALSE;
+}
+
+//------------------------------------------------------------------------
+
+void SfxUndoManager::EnterListAction(const XubString& rComment, const XubString &rRepeatComment, USHORT nId )
+{
+ if ( !pUndoArray->nMaxUndoActions )
+ return;
+
+ pFatherUndoArray=pActUndoArray;
+ SfxListUndoAction *pAction=new SfxListUndoAction(
+ rComment, rRepeatComment, nId, pActUndoArray);
+ AddUndoAction( pAction );
+ pActUndoArray=pAction;
+}
+
+//------------------------------------------------------------------------
+
+void SfxUndoManager::LeaveListAction()
+{
+ if ( !pUndoArray->nMaxUndoActions )
+ return;
+
+ if( pActUndoArray == pUndoArray )
+ {
+ return;
+ }
+
+ SfxUndoArray* pTmp=pActUndoArray;
+ pActUndoArray=pActUndoArray->pFatherUndoArray;
+
+ // If no undo action where added, delete the undo list action
+ SfxUndoAction *pTmpAction= pActUndoArray->aUndoActions[pActUndoArray->nCurUndoAction-1];
+ if(!pTmp->nCurUndoAction)
+ {
+ pActUndoArray->aUndoActions.Remove( --pActUndoArray->nCurUndoAction);
+ delete pTmpAction;
+ }
+ else
+ {
+ // if the undo array has no comment, try to get it from its children
+ SfxListUndoAction* pList = dynamic_cast< SfxListUndoAction * >( pTmpAction );
+ if( pList && pList->GetComment().Len() == 0 )
+ {
+ USHORT n;
+ for( n = 0; n < pList->aUndoActions.Count(); n++ )
+ {
+ if( pList->aUndoActions[n]->GetComment().Len() )
+ {
+ pList->SetComment( pList->aUndoActions[n]->GetComment() );
+ break;
+ }
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+USHORT SfxListUndoAction::GetId() const
+{
+ return nId;
+}
+
+//------------------------------------------------------------------------
+
+XubString SfxListUndoAction::GetComment() const
+{
+ return aComment;
+}
+
+//------------------------------------------------------------------------
+
+void SfxListUndoAction::SetComment( const UniString& rComment )
+{
+ aComment = rComment;
+}
+
+//------------------------------------------------------------------------
+
+XubString SfxListUndoAction::GetRepeatComment(SfxRepeatTarget &) const
+{
+ return aRepeatComment;
+}
+
+
+//------------------------------------------------------------------------
+
+SfxListUndoAction::SfxListUndoAction
+(
+ const XubString &rComment,
+ const XubString rRepeatComment,
+ USHORT Id,
+ SfxUndoArray *pFather
+)
+: nId(Id), aComment(rComment), aRepeatComment(rRepeatComment)
+{
+ pFatherUndoArray = pFather;
+ nMaxUndoActions = USHRT_MAX;
+}
+
+//------------------------------------------------------------------------
+
+void SfxListUndoAction::Undo()
+{
+ for(INT16 i=nCurUndoAction-1;i>=0;i--)
+ aUndoActions[i]->Undo();
+ nCurUndoAction=0;
+}
+
+//------------------------------------------------------------------------
+
+void SfxListUndoAction::Redo()
+{
+ for(USHORT i=nCurUndoAction;i<aUndoActions.Count();i++)
+ aUndoActions[i]->Redo();
+ nCurUndoAction = aUndoActions.Count();
+}
+
+//------------------------------------------------------------------------
+
+void SfxListUndoAction::Repeat(SfxRepeatTarget&rTarget)
+{
+ for(USHORT i=0;i<nCurUndoAction;i++)
+ aUndoActions[i]->Repeat(rTarget);
+}
+
+//------------------------------------------------------------------------
+
+BOOL SfxListUndoAction::CanRepeat(SfxRepeatTarget&r) const
+{
+ for(USHORT i=0;i<nCurUndoAction;i++)
+ if(!aUndoActions[i]->CanRepeat(r))
+ return FALSE;
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+
+BOOL SfxListUndoAction::Merge( SfxUndoAction *pNextAction )
+{
+ return aUndoActions.Count() && aUndoActions[aUndoActions.Count()-1]->Merge( pNextAction );
+}
+
+//------------------------------------------------------------------------
+
+void SfxLinkUndoAction::Undo()
+{
+ if ( pAction )
+ pUndoManager->Undo(1);
+}
+
+//------------------------------------------------------------------------
+
+void SfxLinkUndoAction::Redo()
+{
+ if ( pAction )
+ pUndoManager->Redo(1);
+}
+
+//------------------------------------------------------------------------
+
+
+BOOL SfxLinkUndoAction::CanRepeat(SfxRepeatTarget& r) const
+{
+ return pAction && pUndoManager->CanRepeat(r,*pAction);
+}
+
+
+//------------------------------------------------------------------------
+
+
+void SfxLinkUndoAction::Repeat(SfxRepeatTarget&r)
+{
+ if ( pAction )
+ pUndoManager->Repeat(r,*pAction);
+}
+
+
+//------------------------------------------------------------------------
+
+XubString SfxLinkUndoAction::GetComment() const
+{
+ if ( pAction )
+ return pAction->GetComment();
+ else
+ return XubString();
+}
+
+
+//------------------------------------------------------------------------
+
+XubString SfxLinkUndoAction::GetRepeatComment(SfxRepeatTarget&r) const
+{
+ if ( pAction )
+ return pAction->GetRepeatComment(r);
+ else
+ return XubString();
+}
+
+//------------------------------------------------------------------------
+
+SfxLinkUndoAction::~SfxLinkUndoAction()
+{
+ if( pAction )
+ pAction->SetLinked( FALSE );
+}
+
+
+//------------------------------------------------------------------------
+
+SfxUndoArray::~SfxUndoArray()
+{
+ while ( aUndoActions.Count() )
+ {
+ SfxUndoAction *pAction =
+ aUndoActions[ aUndoActions.Count() - 1 ];
+ aUndoActions.Remove( aUndoActions.Count() - 1 );
+ delete pAction;
+ }
+}
+
+
+USHORT SfxLinkUndoAction::GetId() const
+{
+ return pAction ? pAction->GetId() : 0;
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/uno/makefile.mk b/binfilter/bf_svtools/source/uno/makefile.mk
new file mode 100644
index 000000000000..bea43c2dee2e
--- /dev/null
+++ b/binfilter/bf_svtools/source/uno/makefile.mk
@@ -0,0 +1,48 @@
+
+#
+# DO NOT ALTER 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=binfilter
+TARGET=unoiface
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/svt_unoevent.obj \
+ $(SLO)$/svt_unoimap.obj \
+ $(SLO)$/svt_registerservices.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/binfilter/bf_svtools/source/uno/svt_registerservices.cxx b/binfilter/bf_svtools/source/uno/svt_registerservices.cxx
new file mode 100644
index 000000000000..6e6989cc393b
--- /dev/null
+++ b/binfilter/bf_svtools/source/uno/svt_registerservices.cxx
@@ -0,0 +1,143 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 "sal/types.h"
+
+#include "rtl/ustring.hxx"
+
+#include <cppuhelper/factory.hxx>
+
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+namespace css = com::sun::star;
+using css::uno::Reference;
+using css::uno::Sequence;
+using rtl::OUString;
+
+// -------------------------------------------------------------------------------------
+
+namespace binfilter
+{
+
+#define DECLARE_CREATEINSTANCE( ImplName ) \
+ Reference< css::uno::XInterface > SAL_CALL ImplName##_CreateInstance( const Reference< css::lang::XMultiServiceFactory >& );
+
+DECLARE_CREATEINSTANCE( SvNumberFormatterServiceObj )
+DECLARE_CREATEINSTANCE( SvNumberFormatsSupplierServiceObject )
+
+}
+
+// -------------------------------------------------------------------------------------
+
+extern "C"
+{
+
+SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment (
+ const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */)
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo (
+ void * /* _pServiceManager */, void * _pRegistryKey)
+{
+ if (_pRegistryKey)
+ {
+ Reference< css::registry::XRegistryKey > xRegistryKey (
+ reinterpret_cast< css::registry::XRegistryKey* >(_pRegistryKey));
+ Reference< css::registry::XRegistryKey > xNewKey;
+
+ xNewKey = xRegistryKey->createKey (
+ OUString::createFromAscii(
+ "/com.sun.star.uno.util.numbers.SvNumberFormatsSupplierServiceObject/UNO/SERVICES" ) );
+ xNewKey->createKey (
+ OUString::createFromAscii( "com.sun.star.util.NumberFormatsSupplier" ) );
+
+ xNewKey = xRegistryKey->createKey (
+ OUString::createFromAscii(
+ "/com.sun.star.uno.util.numbers.SvNumberFormatterServiceObject/UNO/SERVICES" ) );
+ xNewKey->createKey (
+ OUString::createFromAscii( "com.sun.star.util.NumberFormatter" ) );
+
+ return sal_True;
+ }
+ return sal_False;
+}
+
+SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory (
+ const sal_Char * pImplementationName, void * _pServiceManager, void * /* _pRegistryKey*/)
+{
+ void * pResult = 0;
+ if ( _pServiceManager )
+ {
+ Reference< css::lang::XSingleServiceFactory > xFactory;
+ if (rtl_str_compare(
+ pImplementationName,
+ "com.sun.star.uno.util.numbers.SvNumberFormatsSupplierServiceObject") == 0)
+ {
+ Sequence< OUString > aServiceNames(1);
+ aServiceNames.getArray()[0] =
+ OUString::createFromAscii( "com.sun.star.util.NumberFormatsSupplier" );
+
+ xFactory = ::cppu::createSingleFactory(
+ reinterpret_cast< css::lang::XMultiServiceFactory* >(_pServiceManager),
+ OUString::createFromAscii( pImplementationName ),
+ ::binfilter::SvNumberFormatsSupplierServiceObject_CreateInstance,
+ aServiceNames);
+ }
+ else if (rtl_str_compare(
+ pImplementationName,
+ "com.sun.star.uno.util.numbers.SvNumberFormatterServiceObject") == 0)
+ {
+ Sequence< OUString > aServiceNames(1);
+ aServiceNames.getArray()[0] =
+ OUString::createFromAscii( "com.sun.star.util.NumberFormatter" );
+
+ xFactory = ::cppu::createSingleFactory(
+ reinterpret_cast< css::lang::XMultiServiceFactory* >(_pServiceManager),
+ OUString::createFromAscii( pImplementationName ),
+ ::binfilter::SvNumberFormatterServiceObj_CreateInstance,
+ aServiceNames);
+ }
+ if ( xFactory.is() )
+ {
+ xFactory->acquire();
+ pResult = xFactory.get();
+ }
+ }
+ return pResult;
+}
+
+} // "C"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/uno/svt_unoevent.cxx b/binfilter/bf_svtools/source/uno/svt_unoevent.cxx
new file mode 100644
index 000000000000..167b7e1baa6e
--- /dev/null
+++ b/binfilter/bf_svtools/source/uno/svt_unoevent.cxx
@@ -0,0 +1,595 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <tools/table.hxx>
+#include <tools/string.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <rtl/ustrbuf.hxx>
+#include <tools/rtti.hxx>
+#include <tools/solar.h>
+#include "unoevent.hxx"
+#include <bf_svtools/macitem.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+using ::com::sun::star::container::NoSuchElementException;
+using ::com::sun::star::container::XNameReplace;
+using ::com::sun::star::lang::IllegalArgumentException;
+using ::com::sun::star::lang::WrappedTargetException;
+using ::com::sun::star::lang::XServiceInfo;
+using ::com::sun::star::beans::PropertyValue;
+using ::cppu::WeakImplHelper2;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+namespace binfilter
+{
+
+const sal_Char sAPI_ServiceName[] = "com.sun.star.container.XNameReplace";
+const sal_Char sAPI_SvDetachedEventDescriptor[] = "SvDetachedEventDescriptor";
+
+//
+// SvBaseEventDescriptor
+//
+
+SvBaseEventDescriptor::SvBaseEventDescriptor( const SvEventDescription* pSupportedMacroItems ) :
+ sEventType(RTL_CONSTASCII_USTRINGPARAM("EventType")),
+ sMacroName(RTL_CONSTASCII_USTRINGPARAM("MacroName")),
+ sLibrary(RTL_CONSTASCII_USTRINGPARAM("Library")),
+ sStarBasic(RTL_CONSTASCII_USTRINGPARAM("StarBasic")),
+ sJavaScript(RTL_CONSTASCII_USTRINGPARAM("JavaScript")),
+ sScript(RTL_CONSTASCII_USTRINGPARAM("Script")),
+ sNone(RTL_CONSTASCII_USTRINGPARAM("None")),
+ sServiceName(RTL_CONSTASCII_USTRINGPARAM(sAPI_ServiceName)),
+ sEmpty(),
+ mpSupportedMacroItems(pSupportedMacroItems),
+ mnMacroItems(0)
+{
+ DBG_ASSERT(pSupportedMacroItems != NULL, "Need a list of supported events!");
+
+ for( ; mpSupportedMacroItems[mnMacroItems].mnEvent != 0; mnMacroItems++) ;
+}
+
+
+SvBaseEventDescriptor::~SvBaseEventDescriptor()
+{
+}
+
+void SvBaseEventDescriptor::replaceByName(
+ const OUString& rName,
+ const Any& rElement )
+ throw(
+ IllegalArgumentException,
+ NoSuchElementException,
+ WrappedTargetException,
+ RuntimeException)
+{
+ sal_uInt16 nMacroID = getMacroID(rName);
+
+ // error checking
+ if (0 == nMacroID)
+ throw NoSuchElementException();
+ if (rElement.getValueType() != getElementType())
+ throw IllegalArgumentException();
+
+ // get sequence
+ Sequence<PropertyValue> aSequence;
+ rElement >>= aSequence;
+
+ // perform replace (in subclass)
+ SvxMacro aMacro(sEmpty,sEmpty);
+ getMacroFromAny(aMacro, rElement);
+ replaceByName(nMacroID, aMacro);
+}
+
+Any SvBaseEventDescriptor::getByName(
+ const OUString& rName )
+ throw(
+ NoSuchElementException,
+ WrappedTargetException,
+ RuntimeException)
+{
+ sal_uInt16 nMacroID = getMacroID(rName);
+
+ // error checking
+ if (0 == nMacroID)
+ throw NoSuchElementException();
+
+ // perform get (in subclass)
+ Any aAny;
+ SvxMacro aMacro( sEmpty, sEmpty );
+ getByName(aMacro, nMacroID);
+ getAnyFromMacro(aAny, aMacro);
+ return aAny;
+}
+
+Sequence<OUString> SvBaseEventDescriptor::getElementNames()
+ throw(RuntimeException)
+{
+ // create and fill sequence
+ Sequence<OUString> aSequence(mnMacroItems);
+ for( sal_Int16 i = 0; i < mnMacroItems; i++)
+ {
+ aSequence[i] = OUString::createFromAscii( mpSupportedMacroItems[i].mpEventName );
+ }
+
+ return aSequence;
+}
+
+sal_Bool SvBaseEventDescriptor::hasByName(
+ const OUString& rName )
+ throw(RuntimeException)
+{
+ sal_uInt16 nMacroID = getMacroID(rName);
+ return (nMacroID != 0);
+}
+
+Type SvBaseEventDescriptor::getElementType()
+ throw(RuntimeException)
+{
+ return ::getCppuType((Sequence<PropertyValue> *)0);
+}
+
+sal_Bool SvBaseEventDescriptor::hasElements()
+ throw(RuntimeException)
+{
+ return mnMacroItems != 0;
+}
+
+sal_Bool SvBaseEventDescriptor::supportsService(const OUString& rServiceName)
+ throw(RuntimeException)
+{
+ return sServiceName.equals(rServiceName);
+}
+
+Sequence<OUString> SvBaseEventDescriptor::getSupportedServiceNames(void)
+ throw(RuntimeException)
+{
+ Sequence<OUString> aSequence(1);
+ aSequence[0] = sServiceName;
+
+ return aSequence;
+}
+
+sal_uInt16 SvBaseEventDescriptor::mapNameToEventID(const OUString& rName) const
+{
+ // iterate over known event names
+ for(sal_Int16 i = 0; i < mnMacroItems; i++)
+ {
+ if (0 == rName.compareToAscii(mpSupportedMacroItems[i].mpEventName))
+ {
+ return mpSupportedMacroItems[i].mnEvent;
+ }
+ }
+
+ // not found -> return zero
+ return 0;
+}
+
+sal_uInt16 SvBaseEventDescriptor::getMacroID(const OUString& rName) const
+{
+ return mapNameToEventID(rName);
+}
+
+void SvBaseEventDescriptor::getAnyFromMacro(Any& rAny,
+ const SvxMacro& rMacro)
+{
+ sal_Bool bRetValueOK = sal_False; // do we have a ret value?
+
+ if (rMacro.HasMacro())
+ {
+ switch (rMacro.GetScriptType())
+ {
+ case STARBASIC:
+ {
+ // create sequence
+ Sequence<PropertyValue> aSequence(3);
+ Any aTmp;
+
+ // create type
+ PropertyValue aTypeValue;
+ aTypeValue.Name = sEventType;
+ aTmp <<= sStarBasic;
+ aTypeValue.Value = aTmp;
+ aSequence[0] = aTypeValue;
+
+ // macro name
+ PropertyValue aNameValue;
+ aNameValue.Name = sMacroName;
+ OUString sNameTmp(rMacro.GetMacName());
+ aTmp <<= sNameTmp;
+ aNameValue.Value = aTmp;
+ aSequence[1] = aNameValue;
+
+ // library name
+ PropertyValue aLibValue;
+ aLibValue.Name = sLibrary;
+ OUString sLibTmp(rMacro.GetLibName());
+ aTmp <<= sLibTmp;
+ aLibValue.Value = aTmp;
+ aSequence[2] = aLibValue;
+
+ rAny <<= aSequence;
+ bRetValueOK = sal_True;
+ break;
+ }
+ case EXTENDED_STYPE:
+ {
+ // create sequence
+ Sequence<PropertyValue> aSequence(2);
+ Any aTmp;
+
+ // create type
+ PropertyValue aTypeValue;
+ aTypeValue.Name = sEventType;
+ aTmp <<= sScript;
+ aTypeValue.Value = aTmp;
+ aSequence[0] = aTypeValue;
+
+ // macro name
+ PropertyValue aNameValue;
+ aNameValue.Name = sScript;
+ OUString sNameTmp(rMacro.GetMacName());
+ aTmp <<= sNameTmp;
+ aNameValue.Value = aTmp;
+ aSequence[1] = aNameValue;
+
+ rAny <<= aSequence;
+ bRetValueOK = sal_True;
+ break;
+ }
+ case JAVASCRIPT:
+ default:
+ DBG_ERROR("not implemented");
+ }
+ }
+ // else: bRetValueOK not set
+
+ // if we don't have a return value, make an empty one
+ if (! bRetValueOK)
+ {
+ // create "None" macro
+ Sequence<PropertyValue> aSequence(1);
+
+ PropertyValue aKindValue;
+ aKindValue.Name = sEventType;
+ Any aTmp;
+ aTmp <<= sNone;
+ aKindValue.Value = aTmp;
+ aSequence[0] = aKindValue;
+
+ rAny <<= aSequence;
+ bRetValueOK = sal_True;
+ }
+}
+
+
+void SvBaseEventDescriptor::getMacroFromAny(
+ SvxMacro& rMacro,
+ const Any& rAny)
+ throw ( IllegalArgumentException )
+{
+ // get sequence
+ Sequence<PropertyValue> aSequence;
+ rAny >>= aSequence;
+
+ // process ...
+ sal_Bool bTypeOK = sal_False;
+ sal_Bool bNone = sal_False; // true if EventType=="None"
+ enum ScriptType eType = EXTENDED_STYPE;
+ OUString sScriptVal;
+ OUString sMacroVal;
+ OUString sLibVal;
+ sal_Int32 nCount = aSequence.getLength();
+ for (sal_Int32 i = 0; i < nCount; i++)
+ {
+ PropertyValue& aValue = aSequence[i];
+ if (aValue.Name.equals(sEventType))
+ {
+ OUString sTmp;
+ aValue.Value >>= sTmp;
+ if (sTmp.equals(sStarBasic))
+ {
+ eType = STARBASIC;
+ bTypeOK = sal_True;
+ }
+ else if (sTmp.equals(sJavaScript))
+ {
+ eType = JAVASCRIPT;
+ bTypeOK = sal_True;
+ }
+ else if (sTmp.equals(sScript))
+ {
+ eType = EXTENDED_STYPE;
+ bTypeOK = sal_True;
+ }
+ else if (sTmp.equals(sNone))
+ {
+ bNone = sal_True;
+ bTypeOK = sal_True;
+ }
+ // else: unknown script type
+ }
+ else if (aValue.Name.equals(sMacroName))
+ {
+ aValue.Value >>= sMacroVal;
+ }
+ else if (aValue.Name.equals(sLibrary))
+ {
+ aValue.Value >>= sLibVal;
+ }
+ else if (aValue.Name.equals(sScript))
+ {
+ aValue.Value >>= sScriptVal;
+ }
+ // else: unknown PropertyValue -> ignore
+ }
+
+ if (bTypeOK)
+ {
+ if (bNone)
+ {
+ // return empty macro
+ rMacro = SvxMacro( sEmpty, sEmpty );
+ }
+ else
+ {
+ if (eType == STARBASIC)
+ {
+ // create macro and return
+ SvxMacro aMacro(sMacroVal, sLibVal, eType);
+ rMacro = aMacro;
+ }
+ else if (eType == EXTENDED_STYPE)
+ {
+ SvxMacro aMacro(sScriptVal, sScript);
+ rMacro = aMacro;
+ }
+ else
+ {
+ // we can't process type: abort
+ // TODO: JavaScript macros
+ throw IllegalArgumentException();
+ }
+ }
+ }
+ else
+ {
+ // no valid type: abort
+ throw IllegalArgumentException();
+ }
+}
+
+
+
+
+//
+// SvEventDescriptor
+//
+
+
+SvEventDescriptor::SvEventDescriptor(
+ XInterface& rParent,
+ const SvEventDescription* pSupportedMacroItems) :
+ SvBaseEventDescriptor(pSupportedMacroItems),
+ xParentRef(&rParent)
+{
+}
+
+
+SvEventDescriptor::~SvEventDescriptor()
+{
+ // automatically release xParentRef !
+}
+
+void SvEventDescriptor::replaceByName(
+ const sal_uInt16 nEvent,
+ const SvxMacro& rMacro)
+ throw(
+ IllegalArgumentException,
+ NoSuchElementException,
+ WrappedTargetException,
+ RuntimeException)
+{
+ SvxMacroItem aItem(getMacroItemWhich());
+ aItem.SetMacroTable(getMacroItem().GetMacroTable());
+ aItem.SetMacro(nEvent, rMacro);
+ setMacroItem(aItem);
+}
+
+void SvEventDescriptor::getByName(
+ SvxMacro& rMacro,
+ const sal_uInt16 nEvent )
+ throw(
+ NoSuchElementException,
+ WrappedTargetException,
+ RuntimeException)
+{
+ const SvxMacroItem& rItem = getMacroItem();
+ if( rItem.HasMacro( nEvent ) )
+ rMacro = rItem.GetMacro(nEvent);
+ else
+ {
+ SvxMacro aEmptyMacro(sEmpty, sEmpty);
+ rMacro = aEmptyMacro;
+ }
+}
+
+
+
+
+//
+// SvDetachedEventDescriptor
+//
+
+SvDetachedEventDescriptor::SvDetachedEventDescriptor(
+ const SvEventDescription* pSupportedMacroItems) :
+ SvBaseEventDescriptor(pSupportedMacroItems),
+ sImplName(RTL_CONSTASCII_USTRINGPARAM(sAPI_SvDetachedEventDescriptor))
+{
+ // allocate aMacros
+ aMacros = new SvxMacro*[mnMacroItems];
+
+ // ... and initialize
+ for(sal_Int16 i = 0; i < mnMacroItems; i++)
+ {
+ aMacros[i] = NULL;
+ }
+}
+
+SvDetachedEventDescriptor::~SvDetachedEventDescriptor()
+{
+ // delete contents of aMacros
+ for(sal_Int16 i = 0; i < mnMacroItems; i++)
+ {
+ if (NULL != aMacros[i])
+ delete aMacros[i];
+ }
+
+ delete aMacros;
+}
+
+sal_Int16 SvDetachedEventDescriptor::getIndex(const sal_uInt16 nID)
+{
+ // iterate over supported events
+ sal_Int16 nIndex = 0;
+ while ( (mpSupportedMacroItems[nIndex].mnEvent != nID) &&
+ (mpSupportedMacroItems[nIndex].mnEvent != 0) )
+ {
+ nIndex++;
+ }
+ return (mpSupportedMacroItems[nIndex].mnEvent == nID) ? nIndex : -1;
+}
+
+OUString SvDetachedEventDescriptor::getImplementationName()
+ throw( ::com::sun::star::uno::RuntimeException )
+{
+ return sImplName;
+}
+
+
+void SvDetachedEventDescriptor::replaceByName(
+ const sal_uInt16 nEvent,
+ const SvxMacro& rMacro)
+ throw(
+ IllegalArgumentException,
+ NoSuchElementException,
+ WrappedTargetException,
+ RuntimeException)
+{
+ sal_Int16 nIndex = getIndex(nEvent);
+ if (-1 == nIndex)
+ throw IllegalArgumentException();
+
+ aMacros[nIndex] = new SvxMacro(rMacro.GetMacName(), rMacro.GetLibName(),
+ rMacro.GetScriptType() );
+}
+
+
+void SvDetachedEventDescriptor::getByName(
+ SvxMacro& rMacro,
+ const sal_uInt16 nEvent )
+ throw(
+ NoSuchElementException,
+ WrappedTargetException,
+ RuntimeException)
+{
+ sal_Int16 nIndex = getIndex(nEvent);
+ if (-1 == nIndex )
+ throw NoSuchElementException();
+
+ if( aMacros[nIndex] )
+ rMacro = (*aMacros[nIndex]);
+}
+
+sal_Bool SvDetachedEventDescriptor::hasByName(
+ const sal_uInt16 nEvent ) /// item ID of event
+ throw(IllegalArgumentException)
+{
+ sal_Int16 nIndex = getIndex(nEvent);
+ if (-1 == nIndex)
+ throw IllegalArgumentException();
+
+ return (NULL == aMacros[nIndex]) ? sal_False : aMacros[nIndex]->HasMacro();
+}
+
+
+//
+// SvMacroTableEventDescriptor
+//
+
+SvMacroTableEventDescriptor::SvMacroTableEventDescriptor(const SvEventDescription* pSupportedMacroItems) :
+ SvDetachedEventDescriptor(pSupportedMacroItems)
+{
+}
+
+SvMacroTableEventDescriptor::SvMacroTableEventDescriptor(
+ const SvxMacroTableDtor& rMacroTable,
+ const SvEventDescription* pSupportedMacroItems) :
+ SvDetachedEventDescriptor(pSupportedMacroItems)
+{
+ copyMacrosFromTable(rMacroTable);
+}
+
+SvMacroTableEventDescriptor::~SvMacroTableEventDescriptor()
+{
+}
+
+void SvMacroTableEventDescriptor::copyMacrosFromTable(
+ const SvxMacroTableDtor& rMacroTable)
+{
+ for(sal_Int16 i = 0; mpSupportedMacroItems[i].mnEvent != 0; i++)
+ {
+ const sal_uInt16 nEvent = mpSupportedMacroItems[i].mnEvent;
+ const SvxMacro* pMacro = rMacroTable.Get(nEvent);
+ if (NULL != pMacro)
+ replaceByName(nEvent, *pMacro);
+ }
+
+}
+
+void SvMacroTableEventDescriptor::copyMacrosIntoTable(
+ SvxMacroTableDtor& rMacroTable)
+{
+ for(sal_Int16 i = 0; mpSupportedMacroItems[i].mnEvent != 0; i++)
+ {
+ const sal_uInt16 nEvent = mpSupportedMacroItems[i].mnEvent;
+ if (hasByName(nEvent))
+ {
+ SvxMacro* pMacro = new SvxMacro(sEmpty, sEmpty);
+ getByName(*pMacro, nEvent);
+ rMacroTable.Insert(nEvent, pMacro);
+ }
+ }
+}
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/uno/svt_unoimap.cxx b/binfilter/bf_svtools/source/uno/svt_unoimap.cxx
new file mode 100644
index 000000000000..fd7809569c2d
--- /dev/null
+++ b/binfilter/bf_svtools/source/uno/svt_unoimap.cxx
@@ -0,0 +1,826 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER 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 <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/container/XIndexContainer.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/document/XEventsSupplier.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/drawing/PointSequence.hpp>
+
+#include <comphelper/servicehelper.hxx>
+#include <comphelper/propertysethelper.hxx>
+#include <comphelper/propertysetinfo.hxx>
+
+#include <cppuhelper/weakagg.hxx>
+#include <cppuhelper/implbase3.hxx>
+
+#include <tools/table.hxx>
+#include <list>
+
+#include <rtl/uuid.h>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+
+#include "unoevent.hxx"
+#include "unoimap.hxx"
+#include <bf_svtools/imap.hxx>
+#include <bf_svtools/imapcirc.hxx>
+#include <bf_svtools/imaprect.hxx>
+#include <bf_svtools/imappoly.hxx>
+
+#ifndef SEQTYPE
+ #if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)
+ #define SEQTYPE(x) (new ::com::sun::star::uno::Type( x ))
+ #else
+ #define SEQTYPE(x) &(x)
+ #endif
+#endif
+
+#define MAP_LEN(x) x, sizeof(x)-1
+
+
+using namespace comphelper;
+using namespace cppu;
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::container;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::document;
+using namespace com::sun::star::drawing;
+
+namespace binfilter
+{
+
+const sal_Int32 HANDLE_URL = 1;
+const sal_Int32 HANDLE_DESCRIPTION = 2;
+const sal_Int32 HANDLE_TARGET = 3;
+const sal_Int32 HANDLE_NAME = 4;
+const sal_Int32 HANDLE_ISACTIVE = 5;
+const sal_Int32 HANDLE_POLYGON = 6;
+const sal_Int32 HANDLE_CENTER = 7;
+const sal_Int32 HANDLE_RADIUS = 8;
+const sal_Int32 HANDLE_BOUNDARY = 9;
+const sal_Int32 HANDLE_TITLE = 10;
+
+class SvUnoImageMapObject : public OWeakAggObject,
+ public XEventsSupplier,
+ public XServiceInfo,
+ public PropertySetHelper,
+ public XTypeProvider,
+ public XUnoTunnel
+{
+public:
+ SvUnoImageMapObject( UINT16 nType, const SvEventDescription* pSupportedMacroItems );
+ SvUnoImageMapObject( const IMapObject& rMapObject, const SvEventDescription* pSupportedMacroItems );
+ virtual ~SvUnoImageMapObject() throw();
+
+ UNO3_GETIMPLEMENTATION_DECL( SvUnoImageMapObject )
+
+ IMapObject* createIMapObject() const;
+
+ SvMacroTableEventDescriptor* mpEvents;
+
+ // overiden helpers from PropertySetHelper
+ virtual void _setPropertyValues( const PropertyMapEntry** ppEntries, const Any* pValues ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException );
+ virtual void _getPropertyValues( const PropertyMapEntry** ppEntries, Any* pValue ) throw(UnknownPropertyException, WrappedTargetException );
+
+ // XInterface
+ virtual Any SAL_CALL queryAggregation( const Type & rType ) throw(RuntimeException);
+ virtual Any SAL_CALL queryInterface( const Type & rType ) throw(RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XTypeProvider
+ virtual Sequence< Type > SAL_CALL getTypes( ) throw(RuntimeException);
+ virtual Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(RuntimeException);
+
+ // XEventsSupplier
+ virtual Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw(RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw( RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( RuntimeException );
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw( RuntimeException );
+
+private:
+ static PropertySetInfo* createPropertySetInfo( UINT16 nType );
+
+
+ UINT16 mnType;
+
+ ::rtl::OUString maURL;
+ ::rtl::OUString maAltText;
+ ::rtl::OUString maDesc;
+ ::rtl::OUString maTarget;
+ ::rtl::OUString maName;
+ sal_Bool mbIsActive;
+ awt::Rectangle maBoundary;
+ awt::Point maCenter;
+ sal_Int32 mnRadius;
+ PointSequence maPolygon;
+};
+
+UNO3_GETIMPLEMENTATION_IMPL( SvUnoImageMapObject );
+
+PropertySetInfo* SvUnoImageMapObject::createPropertySetInfo( UINT16 nType )
+{
+ switch( nType )
+ {
+ case IMAP_OBJ_POLYGON:
+ {
+ static PropertyMapEntry aPolygonObj_Impl[] =
+ {
+ { MAP_LEN( "URL" ), HANDLE_URL, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_LEN( "Title" ), HANDLE_TITLE, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_LEN( "Description" ), HANDLE_DESCRIPTION, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_LEN( "Target" ), HANDLE_TARGET, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_LEN( "Name" ), HANDLE_NAME, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_LEN( "IsActive" ), HANDLE_ISACTIVE, &::getBooleanCppuType(), 0, 0 },
+ { MAP_LEN( "Polygon" ), HANDLE_POLYGON, SEQTYPE(::getCppuType((const PointSequence*)0)), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+
+ return new PropertySetInfo( aPolygonObj_Impl );
+ }
+ case IMAP_OBJ_CIRCLE:
+ {
+ static PropertyMapEntry aCircleObj_Impl[] =
+ {
+ { MAP_LEN( "URL" ), HANDLE_URL, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_LEN( "Title" ), HANDLE_TITLE, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_LEN( "Description" ), HANDLE_DESCRIPTION, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_LEN( "Target" ), HANDLE_TARGET, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_LEN( "Name" ), HANDLE_NAME, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_LEN( "IsActive" ), HANDLE_ISACTIVE, &::getBooleanCppuType(), 0, 0 },
+ { MAP_LEN( "Center" ), HANDLE_CENTER, &::getCppuType((const awt::Point*)0), 0, 0 },
+ { MAP_LEN( "Radius" ), HANDLE_RADIUS, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+
+ return new PropertySetInfo( aCircleObj_Impl );
+ }
+ case IMAP_OBJ_RECTANGLE:
+ default:
+ {
+ static PropertyMapEntry aRectangleObj_Impl[] =
+ {
+ { MAP_LEN( "URL" ), HANDLE_URL, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_LEN( "Title" ), HANDLE_TITLE, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_LEN( "Description" ), HANDLE_DESCRIPTION, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_LEN( "Target" ), HANDLE_TARGET, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_LEN( "Name" ), HANDLE_NAME, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_LEN( "IsActive" ), HANDLE_ISACTIVE, &::getBooleanCppuType(), 0, 0 },
+ { MAP_LEN( "Boundary" ), HANDLE_BOUNDARY, &::getCppuType((const awt::Rectangle*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+
+ return new PropertySetInfo( aRectangleObj_Impl );
+ }
+ }
+}
+
+SvUnoImageMapObject::SvUnoImageMapObject( UINT16 nType, const SvEventDescription* pSupportedMacroItems )
+: PropertySetHelper( createPropertySetInfo( nType ) ),
+ mnType( nType )
+{
+ mpEvents = new SvMacroTableEventDescriptor( pSupportedMacroItems );
+ mpEvents->acquire();
+}
+
+SvUnoImageMapObject::SvUnoImageMapObject( const IMapObject& rMapObject, const SvEventDescription* pSupportedMacroItems )
+: PropertySetHelper( createPropertySetInfo( rMapObject.GetType() ) ),
+ mnType( rMapObject.GetType() )
+{
+ maURL = rMapObject.GetURL();
+ maAltText = rMapObject.GetAltText();
+ maDesc = rMapObject.GetDesc();
+ maTarget = rMapObject.GetTarget();
+ maName = rMapObject.GetName();
+ mbIsActive = rMapObject.IsActive();
+
+ switch( mnType )
+ {
+ case IMAP_OBJ_RECTANGLE:
+ {
+ const Rectangle aRect( ((IMapRectangleObject*)&rMapObject)->GetRectangle(sal_False) );
+ maBoundary.X = aRect.Left();
+ maBoundary.Y = aRect.Top();
+ maBoundary.Width = aRect.GetWidth();
+ maBoundary.Height = aRect.GetHeight();
+ }
+ break;
+ case IMAP_OBJ_CIRCLE:
+ {
+ mnRadius = (sal_Int32)((IMapCircleObject*)&rMapObject)->GetRadius(sal_False);
+ const Point aPoint( ((IMapCircleObject*)&rMapObject)->GetCenter(sal_False) );
+
+ maCenter.X = aPoint.X();
+ maCenter.Y = aPoint.Y();
+ }
+ break;
+ case IMAP_OBJ_POLYGON:
+ default:
+ {
+ const Polygon aPoly( ((IMapPolygonObject*)&rMapObject)->GetPolygon(sal_False) );
+
+ const USHORT nCount = aPoly.GetSize();
+ maPolygon.realloc( nCount );
+ awt::Point* pPoints = maPolygon.getArray();
+
+ for( USHORT nPoint = 0; nPoint < nCount; nPoint++ )
+ {
+ const Point& rPoint = aPoly.GetPoint( nPoint );
+ pPoints->X = rPoint.X();
+ pPoints->Y = rPoint.Y();
+
+ pPoints++;
+ }
+ }
+ }
+
+ mpEvents = new SvMacroTableEventDescriptor( rMapObject.GetMacroTable(), pSupportedMacroItems );
+ mpEvents->acquire();
+}
+
+SvUnoImageMapObject::~SvUnoImageMapObject() throw()
+{
+ mpEvents->release();
+}
+
+IMapObject* SvUnoImageMapObject::createIMapObject() const
+{
+ const String aURL( maURL );
+ const String aAltText( maAltText );
+ const String aDesc( maDesc );
+ const String aTarget( maTarget );
+ const String aName( maName );
+
+ IMapObject* pNewIMapObject;
+
+ switch( mnType )
+ {
+ case IMAP_OBJ_RECTANGLE:
+ {
+ const Rectangle aRect( maBoundary.X, maBoundary.Y, maBoundary.X + maBoundary.Width - 1, maBoundary.Y + maBoundary.Height - 1 );
+ pNewIMapObject = new IMapRectangleObject( aRect, aURL, aAltText, aDesc, aTarget, aName, mbIsActive, sal_False );
+ }
+ break;
+
+ case IMAP_OBJ_CIRCLE:
+ {
+ const Point aCenter( maCenter.X, maCenter.Y );
+ pNewIMapObject = new IMapCircleObject( aCenter, mnRadius, aURL, aAltText, aDesc, aTarget, aName, mbIsActive, sal_False );
+ }
+ break;
+
+ case IMAP_OBJ_POLYGON:
+ default:
+ {
+ const sal_uInt16 nCount = (sal_uInt16)maPolygon.getLength();
+
+ Polygon aPoly( nCount );
+ for( sal_uInt16 nPoint = 0; nPoint < nCount; nPoint++ )
+ {
+ Point aPoint( maPolygon[nPoint].X, maPolygon[nPoint].Y );
+ aPoly.SetPoint( aPoint, nPoint );
+ }
+
+ aPoly.Optimize( POLY_OPTIMIZE_CLOSE );
+ pNewIMapObject = new IMapPolygonObject( aPoly, aURL, aAltText, aDesc, aTarget, aName, mbIsActive, sal_False );
+ }
+ break;
+ }
+
+ SvxMacroTableDtor aMacroTable;
+ mpEvents->copyMacrosIntoTable(aMacroTable);
+ pNewIMapObject->SetMacroTable( aMacroTable );
+
+ return pNewIMapObject;
+}
+
+// XInterface
+
+Any SAL_CALL SvUnoImageMapObject::queryInterface( const Type & rType )
+ throw( RuntimeException )
+{
+ return OWeakAggObject::queryInterface( rType );
+}
+
+Any SAL_CALL SvUnoImageMapObject::queryAggregation( const Type & rType )
+ throw(RuntimeException)
+{
+ Any aAny;
+
+ if( rType == ::getCppuType((const Reference< XServiceInfo >*)0) )
+ aAny <<= Reference< XServiceInfo >(this);
+ else if( rType == ::getCppuType((const Reference< XTypeProvider >*)0) )
+ aAny <<= Reference< XTypeProvider >(this);
+ else if( rType == ::getCppuType((const Reference< XPropertySet >*)0) )
+ aAny <<= Reference< XPropertySet >(this);
+ else if( rType == ::getCppuType((const Reference< XEventsSupplier >*)0) )
+ aAny <<= Reference< XEventsSupplier >(this);
+ else if( rType == ::getCppuType((const Reference< XMultiPropertySet >*)0) )
+ aAny <<= Reference< XMultiPropertySet >(this);
+ else if( rType == ::getCppuType((const Reference< XUnoTunnel >*)0) )
+ aAny <<= Reference< XUnoTunnel >(this);
+ else
+ aAny <<= OWeakAggObject::queryAggregation( rType );
+
+ return aAny;
+}
+
+void SAL_CALL SvUnoImageMapObject::acquire() throw()
+{
+ OWeakAggObject::acquire();
+}
+
+void SAL_CALL SvUnoImageMapObject::release() throw()
+{
+ OWeakAggObject::release();
+}
+
+uno::Sequence< uno::Type > SAL_CALL SvUnoImageMapObject::getTypes()
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< uno::Type > aTypes( 7 );
+ uno::Type* pTypes = aTypes.getArray();
+
+ *pTypes++ = ::getCppuType((const uno::Reference< XAggregation>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< XEventsSupplier>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< XServiceInfo>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< XPropertySet>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< XMultiPropertySet>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< XTypeProvider>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< XUnoTunnel>*)0);
+
+ return aTypes;
+}
+
+uno::Sequence< sal_Int8 > SAL_CALL SvUnoImageMapObject::getImplementationId()
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+// XServiceInfo
+
+sal_Bool SAL_CALL SvUnoImageMapObject::supportsService( const ::rtl::OUString& ServiceName ) throw(RuntimeException)
+{
+ const Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() );
+ const ::rtl::OUString * pArray = aSNL.getConstArray();
+
+ const sal_Int32 nCount = aSNL.getLength();
+ for( sal_Int32 i = 0; i < nCount; i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+
+ return sal_False;
+}
+
+Sequence< ::rtl::OUString > SAL_CALL SvUnoImageMapObject::getSupportedServiceNames()
+ throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapObject" ));
+ switch( mnType )
+ {
+ case IMAP_OBJ_POLYGON:
+ default:
+ aSNS.getArray()[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapPolygonObject" ));
+ break;
+ case IMAP_OBJ_RECTANGLE:
+ aSNS.getArray()[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapRectangleObject" ));
+ break;
+ case IMAP_OBJ_CIRCLE:
+ aSNS.getArray()[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapCircleObject" ));
+ break;
+ }
+ return aSNS;
+}
+
+::rtl::OUString SAL_CALL SvUnoImageMapObject::getImplementationName() throw(RuntimeException)
+{
+ switch( mnType )
+ {
+ case IMAP_OBJ_POLYGON:
+ default:
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.svt.ImageMapPolygonObject") );
+ case IMAP_OBJ_CIRCLE:
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.svt.ImageMapCircleObject") );
+ case IMAP_OBJ_RECTANGLE:
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.svt.ImageMapRectangleObject") );
+ }
+}
+
+// overiden helpers from PropertySetHelper
+void SvUnoImageMapObject::_setPropertyValues( const PropertyMapEntry** ppEntries, const Any* pValues )
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ sal_Bool bOk = sal_False;
+
+ while( *ppEntries )
+ {
+ switch( (*ppEntries)->mnHandle )
+ {
+ case HANDLE_URL:
+ bOk = *pValues >>= maURL;
+ break;
+ case HANDLE_TITLE:
+ bOk = *pValues >>= maAltText;
+ break;
+ case HANDLE_DESCRIPTION:
+ bOk = *pValues >>= maDesc;
+ break;
+ case HANDLE_TARGET:
+ bOk = *pValues >>= maTarget;
+ break;
+ case HANDLE_NAME:
+ bOk = *pValues >>= maName;
+ break;
+ case HANDLE_ISACTIVE:
+ bOk = *pValues >>= mbIsActive;
+ break;
+ case HANDLE_BOUNDARY:
+ bOk = *pValues >>= maBoundary;
+ break;
+ case HANDLE_CENTER:
+ bOk = *pValues >>= maCenter;
+ break;
+ case HANDLE_RADIUS:
+ bOk = *pValues >>= mnRadius;
+ break;
+ case HANDLE_POLYGON:
+ bOk = *pValues >>= maPolygon;
+ break;
+ default:
+ DBG_ERROR( "SvUnoImageMapObject::_setPropertyValues: unexpected property handle" );
+ break;
+ }
+
+ if( !bOk )
+ throw IllegalArgumentException();
+
+ ppEntries++;
+ pValues++;
+ }
+}
+
+void SvUnoImageMapObject::_getPropertyValues( const PropertyMapEntry** ppEntries, Any* pValues )
+ throw(UnknownPropertyException, WrappedTargetException )
+{
+ while( *ppEntries )
+ {
+ switch( (*ppEntries)->mnHandle )
+ {
+ case HANDLE_URL:
+ *pValues <<= maURL;
+ break;
+ case HANDLE_TITLE:
+ *pValues <<= maAltText;
+ break;
+ case HANDLE_DESCRIPTION:
+ *pValues <<= maDesc;
+ break;
+ case HANDLE_TARGET:
+ *pValues <<= maTarget;
+ break;
+ case HANDLE_NAME:
+ *pValues <<= maName;
+ break;
+ case HANDLE_ISACTIVE:
+ *pValues <<= mbIsActive;
+ break;
+ case HANDLE_BOUNDARY:
+ *pValues <<= maBoundary;
+ break;
+ case HANDLE_CENTER:
+ *pValues <<= maCenter;
+ break;
+ case HANDLE_RADIUS:
+ *pValues <<= mnRadius;
+ break;
+ case HANDLE_POLYGON:
+ *pValues <<= maPolygon;
+ break;
+ default:
+ DBG_ERROR( "SvUnoImageMapObject::_getPropertyValues: unexpected property handle" );
+ break;
+ }
+
+ ppEntries++;
+ pValues++;
+ }
+}
+
+
+Reference< XNameReplace > SAL_CALL SvUnoImageMapObject::getEvents()
+ throw( RuntimeException )
+{
+ // try weak reference first
+ Reference< XNameReplace > xEvents( mpEvents );
+ return xEvents;
+}
+
+///////////////////////////////////////////////////////////////////////
+
+class SvUnoImageMap : public WeakImplHelper3< XIndexContainer, XServiceInfo, XUnoTunnel >
+{
+public:
+ SvUnoImageMap( const SvEventDescription* pSupportedMacroItems );
+ SvUnoImageMap( const ImageMap& rMap, const SvEventDescription* pSupportedMacroItems );
+ virtual ~SvUnoImageMap();
+
+ sal_Bool fillImageMap( ImageMap& rMap ) const;
+ SvUnoImageMapObject* getObject( const Any& aElement ) const throw( IllegalArgumentException );
+
+ UNO3_GETIMPLEMENTATION_DECL( SvUnoImageMap )
+
+ // XIndexContainer
+ virtual void SAL_CALL insertByIndex( sal_Int32 Index, const Any& Element ) throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
+ virtual void SAL_CALL removeByIndex( sal_Int32 Index ) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
+
+ // XIndexReplace
+ virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const Any& Element ) throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
+
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount( ) throw( RuntimeException );
+ virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
+
+ // XElementAccess
+ virtual Type SAL_CALL getElementType( ) throw( RuntimeException );
+ virtual sal_Bool SAL_CALL hasElements( ) throw( RuntimeException );
+
+ // XSerivceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw( RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( RuntimeException );
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw( RuntimeException );
+
+private:
+ ::rtl::OUString maName;
+
+ std::list< SvUnoImageMapObject* > maObjectList;
+};
+
+UNO3_GETIMPLEMENTATION_IMPL( SvUnoImageMap );
+
+SvUnoImageMap::SvUnoImageMap( const SvEventDescription* )
+{
+}
+
+SvUnoImageMap::SvUnoImageMap( const ImageMap& rMap, const SvEventDescription* pSupportedMacroItems )
+{
+ maName = rMap.GetName();
+
+ const UINT16 nCount = rMap.GetIMapObjectCount();
+ for( UINT16 nPos = 0; nPos < nCount; nPos++ )
+ {
+ IMapObject* pMapObject = rMap.GetIMapObject( nPos );
+ SvUnoImageMapObject* pUnoObj = new SvUnoImageMapObject( *pMapObject, pSupportedMacroItems );
+ pUnoObj->acquire();
+ maObjectList.push_back( pUnoObj );
+ }
+}
+
+SvUnoImageMap::~SvUnoImageMap()
+{
+ std::list< SvUnoImageMapObject* >::iterator aIter = maObjectList.begin();
+ const std::list< SvUnoImageMapObject* >::iterator aEnd = maObjectList.end();
+ while( aIter != aEnd )
+ {
+ (*aIter++)->release();
+ }
+}
+
+SvUnoImageMapObject* SvUnoImageMap::getObject( const Any& aElement ) const
+ throw( IllegalArgumentException )
+{
+ Reference< XInterface > xObject;
+ aElement >>= xObject;
+
+ SvUnoImageMapObject* pObject = SvUnoImageMapObject::getImplementation( xObject );
+ if( NULL == pObject )
+ throw IllegalArgumentException();
+
+ return pObject;
+}
+
+// XIndexContainer
+void SAL_CALL SvUnoImageMap::insertByIndex( sal_Int32 Index, const Any& Element )
+ throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
+{
+ SvUnoImageMapObject* pObject = getObject( Element );
+ const sal_Int32 nCount = maObjectList.size();
+ if( NULL == pObject || Index > nCount )
+ throw IndexOutOfBoundsException();
+
+ pObject->acquire();
+
+ if( Index == nCount )
+ maObjectList.push_back( pObject );
+ else
+ {
+ std::list< SvUnoImageMapObject* >::iterator aIter = maObjectList.begin();
+ for( sal_Int32 n = 0; n < Index; n++ )
+ aIter++;
+
+ maObjectList.insert( aIter, pObject );
+ }
+}
+
+void SAL_CALL SvUnoImageMap::removeByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+{
+ const sal_Int32 nCount = maObjectList.size();
+ if( Index >= nCount )
+ throw IndexOutOfBoundsException();
+
+ if( nCount - 1 == Index )
+ {
+ maObjectList.back()->release();
+ maObjectList.pop_back();
+ }
+ else
+ {
+ std::list< SvUnoImageMapObject* >::iterator aIter = maObjectList.begin();
+ for( sal_Int32 n = 0; n < Index; n++ )
+ aIter++;
+
+ (*aIter)->release();
+ maObjectList.erase( aIter );
+ }
+}
+
+// XIndexReplace
+void SAL_CALL SvUnoImageMap::replaceByIndex( sal_Int32 Index, const Any& Element ) throw(IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+{
+ SvUnoImageMapObject* pObject = getObject( Element );
+ const sal_Int32 nCount = maObjectList.size();
+ if( NULL == pObject || Index >= nCount )
+ throw IndexOutOfBoundsException();
+
+ std::list< SvUnoImageMapObject* >::iterator aIter = maObjectList.begin();
+ for( sal_Int32 n = 0; n < Index; n++ )
+ aIter++;
+
+ (*aIter)->release();
+ *aIter = pObject;
+ pObject->acquire();
+}
+
+// XIndexAccess
+sal_Int32 SAL_CALL SvUnoImageMap::getCount( ) throw(RuntimeException)
+{
+ return maObjectList.size();
+}
+
+Any SAL_CALL SvUnoImageMap::getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+{
+ const sal_Int32 nCount = maObjectList.size();
+ if( Index >= nCount )
+ throw IndexOutOfBoundsException();
+
+ std::list< SvUnoImageMapObject* >::iterator aIter = maObjectList.begin();
+ for( sal_Int32 n = 0; n < Index; n++ )
+ aIter++;
+
+ Reference< XPropertySet > xObj( *aIter );
+ return makeAny( xObj );
+}
+
+// XElementAccess
+Type SAL_CALL SvUnoImageMap::getElementType( ) throw(RuntimeException)
+{
+ return ::getCppuType((const Reference< XPropertySet >*)0);
+}
+
+sal_Bool SAL_CALL SvUnoImageMap::hasElements( ) throw(RuntimeException)
+{
+ return maObjectList.size() != 0;
+}
+
+// XSerivceInfo
+::rtl::OUString SAL_CALL SvUnoImageMap::getImplementationName( )
+ throw(RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.svt.SvUnoImageMap" ) );
+}
+
+sal_Bool SAL_CALL SvUnoImageMap::supportsService( const ::rtl::OUString& ServiceName )
+ throw(RuntimeException)
+{
+ const Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() );
+ const ::rtl::OUString * pArray = aSNL.getConstArray();
+
+ const sal_Int32 nCount = aSNL.getLength();
+ for( sal_Int32 i = 0; i < nCount; i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+
+ return sal_False;
+}
+
+Sequence< ::rtl::OUString > SAL_CALL SvUnoImageMap::getSupportedServiceNames( )
+ throw(RuntimeException)
+{
+ const ::rtl::OUString aSN( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.image.ImageMap" ) );
+ return Sequence< ::rtl::OUString >( &aSN, 1 );
+}
+
+sal_Bool SvUnoImageMap::fillImageMap( ImageMap& rMap ) const
+{
+ rMap.ClearImageMap();
+
+ rMap.SetName( maName );
+
+ std::list< SvUnoImageMapObject* >::const_iterator aIter = maObjectList.begin();
+ const std::list< SvUnoImageMapObject* >::const_iterator aEnd = maObjectList.end();
+ while( aIter != aEnd )
+ {
+ IMapObject* pNewMapObject = (*aIter)->createIMapObject();
+ rMap.InsertIMapObject( *pNewMapObject );
+ delete pNewMapObject;
+
+ aIter++;
+ }
+
+ return sal_True;
+}
+
+// -------------------------------------------------------------------
+// factory helper methods
+// -------------------------------------------------------------------
+
+Reference< XInterface > SvUnoImageMapRectangleObject_createInstance( const SvEventDescription* pSupportedMacroItems )
+{
+ return (XWeak*)new SvUnoImageMapObject( IMAP_OBJ_RECTANGLE, pSupportedMacroItems );
+}
+
+Reference< XInterface > SvUnoImageMapCircleObject_createInstance( const SvEventDescription* pSupportedMacroItems )
+{
+ return (XWeak*)new SvUnoImageMapObject( IMAP_OBJ_CIRCLE, pSupportedMacroItems );
+}
+
+Reference< XInterface > SvUnoImageMapPolygonObject_createInstance( const SvEventDescription* pSupportedMacroItems )
+{
+ return (XWeak*)new SvUnoImageMapObject( IMAP_OBJ_POLYGON, pSupportedMacroItems );
+}
+
+Reference< XInterface > SvUnoImageMap_createInstance( const SvEventDescription* pSupportedMacroItems )
+{
+ return (XWeak*)new SvUnoImageMap( pSupportedMacroItems );
+}
+
+Reference< XInterface > SvUnoImageMap_createInstance( const ImageMap& rMap, const SvEventDescription* pSupportedMacroItems )
+{
+ return (XWeak*)new SvUnoImageMap( rMap, pSupportedMacroItems );
+}
+
+sal_Bool SvUnoImageMap_fillImageMap( Reference< XInterface > xImageMap, ImageMap& rMap )
+{
+ SvUnoImageMap* pUnoImageMap = SvUnoImageMap::getImplementation( xImageMap );
+ if( NULL == pUnoImageMap )
+ return sal_False;
+
+ return pUnoImageMap->fillImageMap( rMap );
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */