summaryrefslogtreecommitdiff
path: root/xmloff/source/core
diff options
context:
space:
mode:
authorChristian Lippka <cl@openoffice.org>2001-04-05 15:41:01 +0000
committerChristian Lippka <cl@openoffice.org>2001-04-05 15:41:01 +0000
commitc98e47b257b682e4fabfbfdaf96c5b16025e6005 (patch)
tree1a8bd964f99d44bac50ea1ed93365d9a04fdd971 /xmloff/source/core
parentf6cf69e5390fa6094bb4fdcce08f4b6b180ee8d3 (diff)
#85721# added support for forbidden characters
Diffstat (limited to 'xmloff/source/core')
-rw-r--r--xmloff/source/core/DocumentSettingsContext.cxx119
-rw-r--r--xmloff/source/core/SettingsExportHelper.cxx96
2 files changed, 207 insertions, 8 deletions
diff --git a/xmloff/source/core/DocumentSettingsContext.cxx b/xmloff/source/core/DocumentSettingsContext.cxx
index b86923b1c749..d502f4507219 100644
--- a/xmloff/source/core/DocumentSettingsContext.cxx
+++ b/xmloff/source/core/DocumentSettingsContext.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DocumentSettingsContext.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: sab $ $Date: 2001-04-04 05:26:51 $
+ * last change: $Author: cl $ $Date: 2001-04-05 16:41:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -93,6 +93,9 @@
#include <list>
#endif
+#ifndef _COM_SUN_STAR_I18N_XFORBIDDENCHARACTERS_HPP_
+#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
+#endif
#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_
#include <com/sun/star/container/XIndexContainer.hpp>
#endif
@@ -111,6 +114,16 @@
using namespace com::sun::star;
+enum XMLForbiddenCharactersEnum
+{
+ XML_FORBIDDEN_CHARACTER_LANGUAGE,
+ XML_FORBIDDEN_CHARACTER_COUNTRY,
+ XML_FORBIDDEN_CHARACTER_VARIANT,
+ XML_FORBIDDEN_CHARACTER_BEGIN_LINE,
+ XML_FORBIDDEN_CHARACTER_END_LINE,
+ XML_FORBIDDEN_CHARACTER_MAX
+};
+
//------------------------------------------------------------------
class XMLMyList
@@ -282,12 +295,16 @@ public:
class XMLConfigItemMapIndexedContext : public XMLConfigBaseContext
{
+private:
+ rtl::OUString maConfigItemName;
+
public:
XMLConfigItemMapIndexedContext(SvXMLImport& rImport, USHORT nPrfx,
const rtl::OUString& rLName,
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList>& xAttrList,
com::sun::star::uno::Any& rAny,
+ const rtl::OUString& rConfigItemName,
XMLConfigBaseContext* pBaseContext);
virtual ~XMLConfigItemMapIndexedContext();
@@ -335,7 +352,7 @@ SvXMLImportContext *CreateSettingsContext(SvXMLImport& rImport, USHORT nPrefix,
else if(rLocalName.compareToAscii(sXML_config_item_map_named) == 0)
pContext = new XMLConfigItemMapNamedContext(rImport, nPrefix, rLocalName, xAttrList, rProp.Value, pBaseContext);
else if(rLocalName.compareToAscii(sXML_config_item_map_indexed) == 0)
- pContext = new XMLConfigItemMapIndexedContext(rImport, nPrefix, rLocalName, xAttrList, rProp.Value, pBaseContext);
+ pContext = new XMLConfigItemMapIndexedContext(rImport, nPrefix, rLocalName, xAttrList, rProp.Value, rProp.Name, pBaseContext);
}
if( !pContext )
@@ -618,8 +635,10 @@ XMLConfigItemMapIndexedContext::XMLConfigItemMapIndexedContext(SvXMLImport& rImp
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList>& xAttrList,
com::sun::star::uno::Any& rAny,
+ const ::rtl::OUString& rConfigItemName,
XMLConfigBaseContext* pBaseContext)
- : XMLConfigBaseContext(rImport, nPrfx, rLName, rAny, pBaseContext)
+ : XMLConfigBaseContext(rImport, nPrfx, rLName, rAny, pBaseContext),
+ maConfigItemName( rConfigItemName )
{
}
@@ -639,7 +658,97 @@ void XMLConfigItemMapIndexedContext::EndElement()
{
if (pBaseContext)
{
- rAny <<= aProps.GetIndexContainer();
+ if( maConfigItemName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ForbiddenCharacters" ) ) )
+ {
+ uno::Reference< i18n::XForbiddenCharacters > xForbChars;
+
+ // get the forbidden characters from the document
+ uno::Reference< lang::XMultiServiceFactory > xFac( GetImport().GetModel(), uno::UNO_QUERY );
+ if( xFac.is() )
+ {
+ uno::Reference< beans::XPropertySet > xProps( xFac->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.Settings" ) ) ), uno::UNO_QUERY );
+ if( xProps.is() && xProps->getPropertySetInfo()->hasPropertyByName( maConfigItemName ) )
+ {
+ xProps->getPropertyValue( maConfigItemName ) >>= xForbChars;
+ }
+ }
+
+ if( xForbChars.is() )
+ {
+
+ uno::Reference< container::XIndexAccess > xIndex( aProps.GetIndexContainer(), uno::UNO_QUERY );
+
+ const sal_Int32 nCount = xIndex->getCount();
+ uno::Sequence < beans::PropertyValue > aProps;
+ for (sal_Int32 i = 0; i < nCount; i++)
+ {
+ if ((xIndex->getByIndex( i ) >>= aProps) && (aProps.getLength() == XML_FORBIDDEN_CHARACTER_MAX ) )
+ {
+ beans::PropertyValue *pForChar = aProps.getArray();
+ i18n::ForbiddenCharacters aForbid;
+ lang::Locale aLocale;
+ const rtl::OUString sLanguage ( RTL_CONSTASCII_USTRINGPARAM ( "Language" ) );
+ const rtl::OUString sCountry ( RTL_CONSTASCII_USTRINGPARAM ( "Country" ) );
+ const rtl::OUString sVariant ( RTL_CONSTASCII_USTRINGPARAM ( "Variant" ) );
+ const rtl::OUString sBeginLine ( RTL_CONSTASCII_USTRINGPARAM ( "BeginLine" ) );
+ const rtl::OUString sEndLine ( RTL_CONSTASCII_USTRINGPARAM ( "EndLine" ) );
+ sal_Bool bHaveLanguage = sal_False, bHaveCountry = sal_False, bHaveVariant = sal_False,
+ bHaveBegin = sal_False, bHaveEnd = sal_False;
+
+ for ( sal_Int32 j = 0 ; j < XML_FORBIDDEN_CHARACTER_MAX ; j++ )
+ {
+ if (pForChar->Name.equals (sLanguage ) )
+ {
+ pForChar->Value >>= aLocale.Language;
+ bHaveLanguage = sal_True;
+ }
+ else if (pForChar->Name.equals (sCountry ) )
+ {
+ pForChar->Value >>= aLocale.Country;
+ bHaveCountry = sal_True;
+ }
+ else if (pForChar->Name.equals (sVariant ) )
+ {
+ pForChar->Value >>= aLocale.Variant;
+ bHaveVariant = sal_True;
+ }
+ else if (pForChar->Name.equals (sBeginLine ) )
+ {
+ pForChar->Value >>= aForbid.beginLine;
+ bHaveBegin = sal_True;
+ }
+ else if (pForChar->Name.equals (sEndLine ) )
+ {
+ pForChar->Value >>= aForbid.endLine;
+ bHaveEnd = sal_True;
+ }
+ pForChar++;
+ }
+
+ if ( bHaveLanguage && bHaveCountry && bHaveVariant && bHaveBegin && bHaveEnd )
+ {
+ try
+ {
+ xForbChars->setForbiddenCharacters( aLocale, aForbid );
+ }
+ catch( uno::Exception& )
+ {
+ DBG_ERROR( "Exception while importing forbidden characters" );
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ DBG_ERROR( "could not get the XForbiddenCharacters from document!" );
+ rAny <<= aProps.GetIndexContainer();
+ }
+ }
+ else
+ {
+ rAny <<= aProps.GetIndexContainer();
+ }
pBaseContext->AddPropertyValue();
}
else
diff --git a/xmloff/source/core/SettingsExportHelper.cxx b/xmloff/source/core/SettingsExportHelper.cxx
index 04e9df6f84f9..171527af239a 100644
--- a/xmloff/source/core/SettingsExportHelper.cxx
+++ b/xmloff/source/core/SettingsExportHelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: SettingsExportHelper.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: sab $ $Date: 2001-03-22 17:37:03 $
+ * last change: $Author: cl $ $Date: 2001-04-05 16:41:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -78,16 +78,40 @@
#ifndef _COMPHELPER_EXTRACT_HXX_
#include <comphelper/extract.hxx>
#endif
-
+#ifndef _COMPHELPER_PROCESSFACTORYHXX_
+#include <comphelper/processfactory.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LINGUISTIC2_XSUPPORTEDLOCALES_HPP_
+#include <com/sun/star/linguistic2/XSupportedLocales.hpp>
+#endif
+#ifndef _COM_SUN_STAR_I18N_XFORBIDDENCHARACTERS_HPP_
+#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
+#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
#include <com/sun/star/container/XNameAccess.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_
#include <com/sun/star/util/DateTime.hpp>
#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_
+#include <com/sun/star/container/XIndexContainer.hpp>
+#endif
using namespace ::com::sun::star;
+enum XMLForbiddenCharactersEnum
+{
+ XML_FORBIDDEN_CHARACTER_LANGUAGE,
+ XML_FORBIDDEN_CHARACTER_COUNTRY,
+ XML_FORBIDDEN_CHARACTER_VARIANT,
+ XML_FORBIDDEN_CHARACTER_BEGIN_LINE,
+ XML_FORBIDDEN_CHARACTER_END_LINE,
+ XML_FORBIDDEN_CHARACTER_MAX
+};
+
XMLSettingsExportHelper::XMLSettingsExportHelper(SvXMLExport& rTempExport)
: rExport(rTempExport)
{
@@ -175,6 +199,10 @@ void XMLSettingsExportHelper::CallTypeFunction(const uno::Any& rAny,
rAny >>= aDateTime;
exportDateTime(aDateTime, rName);
}
+ else if( aType.equals(getCppuType( (uno::Reference<i18n::XForbiddenCharacters> *)0 ) ) )
+ {
+ exportForbiddenCharacters( rAny, rName );
+ }
else
DBG_ERROR("this type is not implemented now");
}
@@ -329,6 +357,68 @@ void XMLSettingsExportHelper::exportIndexAccess(
}
}
+void XMLSettingsExportHelper::exportForbiddenCharacters(
+ const uno::Any &rAny,
+ const rtl::OUString rName) const
+{
+ uno::Reference<i18n::XForbiddenCharacters> xForbChars;
+ uno::Reference<linguistic2::XSupportedLocales> xLocales;
+
+ rAny >>= xForbChars;
+ rAny >>= xLocales;
+
+ DBG_ASSERT( xForbChars.is() && xLocales.is(),"XMLSettingsExportHelper::exportForbiddenCharacters: got illegal forbidden characters!" );
+
+ if( !xForbChars.is() || !xLocales.is() )
+ return;
+
+ uno::Reference< lang::XMultiServiceFactory > xServiceFactory( comphelper::getProcessServiceFactory() );
+ DBG_ASSERT( xServiceFactory.is(), "XMLSettingsExportHelper::exportForbiddenCharacters: got no service manager" );
+
+ if( xServiceFactory.is() )
+ {
+ uno::Reference< container::XIndexContainer > xBox(xServiceFactory->createInstance(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.document.IndexedPropertyValues") ) ), uno::UNO_QUERY);
+ DBG_ASSERT( xBox.is(), "could not create service com.sun.star.document.IndexedPropertyValues" );
+ if (xBox.is() )
+ {
+ const uno::Sequence< lang::Locale > aLocales( xLocales->getLocales() );
+ const lang::Locale* pLocales = aLocales.getConstArray();
+
+ const sal_Int32 nCount = aLocales.getLength();
+
+ const rtl::OUString sLanguage ( RTL_CONSTASCII_USTRINGPARAM ( "Language" ) );
+ const rtl::OUString sCountry ( RTL_CONSTASCII_USTRINGPARAM ( "Country" ) );
+ const rtl::OUString sVariant ( RTL_CONSTASCII_USTRINGPARAM ( "Variant" ) );
+ const rtl::OUString sBeginLine ( RTL_CONSTASCII_USTRINGPARAM ( "BeginLine" ) );
+ const rtl::OUString sEndLine ( RTL_CONSTASCII_USTRINGPARAM ( "EndLine" ) );
+
+ for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++, pLocales++ )
+ {
+ const i18n::ForbiddenCharacters aChars( xForbChars->getForbiddenCharacters( *pLocales ) );
+
+
+ uno::Sequence < beans::PropertyValue > aSequence ( XML_FORBIDDEN_CHARACTER_MAX );
+ beans::PropertyValue *pForChar = aSequence.getArray();
+
+ pForChar[XML_FORBIDDEN_CHARACTER_LANGUAGE].Name = sLanguage;
+ pForChar[XML_FORBIDDEN_CHARACTER_LANGUAGE].Value <<= pLocales->Language;
+ pForChar[XML_FORBIDDEN_CHARACTER_COUNTRY].Name = sCountry;
+ pForChar[XML_FORBIDDEN_CHARACTER_COUNTRY].Value <<= pLocales->Country;
+ pForChar[XML_FORBIDDEN_CHARACTER_VARIANT].Name = sVariant;
+ pForChar[XML_FORBIDDEN_CHARACTER_VARIANT].Value <<= pLocales->Variant;
+ pForChar[XML_FORBIDDEN_CHARACTER_BEGIN_LINE].Name = sBeginLine;
+ pForChar[XML_FORBIDDEN_CHARACTER_BEGIN_LINE].Value <<= aChars.beginLine;
+ pForChar[XML_FORBIDDEN_CHARACTER_END_LINE].Name = sEndLine;
+ pForChar[XML_FORBIDDEN_CHARACTER_END_LINE].Value <<= aChars.endLine;
+ xBox->insertByIndex(nIndex, uno::makeAny( aSequence ));
+ }
+
+ uno::Reference< container::XIndexAccess > xIA( xBox, uno::UNO_QUERY );
+ exportIndexAccess( xIA, rName );
+ }
+ }
+}
+
void XMLSettingsExportHelper::exportSettings(
const uno::Sequence<beans::PropertyValue>& aProps,
const rtl::OUString& rName) const