sw/inc/flddat.hxx                  |    2 +-
 sw/source/core/fields/docufld.cxx  |    4 ++--
 sw/source/core/fields/flddat.cxx   |   10 +++++-----
 sw/source/core/unocore/unocoll.cxx |   16 ++++++++--------
 sw/source/core/unocore/unoidx.cxx  |   12 ++++++------
 vcl/unx/gtk3/gtk3gtksys.cxx        |   37 +------------------------------------
 6 files changed, 23 insertions(+), 58 deletions(-)

New commits:
commit 73b1188a3af5edce43508965f95fab1345ccda0e
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Oct 4 20:57:30 2020 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Mon Oct 5 12:40:35 2020 +0200

    we are guaranteed to have gdk_screen_get_primary_monitor now
    
    Change-Id: I03419ff5233da53aeb3644f62357c983b0fe76ea
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103930
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/unx/gtk3/gtk3gtksys.cxx b/vcl/unx/gtk3/gtk3gtksys.cxx
index 379c87343ae8..a0627a6f81e2 100644
--- a/vcl/unx/gtk3/gtk3gtksys.cxx
+++ b/vcl/unx/gtk3/gtk3gtksys.cxx
@@ -186,46 +186,11 @@ bool GtkSalSystem::IsUnifiedDisplay()
     return gdk_display_get_n_screens (mpDisplay) == 1;
 }
 
-namespace {
-int _fallback_get_primary_monitor (GdkScreen *pScreen)
-{
-    // Use monitor name as primacy heuristic
-    int max = gdk_screen_get_n_monitors (pScreen);
-    for (int i = 0; i < max; ++i)
-    {
-        char *name = gdk_screen_get_monitor_plug_name (pScreen, i);
-        bool bLaptop = (name && !g_ascii_strncasecmp (name, "LVDS", 4));
-        g_free (name);
-        if (bLaptop)
-            return i;
-    }
-    return 0;
-}
-
-int _get_primary_monitor (GdkScreen *pScreen)
-{
-    static int (*get_fn) (GdkScreen *) = nullptr;
-    get_fn = gdk_screen_get_primary_monitor;
-    // Perhaps we have a newer gtk+ with this symbol:
-    if (!get_fn)
-    {
-        get_fn = 
reinterpret_cast<int(*)(GdkScreen*)>(osl_getAsciiFunctionSymbol(nullptr,
-            "gdk_screen_get_primary_monitor"));
-    }
-    if (!get_fn)
-        get_fn = _fallback_get_primary_monitor;
-    if (get_fn)
-        return get_fn (pScreen);
-    else
-        return 0;
-}
-} // end anonymous namespace
-
 unsigned int GtkSalSystem::GetDisplayBuiltInScreen()
 {
     GdkScreen *pDefault = gdk_display_get_default_screen (mpDisplay);
     int idx = getScreenIdxFromPtr (pDefault);
-    return idx + _get_primary_monitor (pDefault);
+    return idx + gdk_screen_get_primary_monitor(pDefault);
 }
 
 tools::Rectangle GtkSalSystem::GetDisplayScreenPosSizePixel (unsigned int 
nScreen)
commit 1d35f90dfe46cadc913e35f509669785cfa8ec18
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Oct 4 19:58:51 2020 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Mon Oct 5 12:40:13 2020 +0200

    SwDateTimeField::GetDateTime always dereferences its SwDoc*
    
    ditto:
    SwXFrameEnumeration ctor
    lcl_ReAssignTOXType
    
    Change-Id: Idaa6bef29cbc4c3a08d578ef4bedcaa071547944
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103928
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/inc/flddat.hxx b/sw/inc/flddat.hxx
index 66f13c98bf51..38c16c9039a3 100644
--- a/sw/inc/flddat.hxx
+++ b/sw/inc/flddat.hxx
@@ -68,7 +68,7 @@ public:
         Date                    GetDate() const;
         tools::Time             GetTime() const;
         void                    SetDateTime(const DateTime& rDT);
