diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-05-08 11:48:30 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-05-08 14:23:05 -0400 |
commit | 1af56c22b4b17922f43b67aaf1ceb9562b98f941 (patch) | |
tree | 4d066f129b19a7e83ccf5f2161aaf4e6ed1a5d03 /sc | |
parent | 63114e6d863de32e2d93f0da54caca928916d9c2 (diff) |
Adjust ScEditFieldObj for the change done in SvxUnoTextRangeBase.
Treat date and time field types together, and handle appropriate
properties to have it not throw UnknownPropertyValue exception.
Change-Id: I6a4c512fb3030bfc48ab7372cb1a217069dedfc4
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/fielduno.hxx | 8 | ||||
-rw-r--r-- | sc/inc/unonames.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/unoobj/cellsuno.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/unoobj/fielduno.cxx | 73 | ||||
-rw-r--r-- | sc/source/ui/unoobj/notesuno.cxx | 5 |
5 files changed, 77 insertions, 15 deletions
diff --git a/sc/inc/fielduno.hxx b/sc/inc/fielduno.hxx index c20949c3451e..62ab90f716c3 100644 --- a/sc/inc/fielduno.hxx +++ b/sc/inc/fielduno.hxx @@ -43,6 +43,7 @@ #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/util/XRefreshable.hpp> +#include <com/sun/star/util/DateTime.hpp> #include <cppuhelper/component.hxx> #include <cppuhelper/implbase5.hxx> #include <cppuhelper/implbase4.hxx> @@ -221,7 +222,10 @@ class ScEditFieldObj : public cppu::WeakImplHelper4< boost::scoped_ptr<SvxFieldData> mpData; com::sun::star::uno::Reference<com::sun::star::text::XTextRange> mpContent; + com::sun::star::util::DateTime maDateTime; + sal_Int32 mnNumFormat; bool mbIsDate:1; + bool mbIsFixed:1; private: ScEditFieldObj(); // disabled @@ -234,7 +238,9 @@ private: void setPropertyValueFile(const rtl::OUString& rName, const com::sun::star::uno::Any& rVal); com::sun::star::uno::Any getPropertyValueFile(const rtl::OUString& rName); - void setPropertyValueExtTime(const rtl::OUString& rName, const com::sun::star::uno::Any& rVal); + void setPropertyValueDateTime(const rtl::OUString& rName, const com::sun::star::uno::Any& rVal); + com::sun::star::uno::Any getPropertyValueDateTime(const rtl::OUString& rName); + void setPropertyValueSheet(const rtl::OUString& rName, const com::sun::star::uno::Any& rVal); public: diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index 5ba1a3b760e5..167c10cfac35 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -323,6 +323,7 @@ #define SC_UNONAME_ANCTYPES "AnchorTypes" #define SC_UNONAME_TEXTWRAP "TextWrap" #define SC_UNONAME_FILEFORM "FileFormat" +#define SC_UNONAME_TEXTFIELD_TYPE "TextFieldType" // url field #define SC_UNONAME_REPR "Representation" @@ -334,6 +335,9 @@ #define SC_UNONAME_ISFIXED "IsFixed" #define SC_UNONAME_DATETIME "DateTime" +// table field +#define SC_UNONAME_TABLEPOS "TablePosition" + // conditional format #define SC_UNONAME_OPERATOR "Operator" #define SC_UNONAME_FORMULA1 "Formula1" diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 44fdff56b6a5..7fc9093a223e 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -6436,7 +6436,7 @@ void SAL_CALL ScCellObj::insertTextContent( const uno::Reference<text::XTextRang } if (pCellField->GetFieldType() == text::textfield::Type::TABLE) - pCellField->setPropertyValue("SheetPosition", uno::makeAny<sal_Int32>(aCellPos.Tab())); + pCellField->setPropertyValue(SC_UNONAME_TABLEPOS, uno::makeAny<sal_Int32>(aCellPos.Tab())); SvxFieldItem aItem = pCellField->CreateFieldItem(); SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder(); diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx index 93f3b18b94fa..1168b12589a5 100644 --- a/sc/source/ui/unoobj/fielduno.cxx +++ b/sc/source/ui/unoobj/fielduno.cxx @@ -60,7 +60,7 @@ namespace { // alles ohne Which-ID, Map nur fuer PropertySetInfo -const SfxItemPropertySet* getExtTimePropertySet() +const SfxItemPropertySet* getDateTimePropertySet() { static SfxItemPropertyMapEntry aMapContent[] = { @@ -881,12 +881,35 @@ uno::Any ScEditFieldObj::getPropertyValueFile(const rtl::OUString& rName) return aRet; } -void ScEditFieldObj::setPropertyValueExtTime(const rtl::OUString& rName, const uno::Any& rVal) +void ScEditFieldObj::setPropertyValueDateTime(const rtl::OUString& rName, const uno::Any& rVal) { - if (rName == "IsDate") - { + if (rName == SC_UNONAME_ISDATE) mbIsDate = rVal.get<sal_Bool>(); - } + else if (rName == SC_UNONAME_ISFIXED) + mbIsFixed = rVal.get<sal_Bool>(); + else if (rName == SC_UNONAME_DATETIME) + maDateTime = rVal.get<util::DateTime>(); + else if (rName == SC_UNONAME_NUMFMT) + mnNumFormat = rVal.get<sal_Int32>(); + else + throw beans::UnknownPropertyException(); +} + +uno::Any ScEditFieldObj::getPropertyValueDateTime(const rtl::OUString& rName) +{ + if (rName == SC_UNONAME_ISDATE) + return uno::makeAny<sal_Bool>(mbIsDate); + + if (rName == SC_UNONAME_ISFIXED) + return uno::makeAny<sal_Bool>(mbIsFixed); + + if (rName == SC_UNONAME_DATETIME) + return uno::makeAny(maDateTime); + + if (rName == SC_UNONAME_NUMFMT) + return uno::makeAny(mnNumFormat); + + throw beans::UnknownPropertyException(); } void ScEditFieldObj::setPropertyValueSheet(const rtl::OUString& rName, const uno::Any& rVal) @@ -909,7 +932,7 @@ void ScEditFieldObj::setPropertyValueSheet(const rtl::OUString& rName, const uno SvxTableField* p = static_cast<SvxTableField*>(pField); - if (rName == "SheetPosition") + if (rName == SC_UNONAME_TABLEPOS) { sal_Int32 nTab = rVal.get<sal_Int32>(); p->SetTab(nTab); @@ -928,7 +951,7 @@ void ScEditFieldObj::setPropertyValueSheet(const rtl::OUString& rName, const uno throw uno::RuntimeException(); SvxTableField* p = static_cast<SvxTableField*>(pData); - if (rName == "SheetPosition") + if (rName == SC_UNONAME_TABLEPOS) { sal_Int32 nTab = rVal.get<sal_Int32>(); p->SetTab(nTab); @@ -945,7 +968,7 @@ ScEditFieldObj::ScEditFieldObj( pPropSet(NULL), mpEditSource(pEditSrc), aSelection(rSel), - meType(eType), mpData(NULL), mpContent(rContent), mbIsDate(false) + meType(eType), mpData(NULL), mpContent(rContent), mnNumFormat(0), mbIsDate(false), mbIsFixed(false) { switch (meType) { @@ -955,12 +978,18 @@ ScEditFieldObj::ScEditFieldObj( case text::textfield::Type::URL: pPropSet = lcl_GetURLPropertySet(); break; + case text::textfield::Type::DATE: + case text::textfield::Type::EXTENDED_DATE: + case text::textfield::Type::TIME: case text::textfield::Type::EXTENDED_TIME: - pPropSet = getExtTimePropertySet(); + pPropSet = getDateTimePropertySet(); break; default: pPropSet = lcl_GetHeaderFieldPropertySet(); } + + if (meType == text::textfield::Type::DATE || meType == text::textfield::Type::EXTENDED_DATE) + mbIsDate = true; } void ScEditFieldObj::InitDoc( @@ -1111,6 +1140,12 @@ void SAL_CALL ScEditFieldObj::setPropertyValue( uno::RuntimeException) { SolarMutexGuard aGuard; + if (aPropertyName == SC_UNONAME_ANCHOR) + { + aValue >>= mpContent; + return; + } + switch (meType) { case text::textfield::Type::URL: @@ -1119,8 +1154,11 @@ void SAL_CALL ScEditFieldObj::setPropertyValue( case text::textfield::Type::EXTENDED_FILE: setPropertyValueFile(aPropertyName, aValue); break; + case text::textfield::Type::DATE: + case text::textfield::Type::EXTENDED_DATE: + case text::textfield::Type::TIME: case text::textfield::Type::EXTENDED_TIME: - setPropertyValueExtTime(aPropertyName, aValue); + setPropertyValueDateTime(aPropertyName, aValue); break; case text::textfield::Type::TABLE: setPropertyValueSheet(aPropertyName, aValue); @@ -1135,13 +1173,19 @@ uno::Any SAL_CALL ScEditFieldObj::getPropertyValue( const rtl::OUString& aProper uno::RuntimeException) { SolarMutexGuard aGuard; + if (aPropertyName.equals(SC_UNONAME_TEXTFIELD_TYPE)) + return uno::makeAny(meType); + + if (aPropertyName == SC_UNONAME_ANCHOR) + return uno::makeAny(mpContent); + if (aPropertyName == SC_UNONAME_ANCTYPE) { uno::Any aRet; aRet <<= text::TextContentAnchorType_AS_CHARACTER; return aRet; } - else if (aPropertyName == SC_UNONAME_ANCTYPES) + if (aPropertyName == SC_UNONAME_ANCTYPES) { uno::Any aRet; uno::Sequence<text::TextContentAnchorType> aSeq(1); @@ -1149,7 +1193,7 @@ uno::Any SAL_CALL ScEditFieldObj::getPropertyValue( const rtl::OUString& aProper aRet <<= aSeq; return aRet; } - else if (aPropertyName == SC_UNONAME_TEXTWRAP) + if (aPropertyName == SC_UNONAME_TEXTWRAP) { uno::Any aRet; aRet <<= text::WrapTextMode_NONE; @@ -1162,6 +1206,11 @@ uno::Any SAL_CALL ScEditFieldObj::getPropertyValue( const rtl::OUString& aProper return getPropertyValueURL(aPropertyName); case text::textfield::Type::EXTENDED_FILE: return getPropertyValueFile(aPropertyName); + case text::textfield::Type::DATE: + case text::textfield::Type::TIME: + case text::textfield::Type::EXTENDED_DATE: + case text::textfield::Type::EXTENDED_TIME: + return getPropertyValueDateTime(aPropertyName); default: throw beans::UnknownPropertyException(); } diff --git a/sc/source/ui/unoobj/notesuno.cxx b/sc/source/ui/unoobj/notesuno.cxx index 1ed78c914fde..f94e812bb0a5 100644 --- a/sc/source/ui/unoobj/notesuno.cxx +++ b/sc/source/ui/unoobj/notesuno.cxx @@ -391,7 +391,9 @@ void SAL_CALL ScAnnotationShapeObj::insertTextContent( const uno::Reference< tex uno::RuntimeException) { SolarMutexGuard aGuard; - +#if 1 + GetUnoText().insertTextContent(xRange, xContent, bAbsorb); +#else // Evil hack to convert a ScEditFieldObj based text field into a // SvxUnoTextField based one. See SvxUnoTextBase::insertTextContent() for // the reason why. We need a clean solution for this. @@ -402,6 +404,7 @@ void SAL_CALL ScAnnotationShapeObj::insertTextContent( const uno::Reference< tex xContent2.set(new SvxUnoTextField(pField->GetFieldType())); GetUnoText().insertTextContent(xRange, xContent2, bAbsorb); +#endif } void SAL_CALL ScAnnotationShapeObj::removeTextContent( const uno::Reference< text::XTextContent >& xContent ) |