[Libreoffice-commits] .: 4 commits - svl/source vcl/source vcl/unx

Caolán McNamara caolan at kemper.freedesktop.org
Wed May 25 00:57:58 PDT 2011


 svl/source/misc/lockfilecommon.cxx   |   39 ++++++++++-------------------------
 vcl/source/control/makefile.mk       |   11 ++-------
 vcl/unx/source/printer/ppdparser.cxx |   31 +++++++++------------------
 3 files changed, 26 insertions(+), 55 deletions(-)

New commits:
commit 1e86dbf40d170a95ef2c58fbc6cbb26ea7133ad4
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed May 25 08:53:31 2011 +0100

    add salhelper::LinkResolver

diff --git a/svl/source/misc/lockfilecommon.cxx b/svl/source/misc/lockfilecommon.cxx
index 6ae25fd..5bba124 100644
--- a/svl/source/misc/lockfilecommon.cxx
+++ b/svl/source/misc/lockfilecommon.cxx
@@ -56,6 +56,8 @@
 
 #include <unotools/useroptions.hxx>
 
+#include <salhelper/linkhelper.hxx>
+
 #include <svl/lockfilecommon.hxx>
 
 using namespace ::com::sun::star;
@@ -89,36 +91,19 @@ INetURLObject LockFileCommon::ResolveLinks( const INetURLObject& aDocURL )
     if ( aDocURL.HasError() )
         throw lang::IllegalArgumentException();
 
-    ::rtl::OUString aURLToCheck = aDocURL.GetMainURL( INetURLObject::NO_DECODE );
-
-    sal_Bool bNeedsChecking = sal_True;
-    sal_Int32 nMaxLinkCount = 128;
-    sal_Int32 nCount = 0;
+    ::rtl::OUString aURLToCheck = aDocURL.GetMainURL(INetURLObject::NO_DECODE);
 
-    while( bNeedsChecking )
+    // there is currently no UCB functionality to resolve the symbolic links;
+    // since the lock files are used only for local file systems the osl
+    // functionality is used directly
+    salhelper::LinkResolver aResolver(osl_FileStatus_Mask_FileName);
+    osl::FileBase::RC eStatus = aResolver.fetchFileStatus(aURLToCheck);
+    if (eStatus == osl::FileBase::E_None)
+        aURLToCheck = aResolver.m_aStatus.getFileURL();
+    else if (eStatus == osl::FileBase::E_MULTIHOP)
     {
-        bNeedsChecking = sal_False;
-
         // do not allow too deep links
-        if ( nCount++ >= nMaxLinkCount )
-            throw io::IOException();
-
-        // there is currently no UCB functionality to resolve the symbolic links;
-        // since the lock files are used only for local file systems the osl functionality is used directly
-
-        ::osl::FileStatus aStatus( osl_FileStatus_Mask_Type | osl_FileStatus_Mask_LinkTargetURL );
-        ::osl::DirectoryItem aItem;
-        if ( ::osl::FileBase::E_None == ::osl::DirectoryItem::get( aURLToCheck, aItem )
-          && aItem.is() && ::osl::FileBase::E_None == aItem.getFileStatus( aStatus ) )
-        {
-            if ( aStatus.isValid( osl_FileStatus_Mask_Type )
-              && aStatus.isValid( osl_FileStatus_Mask_LinkTargetURL )
-              && aStatus.getFileType() == ::osl::FileStatus::Link )
-            {
-                aURLToCheck = aStatus.getLinkTargetURL();
-                bNeedsChecking = sal_True;
-            }
-        }
+        throw io::IOException();
     }
 
     return INetURLObject( aURLToCheck );
diff --git a/vcl/unx/source/printer/ppdparser.cxx b/vcl/unx/source/printer/ppdparser.cxx
index dfd2d3f..a685d3c 100644
--- a/vcl/unx/source/printer/ppdparser.cxx
+++ b/vcl/unx/source/printer/ppdparser.cxx
@@ -51,6 +51,7 @@
 #include "rtl/ustrbuf.hxx"
 #include "rtl/instance.hxx"
 #include <sal/macros.h>