-        static double           GetDateTime(SwDoc* pDoc, const DateTime& rDT);
+        static double           GetDateTime(SwDoc& rDoc, const DateTime& rDT);
 
         virtual bool            QueryValue( css::uno::Any& rVal, sal_uInt16 
nMId ) const override;
         virtual bool            PutValue( const css::uno::Any& rVal, 
sal_uInt16 nMId ) override;
diff --git a/sw/source/core/fields/docufld.cxx 
b/sw/source/core/fields/docufld.cxx
index cca0e4ee8c7f..196dcba31d3b 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -952,7 +952,7 @@ OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, 
sal_uInt32 nFormat,
                     else
                     {
                         // start the number formatter
-                        double fVal = SwDateTimeField::GetDateTime( GetDoc(),
+                        double fVal = SwDateTimeField::GetDateTime( *GetDoc(),
                                                     aDate);
                         aStr = ExpandValue(fVal, nFormat, nLang);
                     }
@@ -968,7 +968,7 @@ OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, 
sal_uInt32 nFormat,
                     else
                     {
                         // start the number formatter
-                        double fVal = SwDateTimeField::GetDateTime( GetDoc(),
+                        double fVal = SwDateTimeField::GetDateTime( *GetDoc(),
                                                     aDate);
                         aStr = ExpandValue(fVal, nFormat, nLang);
                     }
diff --git a/sw/source/core/fields/flddat.cxx b/sw/source/core/fields/flddat.cxx
index f2a6a779a0ed..d68fe77beabe 100644
--- a/sw/source/core/fields/flddat.cxx
+++ b/sw/source/core/fields/flddat.cxx
@@ -67,7 +67,7 @@ OUString SwDateTimeField::ExpandImpl(SwRootFrame const*const) 
const
     if (!(IsFixed()))
     {
         DateTime aDateTime( DateTime::SYSTEM );
-        fVal = GetDateTime(GetDoc(), aDateTime);
+        fVal = GetDateTime(*GetDoc(), aDateTime);
     }
     else
         fVal = GetValue();
@@ -115,12 +115,12 @@ OUString SwDateTimeField::GetPar2() const
 
 void SwDateTimeField::SetDateTime(const DateTime& rDT)
 {
-    SetValue(GetDateTime(GetDoc(), rDT));
+    SetValue(GetDateTime(*GetDoc(), rDT));
 }
 
-double SwDateTimeField::GetDateTime(SwDoc* pDoc, const DateTime& rDT)
+double SwDateTimeField::GetDateTime(SwDoc& rDoc, const DateTime& rDT)
 {
-    SvNumberFormatter* pFormatter = pDoc->GetNumberFormatter();
+    SvNumberFormatter* pFormatter = rDoc.GetNumberFormatter();
     const Date& rNullDate = pFormatter->GetNullDate();
 
     double fResult = rDT - DateTime(rNullDate);
@@ -133,7 +133,7 @@ double SwDateTimeField::GetValue() const
     if (IsFixed())
         return SwValueField::GetValue();
     else
-        return GetDateTime(GetDoc(), DateTime( DateTime::SYSTEM ));
+        return GetDateTime(*GetDoc(), DateTime( DateTime::SYSTEM ));
 }
 
 Date SwDateTimeField::GetDate() const
diff --git a/sw/source/core/unocore/unocoll.cxx 
b/sw/source/core/unocore/unocoll.cxx
index c9a2cdc0dff4..a6287cbd714d 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -1056,7 +1056,7 @@ namespace
         protected:
             virtual ~SwXFrameEnumeration() override {};
         public:
-            SwXFrameEnumeration(const SwDoc* const pDoc);
+            SwXFrameEnumeration(const SwDoc& rDoc);
 
             //XEnumeration
             virtual sal_Bool SAL_CALL hasMoreElements() override;
@@ -1070,12 +1070,12 @@ namespace
 }
 
 template<FlyCntType T>
-SwXFrameEnumeration<T>::SwXFrameEnumeration(const SwDoc* const pDoc)
+SwXFrameEnumeration<T>::SwXFrameEnumeration(const SwDoc& rDoc)
     : m_aFrames()
 {
     SolarMutexGuard aGuard;
-    const SwFrameFormats* const pFormats = pDoc->GetSpzFrameFormats();
-    if(pFormats->empty())
+    const SwFrameFormats* const pFormats = rDoc.GetSpzFrameFormats();
+    if (pFormats->empty())
         return;
     // #i104937#
     const size_t nSize = pFormats->size();
@@ -1090,7 +1090,7 @@ SwXFrameEnumeration<T>::SwXFrameEnumeration(const SwDoc* 
const pDoc)
         const SwNodeIndex* pIdx =  pFormat->GetContent().GetContentIdx();
         if(!pIdx || !pIdx->GetNodes().IsDocNodes())
             continue;
-        const SwNode* pNd = pDoc->GetNodes()[ pIdx->GetIndex() + 1 ];
+        const SwNode* pNd = rDoc.GetNodes()[ pIdx->GetIndex() + 1 ];
         if(UnoFrameWrap_traits<T>::filter(pNd))
             m_aFrames.push_back(lcl_UnoWrapFrame<T>(pFormat));
     }
@@ -1165,13 +1165,13 @@ uno::Reference<container::XEnumeration> 
SwXFrames::createEnumeration()
     {
         case FLYCNTTYPE_FRM:
             return uno::Reference< container::XEnumeration >(
-                new SwXFrameEnumeration<FLYCNTTYPE_FRM>(GetDoc()));
+                new SwXFrameEnumeration<FLYCNTTYPE_FRM>(*GetDoc()));
         case FLYCNTTYPE_GRF:
             return uno::Reference< container::XEnumeration >(
-                new SwXFrameEnumeration<FLYCNTTYPE_GRF>(GetDoc()));
+                new SwXFrameEnumeration<FLYCNTTYPE_GRF>(*GetDoc()));
         case FLYCNTTYPE_OLE:
             return uno::Reference< container::XEnumeration >(
-                new SwXFrameEnumeration<FLYCNTTYPE_OLE>(GetDoc()));
+                new SwXFrameEnumeration<FLYCNTTYPE_OLE>(*GetDoc()));
         default:
             throw uno::RuntimeException();
     }
