summaryrefslogtreecommitdiff
path: root/codemaker
ModeNameSize
-rw-r--r--README260logplain
-rwxr-xr-xcodemaker.pmk1656logplain
d---------inc75logplain
d---------prj70logplain
d---------source181logplain
d---------test / javamaker36logplain
emholder2.cxx?h=libreoffice-7-0-5&id=e6b4345c7f4026cb9b3e8dee6ecc84b3531e1950'>svl/source/config/itemholder2.cxx242
-rw-r--r--svl/source/config/itemholder2.hxx92
-rw-r--r--svl/source/config/languageoptions.cxx283
-rw-r--r--svl/source/config/makefile.mk66
-rw-r--r--svl/source/config/misccfg.cxx195
-rw-r--r--svl/source/config/syslocaleoptions.cxx637
-rw-r--r--svl/source/filepicker/makefile.mk51
-rw-r--r--svl/source/filepicker/pickerhelper.cxx102
-rw-r--r--svl/source/filepicker/pickerhistory.cxx141
-rw-r--r--svl/source/filerec/filerec.cxx1019
-rw-r--r--svl/source/filerec/makefile.mk50
-rw-r--r--svl/source/fsstor/exports.map8
-rw-r--r--svl/source/fsstor/fsfactory.cxx295
-rw-r--r--svl/source/fsstor/fsstorage.cxx1617
-rw-r--r--svl/source/fsstor/fsstorage.hxx340
-rw-r--r--svl/source/fsstor/makefile.mk70
-rw-r--r--svl/source/fsstor/oinputstreamcontainer.cxx350
-rw-r--r--svl/source/fsstor/oinputstreamcontainer.hxx99
-rw-r--r--svl/source/fsstor/ostreamcontainer.cxx570
-rw-r--r--svl/source/fsstor/ostreamcontainer.hxx128
-rw-r--r--svl/source/inc/fsfactory.hxx75
-rw-r--r--svl/source/inc/passwordcontainer.hxx429
-rw-r--r--svl/source/inc/poolio.hxx204
-rw-r--r--svl/source/items/aeitem.cxx317
-rw-r--r--svl/source/items/bintitem.cxx169
-rw-r--r--svl/source/items/cenumitm.cxx297
-rw-r--r--svl/source/items/cintitem.cxx565
-rw-r--r--svl/source/items/cntwall.cxx170
-rw-r--r--svl/source/items/cstitem.cxx252
-rw-r--r--svl/source/items/cstitem.src112
-rw-r--r--svl/source/items/ctypeitm.cxx254
-rw-r--r--svl/source/items/custritm.cxx141
-rw-r--r--svl/source/items/dateitem.cxx284
-rw-r--r--svl/source/items/dtritem.cxx244
-rw-r--r--svl/source/items/eitem.cxx50
-rw-r--r--svl/source/items/flagitem.cxx166
-rw-r--r--svl/source/items/frqitem.cxx580
-rw-r--r--svl/source/items/globalnameitem.cxx117
-rw-r--r--svl/source/items/ilstitem.cxx106
-rw-r--r--svl/source/items/imageitm.cxx148
-rw-r--r--svl/source/items/intitem.cxx261
-rw-r--r--svl/source/items/itemiter.cxx122
-rw-r--r--svl/source/items/itempool.cxx1176
-rw-r--r--svl/source/items/itemprop.cxx506
-rw-r--r--svl/source/items/itemset.cxx2128
-rw-r--r--svl/source/items/lckbitem.cxx194
-rw-r--r--svl/source/items/macitem.cxx298
-rw-r--r--svl/source/items/makefile.mk65
-rw-r--r--svl/source/items/nranges.cxx853
-rw-r--r--svl/source/items/poolcach.cxx159
-rw-r--r--svl/source/items/poolio.cxx1715
-rw-r--r--svl/source/items/poolitem.cxx527
-rw-r--r--svl/source/items/ptitem.cxx208
-rw-r--r--svl/source/items/rectitem.cxx204
-rw-r--r--svl/source/items/rngitem.cxx57
-rwxr-xr-xsvl/source/items/rngitem_inc.cxx243
-rw-r--r--svl/source/items/sfontitm.cxx142
-rw-r--r--svl/source/items/sitem.cxx116
-rw-r--r--svl/source/items/slstitm.cxx425
-rw-r--r--svl/source/items/stritem.cxx75
-rw-r--r--svl/source/items/style.cxx1381
-rw-r--r--svl/source/items/stylepool.cxx542
-rw-r--r--svl/source/items/szitem.cxx214
-rw-r--r--svl/source/items/tfrmitem.cxx184
-rw-r--r--svl/source/items/tresitem.cxx78
-rw-r--r--svl/source/items/visitem.cxx148
-rw-r--r--svl/source/items/whassert.hxx57
-rw-r--r--svl/source/items/whiter.cxx127
-rw-r--r--svl/source/memtools/makefile.mk50
-rw-r--r--svl/source/memtools/svarray.cxx385
-rw-r--r--svl/source/misc/PasswordHelper.cxx109
-rw-r--r--svl/source/misc/adrparse.cxx921
-rw-r--r--svl/source/misc/documentlockfile.cxx238
-rw-r--r--svl/source/misc/filenotation.cxx147
-rw-r--r--svl/source/misc/flbytes.cxx432
-rw-r--r--svl/source/misc/folderrestriction.cxx109
-rw-r--r--svl/source/misc/fstathelper.cxx103
-rw-r--r--svl/source/misc/inethist.cxx545
-rw-r--r--svl/source/misc/inettype.cxx1348
-rw-r--r--svl/source/misc/lngmisc.cxx141
-rw-r--r--svl/source/misc/lockfilecommon.cxx276
-rw-r--r--svl/source/misc/mediatyp.src610
-rw-r--r--svl/source/misc/ownlist.cxx330
-rw-r--r--svl/source/misc/restrictedpaths.cxx217
-rw-r--r--svl/source/misc/sharecontrolfile.cxx376
-rw-r--r--svl/source/misc/strmadpt.cxx1048
-rw-r--r--svl/source/misc/svldata.cxx113
-rw-r--r--svl/source/misc/urihelper.cxx952
-rw-r--r--svl/source/notify/brdcst.cxx212
-rw-r--r--svl/source/notify/broadcast.cxx151
-rw-r--r--svl/source/notify/cancel.cxx204
-rw-r--r--svl/source/notify/hint.cxx50
-rw-r--r--svl/source/notify/isethint.cxx78
-rw-r--r--svl/source/notify/listener.cxx169
-rw-r--r--svl/source/notify/listenerbase.cxx84
-rw-r--r--svl/source/notify/listenerbase.hxx60
-rw-r--r--svl/source/notify/listeneriter.cxx195
-rw-r--r--svl/source/notify/lstner.cxx196
-rw-r--r--svl/source/notify/makefile.mk67
-rw-r--r--svl/source/notify/smplhint.cxx50
-rw-r--r--svl/source/numbers/makefile.mk78
-rw-r--r--svl/source/numbers/nbdll.cxx82
-rw-r--r--svl/source/numbers/numfmuno.cxx1144
-rw-r--r--svl/source/numbers/numfmuno.hxx324
-rw-r--r--svl/source/numbers/numhead.cxx252
-rw-r--r--svl/source/numbers/numhead.hxx109
-rw-r--r--svl/source/numbers/numuno.cxx171
-rw-r--r--svl/source/numbers/supservs.cxx233
-rw-r--r--svl/source/numbers/supservs.hxx105
-rw-r--r--svl/source/numbers/zforfind.cxx2819
-rw-r--r--svl/source/numbers/zforfind.hxx291
-rw-r--r--svl/source/numbers/zforlist.cxx4362
-rw-r--r--svl/source/numbers/zformat.cxx4480
-rw-r--r--svl/source/numbers/zforscan.cxx2812
-rw-r--r--svl/source/numbers/zforscan.hxx278
-rw-r--r--svl/source/passwordcontainer/exports.map8
-rw-r--r--svl/source/passwordcontainer/makefile.mk66
-rw-r--r--svl/source/passwordcontainer/passwordcontainer.cxx1595
-rw-r--r--svl/source/passwordcontainer/syscreds.cxx298
-rw-r--r--svl/source/passwordcontainer/syscreds.hxx95
-rw-r--r--svl/source/svdde/ddecli.cxx474
-rw-r--r--svl/source/svdde/ddedata.cxx233
-rw-r--r--svl/source/svdde/ddedll.cxx67
-rw-r--r--svl/source/svdde/ddeimp.hxx180
-rw-r--r--svl/source/svdde/ddeinf.cxx193
-rw-r--r--svl/source/svdde/ddeml1.cxx2661
-rw-r--r--svl/source/svdde/ddeml2.cxx1014
-rw-r--r--svl/source/svdde/ddemldeb.cxx283
-rw-r--r--svl/source/svdde/ddemldeb.hxx69
-rw-r--r--svl/source/svdde/ddemlimp.hxx436
-rw-r--r--svl/source/svdde/ddemlos2.h377
-rw-r--r--svl/source/svdde/ddestrg.cxx81
-rw-r--r--svl/source/svdde/ddesvr.cxx1107
-rw-r--r--svl/source/svdde/ddewrap.cxx103
-rw-r--r--svl/source/svdde/ddewrap.hxx24
-rw-r--r--svl/source/svdde/makefile.mk64
-rw-r--r--svl/source/svsql/converter.cxx45
-rw-r--r--svl/source/svsql/converter.hxx46
-rw-r--r--svl/source/svsql/makefile.mk50
-rw-r--r--svl/source/syslocale/makefile.mk48
-rw-r--r--svl/source/syslocale/syslocale.cxx176
-rw-r--r--svl/source/undo/makefile.mk51
-rw-r--r--svl/source/undo/undo.cxx819
-rw-r--r--svl/source/uno/makefile.mk64
-rw-r--r--svl/source/uno/registerservices.cxx135
147 files changed, 62621 insertions, 0 deletions
diff --git a/svl/source/config/cjkoptions.cxx b/svl/source/config/cjkoptions.cxx
new file mode 100644
index 000000000000..66d70cd1e2a3
--- /dev/null
+++ b/svl/source/config/cjkoptions.cxx
@@ -0,0 +1,510 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: cjkoptions.cxx,v $
+ * $Revision: 1.22 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#ifdef SVL_DLLIMPLEMENTATION
+#undef SVL_DLLIMPLEMENTATION
+#endif
+#define SVT_DLLIMPLEMENTATION
+
+#include <svtools/cjkoptions.hxx>
+
+#include <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;
+
+#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);
+ sal_Bool IsReadOnly(SvtCJKOptions::EOption eOption) const;
+};
+/*-- 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);
+}
+/*-- 13.02.2003 12:12---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SvtCJKOptions_Impl::IsReadOnly(SvtCJKOptions::EOption eOption) const
+{
+ sal_Bool bReadOnly = CFG_READONLY_DEFAULT;
+ switch(eOption)
+ {
+ case SvtCJKOptions::E_CJKFONT : bReadOnly = bROCJKFont; break;
+ case SvtCJKOptions::E_VERTICALTEXT : bReadOnly = bROVerticalText; break;
+ case SvtCJKOptions::E_ASIANTYPOGRAPHY : bReadOnly = bROAsianTypography; break;
+ case SvtCJKOptions::E_JAPANESEFIND : bReadOnly = bROJapaneseFind; break;
+ case SvtCJKOptions::E_RUBY : bReadOnly = bRORuby; break;
+ case SvtCJKOptions::E_CHANGECASEMAP : bReadOnly = bROChangeCaseMap; break;
+ case SvtCJKOptions::E_DOUBLELINES : bReadOnly = bRODoubleLines; break;
+ case SvtCJKOptions::E_EMPHASISMARKS : bReadOnly = bROEmphasisMarks; break;
+ case SvtCJKOptions::E_VERTICALCALLOUT : bReadOnly = bROVerticalCallOut; break;
+ case SvtCJKOptions::E_ALL : if (bROCJKFont || bROVerticalText || bROAsianTypography || bROJapaneseFind || bRORuby || bROChangeCaseMap || bRODoubleLines || bROEmphasisMarks || bROVerticalCallOut)
+ bReadOnly = sal_True;
+ break;
+ }
+ return bReadOnly;
+}
+
+// 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 );
+}
+// -----------------------------------------------------------------------
+sal_Bool SvtCJKOptions::IsCJKFontEnabled() const
+{
+ DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
+ return pCJKOptions->IsCJKFontEnabled();
+}
+// -----------------------------------------------------------------------
+sal_Bool SvtCJKOptions::IsVerticalTextEnabled() const
+{
+ DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
+ return pCJKOptions->IsVerticalTextEnabled();
+}
+// -----------------------------------------------------------------------
+sal_Bool SvtCJKOptions::IsAsianTypographyEnabled() const
+{
+ DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
+ return pCJKOptions->IsAsianTypographyEnabled();
+}
+// -----------------------------------------------------------------------
+sal_Bool SvtCJKOptions::IsJapaneseFindEnabled() const
+{
+ DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
+ return pCJKOptions->IsJapaneseFindEnabled();
+}
+// -----------------------------------------------------------------------
+sal_Bool SvtCJKOptions::IsRubyEnabled() const
+{
+ DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
+ return pCJKOptions->IsRubyEnabled();
+}
+// -----------------------------------------------------------------------
+sal_Bool SvtCJKOptions::IsChangeCaseMapEnabled() const
+{
+ DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
+ return pCJKOptions->IsChangeCaseMapEnabled();
+}
+// -----------------------------------------------------------------------
+sal_Bool SvtCJKOptions::IsDoubleLinesEnabled() const
+{
+ DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
+ return pCJKOptions->IsDoubleLinesEnabled();
+}
+// -----------------------------------------------------------------------
+sal_Bool SvtCJKOptions::IsEmphasisMarksEnabled() const
+{
+ DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
+ return pCJKOptions->IsEmphasisMarksEnabled();
+}
+// -----------------------------------------------------------------------
+sal_Bool SvtCJKOptions::IsVerticalCallOutEnabled() const
+{
+ DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
+ return pCJKOptions->IsVerticalCallOutEnabled();
+}
+/*-- 20.04.01 14:32:04---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SvtCJKOptions::SetAll(sal_Bool bSet)
+{
+ DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
+ pCJKOptions->SetAll(bSet);
+}
+/*-- 20.04.01 14:32:06---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SvtCJKOptions::IsAnyEnabled() const
+{
+ DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
+ return pCJKOptions->IsAnyEnabled();
+}
+/*-- 13.02.2003 12:11---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SvtCJKOptions::IsReadOnly(EOption eOption) const
+{
+ DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
+ return pCJKOptions->IsReadOnly(eOption);
+}
+
diff --git a/svl/source/config/ctloptions.cxx b/svl/source/config/ctloptions.cxx
new file mode 100644
index 000000000000..5d2bf131add1
--- /dev/null
+++ b/svl/source/config/ctloptions.cxx
@@ -0,0 +1,503 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ctloptions.cxx,v $
+ * $Revision: 1.18.140.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#ifdef SVL_DLLIMPLEMENTATION
+#undef SVL_DLLIMPLEMENTATION
+#endif
+#define SVT_DLLIMPLEMENTATION
+
+#include <svtools/ctloptions.hxx>
+
+#include <svtools/languageoptions.hxx>
+#include <i18npool/mslangid.hxx>
+#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 <vos/mutex.hxx>
+#include <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;
+
+#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; }
+ void SetCTLFontEnabled( sal_Bool _bEnabled );
+ sal_Bool IsCTLFontEnabled() const { return m_bCTLFontEnabled; }
+
+ void SetCTLSequenceChecking( sal_Bool _bEnabled );
+ sal_Bool IsCTLSequenceChecking() const { return m_bCTLSequenceChecking;}
+
+ void SetCTLSequenceCheckingRestricted( sal_Bool _bEnable );
+ sal_Bool IsCTLSequenceCheckingRestricted( void ) const { return m_bCTLRestricted; }
+
+ void SetCTLSequenceCheckingTypeAndReplace( sal_Bool _bEnable );
+ sal_Bool IsCTLSequenceCheckingTypeAndReplace() const { return m_bCTLTypeAndReplace; }
+
+ void SetCTLCursorMovement( SvtCTLOptions::CursorMovement _eMovement );
+ SvtCTLOptions::CursorMovement
+ GetCTLCursorMovement() const { return m_eCTLCursorMovement; }
+
+ void SetCTLTextNumerals( SvtCTLOptions::TextNumerals _eNumerals );
+ SvtCTLOptions::TextNumerals
+ GetCTLTextNumerals() const { return m_eCTLTextNumerals; }
+
+ sal_Bool IsReadOnly(SvtCTLOptions::EOption eOption) const;
+};
+//------------------------------------------------------------------------------
+namespace
+{
+ struct PropertyNames
+ : public rtl::Static< Sequence< rtl::OUString >, PropertyNames > {};
+}
+//------------------------------------------------------------------------------
+sal_Bool SvtCTLOptions_Impl::IsReadOnly(SvtCTLOptions::EOption eOption) const
+{
+ sal_Bool bReadOnly = CFG_READONLY_DEFAULT;
+ switch(eOption)
+ {
+ case SvtCTLOptions::E_CTLFONT : bReadOnly = m_bROCTLFontEnabled ; break;
+ case SvtCTLOptions::E_CTLSEQUENCECHECKING : bReadOnly = m_bROCTLSequenceChecking ; break;
+ case SvtCTLOptions::E_CTLCURSORMOVEMENT : bReadOnly = m_bROCTLCursorMovement ; break;
+ case SvtCTLOptions::E_CTLTEXTNUMERALS : bReadOnly = m_bROCTLTextNumerals ; break;
+ case SvtCTLOptions::E_CTLSEQUENCECHECKINGRESTRICTED: bReadOnly = m_bROCTLRestricted ; break;
+ case SvtCTLOptions::E_CTLSEQUENCECHECKINGTYPEANDREPLACE: bReadOnly = m_bROCTLTypeAndReplace; break;
+ default: DBG_ERROR( "SvtCTLOptions_Impl::IsReadOnly() - invalid option" );
+ }
+ return bReadOnly;
+}
+//------------------------------------------------------------------------------
+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 =
+ (MsLangId::needsSequenceChecking( nLanguage) ||
+ MsLangId::needsSequenceChecking( eSystemLanguage));
+ Commit();
+ }
+ m_bIsLoaded = sal_True;
+}
+//------------------------------------------------------------------------------
+void SvtCTLOptions_Impl::SetCTLFontEnabled( sal_Bool _bEnabled )
+{
+ if(!m_bROCTLFontEnabled && m_bCTLFontEnabled != _bEnabled)
+ {
+ m_bCTLFontEnabled = _bEnabled;
+ SetModified();
+ }
+}
+//------------------------------------------------------------------------------
+void SvtCTLOptions_Impl::SetCTLSequenceChecking( sal_Bool _bEnabled )
+{
+ if(!m_bROCTLSequenceChecking && m_bCTLSequenceChecking != _bEnabled)
+ {
+ SetModified();
+ m_bCTLSequenceChecking = _bEnabled;
+ }
+}
+//------------------------------------------------------------------------------
+void SvtCTLOptions_Impl::SetCTLSequenceCheckingRestricted( sal_Bool _bEnabled )
+{
+ if(!m_bROCTLRestricted && m_bCTLRestricted != _bEnabled)
+ {
+ SetModified();
+ m_bCTLRestricted = _bEnabled;
+ }
+}
+//------------------------------------------------------------------------------
+void SvtCTLOptions_Impl::SetCTLSequenceCheckingTypeAndReplace( sal_Bool _bEnabled )
+{
+ if(!m_bROCTLTypeAndReplace && m_bCTLTypeAndReplace != _bEnabled)
+ {
+ SetModified();
+ m_bCTLTypeAndReplace = _bEnabled;
+ }
+}
+//------------------------------------------------------------------------------
+void SvtCTLOptions_Impl::SetCTLCursorMovement( SvtCTLOptions::CursorMovement _eMovement )
+{
+ if (!m_bROCTLCursorMovement && m_eCTLCursorMovement != _eMovement )
+ {
+ SetModified();
+ m_eCTLCursorMovement = _eMovement;
+ }
+}
+//------------------------------------------------------------------------------
+void SvtCTLOptions_Impl::SetCTLTextNumerals( SvtCTLOptions::TextNumerals _eNumerals )
+{
+ if (!m_bROCTLTextNumerals && m_eCTLTextNumerals != _eNumerals )
+ {
+ SetModified();
+ m_eCTLTextNumerals = _eNumerals;
+ }
+}
+// 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 );
+}
+// -----------------------------------------------------------------------------
+void SvtCTLOptions::SetCTLFontEnabled( sal_Bool _bEnabled )
+{
+ DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
+ pCTLOptions->SetCTLFontEnabled( _bEnabled );
+}
+// -----------------------------------------------------------------------------
+sal_Bool SvtCTLOptions::IsCTLFontEnabled() const
+{
+ DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
+ return pCTLOptions->IsCTLFontEnabled();
+}
+// -----------------------------------------------------------------------------
+void SvtCTLOptions::SetCTLSequenceChecking( sal_Bool _bEnabled )
+{
+ DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
+ pCTLOptions->SetCTLSequenceChecking(_bEnabled);
+}
+// -----------------------------------------------------------------------------
+sal_Bool SvtCTLOptions::IsCTLSequenceChecking() const
+{
+ DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
+ return pCTLOptions->IsCTLSequenceChecking();
+}
+// -----------------------------------------------------------------------------
+void SvtCTLOptions::SetCTLSequenceCheckingRestricted( sal_Bool _bEnable )
+{
+ DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
+ pCTLOptions->SetCTLSequenceCheckingRestricted(_bEnable);
+}
+// -----------------------------------------------------------------------------
+sal_Bool SvtCTLOptions::IsCTLSequenceCheckingRestricted( void ) const
+{
+ DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
+ return pCTLOptions->IsCTLSequenceCheckingRestricted();
+}
+// -----------------------------------------------------------------------------
+void SvtCTLOptions::SetCTLSequenceCheckingTypeAndReplace( sal_Bool _bEnable )
+{
+ DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
+ pCTLOptions->SetCTLSequenceCheckingTypeAndReplace(_bEnable);
+}
+// -----------------------------------------------------------------------------
+sal_Bool SvtCTLOptions::IsCTLSequenceCheckingTypeAndReplace() const
+{
+ DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
+ return pCTLOptions->IsCTLSequenceCheckingTypeAndReplace();
+}
+// -----------------------------------------------------------------------------
+void SvtCTLOptions::SetCTLCursorMovement( SvtCTLOptions::CursorMovement _eMovement )
+{
+ DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
+ pCTLOptions->SetCTLCursorMovement( _eMovement );
+}
+// -----------------------------------------------------------------------------
+SvtCTLOptions::CursorMovement SvtCTLOptions::GetCTLCursorMovement() const
+{
+ DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
+ return pCTLOptions->GetCTLCursorMovement();
+}
+// -----------------------------------------------------------------------------
+void SvtCTLOptions::SetCTLTextNumerals( SvtCTLOptions::TextNumerals _eNumerals )
+{
+ DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
+ pCTLOptions->SetCTLTextNumerals( _eNumerals );
+}
+// -----------------------------------------------------------------------------
+SvtCTLOptions::TextNumerals SvtCTLOptions::GetCTLTextNumerals() const
+{
+ DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
+ return pCTLOptions->GetCTLTextNumerals();
+}
+// -----------------------------------------------------------------------------
+sal_Bool SvtCTLOptions::IsReadOnly(EOption eOption) const
+{
+ DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
+ return pCTLOptions->IsReadOnly(eOption);
+}
+/* -----------------30.04.2003 10:40-----------------
+
+ --------------------------------------------------*/
+void SvtCTLOptions::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ vos::OGuard aVclGuard( Application::GetSolarMutex() );
+ Broadcast( rHint );
+}
+
+// -----------------------------------------------------------------------------
+
diff --git a/svl/source/config/itemholder2.cxx b/svl/source/config/itemholder2.cxx
new file mode 100644
index 000000000000..d0e5b30007f9
--- /dev/null
+++ b/svl/source/config/itemholder2.cxx
@@ -0,0 +1,242 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: itemholder2.cxx,v $
+ * $Revision: 1.13 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#ifdef SVL_DLLIMPLEMENTATION
+#undef SVL_DLLIMPLEMENTATION
+#endif
+#define SVT_DLLIMPLEMENTATION
+
+#include "itemholder2.hxx"
+
+//-----------------------------------------------
+// includes
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+
+#include <svtools/accessibilityoptions.hxx>
+#include <apearcfg.hxx>
+#include <svtools/cjkoptions.hxx>
+#include <svtools/menuoptions.hxx>
+#include <svtools/colorcfg.hxx>
+#include <svtools/ctloptions.hxx>
+#include <fontsubstconfig.hxx>
+#include <svtools/helpopt.hxx>
+#include <svtools/languageoptions.hxx>
+#include <misccfg.hxx>
+#include <svtools/printoptions.hxx>
+#include <svtools/syslocaleoptions.hxx>
+#include <unotools/options.hxx>
+#include <svtools/miscopt.hxx>
+
+
+#include <tools/debug.hxx>
+
+//-----------------------------------------------
+// namespaces
+
+namespace css = ::com::sun::star;
+
+//-----------------------------------------------
+// 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_ACCESSIBILITYOPTIONS :
+ rItem.pItem = new SvtAccessibilityOptions();
+ break;
+
+ case E_APEARCFG :
+// no ref count rItem.pItem = new SvtTabAppearanceCfg();
+ break;
+
+ case E_CJKOPTIONS :
+ rItem.pItem = new SvtCJKOptions();
+ break;
+
+ case E_COLORCFG :
+ rItem.pItem = new ::svtools::ColorConfig();
+ break;
+
+ case E_CTLOPTIONS :
+ rItem.pItem = new SvtCTLOptions();
+ break;
+
+ case E_FONTSUBSTCONFIG :
+// no ref count rItem.pItem = new SvtFontSubstConfig();
+ 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_MENUOPTIONS :
+ rItem.pItem = new SvtMenuOptions();
+ 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_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;
+ }
+}
diff --git a/svl/source/config/itemholder2.hxx b/svl/source/config/itemholder2.hxx
new file mode 100644
index 000000000000..192df8f746c9
--- /dev/null
+++ b/svl/source/config/itemholder2.hxx
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: itemholder2.hxx,v $
+ * $Revision: 1.5 $
+ *
+ * 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 <unotools/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
+
+//-----------------------------------------------
+// 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_
diff --git a/svl/source/config/languageoptions.cxx b/svl/source/config/languageoptions.cxx
new file mode 100644
index 000000000000..0dffafee86d2
--- /dev/null
+++ b/svl/source/config/languageoptions.cxx
@@ -0,0 +1,283 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: languageoptions.cxx,v $
+ * $Revision: 1.21 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#ifdef SVL_DLLIMPLEMENTATION
+#undef SVL_DLLIMPLEMENTATION
+#endif
+#define SVT_DLLIMPLEMENTATION
+
+#include <svtools/languageoptions.hxx>
+#include <svtools/cjkoptions.hxx>
+#include <svtools/ctloptions.hxx>
+#include <vcl/svapp.hxx>
+#include <i18npool/mslangid.hxx>
+#include <vos/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 > {}; }
+
+// class SvtLanguageOptions ----------------------------------------------------
+
+SvtLanguageOptions::SvtLanguageOptions( sal_Bool _bDontLoad )
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( ALMutex::get() );
+
+ m_pCJKOptions = new SvtCJKOptions( _bDontLoad );
+ m_pCTLOptions = new SvtCTLOptions( _bDontLoad );
+ StartListening(*m_pCTLOptions);
+}
+//------------------------------------------------------------------------------
+SvtLanguageOptions::~SvtLanguageOptions()
+{
+ // Global access, must be guarded (multithreading)
+ ::osl::MutexGuard aGuard( ALMutex::get() );
+
+ delete m_pCJKOptions;
+ delete m_pCTLOptions;
+}
+//------------------------------------------------------------------------------
+// CJK options -----------------------------------------------------------------
+//------------------------------------------------------------------------------
+sal_Bool SvtLanguageOptions::IsCJKFontEnabled() const
+{
+ return m_pCJKOptions->IsCJKFontEnabled();
+}
+//------------------------------------------------------------------------------
+sal_Bool SvtLanguageOptions::IsVerticalTextEnabled() const
+{
+ return m_pCJKOptions->IsVerticalTextEnabled();
+}
+//------------------------------------------------------------------------------
+sal_Bool SvtLanguageOptions::IsAsianTypographyEnabled() const
+{
+ return m_pCJKOptions->IsAsianTypographyEnabled();
+}
+//------------------------------------------------------------------------------
+sal_Bool SvtLanguageOptions::IsJapaneseFindEnabled() const
+{
+ return m_pCJKOptions->IsJapaneseFindEnabled();
+}
+//------------------------------------------------------------------------------
+sal_Bool SvtLanguageOptions::IsRubyEnabled() const
+{
+ return m_pCJKOptions->IsRubyEnabled();
+}
+//------------------------------------------------------------------------------
+sal_Bool SvtLanguageOptions::IsChangeCaseMapEnabled() const
+{
+ return m_pCJKOptions->IsChangeCaseMapEnabled();
+}
+//------------------------------------------------------------------------------
+sal_Bool SvtLanguageOptions::IsDoubleLinesEnabled() const
+{
+ return m_pCJKOptions->IsDoubleLinesEnabled();
+}
+//------------------------------------------------------------------------------
+sal_Bool SvtLanguageOptions::IsEmphasisMarksEnabled() const
+{
+ return m_pCJKOptions->IsEmphasisMarksEnabled();
+}
+//------------------------------------------------------------------------------
+sal_Bool SvtLanguageOptions::IsVerticalCallOutEnabled() const
+{
+ return m_pCJKOptions->IsVerticalCallOutEnabled();
+}
+//------------------------------------------------------------------------------
+void SvtLanguageOptions::SetAll( sal_Bool _bSet )
+{
+ m_pCJKOptions->SetAll( _bSet );
+}
+//------------------------------------------------------------------------------
+sal_Bool SvtLanguageOptions::IsAnyEnabled() const
+{
+ return m_pCJKOptions->IsAnyEnabled();
+}
+//------------------------------------------------------------------------------
+// CTL options -----------------------------------------------------------------
+//------------------------------------------------------------------------------
+void SvtLanguageOptions::SetCTLFontEnabled( sal_Bool _bEnabled )
+{
+ m_pCTLOptions->SetCTLFontEnabled( _bEnabled );
+}
+//------------------------------------------------------------------------------
+sal_Bool SvtLanguageOptions::IsCTLFontEnabled() const
+{
+ return m_pCTLOptions->IsCTLFontEnabled();
+}
+//------------------------------------------------------------------------------
+void SvtLanguageOptions::SetCTLSequenceChecking( sal_Bool _bEnabled )
+{
+ m_pCTLOptions->SetCTLSequenceChecking( _bEnabled );
+}
+//------------------------------------------------------------------------------
+sal_Bool SvtLanguageOptions::IsCTLSequenceChecking() const
+{
+ return m_pCTLOptions->IsCTLSequenceChecking();
+}
+/*-- 26.09.2005 15:48:23---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SvtLanguageOptions::SetCTLSequenceCheckingRestricted( sal_Bool _bEnable )
+{
+ m_pCTLOptions->SetCTLSequenceCheckingRestricted( _bEnable );
+}
+/*-- 26.09.2005 15:48:23---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SvtLanguageOptions::IsCTLSequenceCheckingRestricted( void ) const
+{
+ return m_pCTLOptions->IsCTLSequenceCheckingRestricted();
+}
+/*-- 26.09.2005 15:48:23---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SvtLanguageOptions::SetCTLSequenceCheckingTypeAndReplace( sal_Bool _bEnable )
+{
+ m_pCTLOptions->SetCTLSequenceCheckingTypeAndReplace( _bEnable );
+}
+/*-- 26.09.2005 15:48:24---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SvtLanguageOptions::IsCTLSequenceCheckingTypeAndReplace() const
+{
+ return m_pCTLOptions->IsCTLSequenceCheckingTypeAndReplace();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SvtLanguageOptions::IsReadOnly(SvtLanguageOptions::EOption eOption) const
+{
+ sal_Bool bReadOnly = sal_False;
+ switch(eOption)
+ {
+ // cjk options
+ case SvtLanguageOptions::E_CJKFONT : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_CJKFONT ); break;
+ case SvtLanguageOptions::E_VERTICALTEXT : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_VERTICALTEXT ); break;
+ case SvtLanguageOptions::E_ASIANTYPOGRAPHY : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_ASIANTYPOGRAPHY); break;
+ case SvtLanguageOptions::E_JAPANESEFIND : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_JAPANESEFIND ); break;
+ case SvtLanguageOptions::E_RUBY : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_RUBY ); break;
+ case SvtLanguageOptions::E_CHANGECASEMAP : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_CHANGECASEMAP ); break;
+ case SvtLanguageOptions::E_DOUBLELINES : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_DOUBLELINES ); break;
+ case SvtLanguageOptions::E_EMPHASISMARKS : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_EMPHASISMARKS ); break;
+ case SvtLanguageOptions::E_VERTICALCALLOUT : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_VERTICALCALLOUT); break;
+ case SvtLanguageOptions::E_ALLCJK : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_ALL ); break;
+ // ctl options
+ case SvtLanguageOptions::E_CTLFONT : bReadOnly = m_pCTLOptions->IsReadOnly(SvtCTLOptions::E_CTLFONT ); break;
+ case SvtLanguageOptions::E_CTLSEQUENCECHECKING : bReadOnly = m_pCTLOptions->IsReadOnly(SvtCTLOptions::E_CTLSEQUENCECHECKING); break;
+ case SvtLanguageOptions::E_CTLCURSORMOVEMENT : bReadOnly = m_pCTLOptions->IsReadOnly(SvtCTLOptions::E_CTLCURSORMOVEMENT ); break;
+ case SvtLanguageOptions::E_CTLTEXTNUMERALS : bReadOnly = m_pCTLOptions->IsReadOnly(SvtCTLOptions::E_CTLTEXTNUMERALS ); break;
+ }
+ return bReadOnly;
+}
+/* -----------------30.04.2003 11:03-----------------
+
+ --------------------------------------------------*/
+void SvtLanguageOptions::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ vos::OGuard aVclGuard( Application::GetSolarMutex() );
+ Broadcast( rHint );
+}
+
+// -----------------------------------------------------------------------------
+// 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 );
+}
+
+
diff --git a/svl/source/config/makefile.mk b/svl/source/config/makefile.mk
new file mode 100644
index 000000000000..d3f2615776da
--- /dev/null
+++ b/svl/source/config/makefile.mk
@@ -0,0 +1,66 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.61 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=svtools
+TARGET=config
+
+ENABLE_EXCEPTIONS := TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/svl.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/accessibilityoptions.obj \
+ $(SLO)$/apearcfg.obj \
+ $(SLO)$/cjkoptions.obj \
+ $(SLO)$/colorcfg.obj \
+ $(SLO)$/ctloptions.obj \
+ $(SLO)$/extcolorcfg.obj \
+ $(SLO)$/fontsubstconfig.obj \
+ $(SLO)$/helpopt.obj \
+ $(SLO)$/itemholder2.obj \
+ $(SLO)$/languageoptions.obj \
+ $(SLO)$/menuoptions.obj \
+ $(SLO)$/misccfg.obj \
+ $(SLO)$/miscopt.obj \
+ $(SLO)$/optionsdrawinglayer.obj \
+ $(SLO)$/printoptions.obj \
+ $(SLO)$/syslocaleoptions.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/svl/source/config/misccfg.cxx b/svl/source/config/misccfg.cxx
new file mode 100644
index 000000000000..06cc9b7446c0
--- /dev/null
+++ b/svl/source/config/misccfg.cxx
@@ -0,0 +1,195 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: misccfg.cxx,v $
+ * $Revision: 1.9 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#ifdef SVL_DLLIMPLEMENTATION
+#undef SVL_DLLIMPLEMENTATION
+#endif
+#define SVT_DLLIMPLEMENTATION
+
+#include "misccfg.hxx"
+#include <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;
+
+#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()
+{
+}
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void SfxMiscCfg::SetNotFoundWarning( BOOL bSet)
+{
+ if(bNotFound != bSet)
+ SetModified();
+ bNotFound = bSet;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void SfxMiscCfg::SetPaperSizeWarning( BOOL bSet)
+{
+ if(bPaperSize != bSet)
+ SetModified();
+ bPaperSize = bSet;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+void SfxMiscCfg::SetPaperOrientationWarning( BOOL bSet)
+{
+ if(bPaperOrientation != bSet)
+ SetModified();
+ bPaperOrientation = bSet;
+}
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void SfxMiscCfg::SetYear2000( sal_Int32 nSet )
+{
+ if(nYear2000 != nSet)
+ SetModified();
+ nYear2000 = nSet;
+}
+/* -----------------------------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);
+}
+
diff --git a/svl/source/config/syslocaleoptions.cxx b/svl/source/config/syslocaleoptions.cxx
new file mode 100644
index 000000000000..a75c63e34af0
--- /dev/null
+++ b/svl/source/config/syslocaleoptions.cxx
@@ -0,0 +1,637 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: syslocaleoptions.cxx,v $
+ * $Revision: 1.23 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#ifdef SVL_DLLIMPLEMENTATION
+#undef SVL_DLLIMPLEMENTATION
+#endif
+#define SVT_DLLIMPLEMENTATION
+
+#include <svtools/syslocaleoptions.hxx>
+#include <broadcast.hxx>
+#include <listener.hxx>
+#include <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"
+
+
+#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; }
+ void SetLocaleString( const OUString& rStr );
+ LanguageType GetLocaleLanguageType() const
+ { return m_eLocaleLanguageType; }
+
+ const OUString& GetCurrencyString() const
+ { return m_aCurrencyString; }
+ void SetCurrencyString( const OUString& rStr );
+
+ sal_Bool IsDecimalSeparatorAsLocale() const { return m_bDecimalSeparator;}
+ void SetDecimalSeparatorAsLocale( sal_Bool bSet);
+
+ SvtBroadcaster& GetBroadcaster()
+ { return m_aBroadcaster; }
+ void BlockBroadcasts( BOOL bBlock );
+ sal_Bool IsReadOnly( SvtSysLocaleOptions::EOption eOption ) const;
+};
+
+
+#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::BlockBroadcasts( BOOL bBlock )
+{
+ if ( bBlock )
+ ++m_nBroadcastBlocked;
+ else if ( m_nBroadcastBlocked )
+ {
+ if ( --m_nBroadcastBlocked == 0 )
+ Broadcast( 0 );
+ }
+}
+
+sal_Bool SvtSysLocaleOptions_Impl::IsReadOnly( SvtSysLocaleOptions::EOption eOption ) const
+{
+ sal_Bool bReadOnly = CFG_READONLY_DEFAULT;
+ switch(eOption)
+ {
+ case SvtSysLocaleOptions::E_LOCALE :
+ {
+ bReadOnly = m_bROLocale;
+ break;
+ }
+ case SvtSysLocaleOptions::E_CURRENCY :
+ {
+ bReadOnly = m_bROCurrency;
+ break;
+ }
+ }
+ return bReadOnly;
+}
+
+
+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();
+}
+
+
+void SvtSysLocaleOptions_Impl::SetLocaleString( const OUString& rStr )
+{
+ if (!m_bROLocale && rStr != m_aLocaleString )
+ {
+ m_aLocaleString = rStr;
+ SetModified();
+ ULONG nHint = SYSLOCALEOPTIONS_HINT_LOCALE;
+ nHint |= ChangeLocaleSettings();
+ Broadcast( nHint );
+ }
+}
+
+
+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::SetCurrencyString( const OUString& rStr )
+{
+ if (!m_bROCurrency && rStr != m_aCurrencyString )
+ {
+ m_aCurrencyString = rStr;
+ SetModified();
+ Broadcast( SYSLOCALEOPTIONS_HINT_CURRENCY );
+ }
+}
+
+void SvtSysLocaleOptions_Impl::SetDecimalSeparatorAsLocale( sal_Bool bSet)
+{
+ if(bSet != m_bDecimalSeparator)
+ {
+ m_bDecimalSeparator = bSet;
+ SetModified();
+ UpdateMiscSettings_Impl();
+ }
+}
+
+
+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;
+}
+
+
+sal_Bool SvtSysLocaleOptions::IsModified()
+{
+ MutexGuard aGuard( GetMutex() );
+ return pOptions->IsModified();
+}
+
+
+void SvtSysLocaleOptions::Commit()
+{
+ MutexGuard aGuard( GetMutex() );
+ pOptions->Commit();
+}
+
+
+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() );
+}
+
+
+void SvtSysLocaleOptions::BlockBroadcasts( BOOL bBlock )
+{
+ MutexGuard aGuard( GetMutex() );
+ pOptions->BlockBroadcasts( bBlock );
+}
+
+
+const OUString& SvtSysLocaleOptions::GetLocaleConfigString() const
+{
+ MutexGuard aGuard( GetMutex() );
+ return pOptions->GetLocaleString();
+}
+
+
+void SvtSysLocaleOptions::SetLocaleConfigString( const OUString& rStr )
+{
+ MutexGuard aGuard( GetMutex() );
+ pOptions->SetLocaleString( rStr );
+}
+
+
+const OUString& SvtSysLocaleOptions::GetCurrencyConfigString() const
+{
+ MutexGuard aGuard( GetMutex() );
+ return pOptions->GetCurrencyString();
+}
+
+
+void SvtSysLocaleOptions::SetCurrencyConfigString( const OUString& rStr )
+{
+ MutexGuard aGuard( GetMutex() );
+ pOptions->SetCurrencyString( rStr );
+}
+
+
+LanguageType SvtSysLocaleOptions::GetLocaleLanguageType() const
+{
+ MutexGuard aGuard( GetMutex() );
+ return pOptions->GetLocaleLanguageType();
+}
+
+/*-- 11.02.2004 13:31:41---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SvtSysLocaleOptions::IsDecimalSeparatorAsLocale() const
+{
+ MutexGuard aGuard( GetMutex() );
+ return pOptions->IsDecimalSeparatorAsLocale();
+}
+/*-- 11.02.2004 13:31:41---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SvtSysLocaleOptions::SetDecimalSeparatorAsLocale( sal_Bool bSet)
+{
+ MutexGuard aGuard( GetMutex() );
+ pOptions->SetDecimalSeparatorAsLocale(bSet);
+}
+
+
+sal_Bool SvtSysLocaleOptions::IsReadOnly( EOption eOption ) const
+{
+ MutexGuard aGuard( GetMutex() );
+ return pOptions->IsReadOnly( eOption );
+}
+
+// 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
+::rtl::OUString SvtSysLocaleOptions::CreateCurrencyConfigString(
+ const String& rAbbrev, LanguageType eLang )
+{
+ String aIsoStr( MsLangId::convertLanguageToIsoString( eLang ) );
+ if ( aIsoStr.Len() )
+ {
+ ::rtl::OUStringBuffer aStr( rAbbrev.Len() + 1 + aIsoStr.Len() );
+ aStr.append( rAbbrev.GetBuffer(), rAbbrev.Len() );
+ aStr.append( sal_Unicode('-') );
+ aStr.append( aIsoStr.GetBuffer(), aIsoStr.Len() );
+ return aStr.makeStringAndClear();
+ }
+ else
+ return rAbbrev;
+}
+
+
+// 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();
+}
+
diff --git a/svl/source/filepicker/makefile.mk b/svl/source/filepicker/makefile.mk
new file mode 100644
index 000000000000..d00ac5170e1a
--- /dev/null
+++ b/svl/source/filepicker/makefile.mk
@@ -0,0 +1,51 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.12 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=svtools
+TARGET=filepicker
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/svl.pmk
+
+# --- Files --------------------------------------------------------------
+
+SLOFILES =\
+ $(SLO)$/pickerhelper.obj \
+ $(SLO)$/pickerhistory.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/svl/source/filepicker/pickerhelper.cxx b/svl/source/filepicker/pickerhelper.cxx
new file mode 100644
index 000000000000..0d8b2db9d8a0
--- /dev/null
+++ b/svl/source/filepicker/pickerhelper.cxx
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: pickerhelper.cxx,v $
+ * $Revision: 1.5 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include "pickerhelper.hxx"
+#include "rtl/ustring.hxx"
+#include "com/sun/star/ui/dialogs/XFilePicker.hpp"
+#include "com/sun/star/ui/dialogs/XFolderPicker.hpp"
+#include "com/sun/star/beans/XPropertySet.hpp"
+#include "com/sun/star/beans/XPropertySetInfo.hpp"
+#include "com/sun/star/uno/Any.hxx"
+#include "tools/debug.hxx"
+
+namespace css = com::sun::star;
+
+using css::uno::Reference;
+using rtl::OUString;
+
+namespace svt
+{
+ void SetDialogHelpId(
+ Reference < css::ui::dialogs::XFilePicker > _mxFileDlg, sal_Int32 _nHelpId )
+ {
+ try
+ {
+ // does the dialog haver a help URL property?
+ Reference< css::beans::XPropertySet > xDialogProps( _mxFileDlg, css::uno::UNO_QUERY );
+ Reference< css::beans::XPropertySetInfo > xInfo;
+ if( xDialogProps.is() )
+ xInfo = xDialogProps->getPropertySetInfo( );
+
+ const OUString sHelpURLPropertyName( RTL_CONSTASCII_USTRINGPARAM( "HelpURL" ) );
+
+ if( xInfo.is() && xInfo->hasPropertyByName( sHelpURLPropertyName ) )
+ { // yep
+ OUString sId( RTL_CONSTASCII_USTRINGPARAM( "HID:" ) );
+ sId += OUString::valueOf( _nHelpId );
+ xDialogProps->setPropertyValue( sHelpURLPropertyName, css::uno::makeAny( sId ) );
+ }
+ }
+ catch( const css::uno::Exception& )
+ {
+ DBG_ERROR( "svt::SetDialogHelpId(): caught an exception while setting the help id!" );
+ }
+ }
+
+ void SetDialogHelpId(
+ Reference< css::ui::dialogs::XFolderPicker > _mxFileDlg, sal_Int32 _nHelpId )
+ {
+ try
+ {
+ // does the dialog haver a help URL property?
+ Reference< css::beans::XPropertySet > xDialogProps( _mxFileDlg, css::uno::UNO_QUERY );
+ Reference< css::beans::XPropertySetInfo > xInfo;
+ if( xDialogProps.is() )
+ xInfo = xDialogProps->getPropertySetInfo( );
+
+ const OUString sHelpURLPropertyName( RTL_CONSTASCII_USTRINGPARAM( "HelpURL" ) );
+
+ if( xInfo.is() && xInfo->hasPropertyByName( sHelpURLPropertyName ) )
+ { // yep
+ OUString sId( RTL_CONSTASCII_USTRINGPARAM( "HID:" ) );
+ sId += OUString::valueOf( _nHelpId );
+ xDialogProps->setPropertyValue( sHelpURLPropertyName, css::uno::makeAny( sId ) );
+ }
+ }
+ catch( const css::uno::Exception& )
+ {
+ DBG_ERROR( "svt::SetDialogHelpId(): caught an exception while setting the help id!" );
+ }
+ }
+}
+
diff --git a/svl/source/filepicker/pickerhistory.cxx b/svl/source/filepicker/pickerhistory.cxx
new file mode 100644
index 000000000000..5bd584618f09
--- /dev/null
+++ b/svl/source/filepicker/pickerhistory.cxx
@@ -0,0 +1,141 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: pickerhistory.cxx,v $
+ * $Revision: 1.6 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include "pickerhistory.hxx"
+#include "pickerhistoryaccess.hxx"
+#include <cppuhelper/weakref.hxx>
+#include <vector>
+
+//.........................................................................
+namespace svt
+{
+//.........................................................................
+ using namespace ::com::sun::star::uno;
+
+ namespace
+ {
+ typedef ::com::sun::star::uno::WeakReference< XInterface > InterfaceAdapter;
+ typedef ::std::vector< InterfaceAdapter > InterfaceArray;
+
+ // ----------------------------------------------------------------
+ InterfaceArray& getFolderPickerHistory()
+ {
+ static InterfaceArray s_aHistory;
+ return s_aHistory;
+ }
+
+ // ----------------------------------------------------------------
+ InterfaceArray& getFilePickerHistory()
+ {
+ static InterfaceArray s_aHistory;
+ return s_aHistory;
+ }
+
+ // ----------------------------------------------------------------
+ void implPushBackPicker( InterfaceArray& _rHistory, const Reference< XInterface >& _rxPicker )
+ {
+ if ( !_rxPicker.is() )
+ return;
+
+ //=============================================================
+ // first, check which of the objects we hold in s_aHistory can be removed
+ {
+ InterfaceArray aCleanedHistory;
+ for ( InterfaceArray::const_iterator aLoop = _rHistory.begin();
+ aLoop != _rHistory.end();
+ ++aLoop
+ )
+ {
+ Reference< XInterface > xCurrent( aLoop->get() );
+ if ( xCurrent.is() )
+ {
+ if ( aCleanedHistory.empty() )
+ // make some room, assume that all interfaces (from here on) are valie
+ aCleanedHistory.reserve( _rHistory.size() - ( aLoop - _rHistory.begin() ) );
+ aCleanedHistory.push_back( InterfaceAdapter( xCurrent ) );
+ }
+ }
+ _rHistory.swap( aCleanedHistory );
+ }
+
+ //=============================================================
+ // then push_back the picker
+ _rHistory.push_back( InterfaceAdapter( _rxPicker ) );
+ }
+
+ //-----------------------------------------------------------------
+ Reference< XInterface > implGetTopMostPicker( const InterfaceArray& _rHistory )
+ {
+ Reference< XInterface > xTopMostAlive;
+
+ //=============================================================
+ // search the first picker which is still alive ...
+ for ( InterfaceArray::const_reverse_iterator aLoop = _rHistory.rbegin();
+ ( aLoop != _rHistory.rend() ) && !xTopMostAlive.is();
+ ++aLoop
+ )
+ {
+ xTopMostAlive = aLoop->get();
+ }
+
+ return xTopMostAlive;
+ }
+ }
+
+ //---------------------------------------------------------------------
+ Reference< XInterface > GetTopMostFolderPicker( )
+ {
+ return implGetTopMostPicker( getFolderPickerHistory() );
+ }
+
+ //---------------------------------------------------------------------
+ Reference< XInterface > GetTopMostFilePicker( )
+ {
+ return implGetTopMostPicker( getFilePickerHistory() );
+ }
+
+ //---------------------------------------------------------------------
+ void addFolderPicker( const Reference< XInterface >& _rxPicker )
+ {
+ implPushBackPicker( getFolderPickerHistory(), _rxPicker );
+ }
+
+ //---------------------------------------------------------------------
+ void addFilePicker( const Reference< XInterface >& _rxPicker )
+ {
+ implPushBackPicker( getFilePickerHistory(), _rxPicker );
+ }
+
+//.........................................................................
+} // namespace svt
+//.........................................................................
+
diff --git a/svl/source/filerec/filerec.cxx b/svl/source/filerec/filerec.cxx
new file mode 100644
index 000000000000..262e5135572a
--- /dev/null
+++ b/svl/source/filerec/filerec.cxx
@@ -0,0 +1,1019 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: filerec.cxx,v $
+ * $Revision: 1.13 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <svtools/filerec.hxx>
+#include <osl/endian.h>
+
+//========================================================================
+
+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;
+}
+
+//=========================================================================
+
+USHORT SfxMiniRecordReader::ScanRecordType
+(
+ SvStream* pStream /* <SvStream> an dessen aktueller Position
+ ein Record liegt, dessen Typ erkannt werden
+ soll.
+ */
+)
+
+/* [Beschreibung]
+
+ Mit dieser statischen Methode kann ermittelt werden, ob sich an der
+ aktuellen Position in einem Stream ein Record befindet, und der Typ
+ des Records kann ermittelt werden.
+
+ Die Position im Stream ist nach dem Aufruf aufver"andert.
+
+
+ [Anmerkung]
+
+ Die Record-Typen k"onnen zwar (abgesehen vom Drawing-Enginge-Record)
+ untereinander eindeutig erkannt werden, es besteht jedoch die Gefahr
+ der Verwechslung von Records mit normalen Daten. File-Formate sollten
+ darauf R"ucksicht nehmen. Handelt es sich um keinen Record, wird
+ am wahrscheinlichsten SFX_REC_TYPE_MINI zur"uckgeliefert, da dieser
+ Typ sich aufgrund seines sparsam kurzen Headers durch die k"urzeste
+ Kennung auszeichnet.
+
+
+ [R"uckgabewert]
+
+ USHORT SFX_REC_TYPE_EOR
+ An der aktuellen Position des Streams
+ steht eine End-Of-Records-Kennung.
+
+ SFX_REC_TYPE_MINI
+ Es handelt sich um einen SW3 kompatiblen
+ Mini-Record, dessen einzige Kennung sein
+ 'Mini-Tag' ist.
+
+ SFX_REC_TYPE_SINGLE
+ Es handelt sich um einen Extended-Record
+ mit einem einzigen Content, der durch eine
+ Version und ein Tag n"aher gekennzeichnet
+ ist.
+
+ SFX_REC_TYPE_FIXSIZE
+ Es handelt sich um einen Extended-Record
+ mit mehreren Contents gleicher Gr"o\se,
+ die gemeinsam durch eine einzige Version
+ und ein einziges gemeinsames Tag n"aher
+ gekennzeichnet sind.
+
+ SFX_REC_TYPE_VARSIZE
+ Es handelt sich um einen Extended-Record
+ mit mehreren Contents variabler Gr"o\se,
+ die gemeinsam durch eine einzige Version
+ und ein einziges gemeinsames Tag n"aher
+ gekennzeichnet sind.
+
+ SFX_REC_TYPE_MIXTAGS
+ Es handelt sich um einen Extended-Record
+ mit mehreren Contents variabler Gr"o\se,
+ die jeweils durch ein eignes Tag und
+ eine eigene Versions-Nummer n"aher
+ gekennzeichnet sind.
+
+ SFX_REC_TYPE_DRAWENG
+ Es handelt sich wahrscheinlich um einen
+ Drawing-Engine-Record. Dieser Record-Typ
+ kann von den Klassen dieser Gruppe nicht
+ interpretiert werden.
+*/
+
+{
+ // die ersten 4 Bytes als Mini-Header lesen
+ sal_uInt32 nHeader;
+ *pStream >> nHeader;
+
+ // k"onnte es sich um einen extended-Record handeln?
+ USHORT nPreTag = sal::static_int_cast< USHORT >(SFX_REC_PRE(nHeader));
+ if ( SFX_REC_PRETAG_EXT == nPreTag )
+ {
+ // die n"achsten 4 Bytes als extended-Header lesen
+ *pStream >> nHeader;
+
+ // Stream-Position restaurieren
+ pStream->SeekRel(-8);
+
+ // liegt eine g"ultige Record-Kennung vor?
+ USHORT nType = sal::static_int_cast< USHORT >(SFX_REC_TYP(nHeader));
+ if ( nType >= SFX_REC_TYPE_FIRST && nType <= SFX_REC_TYPE_LAST )
+ // entsprechenden extended-Record-Typ zur"uckliefern
+ return nType;
+
+ // sonst ist der Record-Typ unbekannt
+ return SFX_REC_TYPE_NONE;
+ }
+
+ // Stream-Position restaurieren
+ pStream->SeekRel(-4);
+
+ // liegt eine End-Of-Record-Kennung vor?
+ if ( SFX_REC_PRETAG_EOR == nPreTag )
+ return nPreTag;
+
+ // liegt ein Drawin-Engine-Record vor?
+ if ( nHeader == UINT32(*"DRMD") || nHeader == UINT32(*"DRVW") )
+ return SFX_REC_TYPE_DRAWENG;
+
+ // alle anderen sind grunds"atzlich g"ultige Mini-Records
+ return SFX_REC_TYPE_MINI;
+}
+
+//-------------------------------------------------------------------------
+
+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.
+ */
+)
+
+/* [Beschreibung]
+
+ Dieser Ctor liest den Header eines <SfxMiniRecord> ab der aktuellen
+ Position von 'pStream'. Da grunds"atzlich fast 4-Byte Kombination ein
+ g"ultiger SfxMiniRecord-Header ist, bleiben die einzig m"oglichen
+ Fehler der EOF-Status des Streams, und ein SFX_REC_PRETAG_EOR
+ als Pre-Tag. Ein entsprechender Error-Code (ERRCODE_IO_EOF bzw.
+ ERRCODE_IO_WRONGFORMAT) ist dann am Stream gesetzt, dessen Position
+ dann au\serdem unver"andert ist.
+*/
+
+: _pStream( pStream ),
+ _bSkipped( FALSE )
+{
+ // Header einlesen
+ UINT32 nStartPos = pStream->Tell(); // um im Fehlerfall zur"uck zu-seeken
+ DBG( DbgOutf( "SfxFileRec: reading record at %ul", nStartPos ) );
+ UINT32 nHeader;
+ *pStream >> nHeader;
+
+ // Headerdaten extrahieren
+ SetHeader_Impl( nHeader );
+
+ // Fehlerbehandlung
+ if ( pStream->IsEof() )
+ _nPreTag = SFX_REC_PRETAG_EOR;
+ else if ( _nPreTag == SFX_REC_PRETAG_EOR )
+ pStream->SetError( ERRCODE_IO_WRONGFORMAT );
+ if ( !IsValid() )
+ pStream->Seek( nStartPos );
+}
+
+//-------------------------------------------------------------------------
+
+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);
+}
+
+//-------------------------------------------------------------------------
+
+SfxSingleRecordWriter::SfxSingleRecordWriter
+(
+ SvStream* pStream, // Stream, in dem der Record angelegt wird
+ UINT16 nContentTag, // Inhalts-Art-Kennung
+ BYTE nContentVer, // Inhalts-Versions-Kennung
+ UINT32 nContentSize // Gr"o\se des Inhalts in Bytes
+)
+
+/* [Beschreibung]
+
+ Legt in 'pStream' einen 'SfxSingleRecord' an, dessen Content-Gr"o\se
+ von vornherein bekannt ist.
+*/
+
+: SfxMiniRecordWriter( pStream, SFX_REC_PRETAG_EXT,
+ nContentSize + SFX_REC_HEADERSIZE_SINGLE )
+{
+ // Erweiterten Header hinter 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 )
+: SfxMiniRecordReader()
+{
+ // Startposition merken, um im Fehlerfall zur"uck-seeken zu k"onnen
+ #ifdef DBG_UTIL
+ UINT32 nStartPos = pStream->Tell();
+ DBG( DbgOutf( "SfxFileRec: reading record at %ul", nStartPos ) );
+ #endif
+
+ // Basisklasse initialisieren (nicht via Ctor, da der nur MiniRecs akzept.)
+ Construct_Impl( pStream );
+
+ // nur Header mit korrektem Record-Type akzeptieren
+ if ( !ReadHeader_Impl( SFX_REC_TYPE_SINGLE ) )
+ {
+ // Error-Code setzen und zur"uck-seeken
+ pStream->SeekRel( - SFX_REC_HEADERSIZE_SINGLE );
+ pStream->SetError( ERRCODE_IO_WRONGFORMAT );
+ }
+}
+
+//-------------------------------------------------------------------------
+
+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 );
+}
+
+//------------------------------------------------------------------------
+
+SfxMultiFixRecordWriter::SfxMultiFixRecordWriter
+(
+ 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]
+
+ Legt in 'pStream' einen 'SfxMultiFixRecord' an, dessen Content-Gr"o\se
+ konstant und von vornherein bekannt ist.
+*/
+
+: SfxSingleRecordWriter( SFX_REC_TYPE_FIXSIZE,
+ 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 )
+: _pContentOfs( NULL ), _nContentNo(0)
+{
+ // Position im Stream merken, um im Fehlerfall zur"uck-seeken zu k"onnen
+ _nStartPos = pStream->Tell();
+
+ // Basisklasse konstruieren (normaler Ctor w"urde nur SingleRecs lesen)
+ SfxSingleRecordReader::Construct_Impl( pStream );
+
+ // Header der Basisklasse lesen
+ if ( !SfxSingleRecordReader::ReadHeader_Impl( SFX_REC_TYPE_FIXSIZE |
+ SFX_REC_TYPE_VARSIZE | SFX_REC_TYPE_VARSIZE_RELOC |
+ SFX_REC_TYPE_MIXTAGS | SFX_REC_TYPE_MIXTAGS_RELOC ) ||
+ !ReadHeader_Impl() )
+ // als ung"ultig markieren und zur"uck-seeken
+ SetInvalid_Impl( _nStartPos );
+}
+
+//-------------------------------------------------------------------------
+
+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;
+}
+
+
diff --git a/svl/source/filerec/makefile.mk b/svl/source/filerec/makefile.mk
new file mode 100644
index 000000000000..33e4b4923183
--- /dev/null
+++ b/svl/source/filerec/makefile.mk
@@ -0,0 +1,50 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.6 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=svtools
+TARGET=filerec
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/svl.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/filerec.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/svl/source/fsstor/exports.map b/svl/source/fsstor/exports.map
new file mode 100644
index 000000000000..f4ed78b9e970
--- /dev/null
+++ b/svl/source/fsstor/exports.map
@@ -0,0 +1,8 @@
+UDK_3_0_0 {
+ global:
+ component_getImplementationEnvironment;
+ component_writeInfo;
+ component_getFactory;
+ local:
+ *;
+};
diff --git a/svl/source/fsstor/fsfactory.cxx b/svl/source/fsstor/fsfactory.cxx
new file mode 100644
index 000000000000..33df962be846
--- /dev/null
+++ b/svl/source/fsstor/fsfactory.cxx
@@ -0,0 +1,295 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: fsfactory.cxx,v $
+ * $Revision: 1.10 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include "fsfactory.hxx"
+#include "cppuhelper/factory.hxx"
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+
+
+#include <ucbhelper/fileidentifierconverter.hxx>
+#include <ucbhelper/contentbroker.hxx>
+#include <ucbhelper/content.hxx>
+
+#include <unotools/tempfile.hxx>
+#include <unotools/ucbhelper.hxx>
+
+#include "fsstorage.hxx"
+
+
+using namespace ::com::sun::star;
+
+//-------------------------------------------------------------------------
+uno::Sequence< ::rtl::OUString > SAL_CALL FSStorageFactory::impl_staticGetSupportedServiceNames()
+{
+ uno::Sequence< ::rtl::OUString > aRet(2);
+ aRet[0] = ::rtl::OUString::createFromAscii("com.sun.star.embed.FileSystemStorageFactory");
+ aRet[1] = ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.FileSystemStorageFactory");
+ return aRet;
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString SAL_CALL FSStorageFactory::impl_staticGetImplementationName()
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.FileSystemStorageFactory");
+}
+
+//-------------------------------------------------------------------------
+uno::Reference< uno::XInterface > SAL_CALL FSStorageFactory::impl_staticCreateSelfInstance(
+ const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
+{
+ return uno::Reference< uno::XInterface >( *new FSStorageFactory( xServiceManager ) );
+}
+
+//-------------------------------------------------------------------------
+uno::Reference< uno::XInterface > SAL_CALL FSStorageFactory::createInstance()
+ throw ( uno::Exception,
+ uno::RuntimeException )
+{
+ ::rtl::OUString aTempURL;
+
+ aTempURL = ::utl::TempFile( NULL, sal_True ).GetURL();
+
+ if ( !aTempURL.getLength() )
+ throw uno::RuntimeException(); // TODO: can not create tempfile
+
+ ::ucbhelper::Content aResultContent(
+ aTempURL, uno::Reference< ucb::XCommandEnvironment >() );
+
+ return uno::Reference< uno::XInterface >(
+ static_cast< OWeakObject* >(
+ new FSStorage( aResultContent,
+ embed::ElementModes::READWRITE,
+ uno::Sequence< beans::PropertyValue >(),
+ m_xFactory ) ),
+ uno::UNO_QUERY );
+}
+
+//-------------------------------------------------------------------------
+uno::Reference< uno::XInterface > SAL_CALL FSStorageFactory::createInstanceWithArguments(
+ const uno::Sequence< uno::Any >& aArguments )
+ throw ( uno::Exception,
+ uno::RuntimeException )
+{
+ // The request for storage can be done with up to three arguments
+
+ // The first argument specifies a source for the storage
+ // it must be URL.
+ // The second value is a mode the storage should be open in.
+ // And the third value is a media descriptor.
+
+ sal_Int32 nArgNum = aArguments.getLength();
+ OSL_ENSURE( nArgNum < 4, "Wrong parameter number" );
+
+ if ( !nArgNum )
+ return createInstance();
+
+ // first try to retrieve storage open mode if any
+ // by default the storage will be open in readonly mode
+ sal_Int32 nStorageMode = embed::ElementModes::READ;
+ if ( nArgNum >= 2 )
+ {
+ if( !( aArguments[1] >>= nStorageMode ) )
+ {
+ OSL_ENSURE( sal_False, "Wrong second argument!\n" );
+ throw uno::Exception(); // TODO: Illegal argument
+ }
+ // it's allways possible to read written storage in this implementation
+ nStorageMode |= embed::ElementModes::READ;
+ }
+
+ // retrieve storage source URL
+ ::rtl::OUString aURL;
+
+ if ( aArguments[0] >>= aURL )
+ {
+ if ( !aURL.getLength() )
+ {
+ OSL_ENSURE( sal_False, "Empty URL is provided!\n" );
+ throw uno::Exception(); // TODO: illegal argument
+ }
+ }
+ else
+ {
+ OSL_ENSURE( sal_False, "Wrong first argument!\n" );
+ throw uno::Exception(); // TODO: Illegal argument
+ }
+
+ // retrieve mediadescriptor and set storage properties
+ uno::Sequence< beans::PropertyValue > aDescr;
+ uno::Sequence< beans::PropertyValue > aPropsToSet;
+
+ if ( nArgNum >= 3 )
+ {
+ if( aArguments[2] >>= aDescr )
+ {
+ aPropsToSet.realloc(1);
+ aPropsToSet[0].Name = ::rtl::OUString::createFromAscii( "URL" );
+ aPropsToSet[0].Value <<= aURL;
+
+ for ( sal_Int32 nInd = 0, nNumArgs = 1; nInd < aDescr.getLength(); nInd++ )
+ {
+ if ( aDescr[nInd].Name.equalsAscii( "InteractionHandler" ) )
+ {
+ aPropsToSet.realloc( ++nNumArgs );
+ aPropsToSet[nNumArgs-1].Name = aDescr[nInd].Name;
+ aPropsToSet[nNumArgs-1].Value = aDescr[nInd].Value;
+ break;
+ }
+ else
+ OSL_ENSURE( sal_False, "Unacceptable property, will be ignored!\n" );
+ }
+ }
+ else
+ {
+ OSL_ENSURE( sal_False, "Wrong third argument!\n" );
+ throw uno::Exception(); // TODO: Illegal argument
+ }
+ }
+
+ // allow to use other ucp's
+ // if ( !isLocalNotFile_Impl( aURL ) )
+ if ( aURL.equalsIgnoreAsciiCaseAsciiL( "vnd.sun.star.pkg", 16 )
+ || aURL.equalsIgnoreAsciiCaseAsciiL( "vnd.sun.star.zip", 16 )
+ || ::utl::UCBContentHelper::IsDocument( aURL ) )
+ {
+ OSL_ENSURE( sal_False, "File system storages can be based only on file URLs!\n" ); // ???
+ throw uno::Exception(); // TODO: illegal argument
+ }
+
+ if ( ( nStorageMode & embed::ElementModes::WRITE ) && !( nStorageMode & embed::ElementModes::NOCREATE ) )
+ FSStorage::MakeFolderNoUI( aURL, sal_False );
+ else if ( !::utl::UCBContentHelper::IsFolder( aURL ) )
+ throw io::IOException(); // there is no such folder
+
+ ::ucbhelper::Content aResultContent(
+ aURL, uno::Reference< ucb::XCommandEnvironment >() );
+
+ // create storage based on source
+ return uno::Reference< uno::XInterface >(
+ static_cast< OWeakObject* >( new FSStorage( aResultContent,
+ nStorageMode,
+ aPropsToSet,
+ m_xFactory ) ),
+ uno::UNO_QUERY );
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString SAL_CALL FSStorageFactory::getImplementationName()
+ throw ( uno::RuntimeException )
+{
+ return impl_staticGetImplementationName();
+}
+
+//-------------------------------------------------------------------------
+sal_Bool SAL_CALL FSStorageFactory::supportsService( const ::rtl::OUString& ServiceName )
+ throw ( uno::RuntimeException )
+{
+ uno::Sequence< ::rtl::OUString > aSeq = impl_staticGetSupportedServiceNames();
+
+ for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
+ if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
+ return sal_True;
+
+ return sal_False;
+}
+
+//-------------------------------------------------------------------------
+uno::Sequence< ::rtl::OUString > SAL_CALL FSStorageFactory::getSupportedServiceNames()
+ throw ( uno::RuntimeException )
+{
+ return impl_staticGetSupportedServiceNames();
+}
+
+//-------------------------------------------------------------------------
+
+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)
+ {
+ uno::Reference< registry::XRegistryKey > xRegistryKey (
+ reinterpret_cast< registry::XRegistryKey*>(pRegistryKey));
+
+ uno::Reference< registry::XRegistryKey > xNewKey;
+ xNewKey = xRegistryKey->createKey(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
+ FSStorageFactory::impl_staticGetImplementationName() +
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES")));
+
+ const uno::Sequence< ::rtl::OUString > aServices (
+ FSStorageFactory::impl_staticGetSupportedServiceNames());
+ for( sal_Int32 i = 0; i < aServices.getLength(); i++ )
+ xNewKey->createKey( aServices.getConstArray()[i] );
+
+ 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)
+ {
+ uno::Reference< lang::XSingleServiceFactory > xFactory;
+ if (FSStorageFactory::impl_staticGetImplementationName().compareToAscii (pImplementationName) == 0)
+ {
+ xFactory = cppu::createOneInstanceFactory (
+ reinterpret_cast< lang::XMultiServiceFactory* >(pServiceManager),
+ FSStorageFactory::impl_staticGetImplementationName(),
+ FSStorageFactory::impl_staticCreateSelfInstance,
+ FSStorageFactory::impl_staticGetSupportedServiceNames() );
+ }
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pResult = xFactory.get();
+ }
+ }
+ return pResult;
+}
+
+} // extern "C"
+
diff --git a/svl/source/fsstor/fsstorage.cxx b/svl/source/fsstor/fsstorage.cxx
new file mode 100644
index 000000000000..cec018533a9a
--- /dev/null
+++ b/svl/source/fsstor/fsstorage.cxx
@@ -0,0 +1,1617 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: fsstorage.cxx,v $
+ * $Revision: 1.11 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/ucb/XProgressHandler.hpp>
+#include <com/sun/star/ucb/XContentAccess.hpp>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+
+#ifndef _COM_SUN_STAR_UCB_INTERACTIVEIODEXCEPTION_HPP_
+#include <com/sun/star/ucb/InteractiveIOException.hpp>
+#endif
+#include <com/sun/star/ucb/IOErrorCode.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/util/XChangesBatch.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
+#include <com/sun/star/io/IOException.hpp>
+#include <com/sun/star/io/XTruncate.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+
+
+#ifndef _COMPHELPER_PROCESSFACTORY_HXX
+#include <comphelper/processfactory.hxx>
+#endif
+#include <comphelper/storagehelper.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+
+#include <tools/urlobj.hxx>
+#include <unotools/ucbhelper.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/streamwrap.hxx>
+#include <ucbhelper/fileidentifierconverter.hxx>
+#include <ucbhelper/contentbroker.hxx>
+#include <ucbhelper/content.hxx>
+
+#include "fsstorage.hxx"
+#include "oinputstreamcontainer.hxx"
+#include "ostreamcontainer.hxx"
+
+using namespace ::com::sun::star;
+
+//=========================================================
+
+// TODO: move to a standard helper
+sal_Bool isLocalFile_Impl( ::rtl::OUString aURL )
+{
+ ::rtl::OUString aSystemPath;
+ ::ucbhelper::ContentBroker* pBroker = ::ucbhelper::ContentBroker::get();
+ if ( !pBroker )
+ throw uno::RuntimeException();
+
+ uno::Reference< ucb::XContentProviderManager > xManager =
+ pBroker->getContentProviderManagerInterface();
+ try
+ {
+ aSystemPath = ::ucbhelper::getSystemPathFromFileURL( xManager, aURL );
+ }
+ catch ( uno::Exception& )
+ {
+ }
+
+ return ( aSystemPath.getLength() != 0 );
+}
+
+
+//=========================================================
+
+struct FSStorage_Impl
+{
+ ::rtl::OUString m_aURL;
+
+ ::ucbhelper::Content* m_pContent;
+ sal_Int32 m_nMode;
+
+ ::cppu::OInterfaceContainerHelper* m_pListenersContainer; // list of listeners
+ ::cppu::OTypeCollection* m_pTypeCollection;
+
+ uno::Reference< lang::XMultiServiceFactory > m_xFactory;
+
+
+ FSStorage_Impl( const ::rtl::OUString& aURL, sal_Int32 nMode, uno::Reference< lang::XMultiServiceFactory > xFactory )
+ : m_aURL( aURL )
+ , m_pContent( NULL )
+ , m_nMode( nMode )
+ , m_pListenersContainer( NULL )
+ , m_pTypeCollection( NULL )
+ , m_xFactory( xFactory )
+ {
+ OSL_ENSURE( m_aURL.getLength(), "The URL must not be empty" );
+ }
+
+ FSStorage_Impl( const ::ucbhelper::Content& aContent, sal_Int32 nMode, uno::Reference< lang::XMultiServiceFactory > xFactory )
+ : m_aURL( aContent.getURL() )
+ , m_pContent( new ::ucbhelper::Content( aContent ) )
+ , m_nMode( nMode )
+ , m_pListenersContainer( NULL )
+ , m_pTypeCollection( NULL )
+ , m_xFactory( xFactory )
+ {
+ OSL_ENSURE( m_aURL.getLength(), "The URL must not be empty" );
+ }
+
+ ~FSStorage_Impl();
+};
+
+//=========================================================
+
+FSStorage_Impl::~FSStorage_Impl()
+{
+ if ( m_pListenersContainer )
+ delete m_pListenersContainer;
+ if ( m_pTypeCollection )
+ delete m_pTypeCollection;
+ if ( m_pContent )
+ delete m_pContent;
+}
+
+//=====================================================
+// FSStorage implementation
+//=====================================================
+
+//-----------------------------------------------
+FSStorage::FSStorage( const ::ucbhelper::Content& aContent,
+ sal_Int32 nMode,
+ uno::Sequence< beans::PropertyValue >,
+ uno::Reference< lang::XMultiServiceFactory > xFactory )
+: m_pImpl( new FSStorage_Impl( aContent, nMode, xFactory ) )
+{
+ // TODO: use properties
+ if ( !xFactory.is() )
+ throw uno::RuntimeException();
+
+ GetContent();
+}
+
+//-----------------------------------------------
+FSStorage::~FSStorage()
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_refCount++; // to call dispose
+ try {
+ dispose();
+ }
+ catch( uno::RuntimeException& )
+ {}
+ }
+}
+
+//-----------------------------------------------
+sal_Bool FSStorage::MakeFolderNoUI( const String& rFolder, sal_Bool )
+{
+ INetURLObject aURL( rFolder );
+ ::rtl::OUString aTitle = aURL.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
+ aURL.removeSegment();
+ ::ucbhelper::Content aParent;
+ ::ucbhelper::Content aResultContent;
+
+ if ( ::ucbhelper::Content::create( aURL.GetMainURL( INetURLObject::NO_DECODE ),
+ uno::Reference< ucb::XCommandEnvironment >(),
+ aParent ) )
+ return ::utl::UCBContentHelper::MakeFolder( aParent, aTitle, aResultContent, sal_False );
+
+ return sal_False;
+}
+
+//-----------------------------------------------
+::ucbhelper::Content* FSStorage::GetContent()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_pImpl->m_pContent )
+ {
+ uno::Reference< ucb::XCommandEnvironment > xDummyEnv;
+
+ try
+ {
+ m_pImpl->m_pContent = new ::ucbhelper::Content( m_pImpl->m_aURL, xDummyEnv );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+
+ return m_pImpl->m_pContent;
+}
+
+//-----------------------------------------------
+void FSStorage::CopyStreamToSubStream( const ::rtl::OUString& aSourceURL,
+ const uno::Reference< embed::XStorage >& xDest,
+ const ::rtl::OUString& aNewEntryName )
+{
+ if ( !xDest.is() )
+ throw uno::RuntimeException();
+
+ uno::Reference< ucb::XCommandEnvironment > xDummyEnv;
+ ::ucbhelper::Content aSourceContent( aSourceURL, xDummyEnv );
+ uno::Reference< io::XInputStream > xSourceInput = aSourceContent.openStream();
+
+ if ( !xSourceInput.is() )
+ throw io::IOException(); // TODO: error handling
+
+ uno::Reference< io::XStream > xSubStream = xDest->openStreamElement(
+ aNewEntryName,
+ embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
+ if ( !xSubStream.is() )
+ throw uno::RuntimeException();
+
+ uno::Reference< io::XOutputStream > xDestOutput = xSubStream->getOutputStream();
+ if ( !xDestOutput.is() )
+ throw uno::RuntimeException();
+
+ ::comphelper::OStorageHelper::CopyInputToOutput( xSourceInput, xDestOutput );
+ xDestOutput->closeOutput();
+}
+
+//-----------------------------------------------
+void FSStorage::CopyContentToStorage_Impl( ::ucbhelper::Content* pContent, const uno::Reference< embed::XStorage >& xDest )
+{
+ if ( !pContent )
+ throw uno::RuntimeException();
+
+ // get list of contents of the Content
+ // create cursor for access to children
+ uno::Sequence< ::rtl::OUString > aProps( 2 );
+ ::rtl::OUString* pProps = aProps.getArray();
+ pProps[0] = ::rtl::OUString::createFromAscii( "TargetURL" );
+ pProps[1] = ::rtl::OUString::createFromAscii( "IsFolder" );
+ ::ucbhelper::ResultSetInclude eInclude = ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS;
+
+ try
+ {
+ uno::Reference< sdbc::XResultSet > xResultSet = pContent->createCursor( aProps, eInclude );
+ uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY );
+ uno::Reference< sdbc::XRow > xRow( xResultSet, uno::UNO_QUERY );
+ if ( xResultSet.is() )
+ {
+ // go through the list: insert files as streams, insert folders as substorages using recursion
+ while ( xResultSet->next() )
+ {
+ ::rtl::OUString aSourceURL( xRow->getString( 1 ) );
+ sal_Bool bIsFolder( xRow->getBoolean(2) );
+
+ // TODO/LATER: not sure whether the entry name must be encoded
+ ::rtl::OUString aNewEntryName( INetURLObject( aSourceURL ).getName( INetURLObject::LAST_SEGMENT,
+ true,
+ INetURLObject::NO_DECODE ) );
+ if ( bIsFolder )
+ {
+ uno::Reference< embed::XStorage > xSubStorage = xDest->openStorageElement( aNewEntryName,
+ embed::ElementModes::READWRITE );
+ if ( !xSubStorage.is() )
+ throw uno::RuntimeException();
+
+ uno::Reference< ucb::XCommandEnvironment > xDummyEnv;
+ ::ucbhelper::Content aSourceContent( aSourceURL, xDummyEnv );
+ CopyContentToStorage_Impl( &aSourceContent, xSubStorage );
+ }
+ else
+ {
+ CopyStreamToSubStream( aSourceURL, xDest, aNewEntryName );
+ }
+ }
+ }
+
+ uno::Reference< embed::XTransactedObject > xTransact( xDest, uno::UNO_QUERY );
+ if ( xTransact.is() )
+ xTransact->commit();
+ }
+ catch( ucb::InteractiveIOException& r )
+ {
+ if ( r.Code == ucb::IOErrorCode_NOT_EXISTING )
+ OSL_ENSURE( sal_False, "The folder does not exist!\n" );
+ else
+ throw;
+ }
+}
+
+//____________________________________________________________________________________________________
+// XInterface
+//____________________________________________________________________________________________________
+
+//-----------------------------------------------
+uno::Any SAL_CALL FSStorage::queryInterface( const uno::Type& rType )
+ throw( uno::RuntimeException )
+{
+ uno::Any aReturn;
+ aReturn <<= ::cppu::queryInterface
+ ( rType
+ , static_cast<lang::XTypeProvider*> ( this )
+ , static_cast<embed::XStorage*> ( this )
+ , static_cast<embed::XHierarchicalStorageAccess*> ( this )
+ , static_cast<container::XNameAccess*> ( this )
+ , static_cast<container::XElementAccess*> ( this )
+ , static_cast<lang::XComponent*> ( this )
+ , static_cast<beans::XPropertySet*> ( this ) );
+
+ if ( aReturn.hasValue() == sal_True )
+ return aReturn ;
+
+ return OWeakObject::queryInterface( rType );
+}
+
+//-----------------------------------------------
+void SAL_CALL FSStorage::acquire() throw()
+{
+ OWeakObject::acquire();
+}
+
+//-----------------------------------------------
+void SAL_CALL FSStorage::release() throw()
+{
+ OWeakObject::release();
+}
+
+//____________________________________________________________________________________________________
+// XTypeProvider
+//____________________________________________________________________________________________________
+
+//-----------------------------------------------
+uno::Sequence< uno::Type > SAL_CALL FSStorage::getTypes()
+ throw( uno::RuntimeException )
+{
+ if ( m_pImpl->m_pTypeCollection == NULL )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_pImpl->m_pTypeCollection == NULL )
+ {
+ m_pImpl->m_pTypeCollection = new ::cppu::OTypeCollection
+ ( ::getCppuType( ( const uno::Reference< lang::XTypeProvider >* )NULL )
+ , ::getCppuType( ( const uno::Reference< embed::XStorage >* )NULL )
+ , ::getCppuType( ( const uno::Reference< embed::XHierarchicalStorageAccess >* )NULL )
+ , ::getCppuType( ( const uno::Reference< beans::XPropertySet >* )NULL ) );
+ }
+ }
+
+ return m_pImpl->m_pTypeCollection->getTypes() ;
+}
+
+//-----------------------------------------------
+uno::Sequence< sal_Int8 > SAL_CALL FSStorage::getImplementationId()
+ throw( uno::RuntimeException )
+{
+ static ::cppu::OImplementationId* pID = NULL ;
+
+ if ( pID == NULL )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ) ;
+
+ if ( pID == NULL )
+ {
+ static ::cppu::OImplementationId aID( sal_False ) ;
+ pID = &aID ;
+ }
+ }
+
+ return pID->getImplementationId() ;
+
+}
+
+//____________________________________________________________________________________________________
+// XStorage
+//____________________________________________________________________________________________________
+
+//-----------------------------------------------
+void SAL_CALL FSStorage::copyToStorage( const uno::Reference< embed::XStorage >& xDest )
+ throw ( embed::InvalidStorageException,
+ io::IOException,
+ lang::IllegalArgumentException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( !xDest.is() || xDest == uno::Reference< uno::XInterface >( static_cast< OWeakObject*> ( this ), uno::UNO_QUERY ) )
+ throw lang::IllegalArgumentException(); // TODO:
+
+ if ( !GetContent() )
+ throw io::IOException(); // TODO: error handling
+
+ try
+ {
+ CopyContentToStorage_Impl( GetContent(), xDest );
+ }
+ catch( embed::InvalidStorageException& )
+ {
+ throw;
+ }
+ catch( lang::IllegalArgumentException& )
+ {
+ throw;
+ }
+ catch( embed::StorageWrappedTargetException& )
+ {
+ throw;
+ }
+ catch( io::IOException& )
+ {
+ throw;
+ }
+ catch( uno::RuntimeException& )
+ {
+ throw;
+ }
+ catch( uno::Exception& )
+ {
+ uno::Any aCaught( ::cppu::getCaughtException() );
+ throw embed::StorageWrappedTargetException( ::rtl::OUString::createFromAscii( "Can't copy raw stream" ),
+ uno::Reference< io::XInputStream >(),
+ aCaught );
+ }
+}
+
+//-----------------------------------------------
+uno::Reference< io::XStream > SAL_CALL FSStorage::openStreamElement(
+ const ::rtl::OUString& aStreamName, sal_Int32 nOpenMode )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ packages::WrongPasswordException,
+ io::IOException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( !GetContent() )
+ throw io::IOException(); // TODO: error handling
+
+ // TODO/LATER: may need possibility to create folder if it was removed, since the folder can not be locked
+ INetURLObject aFileURL( m_pImpl->m_aURL );
+ aFileURL.Append( aStreamName );
+
+ if ( ::utl::UCBContentHelper::IsFolder( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ throw io::IOException();
+
+ if ( ( nOpenMode & embed::ElementModes::NOCREATE )
+ && !::utl::UCBContentHelper::IsDocument( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ throw io::IOException(); // TODO:
+
+ uno::Reference< ucb::XCommandEnvironment > xDummyEnv; // TODO: provide InteractionHandler if any
+ uno::Reference< io::XStream > xResult;
+ try
+ {
+ if ( nOpenMode & embed::ElementModes::WRITE )
+ {
+ if ( isLocalFile_Impl( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ {
+ uno::Reference< ucb::XSimpleFileAccess > xSimpleFileAccess(
+ m_pImpl->m_xFactory->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.SimpleFileAccess" ) ) ),
+ uno::UNO_QUERY_THROW );
+ xResult = xSimpleFileAccess->openFileReadWrite( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) );
+ }
+ else
+ {
+ // TODO: test whether it really works for http and fwp
+ SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aFileURL.GetMainURL( INetURLObject::NO_DECODE ),
+ STREAM_STD_WRITE );
+ if ( pStream )
+ {
+ if ( !pStream->GetError() )
+ xResult = uno::Reference < io::XStream >( new ::utl::OStreamWrapper( *pStream ) );
+ else
+ delete pStream;
+ }
+ }
+
+ if ( !xResult.is() )
+ throw io::IOException();
+
+ if ( ( nOpenMode & embed::ElementModes::TRUNCATE ) )
+ {
+ uno::Reference< io::XTruncate > xTrunc( xResult->getOutputStream(), uno::UNO_QUERY_THROW );
+ xTrunc->truncate();
+ }
+ }
+ else
+ {
+ if ( ( nOpenMode & embed::ElementModes::TRUNCATE )
+ || !::utl::UCBContentHelper::IsDocument( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ throw io::IOException(); // TODO: access denied
+
+ ::ucbhelper::Content aResultContent( aFileURL.GetMainURL( INetURLObject::NO_DECODE ), xDummyEnv );
+ uno::Reference< io::XInputStream > xInStream = aResultContent.openStream();
+ xResult = static_cast< io::XStream* >( new OFSInputStreamContainer( xInStream ) );
+ }
+ }
+ catch( embed::InvalidStorageException& )
+ {
+ throw;
+ }
+ catch( lang::IllegalArgumentException& )
+ {
+ throw;
+ }
+ catch( packages::WrongPasswordException& )
+ {
+ throw;
+ }
+ catch( embed::StorageWrappedTargetException& )
+ {
+ throw;
+ }
+ catch( io::IOException& )
+ {
+ throw;
+ }
+ catch( uno::RuntimeException& )
+ {
+ throw;
+ }
+ catch( uno::Exception& )
+ {
+ uno::Any aCaught( ::cppu::getCaughtException() );
+ throw embed::StorageWrappedTargetException( ::rtl::OUString::createFromAscii( "Can't copy raw stream" ),
+ uno::Reference< io::XInputStream >(),
+ aCaught );
+ }
+
+ return xResult;
+}
+
+//-----------------------------------------------
+uno::Reference< io::XStream > SAL_CALL FSStorage::openEncryptedStreamElement(
+ const ::rtl::OUString&, sal_Int32, const ::rtl::OUString& )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ packages::NoEncryptionException,
+ packages::WrongPasswordException,
+ io::IOException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
+ throw packages::NoEncryptionException();
+}
+
+//-----------------------------------------------
+uno::Reference< embed::XStorage > SAL_CALL FSStorage::openStorageElement(
+ const ::rtl::OUString& aStorName, sal_Int32 nStorageMode )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ io::IOException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( !GetContent() )
+ throw io::IOException(); // TODO: error handling
+
+ if ( ( nStorageMode & embed::ElementModes::WRITE )
+ && !( m_pImpl->m_nMode & embed::ElementModes::WRITE ) )
+ throw io::IOException(); // TODO: error handling
+
+ // TODO/LATER: may need possibility to create folder if it was removed, since the folder can not be locked
+ INetURLObject aFolderURL( m_pImpl->m_aURL );
+ aFolderURL.Append( aStorName );
+
+ sal_Bool bFolderExists = ::utl::UCBContentHelper::IsFolder( aFolderURL.GetMainURL( INetURLObject::NO_DECODE ) );
+ if ( !bFolderExists && ::utl::UCBContentHelper::IsDocument( aFolderURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ throw io::IOException(); // TODO:
+
+ if ( ( nStorageMode & embed::ElementModes::NOCREATE ) && !bFolderExists )
+ throw io::IOException(); // TODO:
+
+ uno::Reference< ucb::XCommandEnvironment > xDummyEnv; // TODO: provide InteractionHandler if any
+ uno::Reference< embed::XStorage > xResult;
+ try
+ {
+ if ( nStorageMode & embed::ElementModes::WRITE )
+ {
+ if ( ( nStorageMode & embed::ElementModes::TRUNCATE ) && bFolderExists )
+ {
+ ::utl::UCBContentHelper::Kill( aFolderURL.GetMainURL( INetURLObject::NO_DECODE ) );
+ bFolderExists =
+ MakeFolderNoUI( aFolderURL.GetMainURL( INetURLObject::NO_DECODE ), sal_True ); // TODO: not atomar :(
+ }
+ else if ( !bFolderExists )
+ {
+ bFolderExists =
+ MakeFolderNoUI( aFolderURL.GetMainURL( INetURLObject::NO_DECODE ), sal_True ); // TODO: not atomar :(
+ }
+ }
+ else if ( ( nStorageMode & embed::ElementModes::TRUNCATE ) )
+ throw io::IOException(); // TODO: access denied
+
+ if ( !bFolderExists )
+ throw io::IOException(); // there is no such folder
+
+ ::ucbhelper::Content aResultContent( aFolderURL.GetMainURL( INetURLObject::NO_DECODE ), xDummyEnv );
+ xResult = uno::Reference< embed::XStorage >(
+ static_cast< OWeakObject* >( new FSStorage( aResultContent,
+ nStorageMode,
+ uno::Sequence< beans::PropertyValue >(),
+ m_pImpl->m_xFactory ) ),
+ uno::UNO_QUERY );
+ }
+ catch( embed::InvalidStorageException& )
+ {
+ throw;
+ }
+ catch( lang::IllegalArgumentException& )
+ {
+ throw;
+ }
+ catch( embed::StorageWrappedTargetException& )
+ {
+ throw;
+ }
+ catch( io::IOException& )
+ {
+ throw;
+ }
+ catch( uno::RuntimeException& )
+ {
+ throw;
+ }
+ catch( uno::Exception& )
+ {
+ uno::Any aCaught( ::cppu::getCaughtException() );
+ throw embed::StorageWrappedTargetException( ::rtl::OUString::createFromAscii( "Can't copy raw stream" ),
+ uno::Reference< io::XInputStream >(),
+ aCaught );
+ }
+
+ return xResult;
+}
+
+//-----------------------------------------------
+uno::Reference< io::XStream > SAL_CALL FSStorage::cloneStreamElement( const ::rtl::OUString& aStreamName )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ packages::WrongPasswordException,
+ io::IOException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( !GetContent() )
+ throw io::IOException(); // TODO: error handling
+
+ // TODO/LATER: may need possibility to create folder if it was removed, since the folder can not be locked
+ INetURLObject aFileURL( m_pImpl->m_aURL );
+ aFileURL.Append( aStreamName );
+
+ uno::Reference < io::XStream > xTempResult;
+ try
+ {
+ uno::Reference< ucb::XCommandEnvironment > xDummyEnv;
+ ::ucbhelper::Content aResultContent( aFileURL.GetMainURL( INetURLObject::NO_DECODE ), xDummyEnv );
+ uno::Reference< io::XInputStream > xInStream = aResultContent.openStream();
+
+ xTempResult = uno::Reference < io::XStream >(
+ m_pImpl->m_xFactory->createInstance ( ::rtl::OUString::createFromAscii( "com.sun.star.io.TempFile" ) ),
+ uno::UNO_QUERY_THROW );
+ uno::Reference < io::XOutputStream > xTempOut = xTempResult->getOutputStream();
+ uno::Reference < io::XInputStream > xTempIn = xTempResult->getInputStream();
+
+ if ( !xTempOut.is() || !xTempIn.is() )
+ throw io::IOException();
+
+ ::comphelper::OStorageHelper::CopyInputToOutput( xInStream, xTempOut );
+ xTempOut->closeOutput();
+ }
+ catch( embed::InvalidStorageException& )
+ {
+ throw;
+ }
+ catch( lang::IllegalArgumentException& )
+ {
+ throw;
+ }
+ catch( packages::WrongPasswordException& )
+ {
+ throw;
+ }
+ catch( io::IOException& )
+ {
+ throw;
+ }
+ catch( embed::StorageWrappedTargetException& )
+ {
+ throw;
+ }
+ catch( uno::RuntimeException& )
+ {
+ throw;
+ }
+ catch( uno::Exception& )
+ {
+ uno::Any aCaught( ::cppu::getCaughtException() );
+ throw embed::StorageWrappedTargetException( ::rtl::OUString::createFromAscii( "Can't copy raw stream" ),
+ uno::Reference< io::XInputStream >(),
+ aCaught );
+ }
+
+ return xTempResult;
+}
+
+//-----------------------------------------------
+uno::Reference< io::XStream > SAL_CALL FSStorage::cloneEncryptedStreamElement(
+ const ::rtl::OUString&,
+ const ::rtl::OUString& )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ packages::NoEncryptionException,
+ packages::WrongPasswordException,
+ io::IOException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
+ throw packages::NoEncryptionException();
+}
+
+//-----------------------------------------------
+void SAL_CALL FSStorage::copyLastCommitTo(
+ const uno::Reference< embed::XStorage >& xTargetStorage )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ io::IOException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
+ copyToStorage( xTargetStorage );
+}
+
+//-----------------------------------------------
+void SAL_CALL FSStorage::copyStorageElementLastCommitTo(
+ const ::rtl::OUString& aStorName,
+ const uno::Reference< embed::XStorage >& xTargetStorage )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ io::IOException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ uno::Reference< embed::XStorage > xSourceStor( openStorageElement( aStorName, embed::ElementModes::READ ),
+ uno::UNO_QUERY_THROW );
+ xSourceStor->copyToStorage( xTargetStorage );
+}
+
+//-----------------------------------------------
+sal_Bool SAL_CALL FSStorage::isStreamElement( const ::rtl::OUString& aElementName )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ container::NoSuchElementException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( !GetContent() )
+ throw embed::InvalidStorageException(); // TODO: error handling
+
+ INetURLObject aURL( m_pImpl->m_aURL );
+ aURL.Append( aElementName );
+
+ return !::utl::UCBContentHelper::IsFolder( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
+}
+
+//-----------------------------------------------
+sal_Bool SAL_CALL FSStorage::isStorageElement( const ::rtl::OUString& aElementName )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ container::NoSuchElementException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( !GetContent() )
+ throw embed::InvalidStorageException(); // TODO: error handling
+
+ INetURLObject aURL( m_pImpl->m_aURL );
+ aURL.Append( aElementName );
+
+ return ::utl::UCBContentHelper::IsFolder( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
+}
+
+//-----------------------------------------------
+void SAL_CALL FSStorage::removeElement( const ::rtl::OUString& aElementName )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ container::NoSuchElementException,
+ io::IOException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( !GetContent() )
+ throw io::IOException(); // TODO: error handling
+
+ INetURLObject aURL( m_pImpl->m_aURL );
+ aURL.Append( aElementName );
+
+ if ( !::utl::UCBContentHelper::IsFolder( aURL.GetMainURL( INetURLObject::NO_DECODE ) )
+ && !::utl::UCBContentHelper::IsDocument( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ throw container::NoSuchElementException(); // TODO:
+
+ ::utl::UCBContentHelper::Kill( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
+}
+
+//-----------------------------------------------
+void SAL_CALL FSStorage::renameElement( const ::rtl::OUString& aElementName, const ::rtl::OUString& aNewName )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ container::NoSuchElementException,
+ container::ElementExistException,
+ io::IOException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( !GetContent() )
+ throw io::IOException(); // TODO: error handling
+
+ INetURLObject aOldURL( m_pImpl->m_aURL );
+ aOldURL.Append( aElementName );
+
+ INetURLObject aNewURL( m_pImpl->m_aURL );
+ aNewURL.Append( aNewName );
+
+ if ( !::utl::UCBContentHelper::IsFolder( aOldURL.GetMainURL( INetURLObject::NO_DECODE ) )
+ && !::utl::UCBContentHelper::IsDocument( aOldURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ throw container::NoSuchElementException(); // TODO:
+
+ if ( ::utl::UCBContentHelper::IsFolder( aNewURL.GetMainURL( INetURLObject::NO_DECODE ) )
+ || ::utl::UCBContentHelper::IsDocument( aNewURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ throw container::ElementExistException(); // TODO:
+
+ try
+ {
+ uno::Reference< ucb::XCommandEnvironment > xDummyEnv;
+ ::ucbhelper::Content aSourceContent( aOldURL.GetMainURL( INetURLObject::NO_DECODE ), xDummyEnv );
+
+ if ( !GetContent()->transferContent( aSourceContent,
+ ::ucbhelper::InsertOperation_MOVE,
+ aNewName,
+ ucb::NameClash::ERROR ) )
+ throw io::IOException(); // TODO: error handling
+ }
+ catch( embed::InvalidStorageException& )
+ {
+ throw;
+ }
+ catch( lang::IllegalArgumentException& )
+ {
+ throw;
+ }
+ catch( container::NoSuchElementException& )
+ {
+ throw;
+ }
+ catch( container::ElementExistException& )
+ {
+ throw;
+ }
+ catch( io::IOException& )
+ {
+ throw;
+ }
+ catch( embed::StorageWrappedTargetException& )
+ {
+ throw;
+ }
+ catch( uno::RuntimeException& )
+ {
+ throw;
+ }
+ catch( uno::Exception& )
+ {
+ uno::Any aCaught( ::cppu::getCaughtException() );
+ throw embed::StorageWrappedTargetException( ::rtl::OUString::createFromAscii( "Can't copy raw stream" ),
+ uno::Reference< io::XInputStream >(),
+ aCaught );
+ }
+}
+
+//-----------------------------------------------
+void SAL_CALL FSStorage::copyElementTo( const ::rtl::OUString& aElementName,
+ const uno::Reference< embed::XStorage >& xDest,
+ const ::rtl::OUString& aNewName )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ container::NoSuchElementException,
+ container::ElementExistException,
+ io::IOException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( !xDest.is() )
+ throw uno::RuntimeException();
+
+ if ( !GetContent() )
+ throw io::IOException(); // TODO: error handling
+
+ INetURLObject aOwnURL( m_pImpl->m_aURL );
+ aOwnURL.Append( aElementName );
+
+ if ( xDest->hasByName( aNewName ) )
+ throw container::ElementExistException(); // TODO:
+
+ try
+ {
+ uno::Reference< ucb::XCommandEnvironment > xDummyEnv;
+ if ( ::utl::UCBContentHelper::IsFolder( aOwnURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ {
+ ::ucbhelper::Content aSourceContent( aOwnURL.GetMainURL( INetURLObject::NO_DECODE ), xDummyEnv );
+ uno::Reference< embed::XStorage > xDestSubStor(
+ xDest->openStorageElement( aNewName, embed::ElementModes::READWRITE ),
+ uno::UNO_QUERY_THROW );
+
+ CopyContentToStorage_Impl( &aSourceContent, xDestSubStor );
+ }
+ else if ( ::utl::UCBContentHelper::IsDocument( aOwnURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ {
+ CopyStreamToSubStream( aOwnURL.GetMainURL( INetURLObject::NO_DECODE ), xDest, aNewName );
+ }
+ else
+ throw container::NoSuchElementException(); // TODO:
+ }
+ catch( embed::InvalidStorageException& )
+ {
+ throw;
+ }
+ catch( lang::IllegalArgumentException& )
+ {
+ throw;
+ }
+ catch( container::NoSuchElementException& )
+ {
+ throw;
+ }
+ catch( container::ElementExistException& )
+ {
+ throw;
+ }
+ catch( embed::StorageWrappedTargetException& )
+ {
+ throw;
+ }
+ catch( io::IOException& )
+ {
+ throw;
+ }
+ catch( uno::RuntimeException& )
+ {
+ throw;
+ }
+ catch( uno::Exception& )
+ {
+ uno::Any aCaught( ::cppu::getCaughtException() );
+ throw embed::StorageWrappedTargetException( ::rtl::OUString::createFromAscii( "Can't copy raw stream" ),
+ uno::Reference< io::XInputStream >(),
+ aCaught );
+ }
+}
+
+//-----------------------------------------------
+void SAL_CALL FSStorage::moveElementTo( const ::rtl::OUString& aElementName,
+ const uno::Reference< embed::XStorage >& xDest,
+ const ::rtl::OUString& aNewName )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ container::NoSuchElementException,
+ container::ElementExistException,
+ io::IOException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ copyElementTo( aElementName, xDest, aNewName );
+
+ INetURLObject aOwnURL( m_pImpl->m_aURL );
+ aOwnURL.Append( aElementName );
+ if ( !::utl::UCBContentHelper::Kill( aOwnURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ throw io::IOException(); // TODO: error handling
+}
+
+//____________________________________________________________________________________________________
+// XNameAccess
+//____________________________________________________________________________________________________
+
+//-----------------------------------------------
+uno::Any SAL_CALL FSStorage::getByName( const ::rtl::OUString& aName )
+ throw ( container::NoSuchElementException,
+ lang::WrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( !GetContent() )
+ throw io::IOException(); // TODO: error handling
+
+ if ( !aName.getLength() )
+ throw lang::IllegalArgumentException();
+
+ INetURLObject aURL( m_pImpl->m_aURL );
+ aURL.Append( aName );
+
+ uno::Any aResult;
+ try
+ {
+ if ( ::utl::UCBContentHelper::IsFolder( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ {
+ aResult <<= openStorageElement( aName, embed::ElementModes::READ );
+ }
+ else if ( ::utl::UCBContentHelper::IsDocument( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ {
+ aResult <<= openStreamElement( aName, embed::ElementModes::READ );
+ }
+ else
+ throw container::NoSuchElementException(); // TODO:
+ }
+ catch( container::NoSuchElementException& )
+ {
+ throw;
+ }
+ catch( lang::WrappedTargetException& )
+ {
+ throw;
+ }
+ catch( uno::RuntimeException& )
+ {
+ throw;
+ }
+ catch ( uno::Exception& )
+ {
+ uno::Any aCaught( ::cppu::getCaughtException() );
+ throw lang::WrappedTargetException( ::rtl::OUString::createFromAscii( "Can not open element!\n" ),
+ uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ),
+ uno::UNO_QUERY ),
+ aCaught );
+ }
+
+ return aResult;
+}
+
+
+//-----------------------------------------------
+uno::Sequence< ::rtl::OUString > SAL_CALL FSStorage::getElementNames()
+ throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( !GetContent() )
+ throw io::IOException(); // TODO: error handling
+
+ uno::Sequence< ::rtl::OUString > aProps( 1 );
+ ::rtl::OUString* pProps = aProps.getArray();
+ pProps[0] = ::rtl::OUString::createFromAscii( "Title" );
+ ::ucbhelper::ResultSetInclude eInclude = ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS;
+
+ uno::Sequence< ::rtl::OUString > aResult;
+ sal_Int32 nSize = 0;
+
+ try
+ {
+ uno::Reference< sdbc::XResultSet > xResultSet = GetContent()->createCursor( aProps, eInclude );
+ uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY );
+ uno::Reference< sdbc::XRow > xRow( xResultSet, uno::UNO_QUERY );
+ if ( xResultSet.is() )
+ {
+ // go through the list
+ while ( xResultSet->next() )
+ {
+ ::rtl::OUString aName( xRow->getString( 1 ) );
+ aResult.realloc( ++nSize );
+ aResult[nSize-1] = aName;
+ }
+ }
+ }
+ catch( ucb::InteractiveIOException& r )
+ {
+ if ( r.Code == ucb::IOErrorCode_NOT_EXISTING )
+ OSL_ENSURE( sal_False, "The folder does not exist!\n" );
+ else
+ {
+ uno::Any aCaught( ::cppu::getCaughtException() );
+ throw lang::WrappedTargetRuntimeException( ::rtl::OUString::createFromAscii( "Can not open storage!\n" ),
+ uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ),
+ uno::UNO_QUERY ),
+ aCaught );
+ }
+ }
+ catch( uno::RuntimeException& )
+ {
+ throw;
+ }
+ catch ( uno::Exception& )
+ {
+ uno::Any aCaught( ::cppu::getCaughtException() );
+ throw lang::WrappedTargetRuntimeException( ::rtl::OUString::createFromAscii( "Can not open storage!\n" ),
+ uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ),
+ uno::UNO_QUERY ),
+ aCaught );
+ }
+
+ return aResult;
+}
+
+
+//-----------------------------------------------
+sal_Bool SAL_CALL FSStorage::hasByName( const ::rtl::OUString& aName )
+ throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ try
+ {
+ if ( !GetContent() )
+ throw io::IOException(); // TODO: error handling
+
+ if ( !aName.getLength() )
+ throw lang::IllegalArgumentException();
+ }
+ catch( uno::RuntimeException& )
+ {
+ throw;
+ }
+ catch ( uno::Exception& )
+ {
+ uno::Any aCaught( ::cppu::getCaughtException() );
+ throw lang::WrappedTargetRuntimeException( ::rtl::OUString::createFromAscii( "Can not open storage!\n" ),
+ uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ),
+ uno::UNO_QUERY ),
+ aCaught );
+ }
+
+ INetURLObject aURL( m_pImpl->m_aURL );
+ aURL.Append( aName );
+
+ return ( ::utl::UCBContentHelper::IsFolder( aURL.GetMainURL( INetURLObject::NO_DECODE ) )
+ || ::utl::UCBContentHelper::IsDocument( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) );
+}
+
+//-----------------------------------------------
+uno::Type SAL_CALL FSStorage::getElementType()
+ throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ // it is a multitype container
+ return uno::Type();
+}
+
+//-----------------------------------------------
+sal_Bool SAL_CALL FSStorage::hasElements()
+ throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( !GetContent() )
+ throw io::IOException(); // TODO: error handling
+
+ uno::Sequence< ::rtl::OUString > aProps( 1 );
+ aProps[0] = ::rtl::OUString::createFromAscii( "TargetURL" );
+ ::ucbhelper::ResultSetInclude eInclude = ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS;
+
+ try
+ {
+ uno::Reference< sdbc::XResultSet > xResultSet = GetContent()->createCursor( aProps, eInclude );
+ return ( xResultSet.is() && xResultSet->next() );
+ }
+ catch( uno::Exception& )
+ {
+ throw uno::RuntimeException();
+ }
+}
+
+
+//____________________________________________________________________________________________________
+// XDisposable
+//____________________________________________________________________________________________________
+
+//-----------------------------------------------
+void SAL_CALL FSStorage::dispose()
+ throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( m_pImpl->m_pListenersContainer )
+ {
+ lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) );
+ m_pImpl->m_pListenersContainer->disposeAndClear( aSource );
+ }
+
+ delete m_pImpl;
+ m_pImpl = NULL;
+}
+
+//-----------------------------------------------
+void SAL_CALL FSStorage::addEventListener(
+ const uno::Reference< lang::XEventListener >& xListener )
+ throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( !m_pImpl->m_pListenersContainer )
+ m_pImpl->m_pListenersContainer = new ::cppu::OInterfaceContainerHelper( m_aMutex );
+
+ m_pImpl->m_pListenersContainer->addInterface( xListener );
+}
+
+//-----------------------------------------------
+void SAL_CALL FSStorage::removeEventListener(
+ const uno::Reference< lang::XEventListener >& xListener )
+ throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( m_pImpl->m_pListenersContainer )
+ m_pImpl->m_pListenersContainer->removeInterface( xListener );
+}
+
+//____________________________________________________________________________________________________
+// XPropertySet
+//____________________________________________________________________________________________________
+
+//-----------------------------------------------
+uno::Reference< beans::XPropertySetInfo > SAL_CALL FSStorage::getPropertySetInfo()
+ throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ //TODO:
+ return uno::Reference< beans::XPropertySetInfo >();
+}
+
+
+//-----------------------------------------------
+void SAL_CALL FSStorage::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& )
+ throw ( beans::UnknownPropertyException,
+ beans::PropertyVetoException,
+ lang::IllegalArgumentException,
+ lang::WrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( aPropertyName.equalsAscii( "URL" ) || aPropertyName.equalsAscii( "OpenMode" ) )
+ throw beans::PropertyVetoException(); // TODO
+ else
+ throw beans::UnknownPropertyException(); // TODO
+}
+
+
+//-----------------------------------------------
+uno::Any SAL_CALL FSStorage::getPropertyValue( const ::rtl::OUString& aPropertyName )
+ throw ( beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( aPropertyName.equalsAscii( "URL" ) )
+ return uno::makeAny( m_pImpl->m_aURL );
+ else if ( aPropertyName.equalsAscii( "OpenMode" ) )
+ return uno::makeAny( m_pImpl->m_nMode );
+
+ throw beans::UnknownPropertyException(); // TODO
+}
+
+
+//-----------------------------------------------
+void SAL_CALL FSStorage::addPropertyChangeListener(
+ const ::rtl::OUString& /*aPropertyName*/,
+ const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ )
+ throw ( beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ //TODO:
+}
+
+
+//-----------------------------------------------
+void SAL_CALL FSStorage::removePropertyChangeListener(
+ const ::rtl::OUString& /*aPropertyName*/,
+ const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ )
+ throw ( beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ //TODO:
+}
+
+
+//-----------------------------------------------
+void SAL_CALL FSStorage::addVetoableChangeListener(
+ const ::rtl::OUString& /*PropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
+ throw ( beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ //TODO:
+}
+
+
+//-----------------------------------------------
+void SAL_CALL FSStorage::removeVetoableChangeListener(
+ const ::rtl::OUString& /*PropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
+ throw ( beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ //TODO:
+}
+
+//____________________________________________________________________________________________________
+// XHierarchicalStorageAccess
+//____________________________________________________________________________________________________
+//-----------------------------------------------
+uno::Reference< embed::XExtendedStorageStream > SAL_CALL FSStorage::openStreamElementByHierarchicalName( const ::rtl::OUString& sStreamPath, ::sal_Int32 nOpenMode )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ packages::WrongPasswordException,
+ io::IOException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( sStreamPath.toChar() == '/' )
+ throw lang::IllegalArgumentException();
+
+ if ( !GetContent() )
+ throw io::IOException(); // TODO: error handling
+
+ INetURLObject aBaseURL( m_pImpl->m_aURL );
+ if ( !aBaseURL.setFinalSlash() )
+ throw uno::RuntimeException();
+
+ INetURLObject aFileURL = INetURLObject::GetAbsURL(
+ aBaseURL.GetMainURL( INetURLObject::NO_DECODE ),
+ sStreamPath );
+
+ if ( ::utl::UCBContentHelper::IsFolder( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ throw io::IOException();
+
+ if ( ( nOpenMode & embed::ElementModes::NOCREATE )
+ && !::utl::UCBContentHelper::IsDocument( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ throw io::IOException(); // TODO:
+
+ uno::Reference< ucb::XCommandEnvironment > xDummyEnv; // TODO: provide InteractionHandler if any
+ uno::Reference< io::XStream > xResult;
+ try
+ {
+ if ( nOpenMode & embed::ElementModes::WRITE )
+ {
+ if ( isLocalFile_Impl( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ {
+ uno::Reference< ucb::XSimpleFileAccess > xSimpleFileAccess(
+ m_pImpl->m_xFactory->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.SimpleFileAccess" ) ) ),
+ uno::UNO_QUERY_THROW );
+ uno::Reference< io::XStream > xStream =
+ xSimpleFileAccess->openFileReadWrite( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) );
+
+ xResult = static_cast< io::XStream* >( new OFSStreamContainer( xStream ) );
+ }
+ else
+ {
+ // TODO: test whether it really works for http and fwp
+ SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aFileURL.GetMainURL( INetURLObject::NO_DECODE ),
+ STREAM_STD_WRITE );
+ if ( pStream )
+ {
+ if ( !pStream->GetError() )
+ {
+ uno::Reference< io::XStream > xStream =
+ uno::Reference < io::XStream >( new ::utl::OStreamWrapper( *pStream ) );
+ xResult = static_cast< io::XStream* >( new OFSStreamContainer( xStream ) );
+ }
+ else
+ delete pStream;
+ }
+ }
+
+ if ( !xResult.is() )
+ throw io::IOException();
+
+ if ( ( nOpenMode & embed::ElementModes::TRUNCATE ) )
+ {
+ uno::Reference< io::XTruncate > xTrunc( xResult->getOutputStream(), uno::UNO_QUERY_THROW );
+ xTrunc->truncate();
+ }
+ }
+ else
+ {
+ if ( ( nOpenMode & embed::ElementModes::TRUNCATE )
+ || !::utl::UCBContentHelper::IsDocument( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ throw io::IOException(); // TODO: access denied
+
+ ::ucbhelper::Content aResultContent( aFileURL.GetMainURL( INetURLObject::NO_DECODE ), xDummyEnv );
+ uno::Reference< io::XInputStream > xInStream = aResultContent.openStream();
+ xResult = static_cast< io::XStream* >( new OFSInputStreamContainer( xInStream ) );
+ }
+ }
+ catch( embed::InvalidStorageException& )
+ {
+ throw;
+ }
+ catch( lang::IllegalArgumentException& )
+ {
+ throw;
+ }
+ catch( packages::WrongPasswordException& )
+ {
+ throw;
+ }
+ catch( embed::StorageWrappedTargetException& )
+ {
+ throw;
+ }
+ catch( io::IOException& )
+ {
+ throw;
+ }
+ catch( uno::RuntimeException& )
+ {
+ throw;
+ }
+ catch( uno::Exception& )
+ {
+ uno::Any aCaught( ::cppu::getCaughtException() );
+ throw embed::StorageWrappedTargetException( ::rtl::OUString::createFromAscii( "Can't copy raw stream" ),
+ uno::Reference< io::XInputStream >(),
+ aCaught );
+ }
+
+ return uno::Reference< embed::XExtendedStorageStream >( xResult, uno::UNO_QUERY_THROW );
+}
+
+//-----------------------------------------------
+uno::Reference< embed::XExtendedStorageStream > SAL_CALL FSStorage::openEncryptedStreamElementByHierarchicalName( const ::rtl::OUString& /*sStreamName*/, ::sal_Int32 /*nOpenMode*/, const ::rtl::OUString& /*sPassword*/ )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ packages::NoEncryptionException,
+ packages::WrongPasswordException,
+ io::IOException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
+ throw packages::NoEncryptionException();
+}
+
+//-----------------------------------------------
+void SAL_CALL FSStorage::removeStreamElementByHierarchicalName( const ::rtl::OUString& sStreamPath )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ container::NoSuchElementException,
+ io::IOException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl )
+ throw lang::DisposedException();
+
+ if ( !GetContent() )
+ throw io::IOException(); // TODO: error handling
+
+ // TODO/LATER: may need possibility to create folder if it was removed, since the folder can not be locked
+ INetURLObject aBaseURL( m_pImpl->m_aURL );
+ if ( !aBaseURL.setFinalSlash() )
+ throw uno::RuntimeException();
+
+ INetURLObject aFileURL = INetURLObject::GetAbsURL(
+ aBaseURL.GetMainURL( INetURLObject::NO_DECODE ),
+ sStreamPath );
+
+ if ( !::utl::UCBContentHelper::IsDocument( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ {
+ if ( ::utl::UCBContentHelper::IsFolder( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ throw lang::IllegalArgumentException();
+ else
+ throw container::NoSuchElementException(); // TODO:
+ }
+
+ if ( !::utl::UCBContentHelper::Kill( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) )
+ throw io::IOException(); // TODO: error handling
+}
+
+
diff --git a/svl/source/fsstor/fsstorage.hxx b/svl/source/fsstor/fsstorage.hxx
new file mode 100644
index 000000000000..670a6917dd40
--- /dev/null
+++ b/svl/source/fsstor/fsstorage.hxx
@@ -0,0 +1,340 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: fsstorage.hxx,v $
+ * $Revision: 1.6 $
+ *
+ * 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 __XSTORAGE_HXX_
+#define __XSTORAGE_HXX_
+
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/XHierarchicalStorageAccess.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/io/XStream.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/packages/NoEncryptionException.hpp>
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/interfacecontainer.h>
+
+#include <ucbhelper/content.hxx>
+
+struct FSStorage_Impl;
+class FSStorage : public ::com::sun::star::lang::XTypeProvider
+ , public ::com::sun::star::embed::XStorage
+ , public ::com::sun::star::embed::XHierarchicalStorageAccess
+ , public ::com::sun::star::beans::XPropertySet
+ , public ::cppu::OWeakObject
+{
+ ::osl::Mutex m_aMutex;
+ FSStorage_Impl* m_pImpl;
+
+protected:
+
+public:
+
+ FSStorage( const ::ucbhelper::Content& aContent,
+ sal_Int32 nMode,
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > xProperties,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory );
+
+ virtual ~FSStorage();
+
+ ::ucbhelper::Content* GetContent();
+
+ void CopyStreamToSubStream( const ::rtl::OUString& aSourceURL,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xDest,
+ const ::rtl::OUString& aNewEntryName );
+
+ void CopyContentToStorage_Impl( ::ucbhelper::Content* pContent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xDest );
+
+ static sal_Bool MakeFolderNoUI( const String& rFolder, sal_Bool bNewOnly );
+
+ //____________________________________________________________________________________________________
+ // XInterface
+ //____________________________________________________________________________________________________
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL acquire() throw();
+
+ virtual void SAL_CALL release() throw();
+
+ //____________________________________________________________________________________________________
+ // XTypeProvider
+ //____________________________________________________________________________________________________
+
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ //____________________________________________________________________________________________________
+ // XStorage
+ //____________________________________________________________________________________________________
+
+ virtual void SAL_CALL copyToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xDest )
+ throw ( ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::embed::StorageWrappedTargetException,
+ ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > SAL_CALL openStreamElement(
+ const ::rtl::OUString& aStreamName, sal_Int32 nOpenMode )
+ throw ( ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::packages::WrongPasswordException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::embed::StorageWrappedTargetException,
+ ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > SAL_CALL openEncryptedStreamElement(
+ const ::rtl::OUString& aStreamName, sal_Int32 nOpenMode, const ::rtl::OUString& aPass )
+ throw ( ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::packages::NoEncryptionException,
+ ::com::sun::star::packages::WrongPasswordException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::embed::StorageWrappedTargetException,
+ ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > SAL_CALL openStorageElement(
+ const ::rtl::OUString& aStorName, sal_Int32 nStorageMode )
+ throw ( ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::embed::StorageWrappedTargetException,
+ ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > SAL_CALL cloneStreamElement(
+ const ::rtl::OUString& aStreamName )
+ throw ( ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::packages::WrongPasswordException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::embed::StorageWrappedTargetException,
+ ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > SAL_CALL cloneEncryptedStreamElement(
+ const ::rtl::OUString& aStreamName, const ::rtl::OUString& aPass )
+ throw ( ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::packages::NoEncryptionException,
+ ::com::sun::star::packages::WrongPasswordException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::embed::StorageWrappedTargetException,
+ ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL copyLastCommitTo(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xTargetStorage )
+ throw ( ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::embed::StorageWrappedTargetException,
+ ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL copyStorageElementLastCommitTo(
+ const ::rtl::OUString& aStorName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xTargetStorage )
+ throw ( ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::embed::StorageWrappedTargetException,
+ ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Bool SAL_CALL isStreamElement( const ::rtl::OUString& aElementName )
+ throw ( ::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Bool SAL_CALL isStorageElement( const ::rtl::OUString& aElementName )
+ throw ( ::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL removeElement( const ::rtl::OUString& aElementName )
+ throw ( ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::embed::StorageWrappedTargetException,
+ ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL renameElement( const ::rtl::OUString& rEleName, const ::rtl::OUString& rNewName )
+ throw ( ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::container::ElementExistException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::embed::StorageWrappedTargetException,
+ ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL copyElementTo( const ::rtl::OUString& aElementName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xDest,
+ const ::rtl::OUString& aNewName )
+ throw ( ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::container::ElementExistException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::embed::StorageWrappedTargetException,
+ ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL moveElementTo( const ::rtl::OUString& aElementName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xDest,
+ const ::rtl::OUString& rNewName )
+ throw ( ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::container::ElementExistException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::embed::StorageWrappedTargetException,
+ ::com::sun::star::uno::RuntimeException );
+
+ //____________________________________________________________________________________________________
+ // XNameAccess
+ //____________________________________________________________________________________________________
+
+ virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
+ throw ( ::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Bool SAL_CALL hasElements()
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+ //____________________________________________________________________________________________________
+ // XComponent
+ //____________________________________________________________________________________________________
+
+ virtual void SAL_CALL dispose()
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL addEventListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener )
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL removeEventListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener )
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+ //____________________________________________________________________________________________________
+ // 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 );
+
+ //____________________________________________________________________________________________________
+ // XHierarchicalStorageAccess
+ //____________________________________________________________________________________________________
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XExtendedStorageStream > SAL_CALL openStreamElementByHierarchicalName( const ::rtl::OUString& sStreamPath, ::sal_Int32 nOpenMode )
+ throw ( ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::packages::WrongPasswordException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::embed::StorageWrappedTargetException,
+ ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XExtendedStorageStream > SAL_CALL openEncryptedStreamElementByHierarchicalName( const ::rtl::OUString& sStreamName, ::sal_Int32 nOpenMode, const ::rtl::OUString& sPassword )
+ throw ( ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::packages::NoEncryptionException,
+ ::com::sun::star::packages::WrongPasswordException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::embed::StorageWrappedTargetException,
+ ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL removeStreamElementByHierarchicalName( const ::rtl::OUString& sElementPath )
+ throw ( ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::embed::StorageWrappedTargetException,
+ ::com::sun::star::uno::RuntimeException );
+};
+
+#endif
+
diff --git a/svl/source/fsstor/makefile.mk b/svl/source/fsstor/makefile.mk
new file mode 100644
index 000000000000..f55f6747f9e1
--- /dev/null
+++ b/svl/source/fsstor/makefile.mk
@@ -0,0 +1,70 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.6 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=svtools
+TARGET=fsstorage.uno
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+DLLPRE=
+
+# --- Files -------------------------------------
+
+SLOFILES=\
+ $(SLO)$/fsfactory.obj \
+ $(SLO)$/fsstorage.obj \
+ $(SLO)$/oinputstreamcontainer.obj \
+ $(SLO)$/ostreamcontainer.obj
+
+SHL1TARGET= $(TARGET)
+SHL1IMPLIB= i$(TARGET)
+SHL1OBJS= $(SLOFILES)
+SHL1STDLIBS=\
+ $(UNOTOOLSLIB) \
+ $(TOOLSLIB) \
+ $(COMPHELPERLIB) \
+ $(UCBHELPERLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB)
+
+SHL1VERSIONMAP=exports.map
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+DEF1NAME= $(SHL1TARGET)
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/svl/source/fsstor/oinputstreamcontainer.cxx b/svl/source/fsstor/oinputstreamcontainer.cxx
new file mode 100644
index 000000000000..dc08a7a34602
--- /dev/null
+++ b/svl/source/fsstor/oinputstreamcontainer.cxx
@@ -0,0 +1,350 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: oinputstreamcontainer.cxx,v $
+ * $Revision: 1.6 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include "oinputstreamcontainer.hxx"
+#include <cppuhelper/typeprovider.hxx>
+
+using namespace ::com::sun::star;
+
+//-----------------------------------------------
+OFSInputStreamContainer::OFSInputStreamContainer( const uno::Reference< io::XInputStream >& xStream )
+: m_xInputStream( xStream )
+, m_xSeekable( xStream, uno::UNO_QUERY )
+, m_bSeekable( sal_False )
+, m_bDisposed( sal_False )
+, m_pListenersContainer( NULL )
+{
+ m_bSeekable = m_xSeekable.is();
+}
+
+//-----------------------------------------------
+OFSInputStreamContainer::~OFSInputStreamContainer()
+{
+ if ( m_pListenersContainer )
+ {
+ delete m_pListenersContainer;
+ m_pListenersContainer = NULL;
+ }
+}
+
+//-----------------------------------------------
+uno::Sequence< uno::Type > SAL_CALL OFSInputStreamContainer::getTypes()
+ throw ( uno::RuntimeException )
+{
+ static ::cppu::OTypeCollection* pTypeCollection = NULL ;
+
+ if ( pTypeCollection == NULL )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex ) ;
+
+ if ( pTypeCollection == NULL )
+ {
+ if ( m_bSeekable )
+ {
+ static ::cppu::OTypeCollection aTypeCollection(
+ ::getCppuType(( const uno::Reference< io::XStream >* )NULL ),
+ ::getCppuType(( const uno::Reference< io::XInputStream >* )NULL ),
+ ::getCppuType(( const uno::Reference< io::XSeekable >* )NULL ) );
+
+ pTypeCollection = &aTypeCollection ;
+ }
+ else
+ {
+ static ::cppu::OTypeCollection aTypeCollection(
+ ::getCppuType(( const uno::Reference< io::XStream >* )NULL ),
+ ::getCppuType(( const uno::Reference< io::XInputStream >* )NULL ) );
+
+ pTypeCollection = &aTypeCollection ;
+ }
+ }
+ }
+
+ return pTypeCollection->getTypes() ;
+
+}
+
+//-----------------------------------------------
+uno::Any SAL_CALL OFSInputStreamContainer::queryInterface( const uno::Type& rType )
+ throw( uno::RuntimeException )
+{
+ // Attention:
+ // Don't use mutex or guard in this method!!! Is a method of XInterface.
+
+ uno::Any aReturn;
+ if ( m_bSeekable )
+ aReturn = uno::Any( ::cppu::queryInterface( rType,
+ static_cast< io::XStream* >( this ),
+ static_cast< io::XInputStream* >( this ),
+ static_cast< io::XSeekable* >( this ) ) );
+ else
+ aReturn = uno::Any( ::cppu::queryInterface( rType,
+ static_cast< io::XStream* >( this ),
+ static_cast< io::XInputStream* >( this ) ) );
+
+ if ( aReturn.hasValue() == sal_True )
+ return aReturn ;
+
+ return ::cppu::OWeakObject::queryInterface( rType ) ;
+}
+
+//-----------------------------------------------
+void SAL_CALL OFSInputStreamContainer::acquire()
+ throw()
+{
+ ::cppu::OWeakObject::acquire();
+}
+
+//-----------------------------------------------
+void SAL_CALL OFSInputStreamContainer::release()
+ throw()
+{
+ ::cppu::OWeakObject::release();
+}
+
+//-----------------------------------------------
+sal_Int32 SAL_CALL OFSInputStreamContainer::readBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
+ throw ( io::NotConnectedException,
+ io::BufferSizeExceededException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xInputStream.is() )
+ throw uno::RuntimeException();
+
+ return m_xInputStream->readBytes( aData, nBytesToRead );
+}
+
+//-----------------------------------------------
+sal_Int32 SAL_CALL OFSInputStreamContainer::readSomeBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
+ throw ( io::NotConnectedException,
+ io::BufferSizeExceededException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xInputStream.is() )
+ throw uno::RuntimeException();
+
+ return m_xInputStream->readSomeBytes( aData, nMaxBytesToRead );
+}
+
+//-----------------------------------------------
+void SAL_CALL OFSInputStreamContainer::skipBytes( sal_Int32 nBytesToSkip )
+ throw ( io::NotConnectedException,
+ io::BufferSizeExceededException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xInputStream.is() )
+ throw uno::RuntimeException();
+
+ m_xInputStream->skipBytes( nBytesToSkip );
+}
+
+//-----------------------------------------------
+sal_Int32 SAL_CALL OFSInputStreamContainer::available( )
+ throw ( io::NotConnectedException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xInputStream.is() )
+ throw uno::RuntimeException();
+
+ return m_xInputStream->available();
+}
+
+//-----------------------------------------------
+void SAL_CALL OFSInputStreamContainer::closeInput( )
+ throw ( io::NotConnectedException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xInputStream.is() )
+ throw uno::RuntimeException();
+
+ dispose();
+}
+
+//-----------------------------------------------
+uno::Reference< io::XInputStream > SAL_CALL OFSInputStreamContainer::getInputStream()
+ throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xInputStream.is() )
+ return uno::Reference< io::XInputStream >();
+
+ return uno::Reference< io::XInputStream >( static_cast< io::XInputStream* >( this ), uno::UNO_QUERY );
+}
+
+//-----------------------------------------------
+uno::Reference< io::XOutputStream > SAL_CALL OFSInputStreamContainer::getOutputStream()
+ throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ return uno::Reference< io::XOutputStream >();
+}
+
+//-----------------------------------------------
+void SAL_CALL OFSInputStreamContainer::seek( sal_Int64 location )
+ throw ( lang::IllegalArgumentException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xSeekable.is() )
+ throw uno::RuntimeException();
+
+ m_xSeekable->seek( location );
+}
+
+//-----------------------------------------------
+sal_Int64 SAL_CALL OFSInputStreamContainer::getPosition()
+ throw ( io::IOException,
+ uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xSeekable.is() )
+ throw uno::RuntimeException();
+
+ return m_xSeekable->getPosition();
+}
+
+//-----------------------------------------------
+sal_Int64 SAL_CALL OFSInputStreamContainer::getLength()
+ throw ( io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xSeekable.is() )
+ throw uno::RuntimeException();
+
+ return m_xSeekable->getLength();
+}
+
+//-----------------------------------------------
+void SAL_CALL OFSInputStreamContainer::dispose( )
+ throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xInputStream.is() )
+ throw uno::RuntimeException();
+
+ m_xInputStream->closeInput();
+
+ if ( m_pListenersContainer )
+ {
+ lang::EventObject aSource( static_cast< ::cppu::OWeakObject*>( this ) );
+ m_pListenersContainer->disposeAndClear( aSource );
+ }
+
+ m_bDisposed = sal_True;
+}
+
+//-----------------------------------------------
+void SAL_CALL OFSInputStreamContainer::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
+ throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_pListenersContainer )
+ m_pListenersContainer = new ::cppu::OInterfaceContainerHelper( m_aMutex );
+
+ m_pListenersContainer->addInterface( xListener );
+}
+
+//-----------------------------------------------
+void SAL_CALL OFSInputStreamContainer::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
+ throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( m_pListenersContainer )
+ m_pListenersContainer->removeInterface( xListener );
+}
+
+
+
diff --git a/svl/source/fsstor/oinputstreamcontainer.hxx b/svl/source/fsstor/oinputstreamcontainer.hxx
new file mode 100644
index 000000000000..308f4283b430
--- /dev/null
+++ b/svl/source/fsstor/oinputstreamcontainer.hxx
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: oinputstreamcontainer.hxx,v $
+ * $Revision: 1.5 $
+ *
+ * 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 _OINPUTSTREAMCONTAINER_HXX_
+#define _OINPUTSTREAMCONTAINER_HXX_
+
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/embed/XExtendedStorageStream.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+
+
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/interfacecontainer.h>
+
+#include <osl/mutex.hxx>
+
+class OFSInputStreamContainer : public cppu::WeakImplHelper2 < ::com::sun::star::io::XInputStream
+ ,::com::sun::star::embed::XExtendedStorageStream >
+ , public ::com::sun::star::io::XSeekable
+{
+protected:
+ ::osl::Mutex m_aMutex;
+
+ ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > m_xInputStream;
+ ::com::sun::star::uno::Reference < ::com::sun::star::io::XSeekable > m_xSeekable;
+
+ sal_Bool m_bSeekable;
+
+ sal_Bool m_bDisposed;
+
+ ::cppu::OInterfaceContainerHelper* m_pListenersContainer; // list of listeners
+
+public:
+ OFSInputStreamContainer( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream >& xStream );
+
+ virtual ~OFSInputStreamContainer();
+
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XInputStream
+ virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL available( )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL closeInput( )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+
+ //XStream
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL getOutputStream( ) throw (::com::sun::star::uno::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);
+
+ //XComponent
+ virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+
+};
+
+#endif
+
diff --git a/svl/source/fsstor/ostreamcontainer.cxx b/svl/source/fsstor/ostreamcontainer.cxx
new file mode 100644
index 000000000000..d801f49532b2
--- /dev/null
+++ b/svl/source/fsstor/ostreamcontainer.cxx
@@ -0,0 +1,570 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ostreamcontainer.cxx,v $
+ * $Revision: 1.4 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include "ostreamcontainer.hxx"
+
+
+using namespace ::com::sun::star;
+
+//-----------------------------------------------
+OFSStreamContainer::OFSStreamContainer( const uno::Reference < io::XStream >& xStream )
+: m_bDisposed( sal_False )
+, m_bInputClosed( sal_False )
+, m_bOutputClosed( sal_False )
+, m_pListenersContainer( NULL )
+, m_pTypeCollection( NULL )
+{
+ try
+ {
+ m_xStream = xStream;
+ if ( !m_xStream.is() )
+ throw uno::RuntimeException();
+
+ m_xSeekable = uno::Reference< io::XSeekable >( xStream, uno::UNO_QUERY );
+ m_xInputStream = xStream->getInputStream();
+ m_xOutputStream = xStream->getOutputStream();
+ m_xTruncate = uno::Reference< io::XTruncate >( m_xOutputStream, uno::UNO_QUERY );
+ m_xAsyncOutputMonitor = uno::Reference< io::XAsyncOutputMonitor >( m_xOutputStream, uno::UNO_QUERY );
+ }
+ catch( uno::Exception& )
+ {
+ m_xStream = uno::Reference< io::XStream >();
+ m_xSeekable = uno::Reference< io::XSeekable >();
+ m_xInputStream = uno::Reference< io::XInputStream >();
+ m_xOutputStream = uno::Reference< io::XOutputStream >();
+ m_xTruncate = uno::Reference< io::XTruncate >();
+ m_xAsyncOutputMonitor = uno::Reference< io::XAsyncOutputMonitor >();
+ }
+}
+
+//-----------------------------------------------
+OFSStreamContainer::~OFSStreamContainer()
+{
+ if ( m_pListenersContainer )
+ {
+ delete m_pListenersContainer;
+ m_pListenersContainer = NULL;
+ }
+}
+
+// XInterface
+//-----------------------------------------------
+uno::Any SAL_CALL OFSStreamContainer::queryInterface( const uno::Type& rType )
+ throw( uno::RuntimeException )
+{
+ uno::Any aReturn;
+
+ aReturn <<= ::cppu::queryInterface
+ ( rType
+ , static_cast<lang::XTypeProvider*> ( this )
+ , static_cast<io::XStream*> ( this )
+ , static_cast<embed::XExtendedStorageStream*> ( this )
+ , static_cast<lang::XComponent*> ( this ) );
+
+ if ( aReturn.hasValue() == sal_True )
+ return aReturn ;
+
+ if ( m_xSeekable.is() )
+ {
+ aReturn <<= ::cppu::queryInterface
+ ( rType
+ , static_cast<io::XSeekable*> ( this ) );
+
+ if ( aReturn.hasValue() == sal_True )
+ return aReturn ;
+ }
+
+ if ( m_xInputStream.is() )
+ {
+ aReturn <<= ::cppu::queryInterface
+ ( rType
+ , static_cast<io::XInputStream*> ( this ) );
+
+ if ( aReturn.hasValue() == sal_True )
+ return aReturn ;
+ }
+ if ( m_xOutputStream.is() )
+ {
+ aReturn <<= ::cppu::queryInterface
+ ( rType
+ , static_cast<io::XOutputStream*> ( this ) );
+
+ if ( aReturn.hasValue() == sal_True )
+ return aReturn ;
+ }
+ if ( m_xTruncate.is() )
+ {
+ aReturn <<= ::cppu::queryInterface
+ ( rType
+ , static_cast<io::XTruncate*> ( this ) );
+
+ if ( aReturn.hasValue() == sal_True )
+ return aReturn ;
+ }
+ if ( m_xAsyncOutputMonitor.is() )
+ {
+ aReturn <<= ::cppu::queryInterface
+ ( rType
+ , static_cast<io::XAsyncOutputMonitor*> ( this ) );
+
+ if ( aReturn.hasValue() == sal_True )
+ return aReturn ;
+ }
+
+ return OWeakObject::queryInterface( rType );
+}
+
+//-----------------------------------------------
+void SAL_CALL OFSStreamContainer::acquire()
+ throw()
+{
+ OWeakObject::acquire();
+}
+
+//-----------------------------------------------
+void SAL_CALL OFSStreamContainer::release()
+ throw()
+{
+ OWeakObject::release();
+}
+
+// XTypeProvider
+//-----------------------------------------------
+uno::Sequence< uno::Type > SAL_CALL OFSStreamContainer::getTypes()
+ throw( uno::RuntimeException )
+{
+ if ( m_pTypeCollection == NULL )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_pTypeCollection == NULL )
+ {
+ ::cppu::OTypeCollection aTypeCollection
+ ( ::getCppuType( ( const uno::Reference< lang::XTypeProvider >* )NULL )
+ , ::getCppuType( ( const uno::Reference< embed::XExtendedStorageStream >* )NULL ) );
+
+ if ( m_xSeekable.is() )
+ aTypeCollection = ::cppu::OTypeCollection
+ ( ::getCppuType( ( const uno::Reference< io::XSeekable >* )NULL ),
+ aTypeCollection.getTypes() );
+ if ( m_xInputStream.is() )
+ aTypeCollection = ::cppu::OTypeCollection
+ ( ::getCppuType( ( const uno::Reference< io::XInputStream >* )NULL ),
+ aTypeCollection.getTypes() );
+
+ if ( m_xOutputStream.is() )
+ aTypeCollection = ::cppu::OTypeCollection
+ ( ::getCppuType( ( const uno::Reference< io::XOutputStream >* )NULL ),
+ aTypeCollection.getTypes() );
+ if ( m_xTruncate.is() )
+ aTypeCollection = ::cppu::OTypeCollection
+ ( ::getCppuType( ( const uno::Reference< io::XTruncate >* )NULL ),
+ aTypeCollection.getTypes() );
+ if ( m_xAsyncOutputMonitor.is() )
+ aTypeCollection = ::cppu::OTypeCollection
+ ( ::getCppuType( ( const uno::Reference< io::XAsyncOutputMonitor >* )NULL ),
+ aTypeCollection.getTypes() );
+
+ m_pTypeCollection = new ::cppu::OTypeCollection( aTypeCollection );
+ }
+ }
+ return m_pTypeCollection->getTypes() ;
+}
+
+//-----------------------------------------------
+uno::Sequence< sal_Int8 > SAL_CALL OFSStreamContainer::getImplementationId()
+ throw( uno::RuntimeException )
+{
+ static ::cppu::OImplementationId* pID = NULL ;
+
+ if ( pID == NULL )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ) ;
+
+ if ( pID == NULL )
+ {
+ static ::cppu::OImplementationId aID( sal_False ) ;
+ pID = &aID ;
+ }
+ }
+
+ return pID->getImplementationId() ;
+}
+
+// XStream
+//-----------------------------------------------
+uno::Reference< io::XInputStream > SAL_CALL OFSStreamContainer::getInputStream()
+ throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xStream.is() )
+ throw uno::RuntimeException();
+
+ if ( m_xInputStream.is() )
+ return uno::Reference< io::XInputStream >( static_cast< io::XInputStream* >( this ) );
+
+ return uno::Reference< io::XInputStream >();
+}
+
+//-----------------------------------------------
+uno::Reference< io::XOutputStream > SAL_CALL OFSStreamContainer::getOutputStream()
+ throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xStream.is() )
+ throw uno::RuntimeException();
+
+ if ( m_xOutputStream.is() )
+ return uno::Reference< io::XOutputStream >( static_cast< io::XOutputStream* >( this ) );
+
+ return uno::Reference< io::XOutputStream >();
+}
+
+// XComponent
+//-----------------------------------------------
+void SAL_CALL OFSStreamContainer::dispose()
+ throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xStream.is() )
+ throw uno::RuntimeException();
+
+ if ( m_xInputStream.is() && !m_bInputClosed )
+ {
+ m_xInputStream->closeInput();
+ m_bInputClosed = sal_True;
+ }
+
+ if ( m_xOutputStream.is() && !m_bOutputClosed )
+ {
+ m_xOutputStream->closeOutput();
+ m_bOutputClosed = sal_True;
+ }
+
+ if ( m_pListenersContainer )
+ {
+ lang::EventObject aSource( static_cast< ::cppu::OWeakObject*>( this ) );
+ m_pListenersContainer->disposeAndClear( aSource );
+ }
+
+ m_bDisposed = sal_True;
+}
+
+//-----------------------------------------------
+void SAL_CALL OFSStreamContainer::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
+ throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_pListenersContainer )
+ m_pListenersContainer = new ::cppu::OInterfaceContainerHelper( m_aMutex );
+
+ m_pListenersContainer->addInterface( xListener );
+}
+
+//-----------------------------------------------
+void SAL_CALL OFSStreamContainer::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
+ throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( m_pListenersContainer )
+ m_pListenersContainer->removeInterface( xListener );
+}
+
+
+// XSeekable
+//-----------------------------------------------
+void SAL_CALL OFSStreamContainer::seek( sal_Int64 location )
+ throw ( lang::IllegalArgumentException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xStream.is() || !m_xSeekable.is() )
+ throw uno::RuntimeException();
+
+ m_xSeekable->seek( location );
+}
+
+//-----------------------------------------------
+sal_Int64 SAL_CALL OFSStreamContainer::getPosition()
+ throw ( io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xStream.is() || !m_xSeekable.is() )
+ throw uno::RuntimeException();
+
+ return m_xSeekable->getPosition();
+}
+
+//-----------------------------------------------
+sal_Int64 SAL_CALL OFSStreamContainer::getLength()
+ throw ( io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xStream.is() || !m_xSeekable.is() )
+ throw uno::RuntimeException();
+
+ return m_xSeekable->getLength();
+}
+
+
+// XInputStream
+//-----------------------------------------------
+sal_Int32 SAL_CALL OFSStreamContainer::readBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
+ throw( io::NotConnectedException,
+ io::BufferSizeExceededException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xStream.is() || !m_xInputStream.is() )
+ throw uno::RuntimeException();
+
+ return m_xInputStream->readBytes( aData, nBytesToRead );
+}
+
+//-----------------------------------------------
+sal_Int32 SAL_CALL OFSStreamContainer::readSomeBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
+ throw( io::NotConnectedException,
+ io::BufferSizeExceededException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xStream.is() || !m_xInputStream.is() )
+ throw uno::RuntimeException();
+
+ return m_xInputStream->readSomeBytes( aData, nMaxBytesToRead );
+}
+
+//-----------------------------------------------
+void SAL_CALL OFSStreamContainer::skipBytes( sal_Int32 nBytesToSkip )
+ throw( io::NotConnectedException,
+ io::BufferSizeExceededException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xStream.is() || !m_xInputStream.is() )
+ throw uno::RuntimeException();
+
+ m_xInputStream->skipBytes( nBytesToSkip );
+}
+
+//-----------------------------------------------
+sal_Int32 SAL_CALL OFSStreamContainer::available()
+ throw( io::NotConnectedException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xStream.is() || !m_xInputStream.is() )
+ throw uno::RuntimeException();
+
+ return m_xInputStream->available();
+}
+
+//-----------------------------------------------
+void SAL_CALL OFSStreamContainer::closeInput()
+ throw( io::NotConnectedException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xStream.is() || !m_xInputStream.is() )
+ throw uno::RuntimeException();
+
+ if ( m_xInputStream.is() )
+ {
+ m_xInputStream->closeInput();
+ m_bInputClosed = sal_True;
+ }
+
+ if ( m_bOutputClosed )
+ dispose();
+}
+
+// XOutputStream
+//-----------------------------------------------
+void SAL_CALL OFSStreamContainer::writeBytes( const uno::Sequence< sal_Int8 >& aData )
+ throw ( io::NotConnectedException,
+ io::BufferSizeExceededException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xStream.is() || !m_xOutputStream.is() )
+ throw uno::RuntimeException();
+
+ return m_xOutputStream->writeBytes( aData );
+}
+
+//-----------------------------------------------
+void SAL_CALL OFSStreamContainer::flush()
+ throw ( io::NotConnectedException,
+ io::BufferSizeExceededException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xStream.is() || !m_xOutputStream.is() )
+ throw uno::RuntimeException();
+
+ return m_xOutputStream->flush();
+}
+
+//-----------------------------------------------
+void SAL_CALL OFSStreamContainer::closeOutput()
+ throw ( io::NotConnectedException,
+ io::BufferSizeExceededException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xStream.is() || !m_xOutputStream.is() )
+ throw uno::RuntimeException();
+
+ if ( m_xOutputStream.is() )
+ {
+ m_xOutputStream->closeOutput();
+ m_bOutputClosed = sal_True;
+ }
+
+ if ( m_bInputClosed )
+ dispose();
+}
+
+
+// XTruncate
+//-----------------------------------------------
+void SAL_CALL OFSStreamContainer::truncate()
+ throw ( io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xStream.is() || !m_xTruncate.is() )
+ throw uno::RuntimeException();
+
+ m_xTruncate->truncate();
+}
+
+
+// XAsyncOutputMonitor
+//-----------------------------------------------
+void SAL_CALL OFSStreamContainer::waitForCompletion()
+ throw ( io::IOException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+
+ if ( !m_xStream.is() || !m_xAsyncOutputMonitor.is() )
+ throw uno::RuntimeException();
+
+ m_xAsyncOutputMonitor->waitForCompletion();
+}
+
+
+
diff --git a/svl/source/fsstor/ostreamcontainer.hxx b/svl/source/fsstor/ostreamcontainer.hxx
new file mode 100644
index 000000000000..6198587c3d35
--- /dev/null
+++ b/svl/source/fsstor/ostreamcontainer.hxx
@@ -0,0 +1,128 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ostreamcontainer.hxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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 _OSTREAMCONTAINER_HXX_
+#define _OSTREAMCONTAINER_HXX_
+
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/embed/XExtendedStorageStream.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/io/XTruncate.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/io/XStream.hpp>
+#include "com/sun/star/io/XAsyncOutputMonitor.hpp"
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <cppuhelper/interfacecontainer.h>
+#include <osl/mutex.hxx>
+
+class OFSStreamContainer : public cppu::OWeakObject,
+ public ::com::sun::star::lang::XTypeProvider,
+ public ::com::sun::star::embed::XExtendedStorageStream,
+ public ::com::sun::star::io::XSeekable,
+ public ::com::sun::star::io::XInputStream,
+ public ::com::sun::star::io::XOutputStream,
+ public ::com::sun::star::io::XTruncate,
+ public ::com::sun::star::io::XAsyncOutputMonitor
+{
+ ::osl::Mutex m_aMutex;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > m_xStream;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable > m_xSeekable;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > m_xInputStream;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > m_xOutputStream;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XTruncate > m_xTruncate;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XAsyncOutputMonitor > m_xAsyncOutputMonitor;
+
+ sal_Bool m_bDisposed;
+ sal_Bool m_bInputClosed;
+ sal_Bool m_bOutputClosed;
+
+ ::cppu::OInterfaceContainerHelper* m_pListenersContainer; // list of listeners
+ ::cppu::OTypeCollection* m_pTypeCollection;
+
+public:
+ OFSStreamContainer( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XStream >& xStream );
+ virtual ~OFSStreamContainer();
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType )
+ throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
+ throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XStream
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL getOutputStream( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::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);
+
+ // XInputStream
+ virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL available( )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL closeInput( )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+
+ // XOutputStream
+ virtual void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< sal_Int8 >& aData ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ 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);
+ virtual void SAL_CALL closeOutput( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+
+ // XTruncate
+ virtual void SAL_CALL truncate() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+
+ // XAsyncOutputMonitor
+ virtual void SAL_CALL waitForCompletion( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+
+};
+
+#endif
+
diff --git a/svl/source/inc/fsfactory.hxx b/svl/source/inc/fsfactory.hxx
new file mode 100644
index 000000000000..5954ecebabc2
--- /dev/null
+++ b/svl/source/inc/fsfactory.hxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: fsfactory.hxx,v $
+ * $Revision: 1.4 $
+ *
+ * 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>
+
+
+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
+
diff --git a/svl/source/inc/passwordcontainer.hxx b/svl/source/inc/passwordcontainer.hxx
new file mode 100644
index 000000000000..a067672f3cf6
--- /dev/null
+++ b/svl/source/inc/passwordcontainer.hxx
@@ -0,0 +1,429 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: passwordcontainer.hxx,v $
+ * $Revision: 1.11 $
+ *
+ * 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_COMPHELPER_PASSWORDCONTAINER_HXX
+#define INCLUDED_COMPHELPER_PASSWORDCONTAINER_HXX
+
+#include <list>
+#include <vector>
+#include <map>
+#include <com/sun/star/task/XPasswordContainer.hpp>
+#include <com/sun/star/task/XUrlContainer.hpp>
+#include <com/sun/star/task/PasswordRequestMode.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/task/XMasterPasswordHandling2.hpp>
+#include <cppuhelper/implbase5.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <cppuhelper/factory.hxx>
+
+#include <tools/stream.hxx>
+#include <unotools/configitem.hxx>
+#include <ucbhelper/interactionrequest.hxx>
+
+#include <rtl/ref.hxx>
+#include <osl/mutex.hxx>
+
+#include "syscreds.hxx"
+
+#define MEMORY_RECORD 0
+#define PERSISTENT_RECORD 1
+
+//----------------------------------------------------------------------------------
+
+class NamePassRecord
+{
+ ::rtl::OUString m_aName;
+
+ // there are two lists of passwords, memory passwords and persistent passwords
+ sal_Bool m_bHasMemPass;
+ ::std::vector< ::rtl::OUString > m_aMemPass;
+
+ // persistent passwords are encrypted in one string
+ sal_Bool m_bHasPersPass;
+ ::rtl::OUString m_aPersPass;
+
+ void InitArrays( sal_Bool bHasMemoryList, const ::std::vector< ::rtl::OUString >& aMemoryList,
+ sal_Bool bHasPersistentList, const ::rtl::OUString& aPersistentList )
+ {
+ m_bHasMemPass = bHasMemoryList;
+ if ( bHasMemoryList )
+ m_aMemPass = aMemoryList;
+
+ m_bHasPersPass = bHasPersistentList;
+ if ( bHasPersistentList )
+ m_aPersPass = aPersistentList;
+ }
+
+public:
+
+ NamePassRecord( const ::rtl::OUString& aName )
+ : m_aName( aName )
+ , m_bHasMemPass( sal_False )
+ , m_bHasPersPass( sal_False )
+ {
+ }
+
+ NamePassRecord( const ::rtl::OUString& aName, const ::std::vector< ::rtl::OUString >& aMemoryList )
+ : m_aName( aName )
+ , m_bHasMemPass( sal_True )
+ , m_aMemPass( aMemoryList )
+ , m_bHasPersPass( sal_False )
+ {
+ }
+
+ NamePassRecord( const ::rtl::OUString& aName, const ::rtl::OUString& aPersistentList )
+ : m_aName( aName )
+ , m_bHasMemPass( sal_False )
+ , m_bHasPersPass( sal_True )
+ , m_aPersPass( aPersistentList )
+ {
+ }
+
+ NamePassRecord( const ::rtl::OUString& aName,
+ sal_Bool bHasMemoryList, const ::std::vector< ::rtl::OUString >& aMemoryList,
+ sal_Bool bHasPersistentList, const ::rtl::OUString aPersistentList )
+ : m_aName( aName )
+ , m_bHasMemPass( bHasMemoryList )
+ , m_bHasPersPass( bHasPersistentList )
+ {
+ InitArrays( bHasMemoryList, aMemoryList, bHasPersistentList, aPersistentList );
+ }
+
+ NamePassRecord( const NamePassRecord& aRecord )
+ : m_aName( aRecord.m_aName )
+ , m_bHasMemPass( sal_False )
+ , m_bHasPersPass( sal_False )
+ {
+ InitArrays( aRecord.m_bHasMemPass, aRecord.m_aMemPass, aRecord.m_bHasPersPass, aRecord.m_aPersPass );
+ }
+
+ NamePassRecord& operator=( const NamePassRecord& aRecord )
+ {
+ m_aName = aRecord.m_aName;
+
+ m_aMemPass.clear();
+ m_aPersPass = ::rtl::OUString();
+ InitArrays( aRecord.m_bHasMemPass, aRecord.m_aMemPass, aRecord.m_bHasPersPass, aRecord.m_aPersPass );
+
+ return *this;
+ }
+
+ ::rtl::OUString GetUserName() const
+ {
+ return m_aName;
+ }
+
+ sal_Bool HasPasswords( sal_Int8 nStatus ) const
+ {
+ if ( nStatus == MEMORY_RECORD )
+ return m_bHasMemPass;
+ if ( nStatus == PERSISTENT_RECORD )
+ return m_bHasPersPass;
+
+ return sal_False;
+ }
+
+ ::std::vector< ::rtl::OUString > GetMemPasswords() const
+ {
+ if ( m_bHasMemPass )
+ return m_aMemPass;
+
+ return ::std::vector< ::rtl::OUString >();
+ }
+
+ ::rtl::OUString GetPersPasswords() const
+ {
+ if ( m_bHasPersPass )
+ return m_aPersPass;
+
+ return ::rtl::OUString();
+ }
+
+ void SetMemPasswords( const ::std::vector< ::rtl::OUString >& aMemList )
+ {
+ m_aMemPass = aMemList;
+ m_bHasMemPass = sal_True;
+ }
+
+ void SetPersPasswords( const ::rtl::OUString& aPersList )
+ {
+ m_aPersPass = aPersList;
+ m_bHasPersPass = sal_True;
+ }
+
+ void RemovePasswords( sal_Int8 nStatus )
+ {
+ if ( nStatus == MEMORY_RECORD )
+ {
+ m_bHasMemPass = sal_False;
+ m_aMemPass.clear();
+ }
+ else if ( nStatus == PERSISTENT_RECORD )
+ {
+ m_bHasPersPass = sal_False;
+ m_aPersPass = ::rtl::OUString();
+ }
+ }
+
+};
+
+//----------------------------------------------------------------------------------
+
+typedef ::std::pair< const ::rtl::OUString, ::std::list< NamePassRecord > > PairUrlRecord;
+typedef ::std::map< ::rtl::OUString, ::std::list< NamePassRecord > > PassMap;
+
+//----------------------------------------------------------------------------------
+
+class PasswordContainer;
+
+class StorageItem : public ::utl::ConfigItem {
+ PasswordContainer* mainCont;
+ sal_Bool hasEncoded;
+ ::rtl::OUString mEncoded;
+public:
+ StorageItem( PasswordContainer* point, const ::rtl::OUString& path ) :
+ ConfigItem( path, CONFIG_MODE_IMMEDIATE_UPDATE ),
+ mainCont( point ),
+ hasEncoded( sal_False )
+ {
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aNode( 1 );
+ *aNode.getArray() = path;
+ *aNode.getArray() += ::rtl::OUString::createFromAscii( "/Store" );
+ EnableNotification( aNode );
+ }
+
+ PassMap getInfo();
+ void update( const ::rtl::OUString& url, const NamePassRecord& rec );
+ void remove( const ::rtl::OUString& url, const ::rtl::OUString& rec );
+ void clear();
+
+ sal_Bool getEncodedMP( ::rtl::OUString& aResult );
+ void setEncodedMP( const ::rtl::OUString& aResult, sal_Bool bAcceptEnmpty = sal_False );
+ void setUseStorage( sal_Bool bUse );
+ sal_Bool useStorage();
+
+ virtual void Notify( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames );
+ virtual void Commit();
+};
+
+//----------------------------------------------------------------------------------
+
+enum PasswordState {
+ no_password,
+ entered,
+ cancelled
+};
+
+class PasswordContainer : public ::cppu::WeakImplHelper5<
+ ::com::sun::star::task::XPasswordContainer,
+ ::com::sun::star::task::XMasterPasswordHandling2,
+ ::com::sun::star::task::XUrlContainer,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::lang::XEventListener >
+{
+private:
+ PassMap m_aContainer;
+ StorageItem* m_pStorageFile;
+ ::osl::Mutex mMutex;
+ ::rtl::OUString m_aMasterPasswd; // master password is set when the string is not empty
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mComponent;
+ SysCredentialsConfig mUrlContainer;
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::task::UserRecord > CopyToUserRecordSequence(
+ const ::std::list< NamePassRecord >& original,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ ::com::sun::star::task::UserRecord CopyToUserRecord(
+ const NamePassRecord& aRecord,
+ sal_Bool& io_bTryToDecode,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& aHandler );
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::task::UserRecord > FindUsr(
+ const ::std::list< NamePassRecord >& userlist,
+ const ::rtl::OUString& name,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler )
+ throw(::com::sun::star::uno::RuntimeException);
+bool createUrlRecord(
+ const PassMap::iterator & rIter,
+ bool bName,
+ const ::rtl::OUString & aName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& aHandler,
+ ::com::sun::star::task::UrlRecord & rRec )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::task::UrlRecord find(
+ const ::rtl::OUString& aURL,
+ const ::rtl::OUString& aName,
+ bool bName, // only needed to support empty user names
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& aHandler ) throw(::com::sun::star::uno::RuntimeException);
+
+ ::rtl::OUString GetDefaultMasterPassword();
+
+ ::rtl::OUString RequestPasswordFromUser(
+ ::com::sun::star::task::PasswordRequestMode aRMode,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler );
+
+ ::rtl::OUString GetMasterPassword( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ void UpdateVector( const ::rtl::OUString& url, ::std::list< NamePassRecord >& toUpdate, NamePassRecord& rec, sal_Bool writeFile )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ void PrivateAdd( const ::rtl::OUString& aUrl,
+ const ::rtl::OUString& aUserName,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPasswords,
+ char aMode,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ ::std::vector< ::rtl::OUString > DecodePasswords( const ::rtl::OUString& aLine, const ::rtl::OUString& aMasterPassword )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ ::rtl::OUString EncodePasswords( ::std::vector< ::rtl::OUString > lines, const ::rtl::OUString& aMasterPassword )
+ throw(::com::sun::star::uno::RuntimeException);
+
+public:
+ PasswordContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& );
+ ~PasswordContainer();
+
+ virtual void SAL_CALL add( const ::rtl::OUString& aUrl,
+ const ::rtl::OUString& aUserName,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPasswords,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL addPersistent( const ::rtl::OUString& aUrl,
+ const ::rtl::OUString& aUserName,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPasswords,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::task::UrlRecord SAL_CALL
+ find( const ::rtl::OUString& aUrl,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::task::UrlRecord SAL_CALL
+ findForName( const ::rtl::OUString& aUrl,
+ const ::rtl::OUString& aUserName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL remove( const ::rtl::OUString& aUrl,
+ const ::rtl::OUString& aUserName )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL removePersistent( const ::rtl::OUString& aUrl,
+ const ::rtl::OUString& aUserName )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL removeAllPersistent() throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::task::UrlRecord > SAL_CALL
+ getAllPersistent( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler ) throw(::com::sun::star::uno::RuntimeException);
+
+
+ // provide factory
+ static ::rtl::OUString SAL_CALL impl_getStaticImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
+ impl_getStaticSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
+ impl_createFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ServiceManager ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ impl_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) 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);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ // XMasterPasswordHandling
+ virtual ::sal_Bool SAL_CALL authorizateWithMasterPassword( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL changeMasterPassword( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeMasterPassword() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasMasterPassword( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL allowPersistentStoring( ::sal_Bool bAllow ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isPersistentStoringAllowed( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XMasterPasswordHandling2
+ virtual ::sal_Bool SAL_CALL useDefaultMasterPassword( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isDefaultMasterPasswordUsed( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XUrlContainer
+ virtual void SAL_CALL addUrl( const ::rtl::OUString& Url, ::sal_Bool MakePersistent ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL findUrl( const ::rtl::OUString& Url ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeUrl( const ::rtl::OUString& Url ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getUrls( ::sal_Bool OnlyPersistent ) throw (::com::sun::star::uno::RuntimeException);
+
+ void Notify();
+};
+
+//----------------------------------------------------------------------------------
+
+class MasterPasswordRequest_Impl : public ucbhelper::InteractionRequest
+{
+ ::rtl::Reference< ucbhelper::InteractionSupplyAuthentication > m_xAuthSupplier;
+
+public:
+ MasterPasswordRequest_Impl( ::com::sun::star::task::PasswordRequestMode Mode );
+
+ const ::rtl::Reference< ucbhelper::InteractionSupplyAuthentication > &
+ getAuthenticationSupplier() const { return m_xAuthSupplier; }
+
+};
+
+//----------------------------------------------------------------------------------
+
+class RW_SvMemoryStream : public SvMemoryStream {
+public:
+ RW_SvMemoryStream( void* Buf, ULONG Size, StreamMode eMode ):
+ SvMemoryStream( Buf, Size, eMode){}
+
+ RW_SvMemoryStream( ULONG InitSize=512, ULONG Resize=64 ):
+ SvMemoryStream( InitSize, Resize ){}
+
+ ULONG getActualSize(){ return nEndOfData; }
+};
+
+
+
+#endif // #ifndef INCLUDED_COMPHELPER_PASSWORDCONTAINER_HXX
+
diff --git a/svl/source/inc/poolio.hxx b/svl/source/inc/poolio.hxx
new file mode 100644
index 000000000000..fb30fc04832d
--- /dev/null
+++ b/svl/source/inc/poolio.hxx
@@ -0,0 +1,204 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: poolio.hxx,v $
+ * $Revision: 1.7 $
+ *
+ * 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 <svtools/brdcst.hxx>
+
+
+#ifndef DELETEZ
+#define DELETEZ(pPtr) { delete pPtr; pPtr = 0; }
+#endif
+
+
+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;
+}
+
diff --git a/svl/source/items/aeitem.cxx b/svl/source/items/aeitem.cxx
new file mode 100644
index 000000000000..63fbd1db6227
--- /dev/null
+++ b/svl/source/items/aeitem.cxx
@@ -0,0 +1,317 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: aeitem.cxx,v $
+ * $Revision: 1.11 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#ifndef GCC
+#endif
+
+#include <tools/string.hxx>
+
+#define _SVSTDARR_USHORTS
+#include <svtools/svstdarr.hxx>
+#include <svtools/svarray.hxx>
+#include <svtools/aeitem.hxx>
+
+// 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, USHORT nVal, const XubString &rText ):
+ SfxEnumItem(which, nVal),
+ pValues( 0 ),
+ pDisabledValues( 0 )
+{
+ DBG_CTOR(SfxAllEnumItem, 0);
+ InsertValue( nVal, rText );
+}
+
+// -----------------------------------------------------------------------
+
+SfxAllEnumItem::SfxAllEnumItem(USHORT which, USHORT nVal):
+ SfxEnumItem(which, nVal),
+ pValues( 0 ),
+ pDisabledValues( 0 )
+{
+ DBG_CTOR(SfxAllEnumItem, 0);
+ InsertValue( nVal );
+}
+
+// -----------------------------------------------------------------------
+
+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, const XubString &rValue )
+{
+ DBG_CHKTHIS(SfxAllEnumItem, 0);
+ SfxAllEnumValue_Impl *pVal = new SfxAllEnumValue_Impl;
+ pVal->nValue = nValue;
+ pVal->aText = rValue;
+ const SfxAllEnumValue_Impl *pTemp = pVal;
+ if ( !pValues )
+ pValues = new SfxAllEnumValueArr;
+ else if ( GetPosByValue( nValue ) != USHRT_MAX )
+ // remove when exists
+ RemoveValue( nValue );
+ // then insert
+ pValues->Insert( pTemp, _GetPosByValue(nValue) ); //! doppelte?!
+}
+
+// -----------------------------------------------------------------------
+
+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?!
+}
+
+void SfxAllEnumItem::DisableValue( USHORT nValue )
+{
+ DBG_CHKTHIS(SfxAllEnumItem, 0);
+ if ( !pDisabledValues )
+ pDisabledValues = new SvUShorts;
+
+ pDisabledValues->Insert( nValue, pDisabledValues->Count() );
+}
+
+BOOL SfxAllEnumItem::IsEnabled( USHORT nValue ) const
+{
+ if ( pDisabledValues )
+ {
+ for ( USHORT i=0; i<pDisabledValues->Count(); i++ )
+ if ( (*pDisabledValues)[i] == nValue )
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+void SfxAllEnumItem::RemoveValue( USHORT nValue )
+{
+ DBG_CHKTHIS(SfxAllEnumItem, 0);
+ USHORT nPos = GetPosByValue(nValue);
+ DBG_ASSERT( nPos != USHRT_MAX, "removing value not in enum" );
+ pValues->Remove( nPos );
+}
+
+// -----------------------------------------------------------------------
+
+
+void SfxAllEnumItem::RemoveAllValues()
+{
+ DBG_CHKTHIS(SfxAllEnumItem, 0);
+ if ( pValues )
+ pValues->DeleteAndDestroy( 0, pValues->Count() );
+}
+
+
+
diff --git a/svl/source/items/bintitem.cxx b/svl/source/items/bintitem.cxx
new file mode 100644
index 000000000000..a3b6c1c2b54d
--- /dev/null
+++ b/svl/source/items/bintitem.cxx
@@ -0,0 +1,169 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: bintitem.cxx,v $
+ * $Revision: 1.8 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <com/sun/star/uno/Any.hxx>
+#include <tools/stream.hxx>
+#include <tools/bigint.hxx>
+#include <svtools/bintitem.hxx>
+
+// STATIC DATA
+
+DBG_NAME(SfxBigIntItem)
+
+// RTTI
+TYPEINIT1_AUTOFACTORY(SfxBigIntItem, SfxPoolItem);
+
+// SfxBigIntItem
+
+//============================================================================
+SfxBigIntItem::SfxBigIntItem()
+ : SfxPoolItem(0),
+ aVal(0)
+{
+ DBG_CTOR(SfxBigIntItem, 0);
+}
+
+//============================================================================
+SfxBigIntItem::SfxBigIntItem(USHORT which, const BigInt& rValue)
+ : SfxPoolItem(which),
+ aVal(rValue)
+{
+ 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;
+}
+
diff --git a/svl/source/items/cenumitm.cxx b/svl/source/items/cenumitm.cxx
new file mode 100644
index 000000000000..1906e62a8cf8
--- /dev/null
+++ b/svl/source/items/cenumitm.cxx
@@ -0,0 +1,297 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: cenumitm.cxx,v $
+ * $Revision: 1.9 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <com/sun/star/uno/Any.hxx>
+#include <tools/stream.hxx>
+#include <svtools/cenumitm.hxx>
+#include <whassert.hxx>
+
+#ifndef _CPPUHELPER_EXTRACT_HXX_
+#include <cppuhelper/extract.hxx>
+#endif
+
+//============================================================================
+//
+// 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"));
+}
+
diff --git a/svl/source/items/cintitem.cxx b/svl/source/items/cintitem.cxx
new file mode 100644
index 000000000000..97cce9b75591
--- /dev/null
+++ b/svl/source/items/cintitem.cxx
@@ -0,0 +1,565 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: cintitem.cxx,v $
+ * $Revision: 1.10 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <com/sun/star/uno/Any.hxx>
+#include <tools/stream.hxx>
+#include <svtools/cintitem.hxx>
+
+//============================================================================
+//
+// class CntByteItem
+//
+//============================================================================
+
+DBG_NAME(CntByteItem)
+
+//============================================================================
+TYPEINIT1_AUTOFACTORY(CntByteItem, SfxPoolItem);
+
+//============================================================================
+CntByteItem::CntByteItem(USHORT which, SvStream & rStream):
+ SfxPoolItem(which)
+{
+ DBG_CTOR(CntByteItem, 0);
+ rStream >> m_nValue;
+}
+
+//============================================================================
+// 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;
+}
+
diff --git a/svl/source/items/cntwall.cxx b/svl/source/items/cntwall.cxx
new file mode 100644
index 000000000000..67e9387fbe26
--- /dev/null
+++ b/svl/source/items/cntwall.cxx
@@ -0,0 +1,170 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: cntwall.cxx,v $
+ * $Revision: 1.7 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include <tools/debug.hxx>
+#include <tools/string.hxx>
+#include <tools/stream.hxx>
+#include <tools/vcompat.hxx>
+
+#include <svtools/cntwall.hxx>
+
+#define CNTWALLPAPERITEM_STREAM_MAGIC ( (UINT32)0xfefefefe )
+#define CNTWALLPAPERITEM_STREAM_SEEKREL (-( (long)( sizeof( UINT32 ) ) ) )
+
+TYPEINIT1( CntWallpaperItem, SfxPoolItem );
+
+// -----------------------------------------------------------------------
+CntWallpaperItem::CntWallpaperItem( USHORT which )
+ : SfxPoolItem( which ), _nColor( COL_TRANSPARENT ), _nStyle( 0 )
+{
+}
+
+// -----------------------------------------------------------------------
+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;
+}
+
+
diff --git a/svl/source/items/cstitem.cxx b/svl/source/items/cstitem.cxx
new file mode 100644
index 000000000000..9755f4bb9944
--- /dev/null
+++ b/svl/source/items/cstitem.cxx
@@ -0,0 +1,252 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: cstitem.cxx,v $
+ * $Revision: 1.9 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <com/sun/star/uno/Any.hxx>
+
+#include <unotools/intlwrapper.hxx>
+
+#include <tools/stream.hxx>
+#include <tools/debug.hxx>
+#include <tools/datetime.hxx>
+
+#include <svtools/svtdata.hxx>
+#include <svtools/cstitem.hxx>
+
+#include <svtools/svtools.hrc>
+#include <com/sun/star/lang/Locale.hpp>
+
+DBG_NAME( SfxCrawlStatusItem )
+TYPEINIT1( SfxCrawlStatusItem, SfxPoolItem );
+
+// -----------------------------------------------------------------------
+
+SfxCrawlStatusItem::SfxCrawlStatusItem( USHORT which ) :
+ SfxPoolItem( which )
+{
+ DBG_CTOR( SfxCrawlStatusItem, 0 );
+}
+
+// -----------------------------------------------------------------------
+
+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 /*ePresentation*/,
+ SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/,
+ XubString& rText,
+ const IntlWrapper * pIntlWrapper
+) const
+{
+ DBG_CHKTHIS(SfxCrawlStatusItem, 0);
+ DBG_ASSERT(pIntlWrapper,
+ "SfxCrawlStatusItem::GetPresentation():"
+ " Using default IntlWrapper");
+
+ ::com::sun::star::lang::Locale aLocale;
+
+ switch (eStatus)
+ {
+ case CSTAT_NEVER_UPD:
+ rText = String(SvtResId(STR_CSTAT_NEVER_UPD,
+ pIntlWrapper ?
+ pIntlWrapper->getLocale() :
+ aLocale));
+ break;
+
+ case CSTAT_IN_UPD:
+ rText = String(SvtResId(STR_CSTAT_IN_UPD,
+ pIntlWrapper ?
+ pIntlWrapper->getLocale() :
+ aLocale));
+ break;
+
+ case CSTAT_UPD_NEWER:
+ rText = String(SvtResId(STR_CSTAT_UPD_NEWER,
+ pIntlWrapper ?
+ pIntlWrapper->getLocale() :
+ aLocale));
+ break;
+
+ case CSTAT_UPD_NOT_NEWER:
+ rText = String(SvtResId(STR_CSTAT_UPD_NOT_NEWER,
+ pIntlWrapper ?
+ pIntlWrapper->getLocale() :
+ aLocale));
+ break;
+
+ case CSTAT_UPD_CANCEL:
+ rText = String(SvtResId(STR_CSTAT_UPD_CANCEL,
+ pIntlWrapper ?
+ pIntlWrapper->getLocale() :
+ aLocale));
+ break;
+
+ case CSTAT_ERR_GENERAL:
+ rText = String(SvtResId(STR_CSTAT_ERR_GENERAL,
+ pIntlWrapper ?
+ pIntlWrapper->getLocale() :
+ aLocale));
+ break;
+
+ case CSTAT_ERR_NOTEXISTS:
+ rText = String(SvtResId(STR_CSTAT_ERR_NOTEXISTS,
+ pIntlWrapper ?
+ pIntlWrapper->getLocale() :
+ aLocale));
+ break;
+
+ case CSTAT_ERR_NOTREACHED:
+ rText = String(SvtResId(STR_CSTAT_ERR_NOTREACHED,
+ pIntlWrapper ?
+ pIntlWrapper->getLocale() :
+ aLocale));
+ break;
+
+ case CSTAT_UPD_IMMEDIATELY:
+ rText = String(SvtResId(STR_CSTAT_UPD_IMMEDIATELY,
+ pIntlWrapper ?
+ pIntlWrapper->getLocale() :
+ aLocale));
+ break;
+
+ case CSTAT_ERR_OFFLINE:
+ rText = String(SvtResId(STR_CSTAT_ERR_OFFLINE,
+ pIntlWrapper ?
+ pIntlWrapper->getLocale() :
+ aLocale));
+ break;
+
+ default:
+ rText.Erase();
+ break;
+ }
+ 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;
+}
+
diff --git a/svl/source/items/cstitem.src b/svl/source/items/cstitem.src
new file mode 100644
index 000000000000..8d6e2d0280c0
--- /dev/null
+++ b/svl/source/items/cstitem.src
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: cstitem.src,v $
+ * $Revision: 1.7 $
+ *
+ * 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 <svtools/svtools.hrc>
+String STR_CSTAT_NEVER_UPD
+{
+ Text [ en-US ] = "No update has occurred" ;
+};
+String STR_CSTAT_IN_UPD
+{
+ Text [ en-US ] = "Updating in progress" ;
+};
+String STR_CSTAT_UPD_NEWER
+{
+ Text [ en-US ] = "Changes discovered" ;
+};
+String STR_CSTAT_UPD_NOT_NEWER
+{
+ Text [ en-US ] = "No changes discovered" ;
+};
+String STR_CSTAT_UPD_CANCEL
+{
+ Text [ en-US ] = "Canceled by user" ;
+};
+String STR_CSTAT_UPD_IMMEDIATELY
+{
+ Text [ en-US ] = "Updating immediately" ;
+};
+String STR_CSTAT_ERR_OFFLINE
+{
+ Text [ en-US ] = "failed, you have not been online" ;
+};
+String STR_CSTAT_ERR_GENERAL
+{
+ Text [ en-US ] = "General error" ;
+};
+String STR_CSTAT_ERR_NOTEXISTS
+{
+ Text [ en-US ] = "Server does not exist" ;
+};
+String STR_CSTAT_ERR_NOTREACHED
+{
+ Text [ en-US ] = "Server not available" ;
+};
+String STR_COLUM_DT_AUTO
+{
+ Text [ en-US ] = "automatic" ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svl/source/items/ctypeitm.cxx b/svl/source/items/ctypeitm.cxx
new file mode 100644
index 000000000000..552d4a6a9041
--- /dev/null
+++ b/svl/source/items/ctypeitm.cxx
@@ -0,0 +1,254 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ctypeitm.cxx,v $
+ * $Revision: 1.7.136.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <com/sun/star/uno/Any.hxx>
+
+#include <unotools/intlwrapper.hxx>
+#include <tools/stream.hxx>
+#include <svtools/ctypeitm.hxx>
+
+//============================================================================
+// 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( USHORT which,
+ const INetContentType eType )
+: CntUnencodedStringItem( which, INetContentTypes::GetContentType( eType ) ),
+ _eType( eType )
+{
+}
+
+//----------------------------------------------------------------------------
+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 );
+}
+
+//----------------------------------------------------------------------------
+void CntContentTypeItem::SetPresentation( const XubString& rNewVal )
+{
+ _aPresentation = 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;
+}
diff --git a/svl/source/items/custritm.cxx b/svl/source/items/custritm.cxx
new file mode 100644
index 000000000000..9f573beb56fd
--- /dev/null
+++ b/svl/source/items/custritm.cxx
@@ -0,0 +1,141 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: custritm.cxx,v $
+ * $Revision: 1.6 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <com/sun/star/uno/Any.hxx>
+
+#include <unotools/intlwrapper.hxx>
+#include <tools/stream.hxx>
+#include <svtools/custritm.hxx>
+
+//============================================================================
+//
+// 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);
+}
+
diff --git a/svl/source/items/dateitem.cxx b/svl/source/items/dateitem.cxx
new file mode 100644
index 000000000000..4ba6e1d460f9
--- /dev/null
+++ b/svl/source/items/dateitem.cxx
@@ -0,0 +1,284 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dateitem.cxx,v $
+ * $Revision: 1.8 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+// include ---------------------------------------------------------------
+
+#define _DATETIMEITEM_CXX
+#include <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 <svtools/svtdata.hxx>
+#include <svtools/svtools.hrc>
+
+// STATIC DATA -----------------------------------------------------------
+
+DBG_NAME(SfxDateTimeItem)
+
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1(SfxDateTimeItem, SfxPoolItem);
+
+// -----------------------------------------------------------------------
+
+SfxDateTimeItem::SfxDateTimeItem( USHORT which ) :
+ SfxPoolItem( which )
+{
+ DBG_CTOR(SfxDateTimeItem, 0);
+}
+
+// -----------------------------------------------------------------------
+
+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);
+
+
+SfxColumnDateTimeItem::SfxColumnDateTimeItem( USHORT which ) :
+ SfxDateTimeItem( which )
+{}
+
+SfxColumnDateTimeItem::SfxColumnDateTimeItem( USHORT which, const DateTime& rDT ) :
+ SfxDateTimeItem( which, rDT )
+{}
+
+SfxColumnDateTimeItem::SfxColumnDateTimeItem( const SfxDateTimeItem& rCpy ) :
+ SfxDateTimeItem( rCpy )
+{}
+
+SfxPoolItem* SfxColumnDateTimeItem::Clone( SfxItemPool* ) const
+{
+ return new SfxColumnDateTimeItem( *this );
+}
+
+SfxItemPresentation SfxColumnDateTimeItem::GetPresentation
+(
+ SfxItemPresentation /*ePresentation*/,
+ SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/,
+ XubString& rText,
+ const IntlWrapper * pIntlWrapper
+) const
+{
+ DBG_ASSERT(pIntlWrapper,
+ "SfxColumnDateTimeItem::GetPresentation():"
+ " Using default en_US IntlWrapper");
+
+ ::com::sun::star::lang::Locale aLocale;
+ if (GetDateTime() == DateTime(Date(1, 2, 3), Time(3, 2, 1)))
+ rText = String(SvtResId(STR_COLUM_DT_AUTO,
+ pIntlWrapper ?
+ pIntlWrapper->getLocale() :
+ aLocale));
+ else if (pIntlWrapper)
+ {
+ rText = pIntlWrapper->getLocaleData()->getDate(GetDateTime());
+ rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ rText += pIntlWrapper->getLocaleData()->getTime(GetDateTime());
+ }
+ else
+ {
+ const IntlWrapper aIntlWrapper(
+ ::comphelper::getProcessServiceFactory(), LANGUAGE_ENGLISH_US );
+ rText = aIntlWrapper.getLocaleData()->getDate(GetDateTime());
+ rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ rText += aIntlWrapper.getLocaleData()->getTime(GetDateTime());
+ }
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+
+
diff --git a/svl/source/items/dtritem.cxx b/svl/source/items/dtritem.cxx
new file mode 100644
index 000000000000..fa3a36b762f5
--- /dev/null
+++ b/svl/source/items/dtritem.cxx
@@ -0,0 +1,244 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dtritem.cxx,v $
+ * $Revision: 1.8 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <com/sun/star/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 <svtools/dtritem.hxx>
+
+
+DBG_NAME( SfxDateTimeRangeItem )
+TYPEINIT1( SfxDateTimeRangeItem, SfxPoolItem );
+
+// -----------------------------------------------------------------------
+
+SfxDateTimeRangeItem::SfxDateTimeRangeItem( USHORT which ) :
+ SfxPoolItem( which )
+{
+ DBG_CTOR( SfxDateTimeRangeItem, 0 );
+}
+
+// -----------------------------------------------------------------------
+
+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;
+}
+
+
diff --git a/svl/source/items/eitem.cxx b/svl/source/items/eitem.cxx
new file mode 100644
index 000000000000..f7b95665391d
--- /dev/null
+++ b/svl/source/items/eitem.cxx
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: eitem.cxx,v $
+ * $Revision: 1.5 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <svtools/eitem.hxx>
+//============================================================================
+//
+// class SfxEnumItem
+//
+//============================================================================
+
+TYPEINIT1(SfxEnumItem, CntEnumItem);
+
+//============================================================================
+//
+// class SfxBoolItem
+//
+//============================================================================
+
+TYPEINIT1_AUTOFACTORY(SfxBoolItem, CntBoolItem);
+
+
diff --git a/svl/source/items/flagitem.cxx b/svl/source/items/flagitem.cxx
new file mode 100644
index 000000000000..e59f981c5afa
--- /dev/null
+++ b/svl/source/items/flagitem.cxx
@@ -0,0 +1,166 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: flagitem.cxx,v $
+ * $Revision: 1.11 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include <svtools/flagitem.hxx>
+#include <svtools/poolitem.hxx>
+#include <tools/stream.hxx>
+
+// 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( USHORT nW, SvStream &rStream) :
+ SfxPoolItem( nW )
+{
+ DBG_CTOR(SfxFlagItem, 0);
+ rStream >> nVal;
+}
+
+// -----------------------------------------------------------------------
+
+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);
+}
+
+// -----------------------------------------------------------------------
+
+void SfxFlagItem::SetFlag( BYTE nFlag, int bVal )
+{
+ if ( bVal )
+ nVal |= nSfxFlagVal[nFlag];
+ else
+ nVal &= ~nSfxFlagVal[nFlag];
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxFlagItem::Clone(SfxItemPool *) const
+{
+ DBG_CHKTHIS(SfxFlagItem, 0);
+ return new SfxFlagItem( *this );
+}
+
+
+
+
+
diff --git a/svl/source/items/frqitem.cxx b/svl/source/items/frqitem.cxx
new file mode 100644
index 000000000000..4068ef8f97f1
--- /dev/null
+++ b/svl/source/items/frqitem.cxx
@@ -0,0 +1,580 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: frqitem.cxx,v $
+ * $Revision: 1.8.136.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#ifndef GCC
+#endif
+
+#include <unotools/intlwrapper.hxx>
+
+#include <tools/stream.hxx>
+#include <tools/debug.hxx>
+#include <tools/datetime.hxx>
+
+#include <svtools/frqitem.hxx>
+
+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 ) :
+ SfxPoolItem ( which ),
+ eFrqMode ( FRQ_DAILY ),
+ eFrqTimeMode ( FRQ_TIME_AT ),
+ nDInterval1 ( 1 ),
+ nDInterval2 ( 0 ),
+ nDInterval3 ( 0 ),
+ nTInterval1 ( 1 ),
+ aTime1 ( Time( 12, 0, 0 ) ),
+ aTime2 ( Time( 12, 0, 0 ) ),
+ bMissingDate ( FALSE ),
+ aMissingDate ( DateTime(0, 0) )
+{
+ DBG_CTOR( SfxFrequencyItem, 0 );
+}
+
+// -----------------------------------------------------------------------
+
+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;
+}
+
+// -----------------------------------------------------------------------
+
+Time SfxFrequencyItem::_CalcTime( BOOL bForToday ) const
+{
+ Time aNow;
+ Time aTime;
+
+ DECL_SAVE_GOTO();
+
+ switch( eFrqTimeMode )
+ {
+ //////////////////////////////////////////////////////////
+ // FRQ_TIME_AT
+ //
+ // Update um Uhrzeit
+ // nTime1 = 00:00:00 - 24:00:00
+ //
+ case FRQ_TIME_AT :
+ aTime = aTime1;
+ break;
+
+ //////////////////////////////////////////////////////////
+ // FRQ_TIME_REPEAT
+ //
+ // Wiederhole alle X Stunden
+ // nTInterval1 = 1 .. 8
+ //
+ case FRQ_TIME_REPEAT :
+ aTime = Time( 0, 0 );
+ if( bForToday )
+ {
+
+ RECALC_TIME_REPEAT:
+ if( aNow > aTime )
+ {
+ aTime += Time( nTInterval1, 0 );
+ SAVE_GOTO( RECALC_TIME_REPEAT );
+ }
+ break;
+ }
+ break;
+
+ //////////////////////////////////////////////////////////
+ // FRQ_TIME_REPEAT_RANGE
+ //
+ // FRQ_TIME_REPEAT zwischen Uhrzeit 1 und 2
+ // nTime1 = 00:00:00 - 24:00:00
+ // nTime2 = 00:00:00 - 24:00:00
+ //
+ case FRQ_TIME_REPEAT_RANGE :
+ aTime = aTime1;
+ if( bForToday )
+ {
+ if( aNow > aTime2 )
+ return aTime1;
+
+ RECALC_TIME_REPEAT_RANGE:
+ if( aNow > aTime )
+ {
+ aTime += Time( nTInterval1, 0 );
+ if( aTime > aTime2 )
+ return aTime1;
+ SAVE_GOTO( RECALC_TIME_REPEAT_RANGE );
+ }
+ break;
+ }
+ break;
+ }
+ return aTime;
+}
+
+DateTime SfxFrequencyItem::CalcNextTick( const DateTime& rBase, BOOL bFirst )
+{
+ Date aDateToday;
+ Time aTimeToday;
+ Date aDateBase;
+ Time aTimeBase;
+
+ if( bFirst )
+ {
+ aDateBase = Date( 17, 2, 1969 );
+ aTimeBase = Time( 8, 0, 0 );
+ }
+ else
+ {
+ aDateBase = rBase.GetDate();
+ aTimeBase = rBase.GetTime();
+ }
+
+ Time aNextTime( _CalcTime(FALSE) );
+ Date aNextDate( aDateBase );
+ bMissingDate = FALSE;
+
+ DECL_SAVE_GOTO();
+
+ switch( eFrqMode )
+ {
+ //////////////////////////////////////////////////////////
+ // FRQ_DAILY
+ //
+ // jeden X'ten Tag
+ // nInterval1 = 1 .. 999
+ //
+ // jeden Wochentag
+ // nInterval1 = USHRT_MAX
+ //
+ case FRQ_DAILY :
+ {
+ if( bFirst )
+ {
+ aNextTime = _CalcTime( TRUE );
+ if( aNextTime < aTimeToday )
+ {
+ aNextTime = _CalcTime( FALSE );
+ aNextDate = aDateToday + (USHORT)
+ ((nDInterval1 == USHRT_MAX)? 1 : nDInterval1);
+ }
+ else
+ aNextDate = aDateToday;
+ break;
+ }
+
+ RECALC_FRQ_DAILY:
+ if( aNextDate < aDateToday )
+ {
+ bMissingDate = TRUE;
+ aMissingDate.SetDate(aNextDate.GetDate());
+ aMissingDate.SetTime(_CalcTime(FALSE).GetTime());
+
+ aNextDate += (USHORT)((nDInterval1 == USHRT_MAX)? 1 : nDInterval1);
+ SAVE_GOTO( RECALC_FRQ_DAILY );
+ }
+
+ if( aNextDate == aDateToday )
+ {
+ aNextTime = _CalcTime( TRUE );
+ if( aNextTime < aTimeToday )
+ {
+ bMissingDate = TRUE;
+ aMissingDate.SetDate(aNextDate.GetDate());
+ aMissingDate.SetTime(_CalcTime(FALSE).GetTime());
+
+ aNextDate += (USHORT)((nDInterval1 == USHRT_MAX)? 1 : nDInterval1);
+ aNextTime = _CalcTime( FALSE );
+ }
+ }
+ else
+ aNextTime = _CalcTime( FALSE );
+ } break;
+
+ //////////////////////////////////////////////////////////
+ // FRQ_WEEKLY
+ // wiederhole jede X'te Woche
+ // nInterval1 = 1 .. 99
+ //
+ // an SU, MO, TU, WE, TH, FR, SA
+ // nInterval2 = WD_SUNDAY | WD_MONDAY | WD_TUESDAY |
+ // WD_WEDNESDAY | WD_THURSDAY | WD_FRIDAY |
+ // WD_SATURDAY
+ //
+ case FRQ_WEEKLY :
+ {
+ BOOL bInRecalc = FALSE;
+
+ RECALC_FRQ_WEEKLY:
+ if( !bFirst || bInRecalc )
+ aNextDate += (nDInterval1 - 1) * 7;
+
+ aNextDate -= (USHORT) ((aNextDate.GetDayOfWeek() != SUNDAY) ?
+ aNextDate.GetDayOfWeek() + 1 : 0);
+
+ if( nDInterval2 & WD_SUNDAY && (aNextDate >= aDateToday) )
+ aNextDate += 0;
+ else if( nDInterval2 & WD_MONDAY && (aNextDate + 1 >= aDateToday) )
+ aNextDate += 1;
+ else if( nDInterval2 & WD_TUESDAY && (aNextDate + 2 >= aDateToday) )
+ aNextDate += 2;
+ else if( nDInterval2 & WD_WEDNESDAY && (aNextDate + 3 >= aDateToday) )
+ aNextDate += 3;
+ else if( nDInterval2 & WD_THURSDAY && (aNextDate + 4 >= aDateToday) )
+ aNextDate += 4;
+ else if( nDInterval2 & WD_FRIDAY && (aNextDate + 5 >= aDateToday) )
+ aNextDate += 5;
+ else if( nDInterval2 & WD_SATURDAY && (aNextDate + 6 >= aDateToday) )
+ aNextDate += 6;
+
+ if( aNextDate < aDateToday )
+ {
+ bMissingDate = TRUE;
+ aMissingDate.SetDate(aNextDate.GetDate());
+ aMissingDate.SetTime(_CalcTime(FALSE).GetTime());
+
+ bInRecalc = TRUE;
+ aNextDate += 7;
+ SAVE_GOTO( RECALC_FRQ_WEEKLY );
+ }
+ if( aNextDate == aDateToday )
+ {
+ aNextTime = _CalcTime( TRUE );
+ if( aNextTime < aTimeToday )
+ {
+ bInRecalc = TRUE;
+ aNextDate += 7;
+ SAVE_GOTO( RECALC_FRQ_WEEKLY );
+ }
+ }
+ else
+ aNextTime = _CalcTime( FALSE );
+ } break;
+
+ //////////////////////////////////////////////////////////
+ // FRQ_MONTHLY_DAILY
+ //
+ // jeden X'ten Tag von jedem X'ten Monat
+ // nInterval1 = 1 .. 31
+ // nInterval2 = 1 .. 6
+ //
+ case FRQ_MONTHLY_DAILY :
+ {
+ BOOL bInRecalc = FALSE;
+ aNextDate.SetDay( nDInterval1 );
+
+ RECALC_FRQ_MONTHLY_DAILY:
+ if( nDInterval2 > 1 || bInRecalc )
+ {
+ long nMonth = aNextDate.GetMonth() - 1;
+ nMonth += nDInterval2;
+ aNextDate.SetYear(
+ sal::static_int_cast< USHORT >(
+ aNextDate.GetYear() + nMonth / 12 ) );
+ aNextDate.SetMonth(
+ sal::static_int_cast< USHORT >( ( nMonth % 12 ) + 1 ) );
+ }