[Libreoffice-commits] .: 7 commits - oox/source sfx2/source sw/inc sw/source unotest/source

Michael Stahl mst at kemper.freedesktop.org
Fri Mar 2 15:12:13 PST 2012


 oox/source/drawingml/shape.cxx                                |   28 ++++-
 sfx2/source/doc/QuerySaveDocument.cxx                         |    5 +
 sw/inc/txtfld.hxx                                             |    3 
 sw/source/core/crsr/crstrvl.cxx                               |    3 
 sw/source/core/txtnode/atrfld.cxx                             |    7 +
 sw/source/core/txtnode/thints.cxx                             |    3 
 sw/source/core/unocore/unofield.cxx                           |   48 ++++------
 unotest/source/java/org/openoffice/test/OfficeConnection.java |    7 +
 8 files changed, 64 insertions(+), 40 deletions(-)

New commits:
commit 6be1128916b9c9441969d9a37a4b6694ac26eb8b
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Mar 2 21:43:52 2012 +0100

    SwXTextField::setPropertyValue: simplify a bit:
    
    It looks like the second call to PutValue() was accidentally inserted
    in f462a51fcc8e50f3255d2d8c98a4c6408dce725e.
    Also, pDoc is valid when pField is.

diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index db452a4..bb6bef8 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -1893,18 +1893,14 @@ void SwXTextField::setPropertyValue(const OUString& rPropertyName, const uno::An
         else
         {
             SwDoc * pDoc = GetDoc();
-
-            if (NULL != pDoc)
-            {
-                const SwTxtFld* pTxtFld = pFmtFld->GetTxtFld();
-                if(!pTxtFld)
-                    throw uno::RuntimeException();
-                SwPosition aPosition( pTxtFld->GetTxtNode() );
-                aPosition.nContent = *pTxtFld->GetStart();
-                pDoc->PutValueToField( aPosition, rValue, pEntry->nWID);
-            }
+            assert(pDoc);
+            const SwTxtFld* pTxtFld = pFmtFld->GetTxtFld();
+            if(!pTxtFld)
+                throw uno::RuntimeException();
+            SwPosition aPosition( pTxtFld->GetTxtNode() );
+            aPosition.nContent = *pTxtFld->GetStart();
+            pDoc->PutValueToField( aPosition, rValue, pEntry->nWID);
         }
-        pField->PutValue( rValue, pEntry->nWID );
 
         //#i100374# notify SwPostIt about new field content
         if (RES_POSTITFLD== nWhich && pFmtFld)
commit e85130f7224a5902bbb172a9af4abb1ac2205237
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Mar 2 20:48:22 2012 +0100

    unofield.cxx: fix indentation a little

diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index 0cc0223..db452a4 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -1878,7 +1878,7 @@ void SwXTextField::setPropertyValue(const OUString& rPropertyName, const uno::An
 
     if(pField)
     {
-        // Sonderbehandlung Serienbrieffeld
+        // special treatment for mail merge fields
         sal_uInt16 nWhich = pField->Which();
         if( RES_DBFLD == nWhich &&
             (rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_NAME)) ||
@@ -1886,8 +1886,8 @@ void SwXTextField::setPropertyValue(const OUString& rPropertyName, const uno::An
             rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_TABLE_NAME))||
             rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_COLUMN_NAME))))
         {
-            // hier muss ein neuer Feldtyp angelegt werden und
-            // das Feld an den neuen Typ umgehaengt werden
+            // here a new field type must be created and the field must
+            // be registered at the new type
             OSL_FAIL("not implemented");
         }
         else
@@ -1906,11 +1906,12 @@ void SwXTextField::setPropertyValue(const OUString& rPropertyName, const uno::An
         }
         pField->PutValue( rValue, pEntry->nWID );
 
-    //#i100374# notify SwPostIt about new field content
-    if (RES_POSTITFLD== nWhich && pFmtFld)
-    {
-        const_cast<SwFmtFld*>(pFmtFld)->Broadcast(SwFmtFldHint( 0, SWFMTFLD_CHANGED ));
-    }
+        //#i100374# notify SwPostIt about new field content
+        if (RES_POSTITFLD== nWhich && pFmtFld)
+        {
+            const_cast<SwFmtFld*>(pFmtFld)->Broadcast(
+                    SwFmtFldHint( 0, SWFMTFLD_CHANGED ));
+        }
 
         // fdo#42073 notify SwTxtFld about changes of the expanded string
         if (pFmtFld->GetTxtFld())
@@ -1918,10 +1919,10 @@ void SwXTextField::setPropertyValue(const OUString& rPropertyName, const uno::An
             pFmtFld->GetTxtFld()->Expand();
         }
 
-    //#i100374# changing a document field should set the modify flag
-    SwDoc* pDoc = GetDoc();
-    if (pDoc)
-        pDoc->SetModified();
+        //#i100374# changing a document field should set the modify flag
+        SwDoc* pDoc = GetDoc();
+        if (pDoc)
+            pDoc->SetModified();
 
     }
     else if(m_pProps)