diff --git a/sw/source/core/unocore/unoidx.cxx 
b/sw/source/core/unocore/unoidx.cxx
index 9cfe87f04901..442527ef454b 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -98,13 +98,13 @@ static void lcl_BitMaskToAny(uno::Any & o_rValue,
 }
 
 static void
-lcl_ReAssignTOXType(SwDoc* pDoc, SwTOXBase& rTOXBase, const OUString& rNewName)
+lcl_ReAssignTOXType(SwDoc& rDoc, SwTOXBase& rTOXBase, const OUString& rNewName)
 {
-    const sal_uInt16 nUserCount = pDoc->GetTOXTypeCount( TOX_USER );
+    const sal_uInt16 nUserCount = rDoc.GetTOXTypeCount( TOX_USER );
     const SwTOXType* pNewType = nullptr;
     for(sal_uInt16 nUser = 0; nUser < nUserCount; nUser++)
     {
-        const SwTOXType* pType = pDoc->GetTOXType( TOX_USER, nUser );
+        const SwTOXType* pType = rDoc.GetTOXType( TOX_USER, nUser );
         if (pType->GetTypeName()==rNewName)
         {
             pNewType = pType;
@@ -114,7 +114,7 @@ lcl_ReAssignTOXType(SwDoc* pDoc, SwTOXBase& rTOXBase, const 
OUString& rNewName)
     if(!pNewType)
     {
         SwTOXType aNewType(TOX_USER, rNewName);
-        pNewType = pDoc->InsertTOXType( aNewType );
+        pNewType = rDoc.InsertTOXType( aNewType );
     }
 
     rTOXBase.RegisterToTOXType( *const_cast<SwTOXType*>(pNewType) );
@@ -594,7 +594,7 @@ SwXDocumentIndex::setPropertyValue(
             {
                 if (rTOXBase.GetTOXType()->GetTypeName() != sNewName)
                 {
-                    lcl_ReAssignTOXType(pSectionFormat->GetDoc(),
+                    lcl_ReAssignTOXType(*pSectionFormat->GetDoc(),
                             rTOXBase, sNewName);
                 }
             }
@@ -1332,7 +1332,7 @@ SwXDocumentIndex::attach(const uno::Reference< 
text::XTextRange > & xTextRange)
     if ((TOX_USER == pTOXType->GetType()) &&
         m_pImpl->m_pProps->GetTypeName() != pTOXType->GetTypeName())
     {
-        lcl_ReAssignTOXType(pDoc, rTOXBase, m_pImpl->m_pProps->GetTypeName());
+        lcl_ReAssignTOXType(*pDoc, rTOXBase, m_pImpl->m_pProps->GetTypeName());
     }
     //TODO: apply Section attributes (columns and background)
     SwTOXBaseSection *const pTOX =
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to