Anonymous avatar Anonymous committed 034e665

fwk152: #i108004# check the URLs correctly

Comments (0)

Files changed (9)

framework/source/loadenv/loadenv.cxx

 #include <unotools/moduleoptions.hxx>
 #include <svtools/sfxecode.hxx>
 #include <unotools/processfactory.hxx>
+#include <unotools/ucbhelper.hxx>
 #include <comphelper/configurationhelper.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <vcl/svapp.hxx>
             // don't check the complete URL here.
             // use its main part - ignore optional jumpmarks!
 			const ::rtl::OUString sURL = xModel->getURL();
-            if (!m_aURL.Main.equals(sURL))
+            if (!::utl::UCBContentHelper::EqualURLs( m_aURL.Main, sURL ))
 			{
 				xTask.clear ();
                 continue;

sfx2/inc/sfx2/docfile.hxx

 
     static com::sun::star::uno::Sequence < com::sun::star::util::RevisionTag > GetVersionList(
 					const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
-	static sal_Bool EqualURLs( const ::rtl::OUString& aFirstURL, const ::rtl::OUString& aSecondURL );
 	static ::rtl::OUString CreateTempCopyWithExt( const ::rtl::OUString& aURL );
     static sal_Bool CallApproveHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler, ::com::sun::star::uno::Any aRequest, sal_Bool bAllowAbort );
 

sfx2/source/doc/docfile.cxx

 	pImp->m_nSignatureState = nState;
 }
 
-//----------------------------------------------------------------
-sal_Bool SfxMedium::EqualURLs( const ::rtl::OUString& aFirstURL, const ::rtl::OUString& aSecondURL )
-{
-	sal_Bool bResult = sal_False;
-
-	if ( aFirstURL.getLength() && aSecondURL.getLength() )
-	{
-		INetURLObject aFirst( aFirstURL );
-		INetURLObject aSecond( aSecondURL );
-
-        if ( aFirst.GetProtocol() != INET_PROT_NOT_VALID && aSecond.GetProtocol() != INET_PROT_NOT_VALID )
-		{
-			try
-			{
-    			::ucbhelper::ContentBroker* pBroker = ::ucbhelper::ContentBroker::get();
-				if ( !pBroker )
-					throw uno::RuntimeException();
-
-				uno::Reference< ::com::sun::star::ucb::XContentIdentifierFactory > xIdFac
-					= pBroker->getContentIdentifierFactoryInterface();
-				if ( !xIdFac.is() )
-					throw uno::RuntimeException();
-
-				uno::Reference< ::com::sun::star::ucb::XContentIdentifier > xIdFirst
-					= xIdFac->createContentIdentifier( aFirst.GetMainURL( INetURLObject::NO_DECODE ) );
-				uno::Reference< ::com::sun::star::ucb::XContentIdentifier > xIdSecond
-					= xIdFac->createContentIdentifier( aSecond.GetMainURL( INetURLObject::NO_DECODE ) );
-
-				if ( xIdFirst.is() && xIdSecond.is() )
-				{
-					uno::Reference< ::com::sun::star::ucb::XContentProvider > xProvider =
-															pBroker->getContentProviderInterface();
-					if ( !xProvider.is() )
-						throw uno::RuntimeException();
-					bResult = !xProvider->compareContentIds( xIdFirst, xIdSecond );
-				}
-			}
-			catch( uno::Exception& )
-			{
-				OSL_ENSURE( sal_False, "Can't compare URL's, treat as different!\n" );
-			}
-		}
-	}
-
-	return bResult;
-}
-
 BOOL SfxMedium::HasStorage_Impl() const
 {
     return pImp->xStorage.is();

sfx2/source/doc/doctemplates.cxx

 		aStoreArgs[1].Value <<= rTemplateName;
 
 		::rtl::OUString aCurrentDocumentURL = rStorable->getLocation();
-		if( !SfxMedium::EqualURLs( aNewTemplateTargetURL, rStorable->getLocation() ))
+		if( !::utl::UCBContentHelper::EqualURLs( aNewTemplateTargetURL, rStorable->getLocation() ))
 			rStorable->storeToURL( aNewTemplateTargetURL, aStoreArgs );
 		else
 			rStorable->store();

sfx2/source/doc/objmisc.cxx

     SetSharedXMLFlag( sal_False );
 
     if ( IsDocShared() && aTempFileURL.getLength()
-      && !SfxMedium::EqualURLs( aTempFileURL, GetSharedFileURL() ) )
+      && !::utl::UCBContentHelper::EqualURLs( aTempFileURL, GetSharedFileURL() ) )
     {
         if ( pImp->m_bAllowShareControlFileClean )
         {

sfx2/source/doc/objstor.cxx

     if ( pMedium
       && pMedium->GetName().CompareIgnoreCaseToAscii( "private:stream", 14 ) != COMPARE_EQUAL
       && rMedium.GetName().CompareIgnoreCaseToAscii( "private:stream", 14 ) != COMPARE_EQUAL
-      && SfxMedium::EqualURLs( pMedium->GetName(), rMedium.GetName() ) )
+      && ::utl::UCBContentHelper::EqualURLs( pMedium->GetName(), rMedium.GetName() ) )
     {
         bStoreToSameLocation = sal_True;
         AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Save" ) ) );

sfx2/source/doc/sfxbasemodel.cxx

 #include <framework/titlehelper.hxx>
 #include <comphelper/numberedcollection.hxx>
 #include <unotools/ucbstreamhelper.hxx>
+#include <unotools/ucbhelper.hxx>
 
 //________________________________________________________________________________________________________
 //	includes of my own project
     sal_Bool bSaved = sal_False;
     if ( !bSaveTo && m_pData->m_pObjectShell && sURL.getLength()
       && sURL.compareToAscii( "private:stream", 14 ) != COMPARE_EQUAL
-	  && SfxMedium::EqualURLs( getLocation(), sURL ) )
+	  && ::utl::UCBContentHelper::EqualURLs( getLocation(), sURL ) )
     {
         // this is the same file URL as the current document location, try to use storeOwn if possible
 

unotools/inc/unotools/ucbhelper.hxx

         static sal_Bool             FindInPath( const String& rPath, const String& rName, String& rFile, char cDelim = ';', BOOL bAllowWildCards = TRUE );
         static sal_Bool             Find( const String& rFolder, const String& rName, String& rFile, BOOL bAllowWildCards = FALSE );
 		static sal_Bool				IsSubPath( const ::rtl::OUString& rPath, const ::rtl::OUString& rChildCandidate, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentProvider >& xContentProvider = ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentProvider >() );
+        static sal_Bool             EqualURLs( const ::rtl::OUString& aFirstURL, const ::rtl::OUString& aSecondURL );
     };
 }
 

