[Libreoffice-commits] .: 14 commits - editeng/inc editeng/Library_editeng.mk editeng/Package_inc.mk editeng/source officecfg/registry sc/inc sc/qa sc/sdi sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Thu May 3 18:29:23 PDT 2012


 editeng/Library_editeng.mk                                        |    1 
 editeng/Package_inc.mk                                            |    1 
 editeng/inc/editeng/editobj.hxx                                   |    8 
 editeng/inc/editeng/fieldupdater.hxx                              |   66 ++
 editeng/inc/editeng/flditem.hxx                                   |    5 
 editeng/source/editeng/editattr.hxx                               |    7 
 editeng/source/editeng/editobj.cxx                                |  227 +++++-----
 editeng/source/editeng/editobj2.hxx                               |   68 +-
 editeng/source/editeng/fieldupdater.cxx                           |   88 +++
 editeng/source/editeng/impedit4.cxx                               |   41 -
 editeng/source/items/flditem.cxx                                  |   21 
 officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu |   10 
 sc/inc/cell.hxx                                                   |    2 
 sc/inc/editutil.hxx                                               |   19 
 sc/inc/fielduno.hxx                                               |    8 
 sc/inc/sc.hrc                                                     |    3 
 sc/inc/servuno.hxx                                                |    4 
 sc/inc/unonames.hxx                                               |    5 
 sc/qa/unoapi/sc.sce                                               |    2 
 sc/sdi/editsh.sdi                                                 |    3 
 sc/sdi/scalc.sdi                                                  |   47 ++
 sc/source/core/data/cell.cxx                                      |    2 
 sc/source/core/data/cell2.cxx                                     |   10 
 sc/source/core/data/column2.cxx                                   |    3 
 sc/source/core/data/documen2.cxx                                  |    6 
 sc/source/core/data/documen8.cxx                                  |    2 
 sc/source/core/tool/editutil.cxx                                  |   67 ++
 sc/source/filter/rtf/expbase.cxx                                  |    2 
 sc/source/ui/Accessibility/AccessibleText.cxx                     |    6 
 sc/source/ui/app/inputhdl.cxx                                     |    6 
 sc/source/ui/app/inputwin.cxx                                     |   18 
 sc/source/ui/docshell/docsh8.cxx                                  |    2 
 sc/source/ui/src/popup.src                                        |   21 
 sc/source/ui/unoobj/cellsuno.cxx                                  |    4 
 sc/source/ui/unoobj/fielduno.cxx                                  |   98 ++++
 sc/source/ui/unoobj/servuno.cxx                                   |    6 
 sc/source/ui/unoobj/textuno.cxx                                   |    4 
 sc/source/ui/view/editsh.cxx                                      |   18 
 sc/source/ui/view/gridwin.cxx                                     |    2 
 sc/source/ui/view/output2.cxx                                     |    2 
 40 files changed, 686 insertions(+), 229 deletions(-)

New commits:
commit 7b1db375852e92e5ea06436237ef87ec7ced61e7
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu May 3 20:14:39 2012 -0400

    Temporarily disabling a failing API test. I'll fix it soon.
    
    Change-Id: Ibeee491989fd9ae4104a0a3ae3bc7f78f95294a1

diff --git a/sc/qa/unoapi/sc.sce b/sc/qa/unoapi/sc.sce
index 1ad6d8f..ab19f92 100644
--- a/sc/qa/unoapi/sc.sce
+++ b/sc/qa/unoapi/sc.sce
@@ -15,7 +15,7 @@
 -o sc.ScAccessiblePreviewTable
 # fdo#45337 -o sc.ScAccessibleSpreadsheet
 -o sc.ScAnnotationObj
--o sc.ScAnnotationShapeObj
+# FIXME -o sc.ScAnnotationShapeObj
 -o sc.ScAnnotationsObj
 -o sc.ScAreaLinkObj
 -o sc.ScAreaLinksObj
commit 4b8186dbe41677c5c7ee156c586f3295dab7528c
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu May 3 14:48:34 2012 -0400

    Add menu entries for sheet name and date field items.
    
    Change-Id: I5ae910d455a7364209a203c2e3567a902e1f01a2

diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
index c1f1aa3..97fcfc8 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
@@ -1514,9 +1514,14 @@
                     <value>1</value>
                 </prop>
             </node>
-            <node oor:name=".uno:InsertFieldTest" oor:op="replace">
+            <node oor:name=".uno:InsertFieldSheet" oor:op="replace">
                 <prop oor:name="Label" oor:type="xs:string">
-                    <value xml:lang="en-US">Insert Field Test</value>
+                    <value xml:lang="en-US">Insert Sheet Name Field</value>
+                </prop>
+            </node>
+            <node oor:name=".uno:InsertFieldDateVariable" oor:op="replace">
+                <prop oor:name="Label" oor:type="xs:string">
+                    <value xml:lang="en-US">Insert Date Field (variable)</value>
                 </prop>
             </node>
         </node>
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index 1e8b033..f7a556d 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -716,7 +716,8 @@
 
 #define SID_DELETE_SCENARIO     (SID_NEW_SLOTS+95)
 #define SID_EDIT_SCENARIO       (SID_NEW_SLOTS+96)
-#define SID_INSERT_FIELD_TEST   (SID_NEW_SLOTS+97)
+#define SID_INSERT_FIELD_SHEET  (SID_NEW_SLOTS+97)
+#define SID_INSERT_FIELD_DATE_VAR (SID_NEW_SLOTS+98)
 
 // idl parameter
 
diff --git a/sc/sdi/editsh.sdi b/sc/sdi/editsh.sdi
index c896cc4..d306091 100644
--- a/sc/sdi/editsh.sdi
+++ b/sc/sdi/editsh.sdi
@@ -99,7 +99,8 @@ interface TableText
     SID_INSERT_ZWSP             [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ]
     SID_INSERT_ZWNBSP           [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ]
 
-    SID_INSERT_FIELD_TEST [ ExecMethod = Execute; StateMethod = GetState; ]
+    SID_INSERT_FIELD_SHEET [ ExecMethod = Execute; StateMethod = GetState; ]
+    SID_INSERT_FIELD_DATE_VAR  [ ExecMethod = Execute; StateMethod = GetState; ]
 }
 
 
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index 9ca1858..e9a0b7a 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -8001,7 +8001,31 @@ SfxVoidItem SetTabBgColor FID_TAB_MENU_SET_TAB_BG_COLOR
     GroupId = GID_FORMAT;
 ]
 
-SfxVoidItem InsertFieldTest SID_INSERT_FIELD_TEST
+SfxVoidItem InsertFieldSheet SID_INSERT_FIELD_SHEET
+()
+[
+    /* flags: */
+    AutoUpdate = FALSE,
+    Cachable = Cachable,
+    FastCall = FALSE,
+    HasCoreId = FALSE,
+    HasDialog = FALSE,
+    ReadOnlyDoc = TRUE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Synchron;
+
+    /* config: */
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    StatusBarConfig = FALSE,
+    ToolBoxConfig = FALSE,
+    GroupId = GID_OPTIONS;
+]
+
+SfxVoidItem InsertFieldDateVariable SID_INSERT_FIELD_DATE_VAR
 ()
 [
     /* flags: */
diff --git a/sc/source/ui/src/popup.src b/sc/source/ui/src/popup.src
index 66e84bf..67f4089 100644
--- a/sc/source/ui/src/popup.src
+++ b/sc/source/ui/src/popup.src
@@ -438,8 +438,13 @@ Menu RID_POPUP_EDIT
                 {
                     MenuItem
                     {
-                        Identifier = SID_INSERT_FIELD_TEST ;
-                        Text [ en-US ] = "Test Field";
+                        Identifier = SID_INSERT_FIELD_DATE_VAR ;
+                        Text [ en-US ] = "Date" ;
+                    };
+                    MenuItem
+                    {
+                        Identifier = SID_INSERT_FIELD_SHEET ;
+                        Text [ en-US ] = "Sheet Name" ;
                     };
                 };
             };
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index cf47977..adb60bb 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -614,13 +614,20 @@ void ScEditShell::Execute( SfxRequest& rReq )
         case SID_INSERT_ZWNBSP:
             lclInsertCharacter( pTableView, pTopView, CHAR_ZWNBSP );
         break;
-        case SID_INSERT_FIELD_TEST:
+        case SID_INSERT_FIELD_SHEET:
         {
             SvxTableField aField(pViewData->GetTabNo());
             SvxFieldItem aItem(aField, EE_FEATURE_FIELD);
             pTableView->InsertField(aItem);
         }
         break;
+        case SID_INSERT_FIELD_DATE_VAR:
+        {
+            SvxDateField aField;
+            SvxFieldItem aItem(aField, EE_FEATURE_FIELD);
+            pTableView->InsertField(aItem);
+        }
+        break;
     }
 
     pHdl->DataChanged();
@@ -721,7 +728,8 @@ void ScEditShell::GetState( SfxItemSet& rSet )
                         rSet.DisableItem( SID_THES );
                 }
                 break;
-            case SID_INSERT_FIELD_TEST:
+            case SID_INSERT_FIELD_SHEET:
+            case SID_INSERT_FIELD_DATE_VAR:
             break;
 
         }
commit 7684ae6cf43e2fa186f6e9c80d7d377e0dc1a1ab
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu May 3 00:15:30 2012 -0400

    Update sheet IDs in sheet field items during copy and paste.
    
    Change-Id: I1c6e9b4e82eead3c411044482e4fa09332b0babd

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index b4549d1..5de0130 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -243,7 +243,7 @@ public:
 
                     ScEditCell( const EditTextObject* pObject, ScDocument*,
                                 const SfxItemPool* pFromPool /* = NULL */ );
