summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2003-09-19 07:01:51 +0000
committerRüdiger Timm <rt@openoffice.org>2003-09-19 07:01:51 +0000
commit36a9cb3c0884383a262d6d8967009ad51e54af75 (patch)
treec9c115c9c5cca5336165e4b370a817b2676c133a /sfx2
parent5597cc178630d9a051663007725da37246aaabb2 (diff)
INTEGRATION: CWS fwkq1 (1.36.50); FILE MERGED
2003/08/22 15:05:56 mba 1.36.50.3: #111622#: objectshells have different refcount behavior than simple objects 2003/08/21 07:51:08 mba 1.36.50.2: #110843#: wrong short name for master document 2003/07/14 18:00:18 mba 1.36.50.1: #110843#: get rid of factories
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/doc/objxtor.cxx89
1 files changed, 87 insertions, 2 deletions
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index 6e1d5f18a480..7ad12be0a23b 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: objxtor.cxx,v $
*
- * $Revision: 1.37 $
+ * $Revision: 1.38 $
*
- * last change: $Author: kz $ $Date: 2003-08-27 16:23:12 $
+ * last change: $Author: rt $ $Date: 2003-09-19 08:01:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -121,12 +121,16 @@
#ifndef INCLUDED_SVTOOLS_PRINTWARNINGOPTIONS_HXX
#include <svtools/printwarningoptions.hxx>
#endif
+#ifndef _UNOTOOLS_PROCESSFACTORY_HXX
+#include <comphelper/processfactory.hxx>
+#endif
#include <svtools/urihelper.hxx>
#include <svtools/pathoptions.hxx>
#include <unotools/localfilehelper.hxx>
#include <unotools/ucbhelper.hxx>
#include <svtools/asynclink.hxx>
+#include <sot/clsids.hxx>
#include "docfac.hxx"
#include "docfile.hxx"
@@ -977,3 +981,84 @@ SfxObjectShell* SfxObjectShell::GetWorkingDocument()
{
return pWorkingDoc;
}
+
+
+String SfxObjectShell::GetServiceNameFromFactory( const String& rFact )
+{
+ //! Remove everything behind name!
+ String aFact( rFact );
+ String aPrefix = String::CreateFromAscii( "private:factory/" );
+ if ( aPrefix.Len() == aFact.Match( aPrefix ) )
+ aFact.Erase( 0, aPrefix.Len() );
+ USHORT nPos = aFact.Search( '?' );
+ String aParam;
+ if ( nPos != STRING_NOTFOUND )
+ {
+ aParam = aFact.Copy( nPos, aFact.Len() );
+ aFact.Erase( nPos, aFact.Len() );
+ aParam.Erase(0,1);
+ }
+
+ aFact.EraseAllChars('4').ToLowerAscii();
+ ::rtl::OUString aServiceName;
+ if ( aFact.EqualsAscii("swriter") )
+ {
+ aServiceName = ::rtl::OUString::createFromAscii("com.sun.star.text.TextDocument");
+ }
+ else if ( aFact.EqualsAscii("swriter/web") )
+ {
+ aServiceName = ::rtl::OUString::createFromAscii("com.sun.star.text.WebDocument");
+ }
+ else if ( aFact.EqualsAscii("swriter/globaldocument") )
+ {
+ aServiceName = ::rtl::OUString::createFromAscii("com.sun.star.text.GlobalDocument");
+ }
+ else if ( aFact.EqualsAscii("scalc") )
+ {
+ aServiceName = ::rtl::OUString::createFromAscii("com.sun.star.sheet.SpreadsheetDocument");
+ }
+ else if ( aFact.EqualsAscii("sdraw") )
+ {
+ aServiceName = ::rtl::OUString::createFromAscii("com.sun.star.drawing.DrawingDocument");
+ }
+ else if ( aFact.EqualsAscii("simpress") )
+ {
+ aServiceName = ::rtl::OUString::createFromAscii("com.sun.star.presentation.PresentationDocument");
+ }
+ else if ( aFact.EqualsAscii("schart") )
+ {
+ aServiceName = ::rtl::OUString::createFromAscii("com.sun.star.chart.ChartDocument");
+ }
+ else if ( aFact.EqualsAscii("smath") )
+ {
+ aServiceName = ::rtl::OUString::createFromAscii("com.sun.star.formula.FormulaProperties");
+ }
+
+ return aServiceName;
+}
+
+SfxObjectShell* SfxObjectShell::CreateObjectByFactoryName( const String& rFact, SfxObjectCreateMode eMode )
+{
+ return CreateObject( GetServiceNameFromFactory( rFact ), eMode );
+}
+
+
+SfxObjectShell* SfxObjectShell::CreateObject( const String& rServiceName, SfxObjectCreateMode eMode )
+{
+ if ( rServiceName.Len() )
+ {
+ ::com::sun::star::uno::Reference < ::com::sun::star::frame::XModel > xDoc(
+ ::comphelper::getProcessServiceFactory()->createInstance( rServiceName ), UNO_QUERY );
+ if ( xDoc.is() )
+ {
+ ::com::sun::star::uno::Reference < ::com::sun::star::lang::XUnoTunnel > xObj( xDoc, UNO_QUERY );
+ ::com::sun::star::uno::Sequence < sal_Int8 > aSeq( (sal_Int8*) SvGlobalName( SFX_GLOBAL_CLASSID ).GetBytes(), 16 );
+ sal_Int64 nHandle = xObj->getSomething( aSeq );
+ if ( nHandle )
+ return (SfxObjectShell*) (sal_Int32*) nHandle;
+ }
+ }
+
+ return 0;
+}
+