commit e3dfae0741aae8581cd3fc713ba1b4459bb22d88
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Mar 2 21:32:27 2012 +0100

    fdo#42073: sw: expand all text fields when setting properties:
    
    SwXTextField::setPropertyValue: call Expand() for all text fields
    Fixes getPresentation returning stale values.
    (regression from CWS sw34bf01, 8485708f3001fca132c3353c464fe7187ef62bed)
    Also, without this the text formatting does not actually update and the new
    content is not displayed until some other unrelated editing operation.

diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index c12ac14..0cc0223 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -1912,9 +1912,8 @@ void SwXTextField::setPropertyValue(const OUString& rPropertyName, const uno::An
         const_cast<SwFmtFld*>(pFmtFld)->Broadcast(SwFmtFldHint( 0, SWFMTFLD_CHANGED ));
     }
 
-        // changes of the expanded string have to be notified
-        //#to the SwTxtFld
-        if(RES_DBFLD == nWhich && pFmtFld->GetTxtFld())
+        // fdo#42073 notify SwTxtFld about changes of the expanded string
+        if (pFmtFld->GetTxtFld())
         {
             pFmtFld->GetTxtFld()->Expand();
         }
commit 9519deda120b73b72e75d89c3b2ae3d66220ec2d
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Mar 2 19:02:03 2012 +0100

    fdo#39694: SwTxtFld: do expand the field in the ctor
    
    While only the text formatting is able to expand all fields correctly,
    this is still good enough for many field types and fixes a race
    condition when the field value is requested before layout is finished.
    (regression from CWS sw34bf01, 8485708f3001fca132c3353c464fe7187ef62bed)

diff --git a/sw/inc/txtfld.hxx b/sw/inc/txtfld.hxx
index 3ecabb8..f574811 100644
--- a/sw/inc/txtfld.hxx
+++ b/sw/inc/txtfld.hxx
@@ -42,7 +42,8 @@ class SwTxtFld : public SwTxtAttr
     SwTxtNode * m_pTxtNode;
 
 public:
-    SwTxtFld(SwFmtFld & rAttr, xub_StrLen const nStart);
+    SwTxtFld(SwFmtFld & rAttr, xub_StrLen const nStart,
+            bool const bInClipboard);
     virtual ~SwTxtFld();
 
     void CopyFld( SwTxtFld *pDest ) const;
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index fad9d8b..12e8e5f 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -710,7 +710,8 @@ sal_Bool SwCrsrShell::MoveFldType( const SwFieldType* pFldType, sal_Bool bNext,
             SwFmtFld* pFmtFld = new SwFmtFld( SwDateTimeField(
                 (SwDateTimeFieldType*)pDoc->GetSysFldType( RES_DATETIMEFLD ) ) );
 
-            pTxtFld = new SwTxtFld( *pFmtFld, rPos.nContent.GetIndex() );
+            pTxtFld = new SwTxtFld( *pFmtFld, rPos.nContent.GetIndex(),
+                        pDoc->IsClipBoard() );
             pTxtFld->ChgTxtNode( pTNd );
         }
 
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index dc285ef..b0b0757 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -283,9 +283,12 @@ sal_Bool SwFmtFld::IsProtect() const
 |*
 *************************************************************************/
 
-SwTxtFld::SwTxtFld(SwFmtFld & rAttr, xub_StrLen const nStartPos)
+SwTxtFld::SwTxtFld(SwFmtFld & rAttr, xub_StrLen const nStartPos,
+        bool const bInClipboard)
     : SwTxtAttr( rAttr, nStartPos )
