[Libreoffice-commits] .: sw/inc sw/source

Noel Power noelp at kemper.freedesktop.org
Mon Feb 21 04:42:29 PST 2011


 sw/inc/unobookmark.hxx             |   19 +++++++++++++++++--
 sw/inc/unocoll.hxx                 |    4 +++-
 sw/source/core/unocore/unobkm.cxx  |   24 ++++++++++++++++++++++++
 sw/source/core/unocore/unocoll.cxx |    9 +++++++++
 4 files changed, 53 insertions(+), 3 deletions(-)

New commits:
commit 2747138cb602c42b7839426e0193b31be3b330ed
Author: Noel Power <noel.power at novell.com>
Date:   Mon Feb 21 12:10:36 2011 +0000

    make docx import cater for enhanced fields
    
    introduced some new services for enhanced fields ( checkbox & dropdown ) that wrap existing implementations.

diff --git a/sw/inc/unobookmark.hxx b/sw/inc/unobookmark.hxx
index f219286..9c8936c 100644
--- a/sw/inc/unobookmark.hxx
+++ b/sw/inc/unobookmark.hxx
@@ -236,10 +236,9 @@ class SwXFieldmark
     : public SwXFieldmark_Base
 {
 
-private:
+protected:
 
     bool isReplacementObject;
-
 public:
 
     static ::com::sun::star::uno::Reference<
@@ -263,6 +262,22 @@ public:
 
 };
 
+class SwXODFCheckboxField : public SwXFieldmark
+{
+public:
+    SwXODFCheckboxField( ::sw::mark::IMark* pBkm = 0, SwDoc* pDoc = 0) : SwXFieldmark(true,
+            pBkm, pDoc) {}
+
+    virtual void SAL_CALL setPropertyValue(
+            const ::rtl::OUString& rPropertyName,
+            const ::com::sun::star::uno::Any& rValue)
+        throw (::com::sun::star::beans::UnknownPropertyException,
+                ::com::sun::star::beans::PropertyVetoException,
+                ::com::sun::star::lang::IllegalArgumentException,
+                ::com::sun::star::lang::WrappedTargetException,
+                ::com::sun::star::uno::RuntimeException);
+
+};
 #endif // SW_UNOBOOKMARK_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/inc/unocoll.hxx b/sw/inc/unocoll.hxx
index 7abf9d7..14ddbc0 100644
--- a/sw/inc/unocoll.hxx
+++ b/sw/inc/unocoll.hxx
@@ -194,7 +194,9 @@ class SwUnoCollection
 #define SW_SERVICE_VBAOBJECTPROVIDER                    110
 #define SW_SERVICE_VBACODENAMEPROVIDER                  111
 #define SW_SERVICE_VBAPROJECTNAMEPROVIDER               112
-#define SW_SERVICE_VBAGLOBALS                           113
+#define SW_SERVICE_ODF_FORM_CHECKBOX                    113
+#define SW_SERVICE_ODF_FORM_LISTBOX                     114
+#define SW_SERVICE_VBAGLOBALS                           115
 
 #define SW_SERVICE_LAST                 SW_SERVICE_VBAGLOBALS
 
diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx
index 99a3ee8..96e6079 100644
--- a/sw/source/core/unocore/unobkm.cxx
+++ b/sw/source/core/unocore/unobkm.cxx
@@ -617,6 +617,7 @@ IFieldmark::parameter_map_t* SwXFieldmarkParameters::getCoreParameters()
 void SwXFieldmark::attachToRange( const uno::Reference < text::XTextRange >& xTextRange )
     throw(lang::IllegalArgumentException, uno::RuntimeException)
 {
+
     attachToRangeEx( xTextRange,
                      ( isReplacementObject ? IDocumentMarkAccess::CHECKBOX_FIELDMARK : IDocumentMarkAccess::TEXT_FIELDMARK ) );
 }
@@ -677,4 +678,27 @@ SwXFieldmark::CreateXFieldmark(SwDoc & rDoc, ::sw::mark::IMark & rMark)
     return xMark;
 }
 
+void SAL_CALL
+SwXODFCheckboxField::setPropertyValue(const OUString& PropertyName,
+        const uno::Any& rValue)
+throw (beans::UnknownPropertyException, beans::PropertyVetoException,
+    lang::IllegalArgumentException, lang::WrappedTargetException,
+    uno::RuntimeException)
+{
+    if ( PropertyName.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Checked") ) ) )
+    {
+        const ::sw::mark::ICheckboxFieldmark* pCheckboxFm = dynamic_cast< const ::sw::mark::ICheckboxFieldmark* >( GetBookmark());
+        sal_Bool bChecked( sal_False );
+        if ( pCheckboxFm && ( rValue >>= bChecked ) )
+        {
+            // evil #TODO #FIXME
+            ((::sw::mark::ICheckboxFieldmark*)(pCheckboxFm))->SetChecked( bChecked );
+        }
+        else
+            throw uno::RuntimeException();
+    }
+    else
+        throw  lang::IllegalArgumentException();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx
index e508e75..7b037e9 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -399,6 +399,8 @@ const ProvNamesId_Type aProvNamesId[] =
     { "ooo.vba.VBAObjectModuleObjectProvider",                SW_SERVICE_VBAOBJECTPROVIDER },
     { "ooo.vba.VBACodeNameProvider",                          SW_SERVICE_VBACODENAMEPROVIDER },
     { "ooo.vba.VBAProjectNameProvider",                       SW_SERVICE_VBAPROJECTNAMEPROVIDER },
+    { "com.sun.star.text.FormFieldmark.ODFFormCheckbox",                    SW_SERVICE_ODF_FORM_CHECKBOX },
+    { "com.sun.star.text.FormFieldmark.ODFFormListbox",                     SW_SERVICE_ODF_FORM_LISTBOX },
     { "ooo.vba.VBAGlobals",                       SW_SERVICE_VBAGLOBALS },
 
     // case-correct versions of the service names (see #i67811)
@@ -561,6 +563,7 @@ uno::Reference< uno::XInterface >   SwXServiceProvider::MakeInstance(sal_uInt16
             xRet =  (cppu::OWeakObject*)pFieldmark;
         }
         break;
+        case  SW_SERVICE_ODF_FORM_LISTBOX:
         case  SW_SERVICE_TYPE_FORMFIELDMARK :
         {
             SwXFieldmark* pFieldmark = new SwXFieldmark(true);
@@ -835,6 +838,12 @@ uno::Reference< uno::XInterface >   SwXServiceProvider::MakeInstance(sal_uInt16
         case SW_SERVICE_FIELDTYPE_METAFIELD:
             xRet = static_cast< ::cppu::OWeakObject* >(new SwXMetaField(pDoc));
         break;
+        case SW_SERVICE_ODF_FORM_CHECKBOX:
+        {
+            SwXFieldmark* pFormCheckbox = new SwXODFCheckboxField();
+            xRet =  (cppu::OWeakObject*)pFormCheckbox;
+        }
+        break;
         default:
             throw uno::RuntimeException();
     }


More information about the Libreoffice-commits mailing list