summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-04-25 10:55:22 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-04-26 09:58:02 -0400
commite80dd6ace8162e31616df723ecb32c027b3c8449 (patch)
treeb3bb45f4e2e34849934f990defd5d12f2879c27a /sc
parent63143648a0da5f30b4883cbc4ff1885b19afdf0f (diff)
Prepare for supporting fields other than URL in ScEditFieldObj.
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/fielduno.hxx4
-rw-r--r--sc/source/ui/unoobj/fielduno.cxx172
2 files changed, 97 insertions, 79 deletions
diff --git a/sc/inc/fielduno.hxx b/sc/inc/fielduno.hxx
index 7acff6c940ce..7c1929d6a4a3 100644
--- a/sc/inc/fielduno.hxx
+++ b/sc/inc/fielduno.hxx
@@ -337,7 +337,7 @@ class ScEditFieldObj : public cppu::WeakImplHelper4<
private boost::noncopyable
{
public:
- enum FieldType { URL = 0 };
+ enum FieldType { URL = 0, Page, Pages, Date, Time, Title, File, Sheet };
private:
const SfxItemPropertySet* pPropSet;
@@ -354,6 +354,8 @@ private:
SvxFieldData* getData();
+ void setPropertyValueURL(const rtl::OUString& rName, const com::sun::star::uno::Any& rVal);
+
public:
static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
static ScEditFieldObj* getImplementation(const com::sun::star::uno::Reference<com::sun::star::text::XTextContent>& xObj);
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index eacf867de6b4..4ae7236467f8 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -1050,15 +1050,108 @@ SvxFieldData* ScEditFieldObj::getData()
{
switch (meType)
{
+ case Date:
+ mpData.reset(new SvxDateField);
+ break;
+ case File:
+ mpData.reset(
+ new SvxExtFileField(rtl::OUString(), SVXFILETYPE_VAR, SVXFILEFORMAT_NAME_EXT));
+ break;
+ case Page:
+ mpData.reset(new SvxPageField);
+ break;
+ case Pages:
+ mpData.reset(new SvxPagesField);
+ break;
+ case Sheet:
+ mpData.reset(new SvxTableField);
+ break;
+ case Time:
+ mpData.reset(new SvxTimeField);
+ break;
+ case Title:
+ mpData.reset(new SvxFileField);
+ break;
case URL:
mpData.reset(
new SvxURLField(rtl::OUString(), rtl::OUString(), SVXURLFORMAT_APPDEFAULT));
break;
+ default:
+ mpData.reset(new SvxFieldData);
}
}
return mpData.get();
}
+void ScEditFieldObj::setPropertyValueURL(const rtl::OUString& rName, const com::sun::star::uno::Any& rVal)
+{
+ rtl::OUString aStrVal;
+ if (pEditSource)
+ {
+ // Edit engine instance already exists for this field item. Use it.
+ ScEditEngineDefaulter* pEditEngine = ((ScCellEditSource*)pEditSource)->GetEditEngine();
+ ScUnoEditEngine aTempEngine(pEditEngine);
+
+ // Typ egal (in Zellen gibts nur URLs)
+ SvxFieldData* pField = aTempEngine.FindByPos( aSelection.nStartPara, aSelection.nStartPos, 0 );
+ OSL_ENSURE(pField,"setPropertyValue: Feld nicht gefunden");
+ if (!pField)
+ return;
+
+ if (pField->GetClassId() != SVX_URLFIELD)
+ // Make sure this is indeed a URL field.
+ return;
+
+ SvxURLField* pURL = static_cast<SvxURLField*>(pField);
+
+ if (rName == SC_UNONAME_URL)
+ {
+ if (rVal >>= aStrVal)
+ pURL->SetURL(aStrVal);
+ }
+ else if (rName == SC_UNONAME_REPR)
+ {
+ if (rVal >>= aStrVal)
+ pURL->SetRepresentation(aStrVal);
+ }
+ else if (rName == SC_UNONAME_TARGET)
+ {
+ if (rVal >>= aStrVal)
+ pURL->SetTargetFrame(aStrVal);
+ }
+ else
+ throw beans::UnknownPropertyException();
+
+ pEditEngine->QuickInsertField( SvxFieldItem(*pField, EE_FEATURE_FIELD), aSelection );
+ pEditSource->UpdateData();
+ return;
+ }
+
+ // Edit engine instance not yet present. Store the item data for later use.
+ SvxFieldData* pData = getData();
+ if (!pData)
+ throw uno::RuntimeException();
+
+ SvxURLField* p = static_cast<SvxURLField*>(pData);
+ if (rName == SC_UNONAME_URL)
+ {
+ if (rVal >>= aStrVal)
+ p->SetURL(aStrVal);
+ }
+ else if (rName == SC_UNONAME_REPR)
+ {
+ if (rVal >>= aStrVal)
+ p->SetRepresentation(aStrVal);
+ }
+ else if (rName == SC_UNONAME_TARGET)
+ {
+ if (rVal >>= aStrVal)
+ p->SetTargetFrame(aStrVal);
+ }
+ else
+ throw beans::UnknownPropertyException();
+}
+
ScEditFieldObj::ScEditFieldObj(
const uno::Reference<text::XTextRange>& rContent,
SvxEditSource* pEditSrc, FieldType eType, const ESelection& rSel) :
@@ -1215,87 +1308,10 @@ void SAL_CALL ScEditFieldObj::setPropertyValue(
uno::RuntimeException)
{
SolarMutexGuard aGuard;
- rtl::OUString aStrVal;
- if (pEditSource)
- {
- // Edit engine instance already exists for this field item. Use it.
- ScEditEngineDefaulter* pEditEngine = ((ScCellEditSource*)pEditSource)->GetEditEngine();
- ScUnoEditEngine aTempEngine(pEditEngine);
-
- // Typ egal (in Zellen gibts nur URLs)
- SvxFieldData* pField = aTempEngine.FindByPos( aSelection.nStartPara, aSelection.nStartPos, 0 );
- OSL_ENSURE(pField,"setPropertyValue: Feld nicht gefunden");
- if (!pField)
- return;
-
- bool bOk = true;
- switch (meType)
- {
- case URL:
- {
- if (pField->GetClassId() != SVX_URLFIELD)
- {
- // Make sure this is indeed a URL field.
- bOk = false;
- break;
- }
- SvxURLField* pURL = static_cast<SvxURLField*>(pField);
-
- if (aPropertyName == SC_UNONAME_URL)
- {
- if (aValue >>= aStrVal)
- pURL->SetURL(aStrVal);
- }
- else if (aPropertyName == SC_UNONAME_REPR)
- {
- if (aValue >>= aStrVal)
- pURL->SetRepresentation(aStrVal);
- }
- else if (aPropertyName == SC_UNONAME_TARGET)
- {
- if (aValue >>= aStrVal)
- pURL->SetTargetFrame(aStrVal);
- }
- else
- bOk = false;
- }
- break;
- }
-
- if (bOk)
- {
- pEditEngine->QuickInsertField( SvxFieldItem(*pField, EE_FEATURE_FIELD), aSelection );
- pEditSource->UpdateData();
- }
- return;
- }
-
- // Edit engine instance not yet present. Store the item data for later use.
- SvxFieldData* pData = getData();
- if (!pData)
- throw uno::RuntimeException();
-
switch (meType)
{
case URL:
- {
- SvxURLField* p = static_cast<SvxURLField*>(pData);
- if (aPropertyName == SC_UNONAME_URL)
- {
- if (aValue >>= aStrVal)
- p->SetURL(aStrVal);
- }
- else if (aPropertyName == SC_UNONAME_REPR)
- {
- if (aValue >>= aStrVal)
- p->SetRepresentation(aStrVal);
- }
- else if (aPropertyName == SC_UNONAME_TARGET)
- {
- if (aValue >>= aStrVal)
- p->SetTargetFrame(aStrVal);
- }
- }
+ setPropertyValueURL(aPropertyName, aValue);
break;
default:
throw beans::UnknownPropertyException();