summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Milcke <bm@openoffice.org>2003-10-09 15:46:46 +0000
committerBjörn Milcke <bm@openoffice.org>2003-10-09 15:46:46 +0000
commit1f740d15c8593790a347dc0b472cfbfe5e3dcd22 (patch)
tree31d060154fd86fd86035d5799bf0fb0d95abbef9
parent1d31d3ddad10f4756a986d583520eb6afed1a84f (diff)
legend properties
-rw-r--r--chart2/source/controller/inc/LegendItemConverter.hxx104
-rw-r--r--chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx196
-rw-r--r--chart2/source/controller/itemsetwrapper/makefile.mk5
-rw-r--r--chart2/source/controller/main/ChartController_Properties.cxx15
-rw-r--r--chart2/source/inc/LegendHelper.hxx20
-rw-r--r--chart2/source/model/main/Legend.cxx10
-rw-r--r--chart2/source/model/template/ChartTypeTemplate.cxx35
-rw-r--r--chart2/source/model/template/ChartTypeTemplate.hxx10
-rw-r--r--chart2/source/tools/LegendHelper.cxx58
-rw-r--r--chart2/source/view/inc/PropertyMapper.hxx6
-rw-r--r--chart2/source/view/main/ChartView.cxx8
-rw-r--r--chart2/source/view/main/PropertyMapper.cxx50
-rw-r--r--chart2/source/view/main/VLegend.cxx205
-rw-r--r--chart2/source/view/main/VLegend.hxx6
-rw-r--r--chart2/source/view/main/VLegendSymbolFactory.cxx300
-rw-r--r--chart2/source/view/main/makefile.mk5
16 files changed, 925 insertions, 108 deletions
diff --git a/chart2/source/controller/inc/LegendItemConverter.hxx b/chart2/source/controller/inc/LegendItemConverter.hxx
new file mode 100644
index 000000000000..a4977f049e1a
--- /dev/null
+++ b/chart2/source/controller/inc/LegendItemConverter.hxx
@@ -0,0 +1,104 @@
+/*************************************************************************
+ *
+ * $RCSfile: LegendItemConverter.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: bm $ $Date: 2003-10-09 16:46:39 $
+ *
+ * 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: 2003 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef CHART_LEGENDITEMCONVERTER_HXX
+#define CHART_LEGENDITEMCONVERTER_HXX
+
+#include "ItemConverter.hxx"
+
+#include <vector>
+
+class SdrModel;
+
+namespace chart
+{
+namespace wrapper
+{
+
+class LegendItemConverter :
+ public ::comphelper::ItemConverter
+{
+public:
+ LegendItemConverter(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > & rPropertySet,
+ SfxItemPool& rItemPool,
+ SdrModel& rDrawModel );
+ virtual ~LegendItemConverter();
+
+ virtual void FillItemSet( SfxItemSet & rOutItemSet ) const;
+ virtual bool ApplyItemSet( const SfxItemSet & rItemSet );
+
+protected:
+ virtual const USHORT * GetWhichPairs() const;
+ virtual bool GetItemPropertyName( USHORT nWhichId, ::rtl::OUString & rOutName ) const;
+
+ virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const;
+ virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) const;
+
+private:
+ ::std::vector< ItemConverter * > m_aConverters;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// CHART_LEGENDITEMCONVERTER_HXX
+#endif
diff --git a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx
new file mode 100644
index 000000000000..b862a6991f09
--- /dev/null
+++ b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx
@@ -0,0 +1,196 @@
+/*************************************************************************
+ *
+ * $RCSfile: LegendItemConverter.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: bm $ $Date: 2003-10-09 16:46:39 $
+ *
+ * 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: 2003 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "LegendItemConverter.hxx"
+#include "SchWhichPairs.hxx"
+#include "macros.hxx"
+#include "ItemPropertyMap.hxx"
+#include "GraphicPropertyItemConverter.hxx"
+#include "CharacterPropertyItemConverter.hxx"
+
+#ifndef _SVX_CHRTITEM_HXX
+#define ITEMID_CHARTLEGENDPOS SCHATTR_LEGEND_POS
+#include <svx/chrtitem.hxx>
+#endif
+
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XLEGEND_HPP_
+#include <drafts/com/sun/star/chart2/XLegend.hpp>
+#endif
+
+#include <functional>
+#include <algorithm>
+
+using namespace ::com::sun::star;
+using namespace ::drafts::com::sun::star;
+
+namespace
+{
+// ::comphelper::ItemPropertyMapType & lcl_GetLegendPropertyMap()
+// {
+// static ::comphelper::ItemPropertyMapType aLegendPropertyMap(
+// ::comphelper::MakeItemPropertyMap
+// ( SCHATTR_TEXT_STACKED, C2U( "StackCharacters" ))
+// );
+
+// return aLegendPropertyMap;
+// };
+} // anonymous namespace
+
+namespace chart
+{
+namespace wrapper
+{
+
+LegendItemConverter::LegendItemConverter(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > & rPropertySet,
+ SfxItemPool& rItemPool,
+ SdrModel& rDrawModel ) :
+ ItemConverter( rPropertySet, rItemPool )
+{
+ m_aConverters.push_back( new GraphicPropertyItemConverter(
+ rPropertySet, rItemPool, rDrawModel,
+ GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES ));
+ m_aConverters.push_back( new CharacterPropertyItemConverter(
+ rPropertySet, rItemPool ));
+}
+
+LegendItemConverter::~LegendItemConverter()
+{
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ::comphelper::DeleteItemConverterPtr() );
+}
+
+void LegendItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
+{
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ::comphelper::FillItemSetFunc( rOutItemSet ));
+
+ // own items
+ ItemConverter::FillItemSet( rOutItemSet );
+}
+
+bool LegendItemConverter::ApplyItemSet( const SfxItemSet & rItemSet )
+{
+ bool bResult = false;
+
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ::comphelper::ApplyItemSetFunc( rItemSet, bResult ));
+
+ // own items
+ return ItemConverter::ApplyItemSet( rItemSet ) || bResult;
+}
+
+const USHORT * LegendItemConverter::GetWhichPairs() const
+{
+ // must span all used items!
+ return nLegendWhichPairs;
+}
+
+bool LegendItemConverter::GetItemPropertyName( USHORT nWhichId, ::rtl::OUString & rOutName ) const
+{
+ // No own (non-special) properties
+ return false;
+// ::comphelper::ItemPropertyMapType & rMap( lcl_GetLegendPropertyMap());
+// ::comphelper::ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId ));
+
+// if( aIt == rMap.end())
+// return false;
+
+// rOutName =(*aIt).second;
+// return true;
+}
+
+
+bool LegendItemConverter::ApplySpecialItem(
+ USHORT nWhichId, const SfxItemSet & rItemSet ) const
+{
+ bool bChanged = false;
+
+ switch( nWhichId )
+ {
+ case SCHATTR_LEGEND_POS:
+ {
+ // alwas right
+ //todo: implement different positions in model and view
+ }
+ break;
+ }
+
+ return bChanged;
+}
+
+void LegendItemConverter::FillSpecialItem(
+ USHORT nWhichId, SfxItemSet & rOutItemSet ) const
+{
+ switch( nWhichId )
+ {
+ case SCHATTR_LEGEND_POS:
+ {
+ // alwas right
+ //todo: implement different positions in model and view
+ rOutItemSet.Put( SvxChartLegendPosItem( CHLEGEND_RIGHT ) );
+ }
+ break;
+ }
+}
+
+} // namespace wrapper
+} // namespace chart
diff --git a/chart2/source/controller/itemsetwrapper/makefile.mk b/chart2/source/controller/itemsetwrapper/makefile.mk
index 8c4862aef0ca..28932e5a5b54 100644
--- a/chart2/source/controller/itemsetwrapper/makefile.mk
+++ b/chart2/source/controller/itemsetwrapper/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.2 $
+# $Revision: 1.3 $
#
-# last change: $Author: bm $ $Date: 2003-10-07 17:18:36 $
+# last change: $Author: bm $ $Date: 2003-10-09 16:46:40 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -82,6 +82,7 @@ SLOFILES= $(SLO)$/SchItemPool.obj \
$(SLO)$/ChartTypeItemConverter.obj \
$(SLO)$/DataPointItemConverter.obj \
$(SLO)$/GraphicPropertyItemConverter.obj \
+ $(SLO)$/LegendItemConverter.obj \
$(SLO)$/TitleItemConverter.obj
# --- Targets -----------------------------------------------------------------
diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx
index e0d635628a04..311fce8575e1 100644
--- a/chart2/source/controller/main/ChartController_Properties.cxx
+++ b/chart2/source/controller/main/ChartController_Properties.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ChartController_Properties.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: bm $ $Date: 2003-10-07 17:18:43 $
+ * last change: $Author: bm $ $Date: 2003-10-09 16:46:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -66,16 +66,18 @@
#include "SchSlotIds.hxx"
+#include "macros.hxx"
#include "dlg_ObjectProperties.hxx"
#include "ViewElementListProvider.hxx"
#include "DataPointItemConverter.hxx"
#include "AxisItemConverter.hxx"
#include "MultipleChartConverters.hxx"
#include "TitleItemConverter.hxx"
+#include "LegendItemConverter.hxx"
#include "ChartModelHelper.hxx"
#include "MeterHelper.hxx"
-#include "macros.hxx"
#include "TitleHelper.hxx"
+#include "LegendHelper.hxx"
#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XAXISCONTAINER_HPP_
#include <drafts/com/sun/star/chart2/XAxisContainer.hpp>
@@ -139,7 +141,9 @@ uno::Reference< beans::XPropertySet > getObjectPropertySet( const rtl::OUString&
}
break;
case OBJECTTYPE_LEGEND:
- break;
+ if( LegendHelper::getIdentifierForLegend().equals( aParticleID ) )
+ xObjectProperties.set( LegendHelper::getLegend( xModel ), uno::UNO_QUERY );
+ break;
case OBJECTTYPE_LEGEND_ENTRY:
break;
case OBJECTTYPE_DIAGRAM:
@@ -262,6 +266,9 @@ uno::Reference< beans::XPropertySet > getObjectPropertySet( const rtl::OUString&
rDrawModel );
break;
case OBJECTTYPE_LEGEND:
+ pItemConverter = new wrapper::LegendItemConverter( xObjectProperties,
+ rDrawModel.GetItemPool(),
+ rDrawModel );
break;
case OBJECTTYPE_LEGEND_ENTRY:
break;
diff --git a/chart2/source/inc/LegendHelper.hxx b/chart2/source/inc/LegendHelper.hxx
index 074c8a2af62a..d85d4a129cd8 100644
--- a/chart2/source/inc/LegendHelper.hxx
+++ b/chart2/source/inc/LegendHelper.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: LegendHelper.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: bm $ $Date: 2003-10-08 17:40:38 $
+ * last change: $Author: bm $ $Date: 2003-10-09 16:46:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -72,6 +72,9 @@
#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XLEGEND_HPP_
#include <drafts/com/sun/star/chart2/XLegend.hpp>
#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XDIAGRAM_HPP_
+#include <drafts/com/sun/star/chart2/XDiagram.hpp>
+#endif
//.............................................................................
namespace chart
@@ -91,6 +94,19 @@ public:
::drafts::com::sun::star::chart2::XLegend >
getLegend( const ::com::sun::star::uno::Reference<
::com::sun::star::frame::XModel >& xModel );
+
+ /** fills the legend given with XChartTypeGroup elements as XLegendEntry
+ objects.
+
+ Note: In, e.g., a standard bar chart the legend contains only one entry,
+ which is the chart type group. To display all series in the legend, you
+ have to get all XDataSeries in the tree starting at the chart type group
+ */
+ static void defaultFillEmptyLegend(
+ const ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XLegend > & xLegend,
+ const ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XDiagram > & xDiagram );
};
//.............................................................................
diff --git a/chart2/source/model/main/Legend.cxx b/chart2/source/model/main/Legend.cxx
index ed041ffac3c7..4b999260bdae 100644
--- a/chart2/source/model/main/Legend.cxx
+++ b/chart2/source/model/main/Legend.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Legend.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: bm $ $Date: 2003-10-06 09:58:31 $
+ * last change: $Author: bm $ $Date: 2003-10-09 16:46:42 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -63,6 +63,7 @@
#include "algohelper.hxx"
#include "LineProperties.hxx"
#include "FillProperties.hxx"
+#include "CharacterProperties.hxx"
#include "UserDefinedProperties.hxx"
#include "LegendHelper.hxx"
@@ -108,6 +109,8 @@ const uno::Sequence< Property > & lcl_GetPropertySequence()
aProperties, /* bIncludeStyleProperties = */ false );
::chart::FillProperties::AddPropertiesToVector(
aProperties, /* bIncludeStyleProperties = */ false );
+ ::chart::CharacterProperties::AddPropertiesToVector(
+ aProperties, /* bIncludeStyleProperties = */ false );
::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
// and sort them for access via bsearch
@@ -214,6 +217,9 @@ uno::Any Legend::GetDefaultValue( sal_Int32 nHandle ) const
FillProperties::AddDefaultsToMap(
aStaticDefaults,
/* bIncludeStyleProperties = */ false );
+ CharacterProperties::AddDefaultsToMap(
+ aStaticDefaults,
+ /* bIncludeStyleProperties = */ false );
}
helper::tPropertyValueMap::const_iterator aFound(
diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx
index 038980fd88ee..4ff84c4ecc41 100644
--- a/chart2/source/model/template/ChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ChartTypeTemplate.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ChartTypeTemplate.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: bm $ $Date: 2003-10-06 12:54:18 $
+ * last change: $Author: bm $ $Date: 2003-10-09 16:46:43 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -70,6 +70,7 @@
#include "CartesianCoordinateSystem.hxx"
#include "BoundedCoordinateSystem.hxx"
#include "MeterHelper.hxx"
+#include "LegendHelper.hxx"
#ifndef _CPPUHELPER_COMPONENT_CONTEXT_HXX_
#include <cppuhelper/component_context.hxx>
@@ -240,7 +241,7 @@ Reference< chart2::XDiagram > SAL_CALL ChartTypeTemplate::createDiagram(
uno::UNO_QUERY );
xDia->setLegend( xLegend );
- fillEmptyLegend( xLegend, xDia );
+ LegendHelper::defaultFillEmptyLegend( xLegend, xDia );
return xDia;
}
@@ -254,7 +255,7 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const Reference< chart2::XDiagra
Reference< chart2::XLegend > xLegend( xDiagram->getLegend());
lcl_FlushLegend( xLegend );
- fillEmptyLegend( xLegend, xDiagram );
+ LegendHelper::defaultFillEmptyLegend( xLegend, xDiagram );
}
// ________________________________________
@@ -553,32 +554,6 @@ Reference< chart2::XDataSeriesTreeParent > ChartTypeTemplate::createDataSeriesTr
return aRoot;
}
-// finds all chart type groups in the given diagram tree and adds them to the
-// legend
-void ChartTypeTemplate::fillEmptyLegend(
- const Reference< chart2::XLegend > & xLegend,
- const Reference< chart2::XDiagram > & xDiagram )
-{
- if( xLegend.is() &&
- xDiagram.is() )
- {
- Reference< chart2::XDataSeriesTreeParent > xRoot( xDiagram->getTree());
-
- Sequence< Reference< chart2::XDataSeriesTreeNode > > aChildren( xRoot->getChildren());
- for( sal_Int32 i = 0; i < aChildren.getLength(); ++i )
- {
- Reference< lang::XServiceInfo > xInfo( aChildren[ i ], uno::UNO_QUERY );
- if( xInfo.is() &&
- xInfo->supportsService( C2U( "drafts.com.sun.star.chart2.ChartTypeGroup" )))
- {
- Reference< chart2::XLegendEntry > xEntry( xInfo, uno::UNO_QUERY );
- if( xEntry.is())
- xLegend->registerEntry( xEntry );
- }
- }
- }
-}
-
void ChartTypeTemplate::setStackModeAtTree(
const Reference< chart2::XDataSeriesTreeParent > & rTree,
chart2::StackMode eMode )
diff --git a/chart2/source/model/template/ChartTypeTemplate.hxx b/chart2/source/model/template/ChartTypeTemplate.hxx
index 10b330a9b6a7..f69bd610dd31 100644
--- a/chart2/source/model/template/ChartTypeTemplate.hxx
+++ b/chart2/source/model/template/ChartTypeTemplate.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ChartTypeTemplate.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: bm $ $Date: 2003-10-06 09:58:32 $
+ * last change: $Author: bm $ $Date: 2003-10-09 16:46:43 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -204,12 +204,6 @@ protected:
::drafts::com::sun::star::chart2::XBoundedCoordinateSystem > & rCoordSys
);
- virtual void fillEmptyLegend(
- const ::com::sun::star::uno::Reference<
- ::drafts::com::sun::star::chart2::XLegend > & xLegend,
- const ::com::sun::star::uno::Reference<
- ::drafts::com::sun::star::chart2::XDiagram > & xDiagram );
-
// helper methods
// --------------
::com::sun::star::uno::Reference<
diff --git a/chart2/source/tools/LegendHelper.cxx b/chart2/source/tools/LegendHelper.cxx
index 0a187bf214d5..e13e5a825aea 100644
--- a/chart2/source/tools/LegendHelper.cxx
+++ b/chart2/source/tools/LegendHelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: LegendHelper.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: bm $ $Date: 2003-10-08 17:40:38 $
+ * last change: $Author: bm $ $Date: 2003-10-09 16:46:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,6 +65,10 @@
#include <drafts/com/sun/star/chart2/XChartDocument.hpp>
#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
using namespace ::com::sun::star;
using namespace ::drafts::com::sun::star;
@@ -76,8 +80,8 @@ namespace chart
// static
rtl::OUString LegendHelper::getIdentifierForLegend()
{
- static rtl::OUString m_aIdentifier( C2U( "@legend" ) );
- return m_aIdentifier;
+ static rtl::OUString aIdentifier( C2U( "@legend" ) );
+ return aIdentifier;
}
// static
@@ -89,14 +93,54 @@ uno::Reference< chart2::XLegend > LegendHelper::getLegend(
uno::Reference< chart2::XChartDocument > xChartDoc( xModel, uno::UNO_QUERY );
if( xChartDoc.is())
{
- uno::Reference< chart2::XDiagram > xDia( xChartDoc->getDiagram());
- if( xDia.is())
- xResult.set( xDia->getLegend() );
+ try
+ {
+ uno::Reference< chart2::XDiagram > xDia( xChartDoc->getDiagram());
+ if( xDia.is())
+ xResult.set( xDia->getLegend() );
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+
}
return xResult;
}
+// static
+void LegendHelper::defaultFillEmptyLegend(
+ const uno::Reference< chart2::XLegend > & xLegend,
+ const uno::Reference< chart2::XDiagram > & xDiagram )
+{
+ if( xLegend.is() &&
+ xDiagram.is() )
+ {
+ try
+ {
+ uno::Reference< chart2::XDataSeriesTreeParent > xRoot( xDiagram->getTree());
+
+ uno::Sequence< uno::Reference< chart2::XDataSeriesTreeNode > > aChildren( xRoot->getChildren());
+ for( sal_Int32 i = 0; i < aChildren.getLength(); ++i )
+ {
+ uno::Reference< lang::XServiceInfo > xInfo( aChildren[ i ], uno::UNO_QUERY );
+ if( xInfo.is() &&
+ xInfo->supportsService( C2U( "drafts.com.sun.star.chart2.ChartTypeGroup" )))
+ {
+ uno::Reference< chart2::XLegendEntry > xEntry( xInfo, uno::UNO_QUERY );
+ if( xEntry.is())
+ xLegend->registerEntry( xEntry );
+ }
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
+}
+
//.............................................................................
} //namespace chart
//.............................................................................
diff --git a/chart2/source/view/inc/PropertyMapper.hxx b/chart2/source/view/inc/PropertyMapper.hxx
index 638d9141ef45..a878d57e482d 100644
--- a/chart2/source/view/inc/PropertyMapper.hxx
+++ b/chart2/source/view/inc/PropertyMapper.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: PropertyMapper.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: bm $ $Date: 2003-10-06 09:58:33 $
+ * last change: $Author: bm $ $Date: 2003-10-09 16:46:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -137,6 +137,8 @@ public:
static const tMakePropertyNameMap& getPropertyNameMapForFillProperties();
static const tMakePropertyNameMap& getPropertyNameMapForLineProperties();
+ static const tMakePropertyNameMap& getPropertyNameMapForFilledSeriesProperties();
+ static const tMakePropertyNameMap& getPropertyNameMapForLineSeriesProperties();
};
//.............................................................................
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 5a252decca07..fc07f9a61e9c 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ChartView.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: bm $ $Date: 2003-10-08 17:40:39 $
+ * last change: $Author: bm $ $Date: 2003-10-09 16:46:45 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -606,8 +606,8 @@ void createLegend( const uno::Reference< XLegend > & xLegend
{
VLegend aVLegend( xLegend );
aVLegend.init( xPageShapes, xShapeFactory );
- // legend width is 1/6 of the total space
- long nWidth = rOutSpaceLeft.Width / 6;
+ // legend width is 1/5 of the total space
+ long nWidth = rOutSpaceLeft.Width / 5;
aVLegend.setMaxSize( awt::Size( nWidth, rOutSpaceLeft.Height ));
aVLegend.createShapes();
// legend is anchored to (right/middle) position
diff --git a/chart2/source/view/main/PropertyMapper.cxx b/chart2/source/view/main/PropertyMapper.cxx
index aedf30cd0e0c..404b523a9128 100644
--- a/chart2/source/view/main/PropertyMapper.cxx
+++ b/chart2/source/view/main/PropertyMapper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: PropertyMapper.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: bm $ $Date: 2003-10-06 09:58:34 $
+ * last change: $Author: bm $ $Date: 2003-10-09 16:46:45 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -92,7 +92,7 @@ void PropertyMapper::setMappedProperties(
}
catch( uno::Exception& e )
{
- e;
+ ASSERT_EXCEPTION( e );
}
}
else
@@ -110,7 +110,7 @@ void PropertyMapper::setMappedProperties(
}
catch( uno::Exception& e )
{
- e;
+ ASSERT_EXCEPTION( e );
}
}
}
@@ -137,7 +137,7 @@ void PropertyMapper::getValueMap(
}
catch( uno::Exception& e )
{
- e;
+ ASSERT_EXCEPTION( e );
}
}
}
@@ -330,6 +330,44 @@ const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForLineProperties(
}
//static
+const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForLineSeriesProperties()
+{
+ //shape property -- chart model object property
+ static tMakePropertyNameMap m_aShapePropertyMapForLineSeriesProperties =
+ tMakePropertyNameMap
+ ( C2U( "LineStyle" ), C2U("LineStyle") )
+ ( C2U( "LineWidth" ), C2U("LineWidth") )
+ ( C2U( "LineDash" ), C2U("LineDash") )
+ ( C2U( "LineColor" ), C2U("Color") )
+ ( C2U( "LineTransparence" ), C2U("Transparency") )
+// ( C2U( "LineJoint" ), C2U("LineJoint") )
+ ;
+ return m_aShapePropertyMapForLineSeriesProperties;
+}
+
+//static
+const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForFilledSeriesProperties()
+{
+ //shape property -- chart model object property
+ static tMakePropertyNameMap m_aShapePropertyMapForFilledSeriesProperties =
+ tMakePropertyNameMap
+ ( C2U( "FillStyle" ), C2U("FillStyle") )
+ ( C2U( "FillColor" ), C2U("Color") )
+ ( C2U( "FillTransparence" ), C2U("Transparency") )
+ ( C2U( "FillGradient" ), C2U("Gradient") )
+ ( C2U( "FillHatch" ), C2U("Hatch") )
+
+ ( C2U( "LineStyle" ), C2U("BorderStyle") )
+ ( C2U( "LineWidth" ), C2U("BorderWidth") )
+ ( C2U( "LineDash" ), C2U("BorderDash") )
+ ( C2U( "LineColor" ), C2U("BorderColor") )
+ ( C2U( "LineTransparence" ), C2U("BorderTransparency") )
+// ( C2U( "LineJoint" ), C2U("LineJoint") )
+ ;
+ return m_aShapePropertyMapForFilledSeriesProperties;
+}
+
+//static
void PropertyMapper::setMultiProperties(
const tNameSequence& rNames
, const tAnySequence& rValues
@@ -349,7 +387,7 @@ void PropertyMapper::setMultiProperties(
}
catch( uno::Exception& e )
{
- e;
+ ASSERT_EXCEPTION( e );
}
}
diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx
index 013905ec3f22..52543fb18b2e 100644
--- a/chart2/source/view/main/VLegend.cxx
+++ b/chart2/source/view/main/VLegend.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: VLegend.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: bm $ $Date: 2003-10-08 17:40:39 $
+ * last change: $Author: bm $ $Date: 2003-10-09 16:46:45 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -60,7 +60,10 @@
************************************************************************/
#include "VLegend.hxx"
#include "macros.hxx"
+#include "PropertyMapper.hxx"
#include "CommonConverters.hxx"
+#include "VLegendSymbolFactory.hxx"
+#include "chartview/ObjectIdentifier.hxx"
#ifndef _COM_SUN_STAR_TEXT_XTEXTRANGE_HPP_
#include <com/sun/star/text/XTextRange.hpp>
@@ -80,6 +83,16 @@
#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XDATASOURCE_HPP_
#include <drafts/com/sun/star/chart2/XDataSource.hpp>
#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XCHARTTYPEGROUP_HPP_
+#include <drafts/com/sun/star/chart2/XChartTypeGroup.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XIDENTIFIABLE_HPP_
+#include <drafts/com/sun/star/chart2/XIdentifiable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_LINEJOINT_HPP_
+#include <com/sun/star/drawing/LineJoint.hpp>
+#endif
+
// header for class Matrix3D
#ifndef _B2D_MATRIX3D_HXX
@@ -114,6 +127,10 @@ namespace
::rtl::OUString lcl_getLabelForSeries( const uno::Reference< chart2::XDataSource > & xSource )
{
+// uno::Reference< beans::XPropertySet > xProp( xSource, uno::UNO_QUERY );
+// ::rtl::OUString aStr;
+// xProp->getPropertyValue( C2U("Identifier")) >>= aStr;
+// return aStr;
::rtl::OUString aResult;
if( xSource.is())
@@ -138,6 +155,69 @@ namespace
return aResult;
}
+/** creates a symbol shape that is returned and added to the given
+ xShapeContainer The adding to the container may have to be done here, if you
+ use group shapes, because you can only add shapes to a group that itself has
+ been added to an XShapes before.
+ */
+uno::Reference< drawing::XShape > lcl_getSymbol(
+ const uno::Reference< chart2::XChartTypeGroup > & xChartTypeGroup,
+ const uno::Reference< beans::XPropertySet > & xSeriesProp,
+ const uno::Reference< lang::XMultiServiceFactory > & xFact,
+ const uno::Reference< drawing::XShapes > & xShapeContainer )
+{
+ uno::Reference< drawing::XShape > xResult;
+
+ if( xChartTypeGroup.is())
+ {
+ uno::Reference< chart2::XChartType > xType( xChartTypeGroup->getChartType());
+ if( xType.is())
+ {
+ ::rtl::OUString aChartType( xType->getChartType());
+
+ sal_Int32 nColor = 0x191970; // midnight blue
+
+ if( xSeriesProp.is() )
+ {
+ xSeriesProp->getPropertyValue( C2U("Color")) >>= nColor;
+ }
+ xResult.set( xFact->createInstance(
+ C2U( "com.sun.star.drawing.GroupShape" )), uno::UNO_QUERY );
+ xShapeContainer->add( xResult );
+ uno::Reference< drawing::XShapes > xGroup( xResult, uno::UNO_QUERY );
+ if( ! xGroup.is())
+ return uno::Reference< drawing::XShape >();
+
+ xShapeContainer->add( xResult );
+
+ chart2::LegendSymbolStyle eSymbolStyle = chart2::LegendSymbolStyle_BOX;
+
+ // todo: offer UNO components that support the given service-name
+ // and are capable of creating data representations as well as
+ // legend symbols
+
+ if( aChartType.equals( C2U( "com.sun.star.chart2.BarChart" )) ||
+ aChartType.equals( C2U( "com.sun.star.chart2.AreaChart" )) ||
+ aChartType.equals( C2U( "com.sun.star.chart2.PieChart" )))
+ {
+ eSymbolStyle = chart2::LegendSymbolStyle_BOX;
+ }
+ else if( aChartType.equals( C2U( "com.sun.star.chart2.LineChart" )))
+ {
+ eSymbolStyle = chart2::LegendSymbolStyle_LINE;
+ }
+
+ ::chart::VLegendSymbolFactory::createSymbol( xGroup, eSymbolStyle, xFact, xSeriesProp );
+ }
+ }
+ else
+ {
+ OSL_ENSURE( false, "No ChartTypeGroup!" );
+ }
+
+ return xResult;
+}
+
} // anonymous namespace
//.............................................................................
@@ -163,6 +243,7 @@ void SAL_CALL VLegend::init(
void VLegend::createLegendEntries(
const uno::Reference< drawing::XShapes > & xShapeContainer,
const uno::Reference< chart2::XDataSeriesTreeParent > & xParent,
+ const uno::Reference< chart2::XDataSeriesTreeParent > & xRootParent,
sal_Int32 & nOutCurrentHeight )
{
if( ! xParent.is())
@@ -171,16 +252,30 @@ void VLegend::createLegendEntries(
const sal_Int32 nXOffset = 100;
const sal_Int32 nYOffset = 100;
+ uno::Reference< chart2::XChartTypeGroup > xChartTypeGroup( xRootParent, uno::UNO_QUERY );
uno::Sequence< uno::Reference< chart2::XDataSeriesTreeNode > > aChildren(
xParent->getChildren());
+ // CharacterProperties
+
+ tPropertyNameValueMap aValueMap;
+ uno::Reference< beans::XPropertySet > xLegendProp( m_xLegend, uno::UNO_QUERY );
+ if( xLegendProp.is())
+ {
+ tMakePropertyNameMap aNameMap = PropertyMapper::getPropertyNameMapForCharacterProperties();
+ PropertyMapper::getValueMap( aValueMap, aNameMap, xLegendProp );
+ }
+
for( sal_Int32 nI = 0; nI < aChildren.getLength(); ++nI )
{
uno::Reference< chart2::XDataSeriesTreeParent > xNewParent( aChildren[ nI ], uno::UNO_QUERY );
if( xNewParent.is())
{
+ // If there should be lines between two stacking groups, this would
+ // be the place to create and place them.
+
// recurse !
- createLegendEntries( xShapeContainer, xNewParent, nOutCurrentHeight );
+ createLegendEntries( xShapeContainer, xNewParent, xRootParent, nOutCurrentHeight );
}
else
{
@@ -195,57 +290,51 @@ void VLegend::createLegendEntries(
xShapeContainer->add( xEntry );
- ::rtl::OUString aName( RTL_CONSTASCII_USTRINGPARAM( "<none>" ));
+ ::rtl::OUString aName;
uno::Reference< chart2::XDataSource > xSeriesSource(
aChildren[ nI ], uno::UNO_QUERY );
if( xSeriesSource.is())
aName = lcl_getLabelForSeries( xSeriesSource );
uno::Reference< beans::XPropertySet > xTextProp( xEntry, uno::UNO_QUERY );
+ uno::Reference< text::XTextRange > xRange( xEntry, uno::UNO_QUERY );
+ if( xRange.is())
+ {
+ xRange->setString( aName );
+ }
+
if( xTextProp.is())
{
drawing::TextHorizontalAdjust eHorizAdjust( drawing::TextHorizontalAdjust_LEFT );
drawing::TextVerticalAdjust eVertAdjust( drawing::TextVerticalAdjust_TOP );
-
- xTextProp->setPropertyValue( C2U("CharHeight"), uno::makeAny( (float)(10.0)));
xTextProp->setPropertyValue( C2U("TextAutoGrowHeight"), uno::makeAny( sal_True ));
xTextProp->setPropertyValue( C2U("TextAutoGrowWidth"), uno::makeAny( sal_True ));
xTextProp->setPropertyValue( C2U("TextHorizontalAdjust"), uno::makeAny( eHorizAdjust ));
xTextProp->setPropertyValue( C2U("TextVerticalAdjust"), uno::makeAny( eVertAdjust ));
- }
- uno::Reference< text::XTextRange > xRange( xEntry, uno::UNO_QUERY );
- if( xRange.is())
- {
- xRange->setString( aName );
+ tNameSequence aPropNames;
+ tAnySequence aPropValues;
+ PropertyMapper::getMultiPropertyListsFromValueMap( aPropNames, aPropValues, aValueMap );
+ PropertyMapper::setMultiProperties( aPropNames, aPropValues, xEntry );
}
awt::Size aTextSize( xEntry->getSize());
- xEntry->setPosition( awt::Point( 2*nXOffset + aTextSize.Height, nYOffset + nOutCurrentHeight ));
+ xEntry->setPosition( awt::Point( 2*nXOffset + 2 * aTextSize.Height, nYOffset + nOutCurrentHeight ));
// symbol
uno::Reference< drawing::XShape > xSymbol(
- m_xShapeFactory->createInstance(
- C2U( "com.sun.star.drawing.RectangleShape" )), uno::UNO_QUERY );
-
- if( ! xSymbol.is())
- continue;
-
- sal_Int32 nSymbolWidth = aTextSize.Height * 8 / 10;
- sal_Int32 nDiff = (aTextSize.Height - nSymbolWidth) / 2;
- xShapeContainer->add( xSymbol );
- xSymbol->setSize( awt::Size( nSymbolWidth, nSymbolWidth ));
- xSymbol->setPosition( awt::Point( nXOffset + nDiff,
- nYOffset + nOutCurrentHeight + nDiff ));
-
- uno::Reference< beans::XPropertySet > xSymbolProp( xSymbol, uno::UNO_QUERY );
- uno::Reference< beans::XPropertySet > xSeriesProp( xSeriesSource, uno::UNO_QUERY );
- if( xSymbolProp.is() &&
- xSeriesProp.is() )
+ lcl_getSymbol( xChartTypeGroup,
+ uno::Reference< beans::XPropertySet >(
+ xSeriesSource, uno::UNO_QUERY ),
+ m_xShapeFactory,
+ xShapeContainer));
+ if( xSymbol.is())
{
- xSymbolProp->setPropertyValue(
- C2U("FillColor"),
- xSeriesProp->getPropertyValue( C2U("Color")));
+ sal_Int32 nSymbolHeight = aTextSize.Height * 75 / 100;
+ sal_Int32 nDiff = (aTextSize.Height - nSymbolHeight) / 2;
+ xSymbol->setSize( awt::Size( 2 * nSymbolHeight, nSymbolHeight ));
+ xSymbol->setPosition( awt::Point( nXOffset + nDiff,
+ nYOffset + nOutCurrentHeight + nDiff ));
}
nOutCurrentHeight += aTextSize.Height;
@@ -279,17 +368,49 @@ void VLegend::createShapes()
C2U( "com.sun.star.drawing.GroupShape" )), uno::UNO_QUERY );
m_xTarget->add( m_xShape );
+ // set Name
+ {
+ uno::Reference< beans::XPropertySet > xShapeProp( m_xShape, uno::UNO_QUERY );
+ uno::Reference< chart2::XIdentifiable > xLegendIdent( m_xLegend, uno::UNO_QUERY );
+ if( xShapeProp.is() &&
+ xLegendIdent.is())
+ {
+ rtl::OUString aCID = ObjectIdentifier::createClassifiedIdentifier(
+ OBJECTTYPE_LEGEND, xLegendIdent->getIdentifier() );
+ xShapeProp->setPropertyValue( C2U("Name"), uno::makeAny( aCID ));
+ }
+ }
+
uno::Reference< drawing::XShapes > xLegendContainer( m_xShape, uno::UNO_QUERY );
if( xLegendContainer.is())
{
uno::Reference< drawing::XShape > xBorder(
m_xShapeFactory->createInstance(
C2U( "com.sun.star.drawing.RectangleShape" )), uno::UNO_QUERY );
+
+ tPropertyNameValueMap aValueMap;
+
+ // Get Line- and FillProperties from model legend
+ uno::Reference< beans::XPropertySet > xLegendProp( m_xLegend, uno::UNO_QUERY );
+ if( xLegendProp.is())
+ {
+ tMakePropertyNameMap aNameMap = PropertyMapper::getPropertyNameMapForFillProperties();
+ const tMakePropertyNameMap& rLinePropMap = PropertyMapper::getPropertyNameMapForLineProperties();
+ aNameMap.insert( rLinePropMap.begin(), rLinePropMap.end());
+
+ PropertyMapper::getValueMap( aValueMap, aNameMap, xLegendProp );
+ aValueMap[ C2U("LineJoint") ] = uno::makeAny( drawing::LineJoint_ROUND );
+ }
+
if( xBorder.is())
{
xLegendContainer->add( xBorder );
- awt::Point aPos( 0, 0 );
- xBorder->setPosition( aPos );
+
+ // apply legend properties
+ tNameSequence aPropNames;
+ tAnySequence aPropValues;
+ PropertyMapper::getMultiPropertyListsFromValueMap( aPropNames, aPropValues, aValueMap );
+ PropertyMapper::setMultiProperties( aPropNames, aPropValues, xBorder );
}
const sal_Int32 nVerticalPadding = 200;
@@ -304,7 +425,7 @@ void VLegend::createShapes()
uno::Reference< chart2::XDataSeriesTreeParent > xGroup( aEntries[ nI ], uno::UNO_QUERY );
if( xGroup.is())
{
- createLegendEntries( xLegendContainer, xGroup, nCurrentHeight );
+ createLegendEntries( xLegendContainer, xGroup, xGroup, nCurrentHeight );
}
// separator between chart type groups
@@ -316,11 +437,21 @@ void VLegend::createShapes()
if( xSeparator.is())
{
- nCurrentHeight += nSeparatorDist;
+ sal_Int32 nLineWidth = 0;
+ if( xLegendProp.is())
+ xLegendProp->getPropertyValue( C2U("LineWidth")) >>= nLineWidth;
+
+ nCurrentHeight += nSeparatorDist + nLineWidth/2;
xLegendContainer->add( xSeparator );
xSeparator->setSize( awt::Size( aSize.Width, 0 ));
xSeparator->setPosition( awt::Point( 0, nCurrentHeight ));
- nCurrentHeight += nSeparatorDist;
+ nCurrentHeight += nSeparatorDist + nLineWidth/2;
+
+ // apply legend properties
+ tNameSequence aPropNames;
+ tAnySequence aPropValues;
+ PropertyMapper::getMultiPropertyListsFromValueMap( aPropNames, aPropValues, aValueMap );
+ PropertyMapper::setMultiProperties( aPropNames, aPropValues, xSeparator );
}
}
}
diff --git a/chart2/source/view/main/VLegend.hxx b/chart2/source/view/main/VLegend.hxx
index 8fdb118a0c5d..e91dc3f5ebae 100644
--- a/chart2/source/view/main/VLegend.hxx
+++ b/chart2/source/view/main/VLegend.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: VLegend.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: bm $ $Date: 2003-10-08 17:40:39 $
+ * last change: $Author: bm $ $Date: 2003-10-09 16:46:45 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -110,6 +110,8 @@ protected:
::com::sun::star::drawing::XShapes > & xShapeContainer,
const ::com::sun::star::uno::Reference<
::drafts::com::sun::star::chart2::XDataSeriesTreeParent > & xParent,
+ const ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XDataSeriesTreeParent > & xRootParent,
sal_Int32 & nOutCurrentHeight );
private:
diff --git a/chart2/source/view/main/VLegendSymbolFactory.cxx b/chart2/source/view/main/VLegendSymbolFactory.cxx
new file mode 100644
index 000000000000..72d42bf6e801
--- /dev/null
+++ b/chart2/source/view/main/VLegendSymbolFactory.cxx
@@ -0,0 +1,300 @@
+/*************************************************************************
+ *
+ * $RCSfile: VLegendSymbolFactory.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: bm $ $Date: 2003-10-09 16:46:46 $
+ *
+ * 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: 2003 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "VLegendSymbolFactory.hxx"
+#include "macros.hxx"
+#include "PropertyMapper.hxx"
+
+#ifndef _COM_SUN_STAR_DRAWING_FILLSTYLE_HPP_
+#include <com/sun/star/drawing/FillStyle.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_LINESTYLE_HPP_
+#include <com/sun/star/drawing/LineStyle.hpp>
+#endif
+
+// uncomment to disable line dashes at the border of boxes
+// #define DISABLE_DASHES_AT_BORDER
+
+using namespace ::com::sun::star;
+using namespace ::drafts::com::sun::star;
+
+namespace
+{
+void lcl_setPropetiesToShape(
+ const uno::Reference< beans::XPropertySet > & xProp,
+ const uno::Reference< drawing::XShape > & xShape,
+ bool bFilledSeries )
+{
+ static ::chart::tPropertyNameMap aFilledNameMap( ::chart::PropertyMapper::getPropertyNameMapForFilledSeriesProperties());
+ static ::chart::tPropertyNameMap aLineNameMap( ::chart::PropertyMapper::getPropertyNameMapForLineSeriesProperties());
+
+ if( xProp.is() && xShape.is() )
+ {
+ ::chart::tPropertyNameValueMap aValueMap;
+ if( bFilledSeries )
+ ::chart::PropertyMapper::getValueMap( aValueMap, aFilledNameMap, xProp );
+ else
+ ::chart::PropertyMapper::getValueMap( aValueMap, aLineNameMap, xProp );
+
+ ::chart::tNameSequence aPropNames;
+ ::chart::tAnySequence aPropValues;
+ ::chart::PropertyMapper::getMultiPropertyListsFromValueMap( aPropNames, aPropValues, aValueMap );
+ ::chart::PropertyMapper::setMultiProperties( aPropNames, aPropValues, xShape );
+ }
+}
+
+} // anonymous namespace
+
+namespace chart
+{
+
+// static
+void VLegendSymbolFactory::createSymbol(
+ const uno::Reference< drawing::XShapes > xSymbolGroup,
+ chart2::LegendSymbolStyle eStyle,
+ const uno::Reference< lang::XMultiServiceFactory > & xShapeFactory,
+ const uno::Reference< beans::XPropertySet > & xSeriesProperties )
+{
+ awt::Size aBoundSize( 2000, 1000 );
+
+ // add an invisible square box to maintain aspect ratio
+ switch( eStyle )
+ {
+ case chart2::LegendSymbolStyle_BOX:
+ case chart2::LegendSymbolStyle_LINE:
+ case chart2::LegendSymbolStyle_DIAGONAL_LINE:
+ case chart2::LegendSymbolStyle_LINE_WITH_BOX:
+ case chart2::LegendSymbolStyle_LINE_WITH_SYMBOL:
+ case chart2::LegendSymbolStyle_CIRCLE:
+ {
+ try
+ {
+ uno::Reference< drawing::XShape > xBound(
+ xShapeFactory->createInstance(
+ C2U( "com.sun.star.drawing.RectangleShape" )), uno::UNO_QUERY );
+ if( xBound.is())
+ {
+ xSymbolGroup->add( xBound );
+ xBound->setSize( aBoundSize );
+ uno::Reference< beans::XPropertySet > xBoundProp( xBound, uno::UNO_QUERY );
+ if( xBoundProp.is())
+ {
+ xBoundProp->setPropertyValue(
+ C2U("FillStyle"), uno::makeAny( drawing::FillStyle_NONE ));
+ xBoundProp->setPropertyValue(
+ C2U("LineStyle"), uno::makeAny( drawing::LineStyle_NONE ));
+ }
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ break;
+ }
+
+ case chart2::LegendSymbolStyle_BAR:
+ case chart2::LegendSymbolStyle_RECTANGLE:
+ case chart2::LegendSymbolStyle_STRETCHED_RECTANGLE:
+ case chart2::LegendSymbolStyle_USER_DEFINED:
+ default:
+ break;
+ }
+
+ // create symbol
+ switch( eStyle )
+ {
+ case chart2::LegendSymbolStyle_BOX:
+ case chart2::LegendSymbolStyle_BAR:
+ case chart2::LegendSymbolStyle_RECTANGLE:
+ case chart2::LegendSymbolStyle_STRETCHED_RECTANGLE:
+ {
+ try
+ {
+ uno::Reference< drawing::XShape > xRect(
+ xShapeFactory->createInstance(
+ C2U( "com.sun.star.drawing.RectangleShape" )), uno::UNO_QUERY );
+ if( xRect.is())
+ {
+ xSymbolGroup->add( xRect );
+ if( eStyle == chart2::LegendSymbolStyle_BOX )
+ {
+ xRect->setSize( awt::Size( 1000, 1000 ));
+ xRect->setPosition( awt::Point( 500, 0 ));
+ }
+ else
+ {
+ xRect->setSize( aBoundSize );
+ }
+ }
+
+ lcl_setPropetiesToShape( xSeriesProperties, xRect, true /* bFilledSeries */ );
+
+#ifdef DISABLE_DASHES_AT_BORDER
+ // don't allow dashed border style
+ uno::Reference< beans::XPropertySet > xRectProp( xRect, uno::UNO_QUERY );
+ if( xRectProp.is())
+ {
+ drawing::LineStyle aLineStyle;
+ if( ( xRectProp->getPropertyValue( C2U("LineStyle")) >>= aLineStyle ) &&
+ aLineStyle == drawing::LineStyle_DASH )
+ {
+ aLineStyle = drawing::LineStyle_SOLID;
+ xRectProp->setPropertyValue( C2U("LineStyle"), uno::makeAny( aLineStyle ));
+ }
+ }
+#endif
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ break;
+ }
+
+ case chart2::LegendSymbolStyle_LINE:
+ {
+ try
+ {
+ uno::Reference< drawing::XShape > xLine(
+ xShapeFactory->createInstance(
+ C2U( "com.sun.star.drawing.LineShape" )), uno::UNO_QUERY );
+ if( xLine.is())
+ {
+ xSymbolGroup->add( xLine );
+ xLine->setSize( awt::Size( 2000, 0 ));
+ xLine->setPosition( awt::Point( 0, 500 ));
+
+ lcl_setPropetiesToShape( xSeriesProperties, xLine, false /* bFilledSeries */ );
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ break;
+ }
+
+ case chart2::LegendSymbolStyle_DIAGONAL_LINE:
+ {
+ try
+ {
+ uno::Reference< drawing::XShape > xLine(
+ xShapeFactory->createInstance(
+ C2U( "com.sun.star.drawing.LineShape" )), uno::UNO_QUERY );
+ if( xLine.is())
+ {
+ xSymbolGroup->add( xLine );
+ xLine->setSize( awt::Size( 1000, 1000 ));
+ xLine->setPosition( awt::Point( 500, 0 ));
+
+ lcl_setPropetiesToShape( xSeriesProperties, xLine, false /* bFilledSeries */ );
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ break;
+ }
+
+ case chart2::LegendSymbolStyle_LINE_WITH_BOX:
+ {
+ try
+ {
+ uno::Reference< drawing::XShape > xLine(
+ xShapeFactory->createInstance(
+ C2U( "com.sun.star.drawing.LineShape" )), uno::UNO_QUERY );
+ if( xLine.is())
+ {
+ xSymbolGroup->add( xLine );
+ xLine->setSize( awt::Size( 1000, 0 ));
+ xLine->setPosition( awt::Point( 0, 500 ));
+
+ lcl_setPropetiesToShape( xSeriesProperties, xLine, false /* bFilledSeries */ );
+ }
+
+ uno::Reference< drawing::XShape > xSymbol(
+ xShapeFactory->createInstance(
+ C2U( "com.sun.star.drawing.RectangleShape" )), uno::UNO_QUERY );
+ if( xSymbol.is())
+ {
+ xSymbolGroup->add( xSymbol );
+ xSymbol->setSize( awt::Size( 250, 250 ));
+ xSymbol->setPosition( awt::Point( 375, 375 ));
+
+ lcl_setPropetiesToShape( xSeriesProperties, xSymbol, true /* bFilledSeries */ );
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ break;
+ }
+ case chart2::LegendSymbolStyle_LINE_WITH_SYMBOL:
+ case chart2::LegendSymbolStyle_CIRCLE:
+ case chart2::LegendSymbolStyle_USER_DEFINED:
+ default:
+ break;
+ }
+}
+
+} // namespace chart
diff --git a/chart2/source/view/main/makefile.mk b/chart2/source/view/main/makefile.mk
index 7e5024ac116a..6c27c5588005 100644
--- a/chart2/source/view/main/makefile.mk
+++ b/chart2/source/view/main/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.1.1.1 $
+# $Revision: 1.2 $
#
-# last change: $Author: bm $ $Date: 2003-10-06 09:58:34 $
+# last change: $Author: bm $ $Date: 2003-10-09 16:46:46 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -87,6 +87,7 @@ SLOFILES = \
$(SLO)$/PlotterBase.obj \
$(SLO)$/VDataSeries.obj \
$(SLO)$/VLegend.obj \
+ $(SLO)$/VLegendSymbolFactory.obj \
$(SLO)$/VTitle.obj \
$(SLO)$/ChartView.obj