-    , m_aExpand( rAttr.GetFld()->ExpandField(true) )
+// fdo#39694 the ExpandField here may not give the correct result in all cases,
+// but is better than nothing
+    , m_aExpand( rAttr.GetFld()->ExpandField(bInClipboard) )
     , m_pTxtNode( 0 )
 {
     rAttr.pTxtAttr = this;
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index f6bf2e3..5064935 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -1035,7 +1035,8 @@ SwTxtAttr* MakeTxtAttr( SwDoc & rDoc, SfxPoolItem& rAttr,
         pNew = new SwTxtINetFmt( (SwFmtINetFmt&)rNew, nStt, nEnd );
         break;
     case RES_TXTATR_FIELD:
-        pNew = new SwTxtFld( static_cast<SwFmtFld &>(rNew), nStt );
+        pNew = new SwTxtFld( static_cast<SwFmtFld &>(rNew), nStt,
+                    rDoc.IsClipBoard() );
         break;
     case RES_TXTATR_FLYCNT:
         {
commit eb237af5aa0a5d8616e4a8ddd1e528433bdd0f82
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Mar 2 14:53:33 2012 +0100

    ExecuteQuerySaveDocument: return NO when headless instead of CANCEL

diff --git a/sfx2/source/doc/QuerySaveDocument.cxx b/sfx2/source/doc/QuerySaveDocument.cxx
index ff670d6..7ac2b67 100644
--- a/sfx2/source/doc/QuerySaveDocument.cxx
+++ b/sfx2/source/doc/QuerySaveDocument.cxx
@@ -33,9 +33,14 @@
 #include <sfx2/sfxuno.hxx>
 #include "doc.hrc"
 #include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
 // -----------------------------------------------------------------------------
 short ExecuteQuerySaveDocument(Window* _pParent,const String& _rTitle)
 {
+    if (Application::IsHeadlessModeEnabled())
+    {   // don't block Desktop::terminate() if there's no user to ask
+        return RET_NO;
+    }
     String aText( SfxResId( STR_QUERY_SAVE_DOCUMENT ) );
     aText.SearchAndReplace( DEFINE_CONST_UNICODE( "$(DOC)" ),
                             _rTitle );
commit 90f7a3ada68f309a9d3201183ef552e59f9558fb
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Mar 2 13:49:19 2012 +0100

    OfficeConnection.java: don't wait forever if terminate() fails

diff --git a/unotest/source/java/org/openoffice/test/OfficeConnection.java b/unotest/source/java/org/openoffice/test/OfficeConnection.java
index da99d0d..5eb3afa 100644
--- a/unotest/source/java/org/openoffice/test/OfficeConnection.java
+++ b/unotest/source/java/org/openoffice/test/OfficeConnection.java
@@ -128,6 +128,12 @@ public final class OfficeConnection {
                     context = null;
                     try {
                         desktopTerminated = desktop.terminate();
+                        if (!desktopTerminated) {
+                            // in case terminate() fails we would wait forever
+                            // for the process to die, so kill it
+                            process.destroy();
+                        }
+                        assertTrue(desktopTerminated);
                     } catch (DisposedException e) {}
                         // it appears that DisposedExceptions can already happen
                         // while receiving the response of the terminate call
@@ -142,7 +148,6 @@ public final class OfficeConnection {
             }
             boolean outTerminated = outForward == null || outForward.terminated();
             boolean errTerminated = errForward == null || errForward.terminated();
-            assertTrue(desktopTerminated);
             assertEquals(0, code);
             assertTrue(outTerminated);
             assertTrue(errTerminated);
commit 56665a8a22d274f2f335eb38623d226760440e7e
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Mar 1 22:24:04 2012 +0100

    oox::drawingml::Shape: fix "lock underflow in SvxShape" assertions

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 5e3aa73..2b2d815 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -225,9 +225,6 @@ void Shape::addShape(
             if ( xShapes.is() )
                 addChildren( rFilterBase, *this, pTheme, xShapes, pShapeRect ? *pShapeRect : awt::Rectangle( maPosition.X, maPosition.Y, maSize.Width, maSize.Height ), pShapeMap, aMatrix );
         }
-        Reference< document::XActionLockable > xLockable( mxShape, UNO_QUERY );
-        if( xLockable.is() )
-            xLockable->removeActionLock();
     }
     catch( const Exception&  )
     {
@@ -271,6 +268,25 @@ void Shape::addChildren( ::oox::core::XmlFilterBase& rFilterBase,
                 pShapeMap, aTransformation);
 }
 
+struct ActionLockGuard
+{
+    explicit ActionLockGuard(Reference<drawing::XShape> const& xShape)
+        : m_xLockable(xShape, UNO_QUERY)
+    {
+        if (m_xLockable.is()) {
+            m_xLockable->addActionLock();
+        }
+    }
+    ~ActionLockGuard()
+    {
+        if (m_xLockable.is()) {
+            m_xLockable->removeActionLock();
+        }
+    }
+private:
+    Reference<document::XActionLockable> m_xLockable;
+};
+
 // for group shapes, the following method is also adding each child
 void Shape::addChildren(
         XmlFilterBase& rFilterBase,
@@ -446,9 +462,7 @@ Reference< XShape > Shape::createAndInsert(
             xSet->setPropertyValue( sVisible, Any( sal_False ) );
         }
 
-        Reference< document::XActionLockable > xLockable( mxShape, UNO_QUERY );
-        if( xLockable.is() )
-            xLockable->addActionLock();
+        ActionLockGuard const alg(mxShape);
 
         // sj: removing default text of placeholder objects such as SlideNumberShape or HeaderShape
         if ( bClearText )
@@ -562,8 +576,6 @@ Reference< XShape > Shape::createAndInsert(
                 getTextBody()->insertAt( rFilterBase, xText, xAt, aCharStyleProperties, mpMasterTextListStyle );
             }
         }
-        if( xLockable.is() )
-            xLockable->removeActionLock();
     }
 
     if( mxShape.is() )


More information about the Libreoffice-commits mailing list