+#include <salhelper/linkhelper.hxx>
 
 #include "com/sun/star/lang/Locale.hpp"
 
@@ -396,29 +397,19 @@ void PPDDecompressStream::ReadLine( ByteString& o_rLine )
 
 static osl::FileBase::RC resolveLink( const rtl::OUString& i_rURL, rtl::OUString& o_rResolvedURL, rtl::OUString& o_rBaseName, osl::FileStatus::Type& o_rType, int nLinkLevel = 10 )
 {
-    osl::DirectoryItem aLinkItem;
-    osl::FileBase::RC aRet = osl::FileBase::E_None;
+    salhelper::LinkResolver aResolver(osl_FileStatus_Mask_FileName |
+                                      osl_FileStatus_Mask_Type |
+                                      osl_FileStatus_Mask_FileURL);
+
+    osl::FileBase::RC aRet = aResolver.fetchFileStatus(i_rURL, nLinkLevel);
     
-    if( ( aRet = osl::DirectoryItem::get( i_rURL, aLinkItem ) ) == osl::FileBase::E_None )
+    if (aRet  == osl::FileBase::E_None)
     {
-        osl::FileStatus aStatus( osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_Type | osl_FileStatus_Mask_LinkTargetURL );
-        if( ( aRet = aLinkItem.getFileStatus( aStatus ) ) == osl::FileBase::E_None )
-        {
-            if( aStatus.getFileType() == osl::FileStatus::Link )
-            {
-                if( nLinkLevel > 0 )
-                    aRet = resolveLink( aStatus.getLinkTargetURL(), o_rResolvedURL, o_rBaseName, o_rType, nLinkLevel-1 );
-                else
-                    aRet = osl::FileBase::E_MULTIHOP;
-            }
-            else
-            {
-                o_rResolvedURL = i_rURL;
-                o_rBaseName = aStatus.getFileName();
-                o_rType = aStatus.getFileType();
-            }
-        }
+        o_rResolvedURL = aResolver.m_aStatus.getFileURL();
+        o_rBaseName = aResolver.m_aStatus.getFileName();
+        o_rType = aResolver.m_aStatus.getFileType();
     }
+
     return aRet;
 }
 
commit 99b104de58ef2d83e7db0861c98ae66301ba36f6
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 24 22:26:22 2011 +0100

    move this to salhelper

diff --git a/comphelper/Library_comphelp.mk b/comphelper/Library_comphelp.mk
index 2d5d545..8336b8c 100644
--- a/comphelper/Library_comphelp.mk
+++ b/comphelper/Library_comphelp.mk
@@ -90,7 +90,6 @@ $(eval $(call gb_Library_add_exception_objects,comphelper,\
     comphelper/source/misc/ihwrapnofilter \
     comphelper/source/misc/instancelocker \
     comphelper/source/misc/interaction \
-    comphelper/source/misc/linkhelper \
     comphelper/source/misc/listenernotification \
     comphelper/source/misc/locale \
     comphelper/source/misc/logging \
diff --git a/comphelper/Package_inc.mk b/comphelper/Package_inc.mk
index bbb320d..a02bde6 100644
--- a/comphelper/Package_inc.mk
+++ b/comphelper/Package_inc.mk
@@ -135,4 +135,3 @@ $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/namecontainer.hx
 $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/processfactory.hxx,comphelper/processfactory.hxx))
 $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/sequenceashashmap.hxx,comphelper/sequenceashashmap.hxx))
 $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/configurationhelper.hxx,comphelper/configurationhelper.hxx))
-$(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/linkhelper.hxx,comphelper/linkhelper.hxx))
diff --git a/comphelper/inc/comphelper/linkhelper.hxx b/comphelper/inc/comphelper/linkhelper.hxx
deleted file mode 100644
index 493e8d2..0000000
--- a/comphelper/inc/comphelper/linkhelper.hxx
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- 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. 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.
- *
- * The Initial Developer of the Original Code is
- *        Caolán McNamara <caolanm at redhat.com> (Red Hat, Inc.)
- * Portions created by the Initial Developer are Copyright (C) 2011 the
- * Initial Developer. All Rights Reserved.
- *
- * Contributor(s): Caolán McNamara <caolanm at redhat.com>
- *
- * 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 _LINKHELPER_HXX
-#define _LINKHELPER_HXX
-
-#include "comphelper/comphelperdllapi.h"
-#include <rtl/ustring.hxx>
-
-namespace comphelper
-{
-    /** Resolve a file url if its a symbolic link, to a depth of nDepth
-     *
-     *  @return false on failure, true on success
-     */
-    COMPHELPER_DLLPUBLIC bool resolveLink(rtl::OUString &rURL, int nDepth = 128);
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/comphelper/source/misc/linkhelper.cxx b/comphelper/source/misc/linkhelper.cxx
deleted file mode 100644
index 1ec9327..0000000
--- a/comphelper/source/misc/linkhelper.cxx
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- 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. 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.
- *
- * The Initial Developer of the Original Code is
- *        Caolán McNamara <caolanm at redhat.com> (Red Hat, Inc.)
- * Portions created by the Initial Developer are Copyright (C) 2011 the
- * Initial Developer. All Rights Reserved.
- *
- * Contributor(s): Caolán McNamara <caolanm at redhat.com>
- *
- * 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.
- */
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_comphelper.hxx"
-
-#include <comphelper/linkhelper.hxx>
-#include <osl/file.hxx>
-
-namespace comphelper
-{
-    /** Resolve a file url if its a symbolic link, to a depth of nDepth
-     *
-     *  @return false on failure, true on success
-     */
-    bool resolveLink(rtl::OUString &rURL, int nDepth)
-    {
-        bool bReturn = false;
-
-        osl::FileStatus status(osl_FileStatus_Mask_Type | osl_FileStatus_Mask_LinkTargetURL);
-        osl::DirectoryItem item;
-        while (osl::DirectoryItem::get(rURL, item) == osl::File::E_None)
-        {
-            if (--nDepth == 0)
-                break;
-            if (item.getFileStatus(status) != osl::File::E_None)
-                break;
-            if (status.getFileType() != osl::FileStatus::Link)
-            {
-                bReturn = true;
-                break;
-            }
-            rURL = status.getLinkTargetURL();
-        }
-
-        return bReturn;
-    }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 2e2a8f9f46689a1c32d295dfd04d0fb994aff92a
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 24 16:15:54 2011 +0100

    add a single place to attempt to resolve links

diff --git a/comphelper/Library_comphelp.mk b/comphelper/Library_comphelp.mk
index 8336b8c..2d5d545 100644
--- a/comphelper/Library_comphelp.mk
+++ b/comphelper/Library_comphelp.mk
@@ -90,6 +90,7 @@ $(eval $(call gb_Library_add_exception_objects,comphelper,\
     comphelper/source/misc/ihwrapnofilter \
     comphelper/source/misc/instancelocker \
     comphelper/source/misc/interaction \
+    comphelper/source/misc/linkhelper \
     comphelper/source/misc/listenernotification \
     comphelper/source/misc/locale \
     comphelper/source/misc/logging \
diff --git a/comphelper/Package_inc.mk b/comphelper/Package_inc.mk
index a02bde6..bbb320d 100644
--- a/comphelper/Package_inc.mk
+++ b/comphelper/Package_inc.mk
@@ -135,3 +135,4 @@ $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/namecontainer.hx
 $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/processfactory.hxx,comphelper/processfactory.hxx))
 $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/sequenceashashmap.hxx,comphelper/sequenceashashmap.hxx))
 $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/configurationhelper.hxx,comphelper/configurationhelper.hxx))
