summaryrefslogtreecommitdiff
path: root/xmloff/source/chart/XMLSymbolTypePropertyHdl.cxx
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2004-08-20 07:12:59 +0000
committerRüdiger Timm <rt@openoffice.org>2004-08-20 07:12:59 +0000
commit9d7280fe57c102ed347cea34a28eef38e6aebb4c (patch)
tree1c62e2d0d7d7651c3f9e402914c334e3d909759b /xmloff/source/chart/XMLSymbolTypePropertyHdl.cxx
parent6298511638197c306aee1f814cd9e5435d25807a (diff)
INTEGRATION: CWS oasis2 (1.1.2); FILE ADDED
2004/08/04 08:52:48 bm 1.1.2.1: #32439# chart:symbol became chart:symbol-type and chart:symbol-name
Diffstat (limited to 'xmloff/source/chart/XMLSymbolTypePropertyHdl.cxx')
-rw-r--r--xmloff/source/chart/XMLSymbolTypePropertyHdl.cxx208
1 files changed, 208 insertions, 0 deletions
diff --git a/xmloff/source/chart/XMLSymbolTypePropertyHdl.cxx b/xmloff/source/chart/XMLSymbolTypePropertyHdl.cxx
new file mode 100644
index 000000000000..1fef0fbc1fdf
--- /dev/null
+++ b/xmloff/source/chart/XMLSymbolTypePropertyHdl.cxx
@@ -0,0 +1,208 @@
+/*************************************************************************
+ *
+ * $RCSfile: XMLSymbolTypePropertyHdl.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2004-08-20 08:12:59 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "XMLSymbolTypePropertyHdl.hxx"
+
+#ifndef _XMLOFF_XMLUCONV_HXX
+#include "xmluconv.hxx"
+#endif
+#ifndef _COM_SUN_STAR_CHART_CHARTERRORINDICATORTYPE_HPP_
+#include <com/sun/star/chart/ChartErrorIndicatorType.hpp>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+using namespace ::xmloff::token;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+namespace
+{
+struct SvXMLSignedEnumMapEntry
+{
+ ::xmloff::token::XMLTokenEnum eToken;
+ sal_Int32 nValue;
+};
+
+SvXMLSignedEnumMapEntry aXMLChartSymbolTypeEnumMap[] =
+{
+ { XML_NONE, -3 },
+ { XML_AUTOMATIC, -2 },
+ { XML_IMAGE, -1 },
+ { XML_TOKEN_INVALID, 0 }
+};
+
+SvXMLSignedEnumMapEntry aXMLChartSymbolNameMap[] =
+{
+ { XML_GRADIENTSTYLE_SQUARE, 0 }, // "square"
+ { XML_DIAMOND, 1 },
+ { XML_ARROW_DOWN, 2 },
+ { XML_ARROW_UP, 3 },
+ { XML_ARROW_RIGHT, 4 },
+ { XML_ARROW_LEFT, 5 },
+ { XML_BOW_TIE, 6 },
+ { XML_HOURGLASS, 7 },
+ { XML_TOKEN_INVALID, 0 }
+};
+
+sal_Bool lcl_convertEnum(
+ OUStringBuffer & rBuffer,
+ sal_Int32 nValue,
+ const SvXMLSignedEnumMapEntry *pMap )
+{
+ enum XMLTokenEnum eTok = XML_TOKEN_INVALID;
+
+ while( pMap->eToken != XML_TOKEN_INVALID )
+ {
+ if( pMap->nValue == nValue )
+ {
+ eTok = pMap->eToken;
+ break;
+ }
+ pMap++;
+ }
+
+ if( eTok != XML_TOKEN_INVALID )
+ rBuffer.append( GetXMLToken(eTok) );
+
+ return (eTok != XML_TOKEN_INVALID);
+}
+
+sal_Bool lcl_convertEnum(
+ sal_Int32 & rEnum,
+ const OUString & rValue,
+ const SvXMLSignedEnumMapEntry *pMap )
+{
+ while( pMap->eToken != XML_TOKEN_INVALID )
+ {
+ if( IsXMLToken( rValue, pMap->eToken ) )
+ {
+ rEnum = pMap->nValue;
+ return sal_True;
+ }
+ pMap++;
+ }
+ return sal_False;
+}
+
+} // anonymous namespace
+
+using namespace com::sun::star;
+
+XMLSymbolTypePropertyHdl::XMLSymbolTypePropertyHdl( bool bIsNamedSymbol )
+ : m_bIsNamedSymbol( bIsNamedSymbol )
+{}
+
+XMLSymbolTypePropertyHdl::~XMLSymbolTypePropertyHdl()
+{}
+
+sal_Bool XMLSymbolTypePropertyHdl::importXML( const OUString& rStrImpValue,
+ uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
+{
+ sal_Bool bResult = sal_False;
+
+ if( m_bIsNamedSymbol )
+ {
+ sal_Int32 nValue = -3; // NONE
+ bResult = lcl_convertEnum( nValue, rStrImpValue, aXMLChartSymbolNameMap );
+ rValue <<= nValue;
+ }
+ else
+ {
+ sal_Int32 nValue = -3; // NONE
+ bResult = lcl_convertEnum( nValue, rStrImpValue, aXMLChartSymbolTypeEnumMap );
+ rValue <<= nValue;
+ }
+
+ return bResult;
+}
+
+sal_Bool XMLSymbolTypePropertyHdl::exportXML( OUString& rStrExpValue,
+ const uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
+{
+ sal_Bool bResult = sal_False;
+
+ sal_Int32 nType = -3; // NONE
+ rValue >>= nType;
+
+ if( m_bIsNamedSymbol )
+ {
+ OUStringBuffer aBuf;
+ bResult = lcl_convertEnum( aBuf, nType, aXMLChartSymbolNameMap );
+ rStrExpValue = aBuf.makeStringAndClear();
+ }
+ else
+ {
+ if( nType < 0 )
+ {
+ OUStringBuffer aBuf;
+ bResult = lcl_convertEnum( aBuf, nType, aXMLChartSymbolTypeEnumMap );
+ rStrExpValue = aBuf.makeStringAndClear();
+ }
+ else
+ {
+ bResult = true;
+ rStrExpValue = GetXMLToken( XML_NAMED_SYMBOL );
+ }
+ }
+
+ return bResult;
+}