summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorMathias Bauer <mba@openoffice.org>2010-01-12 08:29:31 +0100
committerMathias Bauer <mba@openoffice.org>2010-01-12 08:29:31 +0100
commit5a03ff2c5391d9a25d0bfbb1e4b3f1312df1c70b (patch)
tree6f6a031f32ee21b156ace59e401c2225ef026b26 /svl
parentcf1210e40b872191ba433636480293eabc017d95 (diff)
#i107450#: code from svx/source/options moved to other libs
Diffstat (limited to 'svl')
-rw-r--r--svl/inc/svl/asiancfg.hxx72
-rw-r--r--svl/inc/svl/srchcfg.hxx85
-rw-r--r--svl/source/config/asiancfg.cxx294
-rw-r--r--svl/source/config/makefile.mk2
-rw-r--r--svl/source/config/srchcfg.cxx290
5 files changed, 743 insertions, 0 deletions
diff --git a/svl/inc/svl/asiancfg.hxx b/svl/inc/svl/asiancfg.hxx
new file mode 100644
index 000000000000..55dfeb06d679
--- /dev/null
+++ b/svl/inc/svl/asiancfg.hxx
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * 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: asiancfg.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 _SVX_ASIANCFG_HXX
+#define _SVX_ASIANCFG_HXX
+
+#include <unotools/configitem.hxx>
+#include <com/sun/star/uno/Sequence.h>
+#include <svl/svldllapi.h>
+
+namespace com{namespace sun{namespace star{
+namespace lang{
+ struct Locale;
+}}}}
+//-----------------------------------------------------------------------------
+struct SvxAsianConfig_Impl;
+class SVL_DLLPUBLIC SvxAsianConfig : public utl::ConfigItem
+{
+ SvxAsianConfig_Impl* pImpl;
+
+public:
+ SvxAsianConfig(sal_Bool bEnableNotify = sal_True);
+ virtual ~SvxAsianConfig();
+
+ void Load();
+ virtual void Commit();
+ virtual void Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames);
+
+ sal_Bool IsKerningWesternTextOnly() const;
+ void SetKerningWesternTextOnly(sal_Bool bSet);
+
+ sal_Int16 GetCharDistanceCompression() const;
+ void SetCharDistanceCompression(sal_Int16 nSet);
+
+ com::sun::star::uno::Sequence<com::sun::star::lang::Locale>
+ GetStartEndCharLocales();
+
+ sal_Bool GetStartEndChars( const com::sun::star::lang::Locale& rLocale,
+ rtl::OUString& rStartChars,
+ rtl::OUString& rEndChars );
+ void SetStartEndChars( const com::sun::star::lang::Locale& rLocale,
+ const rtl::OUString* pStartChars,
+ const rtl::OUString* pEndChars );
+};
+
+#endif
diff --git a/svl/inc/svl/srchcfg.hxx b/svl/inc/svl/srchcfg.hxx
new file mode 100644
index 000000000000..8f45843fa5f0
--- /dev/null
+++ b/svl/inc/svl/srchcfg.hxx
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * 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: srchcfg.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 _SVX_SRCHCFG_HXX
+#define _SVX_SRCHCFG_HXX
+
+#include <unotools/configitem.hxx>
+#include <com/sun/star/uno/Sequence.h>
+#include <svl/svldllapi.h>
+
+//-----------------------------------------------------------------------------
+struct SvxSearchConfig_Impl;
+struct SvxSearchEngineData
+{
+ rtl::OUString sEngineName;
+
+ rtl::OUString sAndPrefix;
+ rtl::OUString sAndSuffix;
+ rtl::OUString sAndSeparator;
+ sal_Int32 nAndCaseMatch;
+
+ rtl::OUString sOrPrefix;
+ rtl::OUString sOrSuffix;
+ rtl::OUString sOrSeparator;
+ sal_Int32 nOrCaseMatch;
+
+ rtl::OUString sExactPrefix;
+ rtl::OUString sExactSuffix;
+ rtl::OUString sExactSeparator;
+ sal_Int32 nExactCaseMatch;
+
+ SvxSearchEngineData() :
+ nAndCaseMatch(0),
+ nOrCaseMatch(0),
+ nExactCaseMatch(0){}
+
+ sal_Bool operator==(const SvxSearchEngineData& rData);
+};
+class SVL_DLLPUBLIC SvxSearchConfig : public utl::ConfigItem
+{
+ SvxSearchConfig_Impl* pImpl;
+
+public:
+ SvxSearchConfig(sal_Bool bEnableNotify = sal_True);
+ virtual ~SvxSearchConfig();
+
+ void Load();
+ virtual void Commit();
+ virtual void Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames);
+
+ sal_uInt16 Count();
+ const SvxSearchEngineData& GetData(sal_uInt16 nPos);
+ const SvxSearchEngineData* GetData(const rtl::OUString& rEngineName);
+ void SetData(const SvxSearchEngineData& rData);
+ void RemoveData(const rtl::OUString& rEngineName);
+};
+
+#endif
+
diff --git a/svl/source/config/asiancfg.cxx b/svl/source/config/asiancfg.cxx
new file mode 100644
index 000000000000..fb234781bdf8
--- /dev/null
+++ b/svl/source/config/asiancfg.cxx
@@ -0,0 +1,294 @@
+/*************************************************************************
+ *
+ * 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: asiancfg.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_svl.hxx"
+
+#include <svl/asiancfg.hxx>
+#include <svl/svarray.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <tools/debug.hxx>
+
+//-----------------------------------------------------------------------------
+using namespace utl;
+using namespace rtl;
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::lang;
+
+#define C2U(cChar) OUString::createFromAscii(cChar)
+const sal_Char sStartEndCharacters[] = "StartEndCharacters";
+const sal_Char sStartCharacters[] = "StartCharacters";
+const sal_Char sEndCharacters[] = "EndCharacters";
+
+//-----------------------------------------------------------------------------
+struct SvxForbiddenStruct_Impl
+{
+ Locale aLocale;
+ OUString sStartChars;
+ OUString sEndChars;
+};
+//-----------------------------------------------------------------------------
+typedef SvxForbiddenStruct_Impl* SvxForbiddenStruct_ImplPtr;
+SV_DECL_PTRARR_DEL(SvxForbiddenStructArr, SvxForbiddenStruct_ImplPtr, 2, 2)
+SV_IMPL_PTRARR(SvxForbiddenStructArr, SvxForbiddenStruct_ImplPtr);
+//-----------------------------------------------------------------------------
+struct SvxAsianConfig_Impl
+{
+ sal_Bool bKerningWesternTextOnly;
+ sal_Int16 nCharDistanceCompression;
+
+ SvxForbiddenStructArr aForbiddenArr;
+
+ SvxAsianConfig_Impl() :
+ bKerningWesternTextOnly(sal_True),
+ nCharDistanceCompression(0) {}
+};
+/* -----------------------------16.01.01 15:36--------------------------------
+
+ ---------------------------------------------------------------------------*/
+Sequence<OUString> lcl_GetPropertyNames()
+{
+ Sequence<OUString> aNames(2);
+ OUString* pNames = aNames.getArray();
+ pNames[0] = C2U("IsKerningWesternTextOnly");
+ pNames[1] = C2U("CompressCharacterDistance");
+ return aNames;;
+}
+// ---------------------------------------------------------------------------
+SvxAsianConfig::SvxAsianConfig(sal_Bool bEnableNotify) :
+ utl::ConfigItem(C2U("Office.Common/AsianLayout")),
+ pImpl(new SvxAsianConfig_Impl)
+{
+ if(bEnableNotify)
+ EnableNotification(lcl_GetPropertyNames());
+ Load();
+}
+/* -----------------------------16.01.01 15:36--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SvxAsianConfig::~SvxAsianConfig()
+{
+ delete pImpl;
+}
+/* -----------------------------17.01.01 09:57--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxAsianConfig::Load()
+{
+ Sequence<Any> aValues = GetProperties(lcl_GetPropertyNames());
+ const Any* pValues = aValues.getConstArray();
+ if(pValues[0].hasValue())
+ pImpl->bKerningWesternTextOnly = *(sal_Bool*) pValues[0].getValue();
+ pValues[1] >>= pImpl->nCharDistanceCompression;
+
+ pImpl->aForbiddenArr.DeleteAndDestroy(0, pImpl->aForbiddenArr.Count());
+ OUString sPropPrefix(C2U(sStartEndCharacters));
+ Sequence<OUString> aNodes = GetNodeNames(sPropPrefix);
+
+ Sequence<OUString> aPropNames(aNodes.getLength() * 2);
+ OUString* pNames = aPropNames.getArray();
+ sal_Int32 nName = 0;
+ sPropPrefix += C2U("/");
+ sal_Int32 nNode;
+ const OUString* pNodes = aNodes.getConstArray();
+ for(nNode = 0; nNode < aNodes.getLength(); nNode++)
+ {
+ OUString sStart(sPropPrefix);
+ sStart += pNodes[nNode];
+ sStart += C2U("/");
+ pNames[nName] = sStart; pNames[nName++] += C2U("StartCharacters");
+ pNames[nName] = sStart; pNames[nName++] += C2U("EndCharacters");
+ }
+ Sequence<Any> aNodeValues = GetProperties(aPropNames);
+ const Any* pNodeValues = aNodeValues.getConstArray();
+ nName = 0;
+ for(nNode = 0; nNode < aNodes.getLength(); nNode++)
+ {
+ SvxForbiddenStruct_ImplPtr pInsert = new SvxForbiddenStruct_Impl;
+ pInsert->aLocale.Language = pNodes[nNode].copy(0, 2);
+ DBG_ASSERT(pInsert->aLocale.Language.getLength(), "illegal language");
+ pInsert->aLocale.Country = pNodes[nNode].copy(3, 2);
+
+ pNodeValues[nName++] >>= pInsert->sStartChars;
+ pNodeValues[nName++] >>= pInsert->sEndChars;
+ pImpl->aForbiddenArr.Insert(pInsert, pImpl->aForbiddenArr.Count());
+ }
+}
+/* -----------------------------17.01.01 09:57--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxAsianConfig::Notify( const Sequence<OUString>& )
+{
+ Load();
+}
+/* -----------------------------16.01.01 15:36--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxAsianConfig::Commit()
+{
+ Sequence<Any> aValues(2);
+ Any* pValues = aValues.getArray();
+ pValues[0].setValue(&pImpl->bKerningWesternTextOnly, ::getBooleanCppuType());
+ pValues[1] <<= pImpl->nCharDistanceCompression;
+ PutProperties(lcl_GetPropertyNames(), aValues);
+
+
+ OUString sNode(C2U(sStartEndCharacters));
+ if(!pImpl->aForbiddenArr.Count())
+ ClearNodeSet(sNode);
+ else
+ {
+ Sequence<PropertyValue> aSetValues(2 * pImpl->aForbiddenArr.Count());
+ PropertyValue* pSetValues = aSetValues.getArray();
+ sal_Int32 nSetValue = 0;
+ const OUString sStartChars(C2U(sStartCharacters));
+ const OUString sEndChars(C2U(sEndCharacters));
+ for(sal_uInt16 i = 0; i < pImpl->aForbiddenArr.Count(); i++)
+ {
+ OUString sPrefix(sNode);
+ sPrefix += C2U("/");
+ sPrefix += pImpl->aForbiddenArr[i]->aLocale.Language;
+ DBG_ASSERT(pImpl->aForbiddenArr[i]->aLocale.Language.getLength(), "illegal language");
+ sPrefix += C2U("-");
+ sPrefix += pImpl->aForbiddenArr[i]->aLocale.Country;
+ sPrefix += C2U("/");
+ pSetValues[nSetValue].Name = sPrefix; pSetValues[nSetValue].Name += sStartChars;
+ pSetValues[nSetValue++].Value <<= pImpl->aForbiddenArr[i]->sStartChars;
+ pSetValues[nSetValue].Name = sPrefix; pSetValues[nSetValue].Name += sEndChars;
+ pSetValues[nSetValue++].Value <<= pImpl->aForbiddenArr[i]->sEndChars;
+ }
+ ReplaceSetProperties(sNode, aSetValues);
+ }
+}
+/* -----------------------------16.01.01 15:36--------------------------------
+
+ ---------------------------------------------------------------------------*/
+sal_Bool SvxAsianConfig::IsKerningWesternTextOnly() const
+{
+ return pImpl->bKerningWesternTextOnly;
+}
+/* -----------------------------16.01.01 15:36--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxAsianConfig::SetKerningWesternTextOnly(sal_Bool bSet)
+{
+ pImpl->bKerningWesternTextOnly = bSet;
+ SetModified();
+}
+/* -----------------------------16.01.01 15:36--------------------------------
+
+ ---------------------------------------------------------------------------*/
+sal_Int16 SvxAsianConfig::GetCharDistanceCompression() const
+{
+ return pImpl->nCharDistanceCompression;
+}
+/* -----------------------------16.01.01 15:36--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxAsianConfig::SetCharDistanceCompression(sal_Int16 nSet)
+{
+ DBG_ASSERT(nSet >= 0 && nSet < 3, "compression value illegal");
+ SetModified();
+ pImpl->nCharDistanceCompression = nSet;
+}
+/* -----------------------------16.01.01 15:36--------------------------------
+
+ ---------------------------------------------------------------------------*/
+uno::Sequence<lang::Locale> SvxAsianConfig::GetStartEndCharLocales()
+{
+ Sequence<Locale> aRet(pImpl->aForbiddenArr.Count());
+ Locale* pRet = aRet.getArray();
+ for(sal_uInt16 i = 0; i < pImpl->aForbiddenArr.Count(); i++)
+ {
+ pRet[i] = pImpl->aForbiddenArr[i]->aLocale;
+ }
+ return aRet;
+}
+/* -----------------------------16.01.01 15:36--------------------------------
+
+ ---------------------------------------------------------------------------*/
+sal_Bool SvxAsianConfig::GetStartEndChars( const Locale& rLocale,
+ OUString& rStartChars,
+ OUString& rEndChars )
+{
+ for(sal_uInt16 i = 0; i < pImpl->aForbiddenArr.Count(); i++)
+ {
+ if(rLocale.Language == pImpl->aForbiddenArr[i]->aLocale.Language &&
+ rLocale.Country == pImpl->aForbiddenArr[i]->aLocale.Country)
+ {
+ rStartChars = pImpl->aForbiddenArr[i]->sStartChars;
+ rEndChars = pImpl->aForbiddenArr[i]->sEndChars;
+ return sal_True;
+ }
+ }
+ return sal_False;
+}
+/* -----------------------------16.01.01 15:36--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxAsianConfig::SetStartEndChars( const Locale& rLocale,
+ const OUString* pStartChars,
+ const OUString* pEndChars )
+{
+ sal_Bool bFound = sal_False;
+ for(sal_uInt16 i = 0; i < pImpl->aForbiddenArr.Count(); i++)
+ {
+ if(rLocale.Language == pImpl->aForbiddenArr[i]->aLocale.Language &&
+ rLocale.Country == pImpl->aForbiddenArr[i]->aLocale.Country)
+ {
+ if(pStartChars && pEndChars)
+ {
+ pImpl->aForbiddenArr[i]->sStartChars = *pStartChars;
+ pImpl->aForbiddenArr[i]->sEndChars = *pEndChars;
+ }
+ else
+ pImpl->aForbiddenArr.DeleteAndDestroy(i, 1);
+ bFound = sal_True;
+ }
+ }
+ if(!bFound && pStartChars && pEndChars)
+ {
+ SvxForbiddenStruct_ImplPtr pInsert = new SvxForbiddenStruct_Impl;
+ pInsert->aLocale = rLocale;
+ pInsert->sStartChars = *pStartChars;
+ pInsert->sEndChars = *pEndChars;
+ pImpl->aForbiddenArr.Insert(pInsert, pImpl->aForbiddenArr.Count());
+ }
+#ifdef DBG_UTIL
+ else if(!bFound)
+ DBG_ERROR("attempt to clear unavailable data");
+#endif
+ SetModified();
+}
diff --git a/svl/source/config/makefile.mk b/svl/source/config/makefile.mk
index 82c4ae12828f..fd35bf093d27 100644
--- a/svl/source/config/makefile.mk
+++ b/svl/source/config/makefile.mk
@@ -43,8 +43,10 @@ ENABLE_EXCEPTIONS := TRUE
# --- Files --------------------------------------------------------
SLOFILES= \
+ $(SLO)$/asiancfg.obj \
$(SLO)$/cjkoptions.obj \
$(SLO)$/ctloptions.obj \
+ $(SLO)$/srchcfg.obj \
$(SLO)$/itemholder2.obj \
$(SLO)$/languageoptions.obj
diff --git a/svl/source/config/srchcfg.cxx b/svl/source/config/srchcfg.cxx
new file mode 100644
index 000000000000..b3473dae98af
--- /dev/null
+++ b/svl/source/config/srchcfg.cxx
@@ -0,0 +1,290 @@
+/*************************************************************************
+ *
+ * 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: srchcfg.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_svl.hxx"
+
+#include <svl/srchcfg.hxx>
+#include <svl/svarray.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <tools/debug.hxx>
+#include <unotools/configpathes.hxx>
+
+//-----------------------------------------------------------------------------
+using namespace utl;
+using namespace rtl;
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::beans;
+
+#define C2U(cChar) OUString::createFromAscii(cChar)
+
+//-----------------------------------------------------------------------------
+typedef SvxSearchEngineData* SvxSearchEngineDataPtr;
+SV_DECL_PTRARR_DEL(SvxSearchEngineArr, SvxSearchEngineDataPtr, 2, 2)
+SV_IMPL_PTRARR(SvxSearchEngineArr, SvxSearchEngineDataPtr);
+//-----------------------------------------------------------------------------
+struct SvxSearchConfig_Impl
+{
+ SvxSearchEngineArr aEngineArr;
+};
+/* -----------------------------19.03.01 14:00--------------------------------
+
+ ---------------------------------------------------------------------------*/
+sal_Bool SvxSearchEngineData::operator==(const SvxSearchEngineData& rData)
+{
+ return sEngineName == rData.sEngineName &&
+ sAndPrefix == rData.sAndPrefix &&
+ sAndSuffix == rData.sAndSuffix &&
+ sAndSeparator == rData.sAndSeparator &&
+ nAndCaseMatch == rData.nAndCaseMatch &&
+ sOrPrefix == rData.sOrPrefix &&
+ sOrSuffix == rData.sOrSuffix &&
+ sOrSeparator == rData.sOrSeparator &&
+ nOrCaseMatch == rData.nOrCaseMatch &&
+ sExactPrefix == rData.sExactPrefix &&
+ sExactSuffix == rData.sExactSuffix &&
+ sExactSeparator == rData.sExactSeparator &&
+ nExactCaseMatch == rData.nExactCaseMatch;
+}
+/* -----------------------------16.01.01 15:36--------------------------------
+
+ ---------------------------------------------------------------------------*/
+const Sequence<OUString>& lcl_GetSearchPropertyNames_Impl()
+{
+ static Sequence<OUString> aNames;
+ if(!aNames.getLength())
+ {
+ aNames.realloc(12);
+ OUString* pNames = aNames.getArray();
+ pNames[0] = C2U("And/ooInetPrefix");
+ pNames[1] = C2U("And/ooInetSuffix");
+ pNames[2] = C2U("And/ooInetSeparator");
+ pNames[3] = C2U("And/ooInetCaseMatch");
+ pNames[4] = C2U("Or/ooInetPrefix");
+ pNames[5] = C2U("Or/ooInetSuffix");
+ pNames[6] = C2U("Or/ooInetSeparator");
+ pNames[7] = C2U("Or/ooInetCaseMatch");
+ pNames[8] = C2U("Exact/ooInetPrefix");
+ pNames[9] = C2U("Exact/ooInetSuffix");
+ pNames[10] = C2U("Exact/ooInetSeparator");
+ pNames[11] = C2U("Exact/ooInetCaseMatch");
+ }
+ return aNames;
+}
+// ---------------------------------------------------------------------------
+SvxSearchConfig::SvxSearchConfig(sal_Bool bEnableNotify) :
+ utl::ConfigItem(C2U("Inet/SearchEngines"), CONFIG_MODE_DELAYED_UPDATE),
+ pImpl(new SvxSearchConfig_Impl)
+{
+ if(bEnableNotify)
+ {
+ //request notifications from the node
+ Sequence<OUString> aEnable(1);
+ EnableNotification(aEnable);
+ }
+ Load();
+}
+/* -----------------------------16.01.01 15:36--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SvxSearchConfig::~SvxSearchConfig()
+{
+ delete pImpl;
+}
+/* -----------------------------17.01.01 09:57--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxSearchConfig::Load()
+{
+ pImpl->aEngineArr.DeleteAndDestroy(0, pImpl->aEngineArr.Count());
+ Sequence<OUString> aNodeNames = GetNodeNames(OUString());
+ const OUString* pNodeNames = aNodeNames.getConstArray();
+ for(sal_Int32 nNode = 0; nNode < aNodeNames.getLength(); nNode++)
+ {
+ SvxSearchEngineDataPtr pNew = new SvxSearchEngineData;
+ pNew->sEngineName = pNodeNames[nNode];
+ const Sequence<OUString>& rPropNames = lcl_GetSearchPropertyNames_Impl();
+ const OUString* pPropNames = rPropNames.getConstArray();
+ Sequence<OUString> aPropertyNames(rPropNames.getLength());
+ OUString* pPropertyNames = aPropertyNames.getArray();
+ const OUString sSlash(C2U("/"));
+ sal_Int32 nProp;
+ for(nProp = 0; nProp < rPropNames.getLength(); nProp++)
+ {
+ pPropertyNames[nProp] = wrapConfigurationElementName(pNodeNames[nNode]);
+ pPropertyNames[nProp] += sSlash;
+ pPropertyNames[nProp] += pPropNames[nProp];
+ }
+ Sequence<Any> aValues = GetProperties(aPropertyNames);
+ const Any* pValues = aValues.getConstArray();
+ for(nProp = 0; nProp < rPropNames.getLength(); nProp++)
+ {
+ switch(nProp)
+ {
+ case 0 : pValues[nProp] >>= pNew->sAndPrefix; break;
+ case 1 : pValues[nProp] >>= pNew->sAndSuffix; break;
+ case 2 : pValues[nProp] >>= pNew->sAndSeparator; break;
+ case 3 : pValues[nProp] >>= pNew->nAndCaseMatch; break;
+
+ case 4 : pValues[nProp] >>= pNew->sOrPrefix; break;
+ case 5 : pValues[nProp] >>= pNew->sOrSuffix; break;
+ case 6 : pValues[nProp] >>= pNew->sOrSeparator; break;
+ case 7 : pValues[nProp] >>= pNew->nOrCaseMatch; break;
+
+ case 8 : pValues[nProp] >>= pNew->sExactPrefix; break;
+ case 9 : pValues[nProp] >>= pNew->sExactSuffix; break;
+ case 10: pValues[nProp] >>= pNew->sExactSeparator; break;
+ case 11: pValues[nProp] >>= pNew->nExactCaseMatch; break;
+ }
+ }
+ pImpl->aEngineArr.Insert(pNew, pImpl->aEngineArr.Count());
+ }
+}
+/* -----------------------------17.01.01 09:57--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxSearchConfig::Notify( const Sequence<OUString>& )
+{
+ Load();
+}
+/* -----------------------------16.01.01 15:36--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxSearchConfig::Commit()
+{
+ OUString sNode;
+ if(!pImpl->aEngineArr.Count())
+ ClearNodeSet(sNode);
+ else
+ {
+ Sequence<PropertyValue> aSetValues(12 * pImpl->aEngineArr.Count());
+ PropertyValue* pSetValues = aSetValues.getArray();
+
+ const Sequence<OUString>& rPropNames = lcl_GetSearchPropertyNames_Impl();
+ const OUString* pPropNames = rPropNames.getConstArray();
+ const OUString sSlash(C2U("/"));
+ for(sal_uInt16 i = 0; i < pImpl->aEngineArr.Count(); i++)
+ {
+ SvxSearchEngineDataPtr pSave = pImpl->aEngineArr[i];
+ for(sal_Int16 nProp = 0; nProp < rPropNames.getLength(); nProp++)
+ {
+ OUString sTmpName = sSlash;
+ sTmpName += wrapConfigurationElementName(pSave->sEngineName);
+ sTmpName += sSlash;
+ sTmpName += pPropNames[nProp];
+ pSetValues[nProp].Name = sTmpName;
+ switch(nProp)
+ {
+ case 0 : pSetValues[nProp].Value <<= pSave->sAndPrefix; break;
+ case 1 : pSetValues[nProp].Value <<= pSave->sAndSuffix; break;
+ case 2 : pSetValues[nProp].Value <<= pSave->sAndSeparator; break;
+ case 3 : pSetValues[nProp].Value <<= pSave->nAndCaseMatch; break;
+
+ case 4 : pSetValues[nProp].Value <<= pSave->sOrPrefix; break;
+ case 5 : pSetValues[nProp].Value <<= pSave->sOrSuffix; break;
+ case 6 : pSetValues[nProp].Value <<= pSave->sOrSeparator; break;
+ case 7 : pSetValues[nProp].Value <<= pSave->nOrCaseMatch; break;
+
+ case 8 : pSetValues[nProp].Value <<= pSave->sExactPrefix; break;
+ case 9 : pSetValues[nProp].Value <<= pSave->sExactSuffix; break;
+ case 10: pSetValues[nProp].Value <<= pSave->sExactSeparator; break;
+ case 11: pSetValues[nProp].Value <<= pSave->nExactCaseMatch; break;
+ }
+ }
+ pSetValues+= 12;
+ }
+ ReplaceSetProperties(sNode, aSetValues);
+ }
+}
+/* -----------------------------19.03.01 10:02--------------------------------
+
+ ---------------------------------------------------------------------------*/
+sal_uInt16 SvxSearchConfig::Count()
+{
+ return pImpl->aEngineArr.Count();
+}
+/* -----------------------------19.03.01 10:02--------------------------------
+
+ ---------------------------------------------------------------------------*/
+const SvxSearchEngineData& SvxSearchConfig::GetData(sal_uInt16 nPos)
+{
+ DBG_ASSERT(nPos < pImpl->aEngineArr.Count(), "wrong array index");
+ return *pImpl->aEngineArr[nPos];
+}
+/* -----------------------------19.03.01 10:38--------------------------------
+
+ ---------------------------------------------------------------------------*/
+const SvxSearchEngineData* SvxSearchConfig::GetData(const rtl::OUString& rEngineName)
+{
+ for(sal_uInt16 nPos = 0; nPos < pImpl->aEngineArr.Count(); nPos++)
+ {
+ if(pImpl->aEngineArr[nPos]->sEngineName == rEngineName)
+ return pImpl->aEngineArr[nPos];
+ }
+ return 0;
+}
+/* -----------------------------19.03.01 10:02--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxSearchConfig::SetData(const SvxSearchEngineData& rData)
+{
+ for(sal_uInt16 nPos = 0; nPos < pImpl->aEngineArr.Count(); nPos++)
+ {
+ if(pImpl->aEngineArr[nPos]->sEngineName == rData.sEngineName)
+ {
+ if((*pImpl->aEngineArr[nPos]) == rData)
+ return;
+ pImpl->aEngineArr.DeleteAndDestroy(nPos, 1);
+ break;
+ }
+ }
+ SvxSearchEngineDataPtr pInsert = new SvxSearchEngineData(rData);
+ pImpl->aEngineArr.Insert(pInsert, pImpl->aEngineArr.Count());
+ SetModified();
+}
+/* -----------------------------19.03.01 10:38--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxSearchConfig::RemoveData(const rtl::OUString& rEngineName)
+{
+ for(sal_uInt16 nPos = 0; nPos < pImpl->aEngineArr.Count(); nPos++)
+ {
+ if(pImpl->aEngineArr[nPos]->sEngineName == rEngineName)
+ {
+ pImpl->aEngineArr.DeleteAndDestroy(nPos, 1);
+ SetModified();
+ return ;
+ }
+ }
+}
+