+$(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/linkhelper.hxx,comphelper/linkhelper.hxx))
diff --git a/comphelper/inc/comphelper/linkhelper.hxx b/comphelper/inc/comphelper/linkhelper.hxx
new file mode 100644
index 0000000..493e8d2
--- /dev/null
+++ b/comphelper/inc/comphelper/linkhelper.hxx
@@ -0,0 +1,45 @@
+/* -*- 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. 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.
+ *
+ * The Initial Developer of the Original Code is
+ *        Caolán McNamara <caolanm at redhat.com> (Red Hat, Inc.)
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Caolán McNamara <caolanm at redhat.com>
+ *
+ * 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 _LINKHELPER_HXX
+#define _LINKHELPER_HXX
+
+#include "comphelper/comphelperdllapi.h"
+#include <rtl/ustring.hxx>
+
+namespace comphelper
+{
+    /** Resolve a file url if its a symbolic link, to a depth of nDepth
+     *
+     *  @return false on failure, true on success
+     */
+    COMPHELPER_DLLPUBLIC bool resolveLink(rtl::OUString &rURL, int nDepth = 128);
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/comphelper/source/misc/linkhelper.cxx b/comphelper/source/misc/linkhelper.cxx
new file mode 100644
index 0000000..1ec9327
--- /dev/null
+++ b/comphelper/source/misc/linkhelper.cxx
@@ -0,0 +1,64 @@
+/* -*- 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. 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.
+ *
+ * The Initial Developer of the Original Code is
+ *        Caolán McNamara <caolanm at redhat.com> (Red Hat, Inc.)
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Caolán McNamara <caolanm at redhat.com>
+ *
+ * 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.
+ */
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_comphelper.hxx"
+
+#include <comphelper/linkhelper.hxx>
+#include <osl/file.hxx>
+
+namespace comphelper
+{
+    /** Resolve a file url if its a symbolic link, to a depth of nDepth
+     *
+     *  @return false on failure, true on success
+     */
+    bool resolveLink(rtl::OUString &rURL, int nDepth)
+    {
+        bool bReturn = false;
+
+        osl::FileStatus status(osl_FileStatus_Mask_Type | osl_FileStatus_Mask_LinkTargetURL);
+        osl::DirectoryItem item;
+        while (osl::DirectoryItem::get(rURL, item) == osl::File::E_None)
+        {
+            if (--nDepth == 0)
+                break;
+            if (item.getFileStatus(status) != osl::File::E_None)
+                break;
+            if (status.getFileType() != osl::FileStatus::Link)
+            {
+                bReturn = true;
+                break;
+            }
+            rURL = status.getLinkTargetURL();
+        }
+
+        return bReturn;
+    }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit e5f0d5c39ac7ad08bcab3d9503b77ae27c7200d0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 24 09:11:25 2011 +0100

    WaE: enable exceptions

diff --git a/vcl/source/control/makefile.mk b/vcl/source/control/makefile.mk
index de2613b..0a69d6c 100644
--- a/vcl/source/control/makefile.mk
+++ b/vcl/source/control/makefile.mk
@@ -29,6 +29,7 @@ PRJ=..$/..
 
 PRJNAME=vcl
 TARGET=ctrl
+ENABLE_EXCEPTIONS = TRUE
 
 .INCLUDE :	$(PRJ)$/util$/makefile.pmk
 
@@ -37,22 +38,16 @@ TARGET=ctrl
 .INCLUDE :	settings.mk
 .INCLUDE :  $(PRJ)$/util$/makefile2.pmk
 
-.IF "$(COM)"=="ICC"
-CDEFS+=-D_STD_NO_NAMESPACE -D_VOS_NO_NAMESPACE -D_UNO_NO_NAMESPACE
-.ENDIF
-
 # --- Files --------------------------------------------------------
 
-EXCEPTIONSFILES=					\
+SLOFILES=\
             $(SLO)$/button.obj		\
             $(SLO)$/ctrl.obj		\
             $(SLO)$/edit.obj		\
             $(SLO)$/field2.obj		\
             $(SLO)$/ilstbox.obj		\
             $(SLO)$/tabctrl.obj		\
-            $(SLO)$/throbber.obj
-
-SLOFILES=	$(EXCEPTIONSFILES)      \
+            $(SLO)$/throbber.obj	\
             $(SLO)$/combobox.obj	\
             $(SLO)$/field.obj		\
             $(SLO)$/fixbrd.obj		\


More information about the Libreoffice-commits mailing list