unotools/source/ucbhelper/ucbhelper.cxx

     return bResult;
 }
 
+// -----------------------------------------------------------------------
+sal_Bool UCBContentHelper::EqualURLs( const ::rtl::OUString& aFirstURL, const ::rtl::OUString& aSecondURL )
+{
+	sal_Bool bResult = sal_False;
+
+	if ( aFirstURL.getLength() && aSecondURL.getLength() )
+	{
+		INetURLObject aFirst( aFirstURL );
+		INetURLObject aSecond( aSecondURL );
+
+        if ( aFirst.GetProtocol() != INET_PROT_NOT_VALID && aSecond.GetProtocol() != INET_PROT_NOT_VALID )
+		{
+			try
+			{
+    			::ucbhelper::ContentBroker* pBroker = ::ucbhelper::ContentBroker::get();
+				if ( !pBroker )
+					throw uno::RuntimeException();
+
+				uno::Reference< ::com::sun::star::ucb::XContentIdentifierFactory > xIdFac
+					= pBroker->getContentIdentifierFactoryInterface();
+				if ( !xIdFac.is() )
+					throw uno::RuntimeException();
+
+				uno::Reference< ::com::sun::star::ucb::XContentIdentifier > xIdFirst
+					= xIdFac->createContentIdentifier( aFirst.GetMainURL( INetURLObject::NO_DECODE ) );
+				uno::Reference< ::com::sun::star::ucb::XContentIdentifier > xIdSecond
+					= xIdFac->createContentIdentifier( aSecond.GetMainURL( INetURLObject::NO_DECODE ) );
+
+				if ( xIdFirst.is() && xIdSecond.is() )
+				{
+					uno::Reference< ::com::sun::star::ucb::XContentProvider > xProvider =
+															pBroker->getContentProviderInterface();
+					if ( !xProvider.is() )
+						throw uno::RuntimeException();
+					bResult = !xProvider->compareContentIds( xIdFirst, xIdSecond );
+				}
+			}
+			catch( uno::Exception& )
+			{
+				OSL_ENSURE( sal_False, "Can't compare URL's, treat as different!\n" );
+			}
+		}
+	}
+
+	return bResult;
+}
+
+
+
 } // namespace utl
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.