-                    ScEditCell( const ScEditCell& rCell, ScDocument& rDoc );
+    ScEditCell(const ScEditCell& rCell, ScDocument& rDoc, const ScAddress& rDestPos);
                     // for line breaks
                     ScEditCell( const rtl::OUString& rString, ScDocument* );
 
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index fd9499b..3af1a1b 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -112,7 +112,7 @@ ScBaseCell* lclCloneCell( const ScBaseCell& rSrcCell, ScDocument& rDestDoc, cons
         case CELLTYPE_STRING:
             return new ScStringCell( static_cast< const ScStringCell& >( rSrcCell ) );
         case CELLTYPE_EDIT:
-            return new ScEditCell( static_cast< const ScEditCell& >( rSrcCell ), rDestDoc );
+            return new ScEditCell(static_cast<const ScEditCell&>(rSrcCell), rDestDoc, rDestPos);
         case CELLTYPE_FORMULA:
             return new ScFormulaCell( static_cast< const ScFormulaCell& >( rSrcCell ), rDestDoc, rDestPos, nCloneFlags );
         case CELLTYPE_NOTE:
diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index de24d11..c8c6b9b 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -38,6 +38,7 @@
 #include <vcl/mapmod.hxx>
 #include <editeng/editobj.hxx>
 #include <editeng/editstat.hxx>
+#include "editeng/fieldupdater.hxx"
 
 #include "cell.hxx"
 #include "compiler.hxx"
@@ -73,12 +74,13 @@ ScEditCell::ScEditCell( const EditTextObject* pObject, ScDocument* pDocP,
     SetTextObject( pObject, pFromPool );
 }
 
-ScEditCell::ScEditCell( const ScEditCell& rCell, ScDocument& rDoc )  :
-        ScBaseCell( rCell ),
-        pString( NULL ),
-        pDoc( &rDoc )
+ScEditCell::ScEditCell(const ScEditCell& rCell, ScDocument& rDoc, const ScAddress& rDestPos) :
+    ScBaseCell(rCell), pString(NULL), pDoc(&rDoc)
 {
     SetTextObject( rCell.pData, rCell.pDoc->GetEditPool() );
+
+    editeng::FieldUpdater aUpdater = pData->GetFieldUpdater();
+    aUpdater.updateTableFields(rDestPos.Tab());
 }
 
 ScEditCell::ScEditCell( const rtl::OUString& rString, ScDocument* pDocP )  :
commit 9fbcdedb98f096abfcf1893b3658bc8dc4a2efd4
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu May 3 00:14:56 2012 -0400

    Added a field updater wrapper to allow updating of field items.
    
    Change-Id: If39637fd1123b7e6971c639cb7e6774780106ba2

diff --git a/editeng/Library_editeng.mk b/editeng/Library_editeng.mk
index 3645247..f2a8594 100644
--- a/editeng/Library_editeng.mk
+++ b/editeng/Library_editeng.mk
@@ -69,6 +69,7 @@ $(eval $(call gb_Library_add_exception_objects,editeng,\
     editeng/source/editeng/eeobj \
     editeng/source/editeng/eerdll \
     editeng/source/editeng/eertfpar \
+    editeng/source/editeng/fieldupdater \
     editeng/source/editeng/impedit \
     editeng/source/editeng/impedit2 \
     editeng/source/editeng/impedit3 \
diff --git a/editeng/Package_inc.mk b/editeng/Package_inc.mk
index 0305a04..300e2ae 100644
--- a/editeng/Package_inc.mk
+++ b/editeng/Package_inc.mk
@@ -72,6 +72,7 @@ $(eval $(call gb_Package_add_file,editeng_inc,inc/editeng/eerdll.hxx,editeng/eer
 $(eval $(call gb_Package_add_file,editeng_inc,inc/editeng/emphitem.hxx,editeng/emphitem.hxx))
 $(eval $(call gb_Package_add_file,editeng_inc,inc/editeng/escpitem.hxx,editeng/escpitem.hxx))
 $(eval $(call gb_Package_add_file,editeng_inc,inc/editeng/fhgtitem.hxx,editeng/fhgtitem.hxx))
+$(eval $(call gb_Package_add_file,editeng_inc,inc/editeng/fieldupdater.hxx,editeng/fieldupdater.hxx))
 $(eval $(call gb_Package_add_file,editeng_inc,inc/editeng/flditem.hxx,editeng/flditem.hxx))
 $(eval $(call gb_Package_add_file,editeng_inc,inc/editeng/flstitem.hxx,editeng/flstitem.hxx))
 $(eval $(call gb_Package_add_file,editeng_inc,inc/editeng/fontitem.hxx,editeng/fontitem.hxx))
diff --git a/editeng/inc/editeng/editobj.hxx b/editeng/inc/editeng/editobj.hxx
index c57a70b..37aaa02 100644
--- a/editeng/inc/editeng/editobj.hxx
+++ b/editeng/inc/editeng/editobj.hxx
@@ -48,6 +48,12 @@ class SvxFieldItem;
 #define EDTOBJ_SETTINGS_ULITEMSUMMATION     0x00000001
 #define EDTOBJ_SETTINGS_ULITEMFIRSTPARA     0x00000002
 
+namespace editeng {
+
+class FieldUpdater;
+
+}
+
 class EDITENG_DLLPUBLIC EditTextObject
 {
 private:
@@ -119,6 +125,8 @@ public:
                                             const XubString& rNewName, SfxStyleFamily eNewFamily );
     virtual void        ChangeStyleSheetName( SfxStyleFamily eFamily, const XubString& rOldName, const XubString& rNewName );
 
+    virtual editeng::FieldUpdater GetFieldUpdater() = 0;
+
     bool                operator==( const EditTextObject& rCompare ) const;
 
     // #i102062#
diff --git a/editeng/inc/editeng/fieldupdater.hxx b/editeng/inc/editeng/fieldupdater.hxx
new file mode 100644
index 0000000..960d0e0
--- /dev/null
+++ b/editeng/inc/editeng/fieldupdater.hxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ *   Copyright (C) 2012 Kohei Yoshida <kohei.yoshida at suse.com>
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef __EDITENG_FIELDUPDATER_HXX__
+#define __EDITENG_FIELDUPDATER_HXX__
+
+#include "editengdllapi.h"
+
+class EditTextObject;
+
+namespace editeng {
+
+class FieldUpdaterImpl;
+
+/**
+ * Wrapper for EditTextObject to handle updating of fields without exposing
+ * the internals of EditTextObject structure.
+ */
+class EDITENG_DLLPUBLIC FieldUpdater
+{
+    FieldUpdaterImpl* mpImpl;
+
+    FieldUpdater(); // disabled
+public:
+    FieldUpdater(EditTextObject& rObj);
+    FieldUpdater(const FieldUpdater& r);
+    ~FieldUpdater();
+
+    /**
+     * Set a new table ID to all table fields.
+     *
+     * @param nTab new table ID
+     */
+    void updateTableFields(int nTab);
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/source/editeng/editattr.hxx b/editeng/source/editeng/editattr.hxx
index d2cdb42..30dd97c 100644
--- a/editeng/source/editeng/editattr.hxx
+++ b/editeng/source/editeng/editattr.hxx
@@ -30,6 +30,9 @@
 #define _EDITATTR_HXX
 
 #include <editeng/eeitem.hxx>
+#include <svl/poolitem.hxx>
+
+#include <boost/noncopyable.hpp>
 
 class SvxFont;
 class SvxFontItem;
@@ -52,10 +55,8 @@ class SvxFieldItem;
 class SvxLanguageItem;
 class SvxEmphasisMarkItem;
 class SvxCharReliefItem;
-#include <svl/poolitem.hxx>
-
-
 class SfxVoidItem;
+class OutputDevice;
 
 #define CH_FEATURE_OLD  (sal_uInt8)         0xFF
 #define CH_FEATURE      (sal_Unicode)   0x01
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 0fd9de6..ef84d0b 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -35,6 +35,7 @@
 
 #include <tools/stream.hxx>
 
+#include "editeng/fieldupdater.hxx"
 #include <editobj2.hxx>
 #include <editeng/editdata.hxx>
 #include <editattr.hxx>
@@ -86,6 +87,10 @@ bool XEditAttribute::IsFeature() const
     return  ((nWhich >= EE_FEATURE_START) && (nWhich <=  EE_FEATURE_END));
 }
 
+void XEditAttribute::SetItem(const SfxPoolItem& rNew)
+{
+    pItem = &rNew;
+}
 
 XParaPortionList::XParaPortionList(
     OutputDevice* pRefDev, sal_uLong nPW, sal_uInt16 _nStretchX, sal_uInt16 _nStretchY) :
@@ -1023,6 +1028,11 @@ void BinTextObject::ChangeStyleSheetName( SfxStyleFamily eFamily,
     ImpChangeStyleSheets( rOldName, eFamily, rNewName, eFamily );
 }
 
+editeng::FieldUpdater BinTextObject::GetFieldUpdater()
+{
+    return editeng::FieldUpdater(*this);
+}
+
 namespace {
 
 class FindAttribByChar : public std::unary_function<XEditAttribute, bool>
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index 2338653..cb0642d 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -63,6 +63,7 @@ public:
     sal_uInt16              GetLen() const              { return nEnd-nStart; }
 
     bool IsFeature() const;
+    void SetItem(const SfxPoolItem& rNew);
 
     inline bool operator==( const XEditAttribute& rCompare ) const;
 
@@ -254,6 +255,8 @@ public:
                                                 const String& rNewName, SfxStyleFamily eNewFamily );
     virtual void            ChangeStyleSheetName( SfxStyleFamily eFamily, const XubString& rOldName, const XubString& rNewName );
 
+    virtual editeng::FieldUpdater GetFieldUpdater();
+
     void                    CreateData300( SvStream& rIStream );
 
     sal_Bool                    HasMetric() const           { return nMetric != 0xFFFF; }
diff --git a/editeng/source/editeng/fieldupdater.cxx b/editeng/source/editeng/fieldupdater.cxx
new file mode 100644
index 0000000..0078440
--- /dev/null
+++ b/editeng/source/editeng/fieldupdater.cxx
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ *   Copyright (C) 2012 Kohei Yoshida <kohei.yoshida at suse.com>
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "editeng/fieldupdater.hxx"
+#include "editeng/flditem.hxx"
+#include "editobj2.hxx"
+
+namespace editeng {
+
+class FieldUpdaterImpl
+{
+    BinTextObject& mrObj;
+public:
+    FieldUpdaterImpl(EditTextObject& rObj) : mrObj(static_cast<BinTextObject&>(rObj)) {}
+    FieldUpdaterImpl(const FieldUpdaterImpl& r) : mrObj(r.mrObj) {}
+
+    void updateTableFields(int nTab)
+    {
+        SfxItemPool* pPool = mrObj.GetPool();
+        BinTextObject::ContentInfosType& rContents = mrObj.GetContents();
+        for (size_t i = 0; i < rContents.size(); ++i)
+        {
+            ContentInfo& rContent = rContents[i];
+            ContentInfo::XEditAttributesType& rAttribs = rContent.GetAttribs();
+            for (size_t j = 0; j < rAttribs.size(); ++j)
+            {
+                XEditAttribute& rAttr = rAttribs[j];
+                const SfxPoolItem* pItem = rAttr.GetItem();
+                if (pItem->Which() != EE_FEATURE_FIELD)
+                    // This is not a field item.
+                    continue;
+
+                const SvxFieldItem* pFI = static_cast<const SvxFieldItem*>(pItem);
+                const SvxFieldData* pData = pFI->GetField();
+                if (pData->GetClassId() != SVX_TABLEFIELD)
+                    // This is not a table field.
+                    continue;
+
+                // Create a new table field with the new ID, and set it to the
+                // attribute object.
+                SvxFieldItem aNewItem(SvxTableField(nTab), EE_FEATURE_FIELD);
+                rAttr.SetItem(pPool->Put(aNewItem));
+            }
+        }
+    }
+};
+
+FieldUpdater::FieldUpdater(EditTextObject& rObj) : mpImpl(new FieldUpdaterImpl(rObj)) {}
+FieldUpdater::FieldUpdater(const FieldUpdater& r) : mpImpl(new FieldUpdaterImpl(*r.mpImpl)) {}
+
+FieldUpdater::~FieldUpdater()
+{
+    delete mpImpl;
+}
+
+void FieldUpdater::updateTableFields(int nTab)
+{
+    mpImpl->updateTableFields(nTab);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit e4e4b3d65788d14d5f10cd6bccc713cfe2411cb1
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed May 2 14:58:29 2012 -0400

    Another SV_DECL_PTRARR now gone.
    
    Change-Id: I0521274a6e19414d2640a1473a249a90ce2224fc

diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 21f0cbf..0fd9de6 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -86,6 +86,25 @@ bool XEditAttribute::IsFeature() const
     return  ((nWhich >= EE_FEATURE_START) && (nWhich <=  EE_FEATURE_END));
 }
 
+
+XParaPortionList::XParaPortionList(
+    OutputDevice* pRefDev, sal_uLong nPW, sal_uInt16 _nStretchX, sal_uInt16 _nStretchY) :
+    aRefMapMode(pRefDev->GetMapMode()), nStretchX(_nStretchX), nStretchY(_nStretchY)
+{
+    nRefDevPtr = (sal_uIntPtr)pRefDev; nPaperWidth = nPW;
+    eRefDevType = pRefDev->GetOutDevType();
+}
+
+void XParaPortionList::push_back(XParaPortion* p)
+{
+    maList.push_back(p);
+}
+
+const XParaPortion& XParaPortionList::operator [](size_t i) const
+{
+    return maList[i];
+}
+
 ContentInfo::ContentInfo( SfxItemPool& rPool ) : aParaAttribs( rPool, EE_PARA_START, EE_CHAR_END )
 {
     eFamily = SFX_STYLE_FAMILY_PARA;
@@ -740,8 +759,6 @@ void BinTextObject::ClearPortionInfo()
 {
     if ( pPortionInfo )
     {
-        for ( sal_uInt16 n = pPortionInfo->Count(); n; )
-            delete pPortionInfo->GetObject( --n );
         delete pPortionInfo;
         pPortionInfo = NULL;
     }
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index ad611e6..2338653 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -90,28 +90,23 @@ struct XParaPortion
     TextPortionList     aTextPortions;
 };
 
-typedef XParaPortion* XParaPortionPtr;
-SV_DECL_PTRARR( XBaseParaPortionList, XParaPortionPtr, 0 )
-
-class XParaPortionList : public  XBaseParaPortionList
+class XParaPortionList
 {
-    sal_uIntPtr         nRefDevPtr;
+    typedef boost::ptr_vector<XParaPortion> ListType;
+    ListType maList;
+
+    sal_uIntPtr nRefDevPtr;
     OutDevType  eRefDevType;
     MapMode     aRefMapMode;
     sal_uInt16  nStretchX;
     sal_uInt16  nStretchY;
     sal_uLong   nPaperWidth;
 
-
 public:
-            XParaPortionList( OutputDevice* pRefDev, sal_uLong nPW, sal_uInt16 _nStretchX, sal_uInt16 _nStretchY ) :
-                aRefMapMode( pRefDev->GetMapMode() ),
-                nStretchX(_nStretchX),
-                nStretchY(_nStretchY)
-                {
-                    nRefDevPtr = (sal_uIntPtr)pRefDev; nPaperWidth = nPW;
-                    eRefDevType = pRefDev->GetOutDevType();
-                }
+    XParaPortionList(OutputDevice* pRefDev, sal_uLong nPW, sal_uInt16 _nStretchX, sal_uInt16 _nStretchY);
+
+    void push_back(XParaPortion* p);
+    const XParaPortion& operator[](size_t i) const;
 
     sal_uIntPtr         GetRefDevPtr() const        { return nRefDevPtr; }
     sal_uLong           GetPaperWidth() const       { return nPaperWidth; }
@@ -119,6 +114,7 @@ public:
     const MapMode&  GetRefMapMode() const       { return aRefMapMode; }
     sal_uInt16  GetStretchX() const         { return nStretchX; }
     sal_uInt16  GetStretchY() const         { return nStretchY; }
+
 };
 
 class ContentInfo
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index d20958f..f9b8e86 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1140,7 +1140,7 @@ EditTextObject* ImpEditEngine::CreateBinTextObject( EditSelection aSel, SfxItemP
         {
             const ParaPortion* pParaPortion = GetParaPortions()[nNode];
             XParaPortion* pX = new XParaPortion;
-            pXList->Insert( pX, pXList->Count() );
+            pXList->push_back(pX);
 
             pX->nHeight = pParaPortion->GetHeight();
             pX->nFirstLineOffset = pParaPortion->GetFirstLineOffset();
@@ -1330,31 +1330,30 @@ EditSelection ImpEditEngine::InsertBinTextObject( BinTextObject& rTextObject, Ed
             }
             if ( bNewContent && bUsePortionInfo )
             {
-                XParaPortion* pXP = pPortionInfo->GetObject( n );
-                DBG_ASSERT( pXP, "InsertBinTextObject: PortionInfo?" );
+                const XParaPortion& rXP = (*pPortionInfo)[n];
                 ParaPortion* pParaPortion = GetParaPortions()[ nPara ];
                 DBG_ASSERT( pParaPortion, "InsertBinTextObject: ParaPortion?" );
-                pParaPortion->nHeight = pXP->nHeight;
-                pParaPortion->nFirstLineOffset = pXP->nFirstLineOffset;
+                pParaPortion->nHeight = rXP.nHeight;
+                pParaPortion->nFirstLineOffset = rXP.nFirstLineOffset;
                 pParaPortion->bForceRepaint = sal_True;
                 pParaPortion->SetValid();   // Do not format
 
                 // The Text Portions
                 pParaPortion->GetTextPortions().Reset();
-                sal_uInt16 nCount = pXP->aTextPortions.Count();
+                sal_uInt16 nCount = rXP.aTextPortions.Count();
                 for ( sal_uInt16 _n = 0; _n < nCount; _n++ )
                 {
-                    TextPortion* pTextPortion = pXP->aTextPortions[_n];
+                    const TextPortion* pTextPortion = rXP.aTextPortions[_n];
                     TextPortion* pNew = new TextPortion( *pTextPortion );
                     pParaPortion->GetTextPortions().Insert(_n, pNew);
                 }
 
                 // The lines
                 pParaPortion->GetLines().Reset();
-                nCount = pXP->aLines.Count();
+                nCount = rXP.aLines.Count();
                 for ( sal_uInt16 m = 0; m < nCount; m++ )
                 {
-                    EditLine* pLine = pXP->aLines[m];
+                    const EditLine* pLine = rXP.aLines[m];
                     EditLine* pNew = pLine->Clone();
                     pNew->SetInvalid(); // Paint again!
                     pParaPortion->GetLines().Insert(m, pNew);
commit 1e68b77bb785e5ab9a68e0052436d8e7e8163728
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed May 2 14:28:47 2012 -0400

    Removed another SV_DECL_PTRARR.
    
    Change-Id: Ib3900d000c6a884c209a06b30e990963d92bc33f

diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index a2aaa17..21f0cbf 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -80,15 +80,10 @@ XEditAttribute::~XEditAttribute()
     pItem = 0;  // belongs to the Pool.
 }
 
-XEditAttribute* XEditAttributeList::FindAttrib( sal_uInt16 _nWhich, sal_uInt16 nChar ) const
+bool XEditAttribute::IsFeature() const
 {
-    for ( sal_uInt16 n = Count(); n; )
-    {
-        XEditAttribute* pAttr = GetObject( --n );
-        if( ( pAttr->GetItem()->Which() == _nWhich ) && ( pAttr->GetStart() <= nChar ) && ( pAttr->GetEnd() > nChar ) )
-            return pAttr;
-    }
-    return NULL;
+    sal_uInt16 nWhich = pItem->Which();
+    return  ((nWhich >= EE_FEATURE_START) && (nWhich <=  EE_FEATURE_END));
 }
 
 ContentInfo::ContentInfo( SfxItemPool& rPool ) : aParaAttribs( rPool, EE_PARA_START, EE_CHAR_END )
@@ -108,11 +103,12 @@ ContentInfo::ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse
     aStyle = rCopyFrom.GetStyle();
     eFamily = rCopyFrom.GetFamily();
 
-    for ( sal_uInt16 n = 0; n < rCopyFrom.GetAttribs().Count(); n++  )
+    for (size_t i = 0; i < rCopyFrom.aAttribs.size(); ++i)
     {
-        XEditAttribute* pAttr = rCopyFrom.GetAttribs().GetObject( n );
-        XEditAttribute* pMyAttr = MakeXEditAttribute( rPoolToUse, *pAttr->GetItem(), pAttr->GetStart(), pAttr->GetEnd() );
-        aAttribs.Insert( pMyAttr, aAttribs.Count()  );
+        const XEditAttribute& rAttr = rCopyFrom.aAttribs[i];
+        XEditAttribute* pMyAttr = MakeXEditAttribute(
+            rPoolToUse, *rAttr.GetItem(), rAttr.GetStart(), rAttr.GetEnd());
+        aAttribs.push_back(pMyAttr);
     }
 
     if ( rCopyFrom.GetWrongList() )
@@ -121,13 +117,11 @@ ContentInfo::ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse
 
 ContentInfo::~ContentInfo()
 {
-    for ( sal_uInt16 nAttr = 0; nAttr < aAttribs.Count(); nAttr++ )
-    {
-        XEditAttribute* pAttr = aAttribs.GetObject(nAttr);
-        aParaAttribs.GetPool()->Remove( *pAttr->GetItem() );
-        delete pAttr;
-    }
-    aAttribs.Remove( 0, aAttribs.Count() );
+    XEditAttributesType::iterator it = aAttribs.begin(), itEnd = aAttribs.end();
+    for (; it != itEnd; ++it)
+        aParaAttribs.GetPool()->Remove(*it->GetItem());
+    aAttribs.clear();
+
     delete pWrongs;
 }
 
@@ -147,22 +141,17 @@ bool ContentInfo::operator==( const ContentInfo& rCompare ) const
 {
     if( (aText == rCompare.aText) &&
             (aStyle == rCompare.aStyle ) &&
-            (aAttribs.Count() == rCompare.aAttribs.Count() ) &&
+            (aAttribs.size() == rCompare.aAttribs.size()) &&
             (eFamily == rCompare.eFamily ) &&
             (aParaAttribs == rCompare.aParaAttribs ) )
     {
-        const sal_uInt16 nCount = aAttribs.Count();
-        if( nCount == rCompare.aAttribs.Count() )
+        for (size_t i = 0, n = aAttribs.size(); i < n; ++i)
         {
-            sal_uInt16 n;
-            for( n = 0; n < nCount; n++ )
-            {
-                if( !(*aAttribs.GetObject(n) == *rCompare.aAttribs.GetObject(n)) )
-                    return false;
-            }
-
-            return true;
+            if (aAttribs[i] != rCompare.aAttribs[i])
+                return false;
         }
+
+        return true;
     }
 
     return false;
@@ -775,14 +764,14 @@ sal_Bool BinTextObject::HasCharAttribs( sal_uInt16 _nWhich ) const
     {
         const ContentInfo& rC = aContents[--nPara];
 
-        sal_uInt16 nAttribs = rC.GetAttribs().Count();
+        size_t nAttribs = rC.aAttribs.size();
         if ( nAttribs && !_nWhich )
             return true;
 
-        for ( sal_uInt16 nAttr = nAttribs; nAttr; )
+        for (size_t nAttr = nAttribs; nAttr; )
         {
-            XEditAttribute* pX = rC.GetAttribs().GetObject( --nAttr );
-            if ( pX->GetItem()->Which() == _nWhich )
+            const XEditAttribute& rX = rC.aAttribs[--nAttr];
+            if (rX.GetItem()->Which() == _nWhich)
                 return true;
         }
     }
@@ -793,14 +782,14 @@ void BinTextObject::GetCharAttribs( sal_uInt16 nPara, std::vector<EECharAttrib>&
 {
     rLst.clear();
     const ContentInfo& rC = aContents[nPara];
-    for ( sal_uInt16 nAttr = 0; nAttr < rC.GetAttribs().Count(); nAttr++ )
+    for (size_t nAttr = 0; nAttr < rC.aAttribs.size(); ++nAttr)
     {
-        XEditAttribute* pAttr = rC.GetAttribs().GetObject( nAttr );
+        const XEditAttribute& rAttr = rC.aAttribs[nAttr];
         EECharAttrib aEEAttr;
-        aEEAttr.pAttr = pAttr->GetItem();
+        aEEAttr.pAttr = rAttr.GetItem();
         aEEAttr.nPara = nPara;
-        aEEAttr.nStart = pAttr->GetStart();
-        aEEAttr.nEnd = pAttr->GetEnd();
+        aEEAttr.nStart = rAttr.GetStart();
+        aEEAttr.nEnd = rAttr.GetEnd();
         rLst.push_back(aEEAttr);
     }
 }
@@ -840,12 +829,12 @@ const SvxFieldItem* BinTextObject::GetField() const
         const ContentInfo& rC = aContents[0];
         if (rC.GetText().Len() == 1)
         {
-            sal_uInt16 nAttribs = rC.GetAttribs().Count();
-            for ( sal_uInt16 nAttr = nAttribs; nAttr; )
+            size_t nAttribs = rC.aAttribs.size();
+            for (size_t nAttr = nAttribs; nAttr; )
             {
-                XEditAttribute* pX = rC.GetAttribs().GetObject( --nAttr );
-                if ( pX->GetItem()->Which() == EE_FEATURE_FIELD )
-                    return (const SvxFieldItem*)pX->GetItem();
+                const XEditAttribute& rX = rC.aAttribs[--nAttr];
+                if (rX.GetItem()->Which() == EE_FEATURE_FIELD)
+                    return static_cast<const SvxFieldItem*>(rX.GetItem());
             }
         }
     }
@@ -858,16 +847,16 @@ sal_Bool BinTextObject::HasField( TypeId aType ) const
     for (size_t nPara = 0; nPara < nParagraphs; ++nPara)
     {
         const ContentInfo& rC = aContents[nPara];
-        sal_uInt16 nAttrs = rC.GetAttribs().Count();
-        for ( sal_uInt16 nAttr = 0; nAttr < nAttrs; nAttr++ )
+        size_t nAttrs = rC.aAttribs.size();
+        for (size_t nAttr = 0; nAttr < nAttrs; ++nAttr)
         {
-            XEditAttribute* pAttr = rC.GetAttribs()[nAttr];
-            if ( pAttr->GetItem()->Which() == EE_FEATURE_FIELD )
+            const XEditAttribute& rAttr = rC.aAttribs[nAttr];
+            if (rAttr.GetItem()->Which() == EE_FEATURE_FIELD)
             {
                 if ( !aType )
                     return true;
 
-                const SvxFieldData* pFldData = ((const SvxFieldItem*)pAttr->GetItem())->GetField();
+                const SvxFieldData* pFldData = static_cast<const SvxFieldItem*>(rAttr.GetItem())->GetField();
                 if ( pFldData && pFldData->IsA( aType ) )
                     return true;
             }
@@ -897,13 +886,13 @@ sal_Bool BinTextObject::RemoveCharAttribs( sal_uInt16 _nWhich )
     {
         ContentInfo& rC = aContents[--nPara];
 
-        for ( sal_uInt16 nAttr = rC.GetAttribs().Count(); nAttr; )
+        for (size_t nAttr = rC.aAttribs.size(); nAttr; )
         {
-            XEditAttribute* pAttr = rC.GetAttribs().GetObject( --nAttr );
-            if ( !_nWhich || ( pAttr->GetItem()->Which() == _nWhich ) )
+            XEditAttribute& rAttr = rC.aAttribs[--nAttr];
+            if ( !_nWhich || (rAttr.GetItem()->Which() == _nWhich) )
             {
-                rC.GetAttribs().Remove( nAttr );
-                DestroyAttrib( pAttr );
+                pPool->Remove(*rAttr.GetItem());
+                rC.aAttribs.erase(rC.aAttribs.begin()+nAttr);
                 bChanged = true;
             }
         }
@@ -1017,6 +1006,22 @@ void BinTextObject::ChangeStyleSheetName( SfxStyleFamily eFamily,
     ImpChangeStyleSheets( rOldName, eFamily, rNewName, eFamily );
 }
 
+namespace {
+
+class FindAttribByChar : public std::unary_function<XEditAttribute, bool>
+{
+    sal_uInt16 mnWhich;
+    sal_uInt16 mnChar;
+public:
+    FindAttribByChar(sal_uInt16 nWhich, sal_uInt16 nChar) : mnWhich(nWhich), mnChar(nChar) {}
+    bool operator() (const XEditAttribute& rAttr) const
+    {
+        return (rAttr.GetItem()->Which() == mnWhich) && (rAttr.GetStart() <= mnChar) && (rAttr.GetEnd() > mnChar);
+    }
+};
+
+}
+
 void BinTextObject::StoreData( SvStream& rOStream ) const
 {
     sal_uInt16 nVer = 602;
@@ -1061,21 +1066,21 @@ void BinTextObject::StoreData( SvStream& rOStream ) const
                 bSymbolPara = true;
             }
         }
-        for ( sal_uInt16 nA = 0; nA < rC.GetAttribs().Count(); nA++ )
+        for (size_t nA = 0; nA < rC.aAttribs.size(); ++nA)
         {
-            XEditAttribute* pAttr = rC.GetAttribs().GetObject( nA );
+            const XEditAttribute& rAttr = rC.aAttribs[nA];
 
-            if ( pAttr->GetItem()->Which() == EE_CHAR_FONTINFO )
+            if (rAttr.GetItem()->Which() == EE_CHAR_FONTINFO)
             {
-                const SvxFontItem& rFontItem = (const SvxFontItem&)*pAttr->GetItem();
+                const SvxFontItem& rFontItem = (const SvxFontItem&)*rAttr.GetItem();
                 if ( ( !bSymbolPara && ( rFontItem.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) )
                       || ( bSymbolPara && ( rFontItem.GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) )
                 {
                     // Not correctly converted
-                    String aPart( rC.GetText(), pAttr->GetStart(), pAttr->GetEnd() - pAttr->GetStart() );
+                    String aPart( rC.GetText(), rAttr.GetStart(), rAttr.GetEnd() - rAttr.GetStart() );
                     rtl::OString aNew(rtl::OUStringToOString(aPart, rFontItem.GetCharSet()));
-                    aBuffer.remove(pAttr->GetStart(), pAttr->GetEnd() - pAttr->GetStart());
-                    aBuffer.insert(pAttr->GetStart(), aNew);
+                    aBuffer.remove(rAttr.GetStart(), rAttr.GetEnd() - rAttr.GetStart());
+                    aBuffer.insert(rAttr.GetStart(), aNew);
                 }
 
                 // Convert StarSymbol back to StarBats
@@ -1084,7 +1089,7 @@ void BinTextObject::StoreData( SvStream& rOStream ) const
                 {
                     // Don't create a new Attrib with StarBats font, MBR changed the
                     // SvxFontItem::Store() to store StarBats instead of StarSymbol!
-                    for ( sal_uInt16 nChar = pAttr->GetStart(); nChar < pAttr->GetEnd(); nChar++ )
+                    for (sal_uInt16 nChar = rAttr.GetStart(); nChar < rAttr.GetEnd(); ++nChar)
                     {
                         sal_Unicode cOld = rC.GetText().GetChar( nChar );
                         char cConv = rtl::OUStringToOString(rtl::OUString(ConvertFontToSubsFontChar(hConv, cOld)), RTL_TEXTENCODING_SYMBOL).toChar();
@@ -1109,7 +1114,12 @@ void BinTextObject::StoreData( SvStream& rOStream ) const
         {
             for ( sal_uInt16 nChar = 0; nChar < rC.GetText().Len(); nChar++ )
             {
-                if ( !rC.GetAttribs().FindAttrib( EE_CHAR_FONTINFO, nChar ) )
+                const ContentInfo::XEditAttributesType& rAttribs = rC.aAttribs;
+                ContentInfo::XEditAttributesType::const_iterator it =
+                    std::find_if(rAttribs.begin(), rAttribs.end(),
+                                 FindAttribByChar(EE_CHAR_FONTINFO, nChar));
+
+                if (it == rAttribs.end())
                 {
                     sal_Unicode cOld = rC.GetText().GetChar( nChar );
                     char cConv = rtl::OUStringToOString(rtl::OUString(ConvertFontToSubsFontChar(hConv, cOld)), RTL_TEXTENCODING_SYMBOL).toChar();
@@ -1135,20 +1145,20 @@ void BinTextObject::StoreData( SvStream& rOStream ) const
         rC.GetParaAttribs().Store( rOStream );
 
         // The number of attributes ...
-        sal_uInt16 nAttribs = rC.GetAttribs().Count();
-        rOStream << nAttribs;
+        size_t nAttribs = rC.aAttribs.size();
+        rOStream << static_cast<sal_uInt16>(nAttribs);
 
         // And the individual attributes
         // Items as Surregate => always 8 bytes per Attribute
         // Which = 2; Surregat = 2; Start = 2; End = 2;
-        for ( sal_uInt16 nAttr = 0; nAttr < nAttribs; nAttr++ )
+        for (size_t nAttr = 0; nAttr < nAttribs; ++nAttr)
         {
-            XEditAttribute* pX = rC.GetAttribs().GetObject( nAttr );
+            const XEditAttribute& rX = rC.aAttribs[nAttr];
 
-            rOStream << pX->GetItem()->Which();
-            GetPool()->StoreSurrogate( rOStream, pX->GetItem() );
-            rOStream << pX->GetStart();
-            rOStream << pX->GetEnd();
+            rOStream << rX.GetItem()->Which();
+            GetPool()->StoreSurrogate(rOStream, rX.GetItem());
+            rOStream << rX.GetStart();
+            rOStream << rX.GetEnd();
         }
     }
 
@@ -1235,14 +1245,15 @@ void BinTextObject::CreateData( SvStream& rIStream )
         pC->GetParaAttribs().Load( rIStream );
 
         // The number of attributes ...
-        sal_uInt16 nAttribs;
-        rIStream >> nAttribs;
+        sal_uInt16 nTmp16;
+        rIStream >> nTmp16;
+        size_t nAttribs = nTmp16;
 
         // And the individual attributes
         // Items as Surregate => always 8 bytes per Attributes
         // Which = 2; Surregat = 2; Start = 2; End = 2;
-        sal_uInt16 nAttr;
-        for ( nAttr = 0; nAttr < nAttribs; nAttr++ )
+        size_t nAttr;
+        for (nAttr = 0; nAttr < nAttribs; ++nAttr)
         {
             sal_uInt16 _nWhich, nStart, nEnd;
             const SfxPoolItem* pItem;
@@ -1264,7 +1275,7 @@ void BinTextObject::CreateData( SvStream& rIStream )
                 else
                 {
                     XEditAttribute* pAttr = new XEditAttribute( *pItem, nStart, nEnd );
-                    pC->GetAttribs().Insert( pAttr, pC->GetAttribs().Count() );
+                    pC->aAttribs.push_back(pAttr);
 
                     if ( ( _nWhich >= EE_FEATURE_START ) && ( _nWhich <= EE_FEATURE_END ) )
                     {
@@ -1291,20 +1302,20 @@ void BinTextObject::CreateData( SvStream& rIStream )
             }
         }
 
-        for ( nAttr = pC->GetAttribs().Count(); nAttr; )
+        for (nAttr = pC->aAttribs.size(); nAttr; )
         {
-            XEditAttribute* pAttr = pC->GetAttribs().GetObject( --nAttr );
-            if ( pAttr->GetItem()->Which() == EE_CHAR_FONTINFO )
+            const XEditAttribute& rAttr = pC->aAttribs[--nAttr];
+            if ( rAttr.GetItem()->Which() == EE_CHAR_FONTINFO )
             {
-                const SvxFontItem& rFontItem = (const SvxFontItem&)*pAttr->GetItem();
+                const SvxFontItem& rFontItem = (const SvxFontItem&)*rAttr.GetItem();
                 if ( ( !bSymbolPara && ( rFontItem.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) )
                       || ( bSymbolPara && ( rFontItem.GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) )
                 {
                     // Not correctly converted
-                    rtl::OString aPart(aByteString.copy(pAttr->GetStart(), pAttr->GetEnd()-pAttr->GetStart()));
+                    rtl::OString aPart(aByteString.copy(rAttr.GetStart(), rAttr.GetEnd()-rAttr.GetStart()));
                     rtl::OUString aNew(rtl::OStringToOUString(aPart, rFontItem.GetCharSet()));
-                    pC->GetText().Erase( pAttr->GetStart(), pAttr->GetEnd()-pAttr->GetStart() );
-                    pC->GetText().Insert( aNew, pAttr->GetStart() );
+                    pC->GetText().Erase( rAttr.GetStart(), rAttr.GetEnd()-rAttr.GetStart() );
+                    pC->GetText().Insert( aNew, rAttr.GetStart() );
                 }
 
                 // Convert StarMath and StarBats to StarSymbol
@@ -1314,10 +1325,12 @@ void BinTextObject::CreateData( SvStream& rIStream )
                     SvxFontItem aNewFontItem( rFontItem );
                     aNewFontItem.SetFamilyName( GetFontToSubsFontName( hConv ) );
 
-                    pC->GetAttribs().Remove( nAttr );
-                    XEditAttribute* pNewAttr = CreateAttrib( aNewFontItem, pAttr->GetStart(), pAttr->GetEnd() );
-                    pC->GetAttribs().Insert( pNewAttr, nAttr );
-                    DestroyAttrib( pAttr );
+                    // Replace the existing attribute with a new one.
+                    XEditAttribute* pNewAttr = CreateAttrib(aNewFontItem, rAttr.GetStart(), rAttr.GetEnd());
+
+                    pPool->Remove(*rAttr.GetItem());
+                    pC->aAttribs.erase(pC->aAttribs.begin()+nAttr);
+                    pC->aAttribs.insert(pC->aAttribs.begin()+nAttr, pNewAttr);
 
                     for ( sal_uInt16 nChar = pNewAttr->GetStart(); nChar < pNewAttr->GetEnd(); nChar++ )
                     {
@@ -1348,7 +1361,12 @@ void BinTextObject::CreateData( SvStream& rIStream )
 
                 for ( sal_uInt16 nChar = 0; nChar < pC->GetText().Len(); nChar++ )
                 {
-                    if ( !pC->GetAttribs().FindAttrib( EE_CHAR_FONTINFO, nChar ) )
+                    const ContentInfo::XEditAttributesType& rAttribs = pC->aAttribs;
+                    ContentInfo::XEditAttributesType::const_iterator it =
+                        std::find_if(rAttribs.begin(), rAttribs.end(),
+                                     FindAttribByChar(EE_CHAR_FONTINFO, nChar));
+
+                    if (it == rAttribs.end())
                     {
                         sal_Unicode cOld = pC->GetText().GetChar( nChar );
                         DBG_ASSERT( cOld >= 0xF000, "cOld not converted?!" );
@@ -1550,7 +1568,7 @@ void BinTextObject::CreateData300( SvStream& rIStream )
             if ( pItem )
             {
                 XEditAttribute* pAttr = new XEditAttribute( *pItem, nStart, nEnd );
-                pC->GetAttribs().Insert( pAttr, pC->GetAttribs().Count() );
+                pC->aAttribs.push_back(pAttr);
             }
         }
     }
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index ea633fa..ad611e6 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -34,14 +34,12 @@
 
 #include <unotools/fontcvt.hxx>
 
+#include <boost/ptr_container/ptr_vector.hpp>
 
 class SfxStyleSheetPool;
 
 class XEditAttribute
 {
-    friend class ContentInfo;   // for destructor
-    friend class BinTextObject; // for destructor
-
 private:
     const SfxPoolItem*  pItem;
     sal_uInt16              nStart;
@@ -50,10 +48,9 @@ private:
                         XEditAttribute();
                         XEditAttribute( const XEditAttribute& rCopyFrom );
 
-                        ~XEditAttribute();
-
 public:
-                        XEditAttribute( const SfxPoolItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
+    XEditAttribute( const SfxPoolItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
+    ~XEditAttribute();
 
     const SfxPoolItem*  GetItem() const             { return pItem; }
 
@@ -65,16 +62,17 @@ public:
 
     sal_uInt16              GetLen() const              { return nEnd-nStart; }
 
-    bool                    IsFeature()
+    bool IsFeature() const;
+
+    inline bool operator==( const XEditAttribute& rCompare ) const;
+
+    bool operator!= (const XEditAttribute& r) const
     {
-        sal_uInt16 nWhich = pItem->Which();
-        return  ((nWhich >= EE_FEATURE_START) && (nWhich <=  EE_FEATURE_END));
+        return !operator==(r);
     }
-
-    inline bool         operator==( const XEditAttribute& rCompare );
 };
 
-inline bool XEditAttribute::operator==( const XEditAttribute& rCompare )
+inline bool XEditAttribute::operator==( const XEditAttribute& rCompare ) const
 {
     return  (nStart == rCompare.nStart) &&
             (nEnd == rCompare.nEnd) &&
@@ -83,15 +81,6 @@ inline bool XEditAttribute::operator==( const XEditAttribute& rCompare )
             (*pItem == *rCompare.pItem));
 }
 
-typedef XEditAttribute* XEditAttributePtr;
-SV_DECL_PTRARR( XEditAttributeListImpl, XEditAttributePtr, 0 )
-
-class XEditAttributeList : public XEditAttributeListImpl
-{
-public:
-    XEditAttribute* FindAttrib( sal_uInt16 nWhich, sal_uInt16 nChar ) const;
-};
-
 struct XParaPortion
 {
     long                nHeight;
@@ -135,11 +124,14 @@ public:
 class ContentInfo
 {
     friend class BinTextObject;
+public:
+    typedef boost::ptr_vector<XEditAttribute> XEditAttributesType;
 
 private:
     String              aText;
     String              aStyle;
-    XEditAttributeList  aAttribs;
+
+    XEditAttributesType aAttribs;
     SfxStyleFamily      eFamily;
     SfxItemSet          aParaAttribs;
     WrongList*          pWrongs;
@@ -150,15 +142,16 @@ private:
 public:
                         ~ContentInfo();
 
+    const XEditAttributesType& GetAttribs() const { return aAttribs; }
+    XEditAttributesType& GetAttribs() { return aAttribs; }
+
     const String&       GetText()           const   { return aText; }
     const String&       GetStyle()          const   { return aStyle; }
-    const XEditAttributeList& GetAttribs()  const   { return aAttribs; }
     const SfxItemSet&   GetParaAttribs()    const   { return aParaAttribs; }
     SfxStyleFamily      GetFamily()         const   { return eFamily; }
 
     String&             GetText()           { return aText; }
     String&             GetStyle()          { return aStyle; }
-    XEditAttributeList& GetAttribs()        { return aAttribs; }
     SfxItemSet&         GetParaAttribs()    { return aParaAttribs; }
     SfxStyleFamily&     GetFamily()         { return eFamily; }
 
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index f2373fa..d20958f 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1118,7 +1118,7 @@ EditTextObject* ImpEditEngine::CreateBinTextObject( EditSelection aSel, SfxItemP
                 if ( !pX->GetLen() && !bEmptyPara )
                     pTxtObj->DestroyAttrib( pX );
                 else
-                    pC->GetAttribs().Insert( pX, pC->GetAttribs().Count() );
+                    pC->GetAttribs().push_back(pX);
             }
             nAttr++;
             pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr );
@@ -1256,31 +1256,31 @@ EditSelection ImpEditEngine::InsertBinTextObject( BinTextObject& rTextObject, Ed
 
         // Character attributes ...
         sal_Bool bAllreadyHasAttribs = aPaM.GetNode()->GetCharAttribs().Count() ? sal_True : sal_False;
-        sal_uInt16 nNewAttribs = pC->GetAttribs().Count();
+        size_t nNewAttribs = pC->GetAttribs().size();
         if ( nNewAttribs )
         {
             sal_Bool bUpdateFields = sal_False;
-            for ( sal_uInt16 nAttr = 0; nAttr < nNewAttribs; nAttr++ )
+            for (size_t nAttr = 0; nAttr < nNewAttribs; ++nAttr)
             {
-                XEditAttribute* pX = pC->GetAttribs().GetObject( nAttr );
+                const XEditAttribute& rX = pC->GetAttribs()[nAttr];
                 // Can happen when paragraphs > 16K, it is simply wrapped.
-                if ( pX->GetEnd() <= aPaM.GetNode()->Len() )
+                if ( rX.GetEnd() <= aPaM.GetNode()->Len() )
                 {
-                    if ( !bAllreadyHasAttribs || pX->IsFeature() )
+                    if ( !bAllreadyHasAttribs || rX.IsFeature() )
                     {
                         // Normal attributes then go faster ...
                         // Features shall not be inserted through
                         // EditDoc:: InsertAttrib, using FastInsertText they are
                         // already in the flow
-                        DBG_ASSERT( pX->GetEnd() <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribute too large!" );
+                        DBG_ASSERT( rX.GetEnd() <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribute too large!" );
                         EditCharAttrib* pAttr;
                         if ( !bConvertItems )
-                            pAttr = MakeCharAttrib( aEditDoc.GetItemPool(), *(pX->GetItem()), pX->GetStart()+nStartPos, pX->GetEnd()+nStartPos );
+                            pAttr = MakeCharAttrib( aEditDoc.GetItemPool(), *(rX.GetItem()), rX.GetStart()+nStartPos, rX.GetEnd()+nStartPos );
                         else
                         {
-                            SfxPoolItem* pNew = pX->GetItem()->Clone();
+                            SfxPoolItem* pNew = rX.GetItem()->Clone();
                             ConvertItem( *pNew, eSourceUnit, eDestUnit );
-                            pAttr = MakeCharAttrib( aEditDoc.GetItemPool(), *pNew, pX->GetStart()+nStartPos, pX->GetEnd()+nStartPos );
+                            pAttr = MakeCharAttrib( aEditDoc.GetItemPool(), *pNew, rX.GetStart()+nStartPos, rX.GetEnd()+nStartPos );
                             delete pNew;
                         }
                         DBG_ASSERT( pAttr->GetEnd() <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribute does not fit! (1)" );
@@ -1290,9 +1290,9 @@ EditSelection ImpEditEngine::InsertBinTextObject( BinTextObject& rTextObject, Ed
                     }
                     else
                     {
-                        DBG_ASSERT( pX->GetEnd()+nStartPos <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribute does not fit! (2)" );
+                        DBG_ASSERT( rX.GetEnd()+nStartPos <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribute does not fit! (2)" );
                         // Tabs and other Features can not be inserted through InsertAttrib:
-                        aEditDoc.InsertAttrib( aPaM.GetNode(), pX->GetStart()+nStartPos, pX->GetEnd()+nStartPos, *pX->GetItem() );
+                        aEditDoc.InsertAttrib( aPaM.GetNode(), rX.GetStart()+nStartPos, rX.GetEnd()+nStartPos, *rX.GetItem() );
                     }
                 }
             }
commit 2cf292d9a7ee3667a35350fd949b0cbf4024a8b3
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue May 1 17:09:14 2012 -0400

    Have the table field item store sheet ID.
    
    I forgot to commit this change...
    
    Change-Id: Ifcdbb2b16cf31b180393ea9b4188171c6cfe9963

diff --git a/editeng/inc/editeng/flditem.hxx b/editeng/inc/editeng/flditem.hxx
index 4b85be9..933f3e2 100644
--- a/editeng/inc/editeng/flditem.hxx
+++ b/editeng/inc/editeng/flditem.hxx
@@ -237,9 +237,14 @@ public:
 
 class EDITENG_DLLPUBLIC SvxTableField : public SvxFieldData
 {
+    int mnTab;
 public:
     SV_DECL_PERSIST1( SvxTableField, SvxFieldData, SVX_TABLEFIELD )
     SvxTableField();
+    SvxTableField(int nTab);
+
+    void SetTab(int nTab);
+    int GetTab() const;
 
     virtual SvxFieldData*   Clone() const;
     virtual int             operator==( const SvxFieldData& ) const;
diff --git a/editeng/source/items/flditem.cxx b/editeng/source/items/flditem.cxx
index fb16479..5b5361d 100644
--- a/editeng/source/items/flditem.cxx
+++ b/editeng/source/items/flditem.cxx
@@ -535,16 +535,31 @@ void SvxFileField::Save( SvPersistStream & /*rStm*/ )
 
 SV_IMPL_PERSIST1( SvxTableField, SvxFieldData );
 
-SvxTableField::SvxTableField() {}
+SvxTableField::SvxTableField() : mnTab(0) {}
+
+SvxTableField::SvxTableField(int nTab) : mnTab(nTab) {}
+
+void SvxTableField::SetTab(int nTab)
+{
+    mnTab = nTab;
+}
+
+int SvxTableField::GetTab() const
+{
+    return mnTab;
+}
 
 SvxFieldData* SvxTableField::Clone() const
 {
-    return new SvxTableField;   // empty
+    return new SvxTableField(mnTab);
 }
 
 int SvxTableField::operator==( const SvxFieldData& rCmp ) const
 {
-    return ( rCmp.Type() == TYPE(SvxTableField) );
+    if (rCmp.Type() != TYPE(SvxTableField))
+        return false;
+
+    return mnTab == static_cast<const SvxTableField&>(rCmp).mnTab;
 }
 
 void SvxTableField::Load( SvPersistStream & /*rStm*/ )
commit aabbb0a4d15671f00ced2d9d21395c1574d63cd0
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue May 1 16:53:10 2012 -0400

    Properly handle properties of sheet fields.
    
    Change-Id: I549990186c23e7e560f6f584c4ad76dbbc4cc393

diff --git a/sc/inc/fielduno.hxx b/sc/inc/fielduno.hxx
index bf5f626..6874c0b 100644
--- a/sc/inc/fielduno.hxx
+++ b/sc/inc/fielduno.hxx
@@ -225,7 +225,6 @@ private:
     boost::scoped_ptr<SvxFieldData> mpData;
     com::sun::star::uno::Reference<com::sun::star::text::XTextRange> mpContent;
 
-    sal_Int32 mnTab;
     bool mbIsDate:1;
 
 private:
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index 6ef6625..4b78a7f 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -699,7 +699,7 @@ SvxFieldData* ScEditFieldObj::getData()
                 mpData.reset(new SvxPagesField);
             break;
             case Sheet:
-                mpData.reset(new SvxTableField(mnTab));
+                mpData.reset(new SvxTableField);
             break;
             case Time:
                 mpData.reset(new SvxTimeField);
@@ -923,10 +923,51 @@ void ScEditFieldObj::setPropertyValueExtTime(const rtl::OUString& rName, const u
 
 void ScEditFieldObj::setPropertyValueSheet(const rtl::OUString& rName, const uno::Any& rVal)
 {
+    if (mpEditSource)
+    {
+        // Edit engine instance already exists for this field item.  Use it.
+        ScEditEngineDefaulter* pEditEngine = mpEditSource->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_TABLEFIELD)
+            // Make sure this is indeed a URL field.
+            return;
+
+        SvxTableField* p = static_cast<SvxTableField*>(pField);
+
+        if (rName == "SheetPosition")
+        {
+            sal_Int32 nTab = rVal.get<sal_Int32>();
+            p->SetTab(nTab);
+        }
+        else
+            throw beans::UnknownPropertyException();
+
+        pEditEngine->QuickInsertField(SvxFieldItem(*pField, EE_FEATURE_FIELD), aSelection);
+        mpEditSource->UpdateData();
+        return;
+    }
+
+    // Edit engine instance not yet present.  Store the item data for later use.
+    SvxFieldData* pData = getData();
+    if (!pData)
+        throw uno::RuntimeException();
+
+    SvxTableField* p = static_cast<SvxTableField*>(pData);
     if (rName == "SheetPosition")
     {
-        mnTab = rVal.get<sal_Int32>();
+        sal_Int32 nTab = rVal.get<sal_Int32>();
+        p->SetTab(nTab);
     }
+    else
+        throw beans::UnknownPropertyException();
+
 }
 
 ScEditFieldObj::ScEditFieldObj(
@@ -936,7 +977,7 @@ ScEditFieldObj::ScEditFieldObj(
     pPropSet(NULL),
     mpEditSource(pEditSrc),
     aSelection(rSel),
-    meType(eType), mpData(NULL), mpContent(rContent), mnTab(0), mbIsDate(false)
+    meType(eType), mpData(NULL), mpContent(rContent), mbIsDate(false)
 {
     switch (meType)
     {
commit c92f5f600d65299c135ca9db2ec7e6d13df1152d
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue May 1 16:33:58 2012 -0400

    Support sheet name field in cells.
    
    Change-Id: I7883960c482de0637e0bfaffc96f23a0d43cc96d

diff --git a/sc/inc/fielduno.hxx b/sc/inc/fielduno.hxx
index f238cf1..bf5f626 100644
--- a/sc/inc/fielduno.hxx
+++ b/sc/inc/fielduno.hxx
@@ -225,6 +225,7 @@ private:
     boost::scoped_ptr<SvxFieldData> mpData;
     com::sun::star::uno::Reference<com::sun::star::text::XTextRange> mpContent;
 
+    sal_Int32 mnTab;
     bool mbIsDate:1;
 
 private:
@@ -239,6 +240,7 @@ private:
     com::sun::star::uno::Any getPropertyValueFile(const rtl::OUString& rName);
 
     void setPropertyValueExtTime(const rtl::OUString& rName, const com::sun::star::uno::Any& rVal);
+    void setPropertyValueSheet(const rtl::OUString& rName, const com::sun::star::uno::Any& rVal);
 
 public:
     static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
@@ -249,6 +251,7 @@ public:
         ScEditSource* pEditSrc, FieldType eType, const ESelection& rSel);
     virtual ~ScEditFieldObj();
 
+    FieldType GetFieldType() const;
     void DeleteField();
     bool IsInserted() const;
     SvxFieldItem CreateFieldItem();
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index 19134d7..65d21c3 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -758,6 +758,17 @@ String ScFieldEditEngine::CalcFieldValue( const SvxFieldItem& rField,
             aRet = ScGlobal::pLocaleData->getDate(aDate);
         }
         break;
+        case SVX_TABLEFIELD:
+        {
+            const SvxTableField* pField = static_cast<const SvxTableField*>(pFieldData);
+            SCTAB nTab = pField->GetTab();
+            rtl::OUString aName;
+            if (mpDoc->GetName(nTab, aName))
+                aRet = aName;
+            else
+                aRet = "?";
+        }
+        break;
         default:
             aRet = "?";
     }
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 9f874e3..db2d9b4 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -6434,8 +6434,10 @@ void SAL_CALL ScCellObj::insertTextContent( const uno::Reference<text::XTextRang
                 aSelection.nStartPos  = aSelection.nEndPos;
             }
 
-            SvxFieldItem aItem(pCellField->CreateFieldItem());
+            if (pCellField->GetFieldType() == ScEditFieldObj::Sheet)
+                pCellField->setPropertyValue("SheetPosition", uno::makeAny<sal_Int32>(aCellPos.Tab()));
 
+            SvxFieldItem aItem = pCellField->CreateFieldItem();
             SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder();
             pForwarder->QuickInsertField( aItem, aSelection );
             pEditSource->UpdateData();
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index 693c2c4..6ef6625 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -699,7 +699,7 @@ SvxFieldData* ScEditFieldObj::getData()
                 mpData.reset(new SvxPagesField);
             break;
             case Sheet:
-                mpData.reset(new SvxTableField);
+                mpData.reset(new SvxTableField(mnTab));
             break;
             case Time:
                 mpData.reset(new SvxTimeField);
@@ -921,6 +921,14 @@ void ScEditFieldObj::setPropertyValueExtTime(const rtl::OUString& rName, const u
     }
 }
 
+void ScEditFieldObj::setPropertyValueSheet(const rtl::OUString& rName, const uno::Any& rVal)
+{
+    if (rName == "SheetPosition")
+    {
+        mnTab = rVal.get<sal_Int32>();
+    }
+}
+
 ScEditFieldObj::ScEditFieldObj(
     const uno::Reference<text::XTextRange>& rContent,
     ScEditSource* pEditSrc, FieldType eType, const ESelection& rSel) :
@@ -928,7 +936,7 @@ ScEditFieldObj::ScEditFieldObj(
     pPropSet(NULL),
     mpEditSource(pEditSrc),
     aSelection(rSel),
-    meType(eType), mpData(NULL), mpContent(rContent), mbIsDate(false)
+    meType(eType), mpData(NULL), mpContent(rContent), mnTab(0), mbIsDate(false)
 {
     switch (meType)
     {
@@ -970,6 +978,11 @@ SvxFieldItem ScEditFieldObj::CreateFieldItem()
     return SvxFieldItem(*getData(), EE_FEATURE_FIELD);
 }
 
+ScEditFieldObj::FieldType ScEditFieldObj::GetFieldType() const
+{
+    return meType;
+}
+
 void ScEditFieldObj::DeleteField()
 {
     if (mpEditSource)
@@ -1100,6 +1113,9 @@ void SAL_CALL ScEditFieldObj::setPropertyValue(
         case ExtTime:
             setPropertyValueExtTime(aPropertyName, aValue);
         break;
+        case Sheet:
+            setPropertyValueSheet(aPropertyName, aValue);
+        break;
         default:
             throw beans::UnknownPropertyException();
     }
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index a181403..cf47977 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -616,7 +616,7 @@ void ScEditShell::Execute( SfxRequest& rReq )
         break;
         case SID_INSERT_FIELD_TEST:
         {
-            SvxDateField aField;
+            SvxTableField aField(pViewData->GetTabNo());
             SvxFieldItem aItem(aField, EE_FEATURE_FIELD);
             pTableView->InsertField(aItem);
         }
commit d6d4d00114e267142145f0d6bb80a66dd4bca990
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue May 1 14:27:21 2012 -0400

    Support date field in cells.
    
    Change-Id: Iff20eb16bb4a7f700b0a533bc745b92fdce8ac0f

diff --git a/sc/inc/fielduno.hxx b/sc/inc/fielduno.hxx
index 8f83eeb..f238cf1 100644
--- a/sc/inc/fielduno.hxx
+++ b/sc/inc/fielduno.hxx
@@ -225,6 +225,8 @@ private:
     boost::scoped_ptr<SvxFieldData> mpData;
     com::sun::star::uno::Reference<com::sun::star::text::XTextRange> mpContent;
 
+    bool mbIsDate:1;
+
 private:
     ScEditFieldObj(); // disabled
 
diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx
index 44f1aea..5ba1a3b 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -329,6 +329,11 @@
 #define SC_UNONAME_TARGET           "TargetFrame"
 #define SC_UNONAME_URL              "URL"
 
+// date time field
+#define SC_UNONAME_ISDATE           "IsDate"
+#define SC_UNONAME_ISFIXED          "IsFixed"
+#define SC_UNONAME_DATETIME         "DateTime"
+
 //  conditional format
 #define SC_UNONAME_OPERATOR         "Operator"
 #define SC_UNONAME_FORMULA1         "Formula1"
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index af953e5..19134d7 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -752,6 +752,12 @@ String ScFieldEditEngine::CalcFieldValue( const SvxFieldItem& rField,
                 aRet = pField->GetFormatted(*mpDoc->GetFormatTable(), ScGlobal::eLnge);
         }
         break;
+        case SVX_DATEFIELD:
+        {
+            Date aDate(Date::SYSTEM);
+            aRet = ScGlobal::pLocaleData->getDate(aDate);
+        }
+        break;
         default:
             aRet = "?";
     }
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index 9a04766..693c2c4 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -59,6 +59,20 @@ namespace {
 
 //  alles ohne Which-ID, Map nur fuer PropertySetInfo
 
+const SfxItemPropertySet* getExtTimePropertySet()
+{
+    static SfxItemPropertyMapEntry aMapContent[] =
+    {
+        { MAP_CHAR_LEN(SC_UNONAME_DATETIME), 0, &getCppuType((const util::DateTime*)0), 0, 0 },
+        { MAP_CHAR_LEN(SC_UNONAME_ISFIXED),  0, &getBooleanCppuType(),                  0, 0 },
+        { MAP_CHAR_LEN(SC_UNONAME_ISDATE),   0, &getBooleanCppuType(),                  0, 0 },
+        { MAP_CHAR_LEN(SC_UNONAME_NUMFMT),   0, &getCppuType((const sal_Int32*)0),      0, 0 },
+        {0,0,0,0,0,0}
+    };
+    static SfxItemPropertySet aMap(aMapContent);
+    return &aMap;
+}
+
 const SfxItemPropertySet* lcl_GetURLPropertySet()
 {
     static SfxItemPropertyMapEntry aURLPropertyMap_Impl[] =
@@ -691,7 +705,12 @@ SvxFieldData* ScEditFieldObj::getData()
                 mpData.reset(new SvxTimeField);
             break;
             case ExtTime:
-                mpData.reset(new SvxExtTimeField);
+            {
+                if (mbIsDate)
+                    mpData.reset(new SvxDateField);
+                else
+                    mpData.reset(new SvxExtTimeField);
+            }
             break;
             case Title:
                 mpData.reset(new SvxFileField);
@@ -898,8 +917,7 @@ void ScEditFieldObj::setPropertyValueExtTime(const rtl::OUString& rName, const u
 {
     if (rName == "IsDate")
     {
-        // TODO: Find out what to do with this.
-        sal_Bool b = rVal.get<sal_Bool>();
+        mbIsDate = rVal.get<sal_Bool>();
     }
 }
 
@@ -910,7 +928,7 @@ ScEditFieldObj::ScEditFieldObj(
     pPropSet(NULL),
     mpEditSource(pEditSrc),
     aSelection(rSel),
-    meType(eType), mpData(NULL), mpContent(rContent)
+    meType(eType), mpData(NULL), mpContent(rContent), mbIsDate(false)
 {
     switch (meType)
     {
@@ -920,6 +938,9 @@ ScEditFieldObj::ScEditFieldObj(
         case URL:
             pPropSet = lcl_GetURLPropertySet();
         break;
+        case ExtTime:
+            pPropSet = getExtTimePropertySet();
+        break;
         default:
             pPropSet = lcl_GetHeaderFieldPropertySet();
     }
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 197b004..a181403 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -616,7 +616,7 @@ void ScEditShell::Execute( SfxRequest& rReq )
         break;
         case SID_INSERT_FIELD_TEST:
         {
-            SvxExtTimeField aField;
+            SvxDateField aField;
             SvxFieldItem aItem(aField, EE_FEATURE_FIELD);
             pTableView->InsertField(aItem);
         }
commit 9af4b611190c14b04460e2554735725b4231b685
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue May 1 14:15:31 2012 -0400

    Removed unused methods.
    
    Change-Id: Id9c841274da906032f08abdea93850d3b6a14ade

diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx
index 0a24505..b4a2c06 100644
--- a/sc/inc/editutil.hxx
+++ b/sc/inc/editutil.hxx
@@ -229,14 +229,6 @@ public:
     ScHeaderEditEngine( SfxItemPool* pEnginePool, sal_Bool bDeleteEnginePool = false );
     virtual String CalcFieldValue( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos, Color*& rTxtColor, Color*& rFldColor );
 
-    void SetTitle(const String& rNew)               { aData.aTitle = rNew; }
-    void SetLongDocName(const String& rNew)         { aData.aLongDocName = rNew; }
-    void SetShortDocName(const String& rNew)        { aData.aShortDocName = rNew; }
-    void SetTabName(const String& rNew)             { aData.aTabName = rNew; }
-    void SetDate(const Date& rNew)                  { aData.aDate = rNew; }
-    void SetTime(const Time& rNew)                  { aData.aTime = rNew; }
-    void SetPageNo(long nNew)                       { aData.nPageNo = nNew; }
-    void SetTotalPages(long nNew)                   { aData.nTotalPages = nNew; }
     void SetNumType(SvxNumType eNew)                { aData.eNumType = eNew; }
     void SetData(const ScHeaderFieldData& rNew)     { aData = rNew; }
 };
commit a5c8e9a8cec4202ddc7bac60dd38c5782fa3b2cc
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue May 1 11:28:31 2012 -0400

    Properly import DateTimeField.
    
    Change-Id: Ib56655b3306f9be035e1f59d233e0a118f247e37

diff --git a/sc/inc/fielduno.hxx b/sc/inc/fielduno.hxx
index 4f3d29b..8f83eeb 100644
--- a/sc/inc/fielduno.hxx
+++ b/sc/inc/fielduno.hxx
@@ -214,7 +214,7 @@ class ScEditFieldObj : public cppu::WeakImplHelper4<
                         private boost::noncopyable
 {
 public:
-    enum FieldType { URL = 0, Page, Pages, Date, Time, Title, File, Sheet };
+    enum FieldType { URL = 0, Page, Pages, Date, Time, ExtTime, Title, File, Sheet };
 
 private:
     const SfxItemPropertySet* pPropSet;
@@ -236,6 +236,8 @@ 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);
+
 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/inc/servuno.hxx b/sc/inc/servuno.hxx
index 9adca2a..04abac7 100644
--- a/sc/inc/servuno.hxx
+++ b/sc/inc/servuno.hxx
@@ -98,9 +98,11 @@ class ScDocShell;
 #define SC_SERVICE_VBACODENAMEPROVIDER   41
 #define SC_SERVICE_VBAGLOBALS   42
 
-#define SC_SERVICE_COUNT        43
+
+#define SC_SERVICE_COUNT        44
 #define SC_SERVICE_INVALID      USHRT_MAX
 
+#define SC_SERVICE_EXT_TIMEFIELD 43
 
 class ScServiceProvider
 {
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index 6bef71a..9a04766 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -140,13 +140,14 @@ ScEditFieldObj::FieldType getFieldType(sal_uInt16 nSvxType)
             return ScEditFieldObj::Pages;
         case SVX_TIMEFIELD:
             return ScEditFieldObj::Time;
+        case SVX_EXT_TIMEFIELD:
+            return ScEditFieldObj::ExtTime;
         case SVX_FILEFIELD:
             return ScEditFieldObj::Title;
         case SVX_TABLEFIELD:
             return ScEditFieldObj::Sheet;
         case SVX_EXT_FILEFIELD:
             return ScEditFieldObj::File;
-        case SVX_EXT_TIMEFIELD:
         case SVX_AUTHORFIELD:
         case SVX_HEADERFIELD:
         case SVX_FOOTERFIELD:
@@ -689,6 +690,9 @@ SvxFieldData* ScEditFieldObj::getData()
             case Time:
                 mpData.reset(new SvxTimeField);
             break;
+            case ExtTime:
+                mpData.reset(new SvxExtTimeField);
+            break;
             case Title:
                 mpData.reset(new SvxFileField);
             break;
@@ -890,6 +894,15 @@ uno::Any ScEditFieldObj::getPropertyValueFile(const rtl::OUString& rName)
     return aRet;
 }
 
+void ScEditFieldObj::setPropertyValueExtTime(const rtl::OUString& rName, const uno::Any& rVal)
+{
+    if (rName == "IsDate")
+    {
+        // TODO: Find out what to do with this.
+        sal_Bool b = rVal.get<sal_Bool>();
+    }
+}
+
 ScEditFieldObj::ScEditFieldObj(
     const uno::Reference<text::XTextRange>& rContent,
     ScEditSource* pEditSrc, FieldType eType, const ESelection& rSel) :
@@ -1063,6 +1076,9 @@ void SAL_CALL ScEditFieldObj::setPropertyValue(
         case File:
             setPropertyValueFile(aPropertyName, aValue);
         break;
+        case ExtTime:
+            setPropertyValueExtTime(aPropertyName, aValue);
+        break;
         default:
             throw beans::UnknownPropertyException();
     }
diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx
index 23047b3..50d3362 100644
--- a/sc/source/ui/unoobj/servuno.cxx
+++ b/sc/source/ui/unoobj/servuno.cxx
@@ -272,6 +272,7 @@ static const ProvNamesId_Type aProvNamesId[] =
     { "com.sun.star.text.TextField.PageCount",          SC_SERVICE_PAGESFIELD },
     { "com.sun.star.text.TextField.Date",               SC_SERVICE_DATEFIELD },
     { "com.sun.star.text.TextField.Time",               SC_SERVICE_TIMEFIELD },
+    { "com.sun.star.text.TextField.DateTime",           SC_SERVICE_EXT_TIMEFIELD },
     { "com.sun.star.text.TextField.DocumentTitle",      SC_SERVICE_TITLEFIELD },
     { "com.sun.star.text.TextField.FileName",           SC_SERVICE_FILEFIELD },
     { "com.sun.star.text.TextField.SheetName",          SC_SERVICE_SHEETFIELD },
@@ -321,6 +322,7 @@ static const ProvNamesId_Type aProvNamesId[] =
     { "com.sun.star.text.textfield.PageCount",          SC_SERVICE_PAGESFIELD },
     { "com.sun.star.text.textfield.Date",               SC_SERVICE_DATEFIELD },
     { "com.sun.star.text.textfield.Time",               SC_SERVICE_TIMEFIELD },
+    { "com.sun.star.text.textfield.DateTime",           SC_SERVICE_EXT_TIMEFIELD },
     { "com.sun.star.text.textfield.DocumentTitle",      SC_SERVICE_TITLEFIELD },
     { "com.sun.star.text.textfield.FileName",           SC_SERVICE_FILEFIELD },
     { "com.sun.star.text.textfield.SheetName",          SC_SERVICE_SHEETFIELD },
@@ -380,6 +382,7 @@ static const sal_Char* aOldNames[SC_SERVICE_COUNT] =
         "",                                         // SC_SERVICE_VBAOBJECTPROVIDER
         "",                                         // SC_SERVICE_VBACODENAMEPROVIDER
         "",                                         // SC_SERVICE_VBAGLOBALS
+        "",                                         // SC_SERVICE_EXT_TIMEFIELD
     };
 
 
@@ -434,6 +437,8 @@ ScEditFieldObj::FieldType getFieldType(sal_uInt16 nOldType)
             return ScEditFieldObj::Date;
         case SC_SERVICE_TIMEFIELD:
             return ScEditFieldObj::Time;
+        case SC_SERVICE_EXT_TIMEFIELD:
+            return ScEditFieldObj::ExtTime;
         case SC_SERVICE_TITLEFIELD:
             return ScEditFieldObj::Title;
         case SC_SERVICE_FILEFIELD:
@@ -464,6 +469,7 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance(
         case SC_SERVICE_PAGESFIELD:
         case SC_SERVICE_DATEFIELD:
         case SC_SERVICE_TIMEFIELD:
+        case SC_SERVICE_EXT_TIMEFIELD:
         case SC_SERVICE_TITLEFIELD:
         case SC_SERVICE_FILEFIELD:
         case SC_SERVICE_SHEETFIELD:
commit 4aeb8aff9e418aef1fde4b2b60333216cc527f13
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Apr 20 00:46:19 2012 -0400

    New menu now inserts current time into cell.

diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx
index 35bb41b..0a24505 100644
--- a/sc/inc/editutil.hxx
+++ b/sc/inc/editutil.hxx
@@ -204,14 +204,15 @@ struct ScHeaderFieldData
 class SC_DLLPUBLIC ScFieldEditEngine : public ScEditEngineDefaulter
 {
 private:
-    sal_Bool    bExecuteURL;
+    ScDocument* mpDoc;
+    bool bExecuteURL;
 
 public:
-    ScFieldEditEngine( SfxItemPool* pEnginePool,
-                        SfxItemPool* pTextObjectPool = NULL,
-                        sal_Bool bDeleteEnginePool = false );
+    ScFieldEditEngine(
+        ScDocument* pDoc, SfxItemPool* pEnginePool, SfxItemPool* pTextObjectPool = NULL,
+        bool bDeleteEnginePool = false);
 
-    void    SetExecuteURL(sal_Bool bSet)    { bExecuteURL = bSet; }
+    void SetExecuteURL(bool bSet)    { bExecuteURL = bSet; }
 
     virtual void    FieldClicked( const SvxFieldItem& rField, sal_uInt16, sal_uInt16 );
     virtual String  CalcFieldValue( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos, Color*& rTxtColor, Color*& rFldColor );
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 393e18e..c28249a 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -962,8 +962,7 @@ void ScColumn::RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow )
             //  auf Attribute testen
             if ( !pEngine )
             {
-                //pEngine = new ScTabEditEngine(pDocument);
-                pEngine = new ScFieldEditEngine( pDocument->GetEditPool() );
+                pEngine = new ScFieldEditEngine(pDocument, pDocument->GetEditPool());
                 //  EE_CNTRL_ONLINESPELLING falls schon Fehler drin sind
                 pEngine->SetControlWord( pEngine->GetControlWord() | EE_CNTRL_ONLINESPELLING );
                 pDocument->ApplyAsianEditSettings( *pEngine );
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index c22d977..8df1096 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -515,7 +515,7 @@ ScFieldEditEngine& ScDocument::GetEditEngine()
 {
     if ( !pEditEngine )
     {
-        pEditEngine = new ScFieldEditEngine( GetEnginePool(), GetEditPool() );
+        pEditEngine = new ScFieldEditEngine(this, GetEnginePool(), GetEditPool());
         pEditEngine->SetUpdateMode( false );
         pEditEngine->EnableUndo( false );
         pEditEngine->SetRefMapMode( MAP_100TH_MM );
@@ -1092,8 +1092,8 @@ ScFieldEditEngine* ScDocument::CreateFieldEditEngine()
     ScFieldEditEngine* pNewEditEngine = NULL;
     if (!pCacheFieldEditEngine)
     {
-        pNewEditEngine = new ScFieldEditEngine( GetEnginePool(),
-            GetEditPool(), false );
+        pNewEditEngine = new ScFieldEditEngine(
+            this, GetEnginePool(), GetEditPool(), false);
     }
     else
     {
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 9e207c7..1d14078 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -1545,7 +1545,7 @@ void ScDocument::TransliterateText( const ScMarkData& rMultiMark, sal_Int32 nTyp
                                                      nType == com::sun::star::i18n::TransliterationModulesExtra::TITLE_CASE ) ) )
                 {
                     if (!pEngine)
-                        pEngine = new ScFieldEditEngine( GetEnginePool(), GetEditPool() );
+                        pEngine = new ScFieldEditEngine(this, GetEnginePool(), GetEditPool());
 
                     // defaults from cell attributes must be set so right language is used
                     const ScPatternAttr* pPattern = GetPattern( nCol, nRow, nTab );
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index b513cb2..af953e5 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -696,11 +696,11 @@ String ScHeaderEditEngine::CalcFieldValue( const SvxFieldItem& rField,
 //
 //------------------------------------------------------------------------
 
-ScFieldEditEngine::ScFieldEditEngine( SfxItemPool* pEnginePoolP,
-            SfxItemPool* pTextObjectPool, sal_Bool bDeleteEnginePoolP )
-        :
+ScFieldEditEngine::ScFieldEditEngine(
+    ScDocument* pDoc, SfxItemPool* pEnginePoolP,
+    SfxItemPool* pTextObjectPool, bool bDeleteEnginePoolP) :
         ScEditEngineDefaulter( pEnginePoolP, bDeleteEnginePoolP ),
-        bExecuteURL( sal_True )
+        mpDoc(pDoc), bExecuteURL(true)
 {
     if ( pTextObjectPool )
         SetEditTextObjectPool( pTextObjectPool );
@@ -713,41 +713,51 @@ String ScFieldEditEngine::CalcFieldValue( const SvxFieldItem& rField,
                                     sal_uInt16 /* nPara */, sal_uInt16 /* nPos */,
                                     Color*& rTxtColor, Color*& /* rFldColor */ )
 {
-    String aRet;
+    rtl::OUString aRet;
     const SvxFieldData* pFieldData = rField.GetField();
 
-    if ( pFieldData )
-    {
-        TypeId aType = pFieldData->Type();
+    if (!pFieldData)
+        return rtl::OUString(" ");
 
-        if (aType == TYPE(SvxURLField))
+    sal_uInt16 nClsId = pFieldData->GetClassId();
+    switch (nClsId)
+    {
+        case SVX_URLFIELD:
         {
-            String aURL = ((const SvxURLField*)pFieldData)->GetURL();
+            const SvxURLField* pField = static_cast<const SvxURLField*>(pFieldData);
+            rtl::OUString aURL = pField->GetURL();
 
-            switch ( ((const SvxURLField*)pFieldData)->GetFormat() )
+            switch (pField->GetFormat())
             {
                 case SVXURLFORMAT_APPDEFAULT: //!!! einstellbar an App???
                 case SVXURLFORMAT_REPR:
-                    aRet = ((const SvxURLField*)pFieldData)->GetRepresentation();
-                    break;
-
+                    aRet = pField->GetRepresentation();
+                break;
                 case SVXURLFORMAT_URL:
                     aRet = aURL;
-                    break;
+                break;
+                default:
+                    ;
             }
 
             svtools::ColorConfigEntry eEntry =
-                INetURLHistory::GetOrCreate()->QueryUrl( aURL ) ? svtools::LINKSVISITED : svtools::LINKS;
+                INetURLHistory::GetOrCreate()->QueryUrl(String(aURL)) ? svtools::LINKSVISITED : svtools::LINKS;
             rTxtColor = new Color( SC_MOD()->GetColorConfig().GetColorValue(eEntry).nColor );
         }
-        else
+        break;
+        case SVX_EXT_TIMEFIELD:
         {
-            aRet = '?';
+            const SvxExtTimeField* pField = static_cast<const SvxExtTimeField*>(pFieldData);
+            if (mpDoc)
+                aRet = pField->GetFormatted(*mpDoc->GetFormatTable(), ScGlobal::eLnge);
         }
+        break;
+        default:
+            aRet = "?";
     }
 
-    if (!aRet.Len())        // leer ist baeh
-        aRet = ' ';         // Space ist Default der Editengine
+    if (aRet.isEmpty())        // leer ist baeh
+        aRet = " ";         // Space ist Default der Editengine
 
     return aRet;
 }
diff --git a/sc/source/filter/rtf/expbase.cxx b/sc/source/filter/rtf/expbase.cxx
index 0cef302..e19e729 100644
--- a/sc/source/filter/rtf/expbase.cxx
+++ b/sc/source/filter/rtf/expbase.cxx
@@ -98,7 +98,7 @@ sal_Bool ScExportBase::IsEmptyTable( SCTAB nTab ) const
 ScFieldEditEngine& ScExportBase::GetEditEngine() const
 {
     if ( !pEditEngine )
-        ((ScExportBase*)this)->pEditEngine = new ScFieldEditEngine( pDoc->GetEditPool() );
+        ((ScExportBase*)this)->pEditEngine = new ScFieldEditEngine(pDoc, pDoc->GetEditPool());
     return *pEditEngine;
 }
 
diff --git a/sc/source/ui/Accessibility/AccessibleText.cxx b/sc/source/ui/Accessibility/AccessibleText.cxx
index d9a4486..9d55c97 100644
--- a/sc/source/ui/Accessibility/AccessibleText.cxx
+++ b/sc/source/ui/Accessibility/AccessibleText.cxx
@@ -1166,7 +1166,7 @@ SvxTextForwarder* ScAccessibleEditLineTextData::GetTextForwarder()
             {
                 SfxItemPool* pEnginePool = EditEngine::CreatePool();
                 pEnginePool->FreezeIdRanges();
-                mpEditEngine = new ScFieldEditEngine( pEnginePool, NULL, sal_True );
+                mpEditEngine = new ScFieldEditEngine(NULL, pEnginePool, NULL, true);
                 mbEditEngineCreated = sal_True;
                 mpEditEngine->EnableUndo( false );
                 mpEditEngine->SetRefMapMode( MAP_100TH_MM );
@@ -1386,7 +1386,7 @@ SvxTextForwarder* ScAccessiblePreviewHeaderCellTextData::GetTextForwarder()
         {
             SfxItemPool* pEnginePool = EditEngine::CreatePool();
             pEnginePool->FreezeIdRanges();
-            pEditEngine = new ScFieldEditEngine( pEnginePool, NULL, sal_True );
+            pEditEngine = new ScFieldEditEngine(NULL, pEnginePool, NULL, true);
         }
         pEditEngine->EnableUndo( false );
         if (pDocShell)
@@ -1619,7 +1619,7 @@ SvxTextForwarder* ScAccessibleNoteTextData::GetTextForwarder()
         {
             SfxItemPool* pEnginePool = EditEngine::CreatePool();
             pEnginePool->FreezeIdRanges();
-            mpEditEngine = new ScFieldEditEngine( pEnginePool, NULL, sal_True );
+            mpEditEngine = new ScFieldEditEngine(NULL, pEnginePool, NULL, true);
         }
         mpEditEngine->EnableUndo( false );
         if (mpDocSh)
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index f879e78..62bbe1a 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -620,11 +620,11 @@ void ScInputHandler::ImplCreateEditEngine()
     {
         if ( pActiveViewSh )
         {
-            const ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocShell()->GetDocument();
-            pEngine = new ScFieldEditEngine( pDoc->GetEnginePool(), pDoc->GetEditPool() );
+            ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocShell()->GetDocument();
+            pEngine = new ScFieldEditEngine(pDoc, pDoc->GetEnginePool(), pDoc->GetEditPool());
         }
         else
-            pEngine = new ScFieldEditEngine( EditEngine::CreatePool(), NULL, true );
+            pEngine = new ScFieldEditEngine(NULL, EditEngine::CreatePool(), NULL, true);
         pEngine->SetWordDelimiters( ScEditUtil::ModifyDelimiters( pEngine->GetWordDelimiters() ) );
         UpdateRefDevice();      // also sets MapMode
         pEngine->SetPaperSize( Size( 1000000, 1000000 ) );
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 7fa55df..6f7caa6 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1331,11 +1331,11 @@ void ScMultiTextWnd::InitEditEngine()
     if ( pViewSh )
     {
         pDocSh = pViewSh->GetViewData()->GetDocShell();
-        const ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
-        pNew = new ScFieldEditEngine( pDoc->GetEnginePool(), pDoc->GetEditPool() );
+        ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
+        pNew = new ScFieldEditEngine(pDoc, pDoc->GetEnginePool(), pDoc->GetEditPool());
     }
     else
-        pNew = new ScFieldEditEngine( EditEngine::CreatePool(),	NULL, sal_True );
+        pNew = new ScFieldEditEngine(NULL, EditEngine::CreatePool(), NULL, true);
     pNew->SetExecuteURL( false );
     pEditEngine = pNew;
 
@@ -1716,11 +1716,11 @@ void ScTextWnd::StartEditEngine()
         ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
         if ( pViewSh )
         {
-            const ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
-            pNew = new ScFieldEditEngine( pDoc->GetEnginePool(), pDoc->GetEditPool() );
+            ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
+            pNew = new ScFieldEditEngine(pDoc, pDoc->GetEnginePool(), pDoc->GetEditPool());
         }
         else
-            pNew = new ScFieldEditEngine( EditEngine::CreatePool(), NULL, sal_True );
+            pNew = new ScFieldEditEngine(NULL, EditEngine::CreatePool(), NULL, true);
         pNew->SetExecuteURL( false );
         pEditEngine = pNew;
 
@@ -1947,11 +1947,11 @@ void ScTextWnd::MakeDialogEditView()
     ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
     if ( pViewSh )
     {
-        const ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
-        pNew = new ScFieldEditEngine( pDoc->GetEnginePool(), pDoc->GetEditPool() );
+        ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
+        pNew = new ScFieldEditEngine(pDoc, pDoc->GetEnginePool(), pDoc->GetEditPool());
     }
     else
-        pNew = new ScFieldEditEngine( EditEngine::CreatePool(), NULL, sal_True );
+        pNew = new ScFieldEditEngine(NULL, EditEngine::CreatePool(), NULL, true);
     pNew->SetExecuteURL( false );
     pEditEngine = pNew;
 
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index af91076..ba1c783 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -823,7 +823,7 @@ sal_uLong ScDocShell::DBaseExport( const rtl::OUString& rFullFileName, CharSet e
                         bHasMemo, eCharSet );
     // also needed for exception catch
     SCROW nDocRow = 0;
-    ScFieldEditEngine aEditEngine( aDocument.GetEditPool() );
+    ScFieldEditEngine aEditEngine(&aDocument, aDocument.GetEditPool());
     rtl::OUString aString;
     String aTabName;
 
diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx
index b6fd429..afaa7a5 100644
--- a/sc/source/ui/unoobj/textuno.cxx
+++ b/sc/source/ui/unoobj/textuno.cxx
@@ -885,7 +885,7 @@ ScSimpleEditSourceHelper::ScSimpleEditSourceHelper()
     pEnginePool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
     pEnginePool->FreezeIdRanges();
 
-    pEditEngine = new ScFieldEditEngine( pEnginePool, NULL, sal_True );     // TRUE: become owner of pool
+    pEditEngine = new ScFieldEditEngine(NULL, pEnginePool, NULL, true);     // TRUE: become owner of pool
     pForwarder = new SvxEditEngineForwarder( *pEditEngine );
     pOriginalSource = new ScSimpleEditSource( pForwarder );
 }
@@ -985,7 +985,7 @@ SvxTextForwarder* ScCellTextData::GetTextForwarder()
         {
             SfxItemPool* pEnginePool = EditEngine::CreatePool();
             pEnginePool->FreezeIdRanges();
-            pEditEngine = new ScFieldEditEngine( pEnginePool, NULL, sal_True );
+            pEditEngine = new ScFieldEditEngine(NULL, pEnginePool, NULL, true);
         }
         //  currently, GetPortions doesn't work if UpdateMode is sal_False,
         //  this will be fixed (in EditEngine) by src600
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 8b05f33..197b004 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -615,7 +615,11 @@ void ScEditShell::Execute( SfxRequest& rReq )
             lclInsertCharacter( pTableView, pTopView, CHAR_ZWNBSP );
         break;
         case SID_INSERT_FIELD_TEST:
-            fprintf(stdout, "ScEditShell::Execute:   SID_INSERT_FIELD_TEST\n");
+        {
+            SvxExtTimeField aField;
+            SvxFieldItem aItem(aField, EE_FEATURE_FIELD);
+            pTableView->InsertField(aItem);
+        }
         break;
     }
 
@@ -718,7 +722,6 @@ void ScEditShell::GetState( SfxItemSet& rSet )
                 }
                 break;
             case SID_INSERT_FIELD_TEST:
-                fprintf(stdout, "ScEditShell::GetState:   SID_INSERT_FIELD_TEST\n");
             break;
 
         }
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 8b243df..c0f0a38 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5085,7 +5085,7 @@ bool ScGridWindow::GetEditUrlOrError( bool bSpellErr, const Point& rPos,
 
         //  EditEngine
 
-    ScFieldEditEngine aEngine( pDoc->GetEditPool() );
+    ScFieldEditEngine aEngine(pDoc, pDoc->GetEditPool());
     ScSizeDeviceProvider aProv(pDocSh);
     aEngine.SetRefDevice( aProv.GetDevice() );
     aEngine.SetRefMapMode( MAP_100TH_MM );
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index bca73f5..a91a7fe 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -2001,7 +2001,7 @@ void ScOutputData::DrawStrings( sal_Bool bPixelToLogic )
 
 ScFieldEditEngine* ScOutputData::CreateOutputEditEngine()
 {
-    ScFieldEditEngine* pEngine = new ScFieldEditEngine( pDoc->GetEnginePool() );
+    ScFieldEditEngine* pEngine = new ScFieldEditEngine(pDoc, pDoc->GetEnginePool());
     pEngine->SetUpdateMode( false );
     // a RefDevice always has to be set, otherwise EditEngine would create a VirtualDevice
     pEngine->SetRefDevice( pFmtDevice );
commit 9b99bf09a25d9c9016a1c6b730fa0ef1cc5bc04a
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Apr 19 23:20:53 2012 -0400

    Initial skeleton for inserting a field into cell.

diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
index c41b805..c1f1aa3 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
@@ -1514,6 +1514,11 @@
                     <value>1</value>
                 </prop>
             </node>
+            <node oor:name=".uno:InsertFieldTest" oor:op="replace">
+                <prop oor:name="Label" oor:type="xs:string">
+                    <value xml:lang="en-US">Insert Field Test</value>
+                </prop>
+            </node>
         </node>
         <node oor:name="Popups">
             <node oor:name=".uno:AuditMenu" oor:op="replace">
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index f8b1875..1e8b033 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -716,6 +716,7 @@
 
 #define SID_DELETE_SCENARIO     (SID_NEW_SLOTS+95)
 #define SID_EDIT_SCENARIO       (SID_NEW_SLOTS+96)
+#define SID_INSERT_FIELD_TEST   (SID_NEW_SLOTS+97)
 
 // idl parameter
 
@@ -771,6 +772,7 @@
 #define RID_MEDIA_OBJECTBAR     (SC_RESOURCE_START+60)
 #define RID_POPUP_MEDIA         (SC_RESOURCE_START+61)
 #define RID_FUNCTION_CATEGORIES (SC_RESOURCE_START+62)
+#define RID_MN_INSERT_FIELDS    (SC_RESOURCE_START+63)
 
 #define STR_START               (SC_RESOURCE_START+100)
 #define STR_ROWHEIGHT           (STR_START)
diff --git a/sc/sdi/editsh.sdi b/sc/sdi/editsh.sdi
index 1d95f2d..c896cc4 100644
--- a/sc/sdi/editsh.sdi
+++ b/sc/sdi/editsh.sdi
@@ -98,6 +98,8 @@ interface TableText
     SID_INSERT_LRM              [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ]
     SID_INSERT_ZWSP             [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ]
     SID_INSERT_ZWNBSP           [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ]
+
+    SID_INSERT_FIELD_TEST [ ExecMethod = Execute; StateMethod = GetState; ]
 }
 
 
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index 99976ec..9ca1858 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -8001,3 +8001,26 @@ SfxVoidItem SetTabBgColor FID_TAB_MENU_SET_TAB_BG_COLOR
     GroupId = GID_FORMAT;
 ]
 
+SfxVoidItem InsertFieldTest SID_INSERT_FIELD_TEST
+()
+[
+    /* flags: */
+    AutoUpdate = FALSE,
+    Cachable = Cachable,
+    FastCall = FALSE,
+    HasCoreId = FALSE,
+    HasDialog = FALSE,
+    ReadOnlyDoc = TRUE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Synchron;
+
+    /* config: */
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    StatusBarConfig = FALSE,
+    ToolBoxConfig = FALSE,
+    GroupId = GID_OPTIONS;
+]
diff --git a/sc/source/ui/src/popup.src b/sc/source/ui/src/popup.src
index 6e27ce3..66e84bf 100644
--- a/sc/source/ui/src/popup.src
+++ b/sc/source/ui/src/popup.src
@@ -430,6 +430,22 @@ Menu RID_POPUP_EDIT
          //------------------------------
         MenuItem
         {
+            Text [ en-US ] = "Insert Fields" ;
+            Identifier = RID_MN_INSERT_FIELDS ;
+            SubMenu = Menu
+            {
+                ItemList =
+                {
+                    MenuItem
+                    {
+                        Identifier = SID_INSERT_FIELD_TEST ;
+                        Text [ en-US ] = "Test Field";
+                    };
+                };
+            };
+        };
+        MenuItem
+        {
             ITEM_FORMAT_CHAR_DLG
         };
          //------------------------------
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 9f3dfe1..8b05f33 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -614,6 +614,9 @@ void ScEditShell::Execute( SfxRequest& rReq )
         case SID_INSERT_ZWNBSP:
             lclInsertCharacter( pTableView, pTopView, CHAR_ZWNBSP );
         break;
+        case SID_INSERT_FIELD_TEST:
+            fprintf(stdout, "ScEditShell::Execute:   SID_INSERT_FIELD_TEST\n");
+        break;
     }
 
     pHdl->DataChanged();
@@ -714,7 +717,9 @@ void ScEditShell::GetState( SfxItemSet& rSet )
                         rSet.DisableItem( SID_THES );
                 }
                 break;
-
+            case SID_INSERT_FIELD_TEST:
+                fprintf(stdout, "ScEditShell::GetState:   SID_INSERT_FIELD_TEST\n");
+            break;
 
         }
         nWhich = aIter.NextWhich();


More information about the Libreoffice-commits mailing list