Kaydet (Commit) 6e6f822e authored tarafından Markus Mohrhard's avatar Markus Mohrhard

finally implement and define also date formatting

Change-Id: I261e6d3199573fc2e37d940e4249a1fce105e6eb
üst f5c178f7
...@@ -1206,6 +1206,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,com/sun/star/sheet,\ ...@@ -1206,6 +1206,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,com/sun/star/sheet,\
DatabaseRange \ DatabaseRange \
DatabaseRanges \ DatabaseRanges \
DatabaseRangesEnumeration \ DatabaseRangesEnumeration \
DateCondition \
DocumentSettings \ DocumentSettings \
FormulaParser \ FormulaParser \
FunctionAccess \ FunctionAccess \
...@@ -3369,6 +3370,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/sheet,\ ...@@ -3369,6 +3370,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/sheet,\
ConditionOperator2 \ ConditionOperator2 \
DataBarAxis \ DataBarAxis \
DataBarEntryType \ DataBarEntryType \
DateType \
DDEItemInfo \ DDEItemInfo \
DDELinkInfo \ DDELinkInfo \
DDELinkMode \ DDELinkMode \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef __com_sun_star_sheet_DateCondition_idl__
#define __com_sun_star_sheet_DateCondition_idl__
#include <com/sun/star/sheet/XConditionEntry.idl>
module com { module sun { module star { module sheet {
service DateCondition
{
interface XConditionEntry;
[property] string StyleName;
/**
* See com.sun.star.sheet.DateType for possible values
*/
[property] long DateType;
};
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef __com_sun_star_sheet_DateType_idl__
#define __com_sun_star_sheet_DateType_idl__
module com { module sun { module star { module sheet {
constants DateType
{
const long TODAY = 0;
const long YESTERDAY = 1;
const long TOMORROW = 2;
const long LAST7DAYS = 3;
const long THISWEEK = 4;
const long LASTWEEK = 5;
const long NEXTWEEK = 6;
const long THISMONTH = 7;
const long LASTMONTH = 8;
const long NEXTMONTH = 9;
const long THISYEAR = 10;
const long LASTYEAR = 11;
const long NEXTYEAR = 12;
};
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -35,6 +35,7 @@ class ScDataBarFormat; ...@@ -35,6 +35,7 @@ class ScDataBarFormat;
class ScColorScaleFormat; class ScColorScaleFormat;
class ScCondFormatEntry; class ScCondFormatEntry;
class ScColorScaleEntry; class ScColorScaleEntry;
class ScCondDateFormatEntry;
using namespace com::sun::star; using namespace com::sun::star;
...@@ -515,6 +516,69 @@ private: ...@@ -515,6 +516,69 @@ private:
size_t mnPos; size_t mnPos;
}; };
class ScCondDateFormatObj : public cppu::WeakImplHelper2<com::sun::star::beans::XPropertySet,
com::sun::star::sheet::XConditionEntry>
{
public:
ScCondDateFormatObj(rtl::Reference<ScCondFormatObj> xParent,
const ScCondDateFormatEntry* pFormat);
virtual ~ScCondDateFormatObj();
ScCondDateFormatEntry* getCoreObject();
// XConditionEntry
virtual sal_Int32 SAL_CALL getType()
throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XPropertySet
virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
SAL_CALL getPropertySetInfo()
throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
const ::com::sun::star::uno::Any& aValue )
throw(::com::sun::star::beans::UnknownPropertyException,
::com::sun::star::beans::PropertyVetoException,
::com::sun::star::lang::IllegalArgumentException,
::com::sun::star::lang::WrappedTargetException,
::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
const OUString& PropertyName )
throw(::com::sun::star::beans::UnknownPropertyException,
::com::sun::star::lang::WrappedTargetException,
::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
const ::com::sun::star::uno::Reference<
::com::sun::star::beans::XPropertyChangeListener >& xListener )
throw(::com::sun::star::beans::UnknownPropertyException,
::com::sun::star::lang::WrappedTargetException,
::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
const ::com::sun::star::uno::Reference<
::com::sun::star::beans::XPropertyChangeListener >& aListener )
throw(::com::sun::star::beans::UnknownPropertyException,
::com::sun::star::lang::WrappedTargetException,
::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
const ::com::sun::star::uno::Reference<
::com::sun::star::beans::XVetoableChangeListener >& aListener )
throw(::com::sun::star::beans::UnknownPropertyException,
::com::sun::star::lang::WrappedTargetException,
::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
const ::com::sun::star::uno::Reference<
::com::sun::star::beans::XVetoableChangeListener >& aListener )
throw(::com::sun::star::beans::UnknownPropertyException,
::com::sun::star::lang::WrappedTargetException,
::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
private:
ScDocShell* mpDocShell;
rtl::Reference<ScCondFormatObj> mxParent;
SfxItemPropertySet maPropSet;
const ScCondDateFormatEntry* mpFormat;
};
#endif #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <com/sun/star/sheet/ColorScaleEntryType.hpp> #include <com/sun/star/sheet/ColorScaleEntryType.hpp>
#include <com/sun/star/sheet/IconSetFormatEntry.hpp> #include <com/sun/star/sheet/IconSetFormatEntry.hpp>
#include <com/sun/star/sheet/ConditionEntryType.hpp> #include <com/sun/star/sheet/ConditionEntryType.hpp>
#include <com/sun/star/sheet/DateType.hpp>
namespace { namespace {
...@@ -263,6 +264,45 @@ IconSetEntryTypeApiMap aIconSetEntryTypeMap[] = ...@@ -263,6 +264,45 @@ IconSetEntryTypeApiMap aIconSetEntryTypeMap[] =
{ COLORSCALE_PERCENTILE, sheet::IconSetFormatEntry::ICONSET_PERCENTILE } { COLORSCALE_PERCENTILE, sheet::IconSetFormatEntry::ICONSET_PERCENTILE }
}; };
enum DateProperties
{
Date_StyleName,
DateType
};
const SfxItemPropertyMapEntry* getCondDatePropSet()
{
static const SfxItemPropertyMapEntry aCondDatePropertyMap_Impl[] =
{
{OUString("StyleName"), StyleName, cppu::UnoType<OUString>::get(), 0, 0},
{OUString(), 0, css::uno::Type(), 0, 0}
};
return aCondDatePropertyMap_Impl;
}
struct DateTypeApiMap
{
condformat::ScCondFormatDateType eType;
sal_Int32 nApiType;
};
DateTypeApiMap aDateTypeApiMap[] =
{
{ condformat::TODAY, sheet::DateType::TODAY },
{ condformat::YESTERDAY, sheet::DateType::YESTERDAY },
{ condformat::TOMORROW, sheet::DateType::TOMORROW },
{ condformat::LAST7DAYS, sheet::DateType::LAST7DAYS },
{ condformat::THISWEEK, sheet::DateType::THISWEEK },
{ condformat::LASTWEEK, sheet::DateType::LASTWEEK },
{ condformat::NEXTWEEK, sheet::DateType::NEXTWEEK },
{ condformat::THISMONTH, sheet::DateType::THISMONTH },
{ condformat::LASTMONTH, sheet::DateType::LASTMONTH },
{ condformat::NEXTMONTH, sheet::DateType::NEXTMONTH },
{ condformat::THISYEAR, sheet::DateType::THISYEAR },
{ condformat::LASTYEAR, sheet::DateType::LASTYEAR },
{ condformat::NEXTYEAR, sheet::DateType::NEXTYEAR }
};
} }
ScCondFormatsObj::ScCondFormatsObj(ScDocShell* pDocShell, SCTAB nTab): ScCondFormatsObj::ScCondFormatsObj(ScDocShell* pDocShell, SCTAB nTab):
...@@ -371,6 +411,8 @@ uno::Reference<beans::XPropertySet> createConditionEntry(const ScFormatEntry* pE ...@@ -371,6 +411,8 @@ uno::Reference<beans::XPropertySet> createConditionEntry(const ScFormatEntry* pE
static_cast<const ScIconSetFormat*>(pEntry)); static_cast<const ScIconSetFormat*>(pEntry));
break; break;
case condformat::DATE: case condformat::DATE:
return new ScCondDateFormatObj(xParent,
static_cast<const ScCondDateFormatEntry*>(pEntry));
break; break;
default: default:
break; break;
...@@ -1743,4 +1785,160 @@ void ScIconSetEntryObj::setFormula(const OUString& rFormula) ...@@ -1743,4 +1785,160 @@ void ScIconSetEntryObj::setFormula(const OUString& rFormula)
} }
} }
ScCondDateFormatObj::ScCondDateFormatObj(rtl::Reference<ScCondFormatObj> xParent,
const ScCondDateFormatEntry* pFormat):
mpDocShell(xParent->getDocShell()),
mxParent(xParent),
maPropSet(getCondDatePropSet()),
mpFormat(pFormat)
{
}
ScCondDateFormatObj::~ScCondDateFormatObj()
{
}
ScCondDateFormatEntry* ScCondDateFormatObj::getCoreObject()
{
ScConditionalFormat* pFormat = mxParent->getCoreObject();
if (isObjectStillAlive(pFormat, mpFormat))
return const_cast<ScCondDateFormatEntry*>(mpFormat);
throw lang::IllegalArgumentException();
}
sal_Int32 ScCondDateFormatObj::getType()
throw(uno::RuntimeException, std::exception)
{
return sheet::ConditionEntryType::DATE;
}
uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCondDateFormatObj::getPropertySetInfo()
throw(uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
static uno::Reference<beans::XPropertySetInfo> aRef(
new SfxItemPropertySetInfo( maPropSet.getPropertyMap() ));
return aRef;
}
void SAL_CALL ScCondDateFormatObj::setPropertyValue(
const OUString& aPropertyName, const uno::Any& aValue )
throw(beans::UnknownPropertyException, beans::PropertyVetoException,
lang::IllegalArgumentException, lang::WrappedTargetException,
uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
const SfxItemPropertyMap& rPropertyMap = maPropSet.getPropertyMap(); // from derived class
const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
if ( !pEntry )
throw beans::UnknownPropertyException();
switch(pEntry->nWID)
{
case Date_StyleName:
{
OUString aStyleName;
if (aValue >>= aStyleName)
{
getCoreObject()->SetStyleName(aStyleName);
}
else
throw lang::IllegalArgumentException();
}
break;
case DateType:
{
sal_Int32 nApiType = -1;
if (!(aValue >>= nApiType))
throw lang::IllegalArgumentException();
for (size_t i = 0; i < SAL_N_ELEMENTS(aDateTypeApiMap); ++i)
{
if (aDateTypeApiMap[i].nApiType == nApiType)
{
getCoreObject()->SetDateType(aDateTypeApiMap[i].eType);
break;
}
}
}
break;
default:
break;
}
}
uno::Any SAL_CALL ScCondDateFormatObj::getPropertyValue( const OUString& aPropertyName )
throw(beans::UnknownPropertyException, lang::WrappedTargetException,
uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
const SfxItemPropertyMap& rPropertyMap = maPropSet.getPropertyMap(); // from derived class
const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
if ( !pEntry )
throw beans::UnknownPropertyException();
uno::Any aAny;
switch(pEntry->nWID)
{
case Date_StyleName:
{
OUString aStyleName = getCoreObject()->GetStyleName();
aAny <<= aStyleName;
}
break;
case DateType:
{
condformat::ScCondFormatDateType eType = getCoreObject()->GetDateType();
for (size_t i = 0; i < SAL_N_ELEMENTS(aDateTypeApiMap); ++i)
{
if (aDateTypeApiMap[i].eType == eType)
{
aAny <<= aDateTypeApiMap[i].nApiType;
break;
}
}
}
break;
default:
SAL_WARN("sc", "unknown property");
}
return aAny;
}
void SAL_CALL ScCondDateFormatObj::addPropertyChangeListener( const OUString& /* aPropertyName */,
const uno::Reference<beans::XPropertyChangeListener>& /* aListener */)
throw(beans::UnknownPropertyException,
lang::WrappedTargetException, uno::RuntimeException, std::exception)
{
SAL_WARN("sc", "not implemented");
}
void SAL_CALL ScCondDateFormatObj::removePropertyChangeListener( const OUString& /* aPropertyName */,
const uno::Reference<beans::XPropertyChangeListener>& /* aListener */)
throw(beans::UnknownPropertyException,
lang::WrappedTargetException, uno::RuntimeException, std::exception)
{
SAL_WARN("sc", "not implemented");
}
void SAL_CALL ScCondDateFormatObj::addVetoableChangeListener( const OUString&,
const uno::Reference<beans::XVetoableChangeListener>&)
throw(beans::UnknownPropertyException,
lang::WrappedTargetException, uno::RuntimeException, std::exception)
{
SAL_WARN("sc", "not implemented");
}
void SAL_CALL ScCondDateFormatObj::removeVetoableChangeListener( const OUString&,
const uno::Reference<beans::XVetoableChangeListener>&)
throw(beans::UnknownPropertyException,
lang::WrappedTargetException, uno::RuntimeException, std::exception)
{
SAL_WARN("sc", "not implemented");
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment