summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2011-08-30 00:05:53 -0400
committerKohei Yoshida <kohei.yoshida@suse.com>2011-08-30 00:19:35 -0400
commit3c2a26c84e70fd996855181d319970e2230b2459 (patch)
treec7797f0cfd3183454e0ade5717b3989f7ac6e1c7
parent382ac86a3ab9ba105aa3e469566b7cd86c6ca39f (diff)
More string conversion around ScDocumentLoader.
-rw-r--r--sc/inc/tablink.hxx15
-rw-r--r--sc/source/filter/xml/XMLTableSourceContext.cxx15
-rw-r--r--sc/source/ui/docshell/arealink.cxx17
-rw-r--r--sc/source/ui/docshell/docfunc.cxx11
-rw-r--r--sc/source/ui/docshell/docsh4.cxx19
-rw-r--r--sc/source/ui/docshell/tablink.cxx37
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx14
7 files changed, 67 insertions, 61 deletions
diff --git a/sc/inc/tablink.hxx b/sc/inc/tablink.hxx
index 5fd98df2d7e5..4dba3164f515 100644
--- a/sc/inc/tablink.hxx
+++ b/sc/inc/tablink.hxx
@@ -89,6 +89,10 @@ private:
SfxObjectShellRef aRef;
SfxMedium* pMedium;
+ static bool GetFilterName( const String& rFileName,
+ String& rFilter, String& rOptions,
+ bool bWithContent, bool bWithInteraction );
+
public:
ScDocumentLoader( const String& rFileName,
String& rFilterName, String& rOptions,
@@ -96,27 +100,24 @@ public:
~ScDocumentLoader();
ScDocument* GetDocument();
ScDocShell* GetDocShell() { return pDocShell; }
- sal_Bool IsError() const;
- String GetTitle() const;
+ bool IsError() const;
+ rtl::OUString GetTitle() const;
void ReleaseDocRef(); // without calling DoClose
- static String GetOptions( SfxMedium& rMedium );
+ static rtl::OUString GetOptions( SfxMedium& rMedium );
/** Returns the filter name and options from a file name.
@param bWithContent
true = Tries to detect the filter by looking at the file contents.
false = Detects filter by file name extension only (should be used in filter code only).
@return sal_True if a filter could be found, sal_False otherwise. */
- static sal_Bool GetFilterName( const String& rFileName,
- String& rFilter, String& rOptions,
- sal_Bool bWithContent, sal_Bool bWithInteraction );
static bool GetFilterName( const ::rtl::OUString& rFileName,
::rtl::OUString& rFilter, ::rtl::OUString& rOptions,
bool bWithContent, bool bWithInteraction );
- static void RemoveAppPrefix( String& rFilterName );
+ static void RemoveAppPrefix( rtl::OUString& rFilterName );
};
#endif
diff --git a/sc/source/filter/xml/XMLTableSourceContext.cxx b/sc/source/filter/xml/XMLTableSourceContext.cxx
index 8e55441f4c90..6877984f21fa 100644
--- a/sc/source/filter/xml/XMLTableSourceContext.cxx
+++ b/sc/source/filter/xml/XMLTableSourceContext.cxx
@@ -121,14 +121,9 @@ void ScXMLTableSourceContext::EndElement()
if (pDoc->RenameTab( GetScImport().GetTables().GetCurrentSheet(),
GetScImport().GetTables().GetCurrentSheetName(), false, sal_True))
{
- String aFileString(sLink);
- String aFilterString(sFilterName);
- String aOptString(sFilterOptions);
- String aSheetString(sTableName);
-
- aFileString = ScGlobal::GetAbsDocName( aFileString, pDoc->GetDocumentShell() );
- if ( !aFilterString.Len() )
- ScDocumentLoader::GetFilterName( aFileString, aFilterString, aOptString, false, false );
+ sLink = ScGlobal::GetAbsDocName( sLink, pDoc->GetDocumentShell() );
+ if (sFilterName.isEmpty())
+ ScDocumentLoader::GetFilterName( sLink, sFilterName, sFilterOptions, false, false );
sal_uInt8 nLinkMode = SC_LINK_NONE;
if ( nMode == sheet::SheetLinkMode_NORMAL )
@@ -137,8 +132,8 @@ void ScXMLTableSourceContext::EndElement()
nLinkMode = SC_LINK_VALUE;
pDoc->SetLink( GetScImport().GetTables().GetCurrentSheet(),
- nLinkMode, aFileString, aFilterString, aOptString,
- aSheetString, nRefresh );
+ nLinkMode, sLink, sFilterName, sFilterOptions,
+ sTableName, nRefresh );
}
}
}
diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx
index a028a5129b70..9928ea783eb9 100644
--- a/sc/source/ui/docshell/arealink.cxx
+++ b/sc/source/ui/docshell/arealink.cxx
@@ -130,23 +130,28 @@ void ScAreaLink::Edit(Window* pParent, const Link& /* rEndEditHdl */ )
sfx2::LinkManager* pLinkManager=pImpl->m_pDocSh->GetDocument()->GetLinkManager();
if (pLinkManager!=NULL)
{
- String aFile;
- String aFilter;
- String aArea;
- pLinkManager->GetDisplayNames( this,0,&aFile,&aArea,&aFilter);
+ String aTmp1;
+ String aTmp2;
+ String aTmp3;
+ pLinkManager->GetDisplayNames(this, NULL, &aTmp1, &aTmp2, &aTmp3);
+ rtl::OUString aFile = aTmp1;
+ rtl::OUString aArea = aTmp2;
+ rtl::OUString aFilter = aTmp3;
// the file dialog returns the filter name with the application prefix
// -> remove prefix
ScDocumentLoader::RemoveAppPrefix( aFilter );
// dialog doesn't set area, so keep old one
- if ( !aArea.Len() )
+ if (aArea.isEmpty())
{
aArea = aSourceArea;
// adjust in dialog:
String aNewLinkName;
- sfx2::MakeLnkName( aNewLinkName, NULL, aFile, aArea, &aFilter );
+ aTmp1 = aFilter;
+ sfx2::MakeLnkName(aNewLinkName, NULL, aFile, aArea, &aTmp1);
+ aFilter = aTmp1;
SetName( aNewLinkName );
}
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index cb79c5026c75..7d2774b47942 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -4902,10 +4902,10 @@ sal_Bool ScDocFunc::InsertAreaLink( const String& rFile, const String& rFilter,
++nLinkPos;
}
- String aFilterName = rFilter;
- String aNewOptions = rOptions;
- if (!aFilterName.Len())
- ScDocumentLoader::GetFilterName( rFile, aFilterName, aNewOptions, sal_True, !bApi );
+ rtl::OUString aFilterName = rFilter;
+ rtl::OUString aNewOptions = rOptions;
+ if (aFilterName.isEmpty())
+ ScDocumentLoader::GetFilterName( rFile, aFilterName, aNewOptions, true, !bApi );
// remove application prefix from filter name here, so the filter options
// aren't reset when the filter name is changed in ScAreaLink::DataChanged
@@ -4913,7 +4913,8 @@ sal_Bool ScDocFunc::InsertAreaLink( const String& rFile, const String& rFilter,
ScAreaLink* pLink = new ScAreaLink( &rDocShell, rFile, aFilterName,
aNewOptions, rSource, rDestRange, nRefresh );
- pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, rFile, &aFilterName, &rSource );
+ String aTmp = aFilterName;
+ pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, rFile, &aTmp, &rSource );
// Undo fuer den leeren Link
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 5fe6de5ffafd..80034f0f5f53 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -713,30 +713,31 @@ void ScDocShell::Execute( SfxRequest& rReq )
pReqArgs->GetItemState( SID_FILE_NAME, sal_True, &pItem ) == SFX_ITEM_SET &&
pItem->ISA(SfxStringItem) )
{
- String aFileName = ((const SfxStringItem*)pItem)->GetValue();
+ rtl::OUString aFileName =
+ static_cast<const SfxStringItem*>(pItem)->GetValue();
- String aFilterName;
+ rtl::OUString aFilterName;
if ( pReqArgs->GetItemState( SID_FILTER_NAME, sal_True, &pItem ) == SFX_ITEM_SET &&
pItem->ISA(SfxStringItem) )
{
- aFilterName = ((const SfxStringItem*)pItem)->GetValue();
+ aFilterName = static_cast<const SfxStringItem*>(pItem)->GetValue();
}
- String aOptions;
+ rtl::OUString aOptions;
if ( pReqArgs->GetItemState( SID_FILE_FILTEROPTIONS, sal_True, &pItem ) == SFX_ITEM_SET &&
pItem->ISA(SfxStringItem) )
{
- aOptions = ((const SfxStringItem*)pItem)->GetValue();
+ aOptions = static_cast<const SfxStringItem*>(pItem)->GetValue();
}
short nVersion = 0;
if ( pReqArgs->GetItemState( SID_VERSION, sal_True, &pItem ) == SFX_ITEM_SET &&
pItem->ISA(SfxInt16Item) )
{
- nVersion = ((const SfxInt16Item*)pItem)->GetValue();
+ nVersion = static_cast<const SfxInt16Item*>(pItem)->GetValue();
}
// kein Filter angegeben -> Detection
- if ( !aFilterName.Len() )
- ScDocumentLoader::GetFilterName( aFileName, aFilterName, aOptions, sal_True, false );
+ if (aFilterName.isEmpty())
+ ScDocumentLoader::GetFilterName( aFileName, aFilterName, aOptions, true, false );
// filter name from dialog contains application prefix,
// GetFilter needs name without the prefix.
@@ -744,7 +745,7 @@ void ScDocShell::Execute( SfxRequest& rReq )
const SfxFilter* pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName( aFilterName );
SfxItemSet* pSet = new SfxAllItemSet( pApp->GetPool() );
- if ( aOptions.Len() )
+ if (!aOptions.isEmpty())
pSet->Put( SfxStringItem( SID_FILE_FILTEROPTIONS, aOptions ) );
if ( nVersion != 0 )
pSet->Put( SfxInt16Item( SID_VERSION, nVersion ) );
diff --git a/sc/source/ui/docshell/tablink.cxx b/sc/source/ui/docshell/tablink.cxx
index 9cfd9e8a11ed..a72e439aa2f1 100644
--- a/sc/source/ui/docshell/tablink.cxx
+++ b/sc/source/ui/docshell/tablink.cxx
@@ -149,9 +149,11 @@ void ScTableLink::Edit( Window* pParent, const Link& rEndEditHdl )
sfx2::LinkManager* pLinkManager=pImpl->m_pDocSh->GetDocument()->GetLinkManager();
if (pLinkManager!=NULL)
{
- String aFile;
- String aFilter;
- pLinkManager->GetDisplayNames( this,0,&aFile,NULL,&aFilter);
+ String aTmp1;
+ String aTmp2;
+ pLinkManager->GetDisplayNames(this, 0, &aTmp1, NULL, &aTmp2);
+ rtl::OUString aFile = aTmp1;
+ rtl::OUString aFilter = aTmp2;
// the file dialog returns the filter name with the application prefix
// -> remove prefix
@@ -458,19 +460,19 @@ IMPL_LINK( ScTableLink, TableEndEditHdl, ::sfx2::SvBaseLink*, pLink )
// === ScDocumentLoader ==================================================
-String ScDocumentLoader::GetOptions( SfxMedium& rMedium )
+rtl::OUString ScDocumentLoader::GetOptions( SfxMedium& rMedium )
{
SfxItemSet* pSet = rMedium.GetItemSet();
const SfxPoolItem* pItem;
- if ( pSet && SFX_ITEM_SET == pSet->GetItemState( SID_FILE_FILTEROPTIONS, sal_True, &pItem ) )
+ if ( pSet && SFX_ITEM_SET == pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
return ((const SfxStringItem*)pItem)->GetValue();
return EMPTY_STRING;
}
-sal_Bool ScDocumentLoader::GetFilterName( const String& rFileName,
- String& rFilter, String& rOptions,
- sal_Bool bWithContent, sal_Bool bWithInteraction )
+bool ScDocumentLoader::GetFilterName( const String& rFileName,
+ String& rFilter, String& rOptions,
+ bool bWithContent, bool bWithInteraction )
{
TypeId aScType = TYPE(ScDocShell);
SfxObjectShell* pDocSh = SfxObjectShell::GetFirst( &aScType );
@@ -535,13 +537,14 @@ bool ScDocumentLoader::GetFilterName(
return bRet;
}
-void ScDocumentLoader::RemoveAppPrefix( String& rFilterName )
+void ScDocumentLoader::RemoveAppPrefix( rtl::OUString& rFilterName )
{
- String aAppPrefix = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( STRING_SCAPP ));
- aAppPrefix.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
- xub_StrLen nPreLen = aAppPrefix.Len();
- if ( rFilterName.Copy(0,nPreLen) == aAppPrefix )
- rFilterName.Erase(0,nPreLen);
+ rtl::OUStringBuffer aAppPrefix;
+ aAppPrefix.appendAscii(STRING_SCAPP);
+ aAppPrefix.appendAscii(": ");
+ sal_Int32 nPreLen = aAppPrefix.getLength();
+ if (rFilterName.copy(0, nPreLen).equals(aAppPrefix.makeStringAndClear()))
+ rFilterName = rFilterName.copy(nPreLen);
}
ScDocumentLoader::ScDocumentLoader( const String& rFileName,
@@ -615,15 +618,15 @@ ScDocument* ScDocumentLoader::GetDocument()
return pDocShell ? pDocShell->GetDocument() : 0;
}
-sal_Bool ScDocumentLoader::IsError() const
+bool ScDocumentLoader::IsError() const
{
if ( pDocShell && pMedium )
return pMedium->GetError() != ERRCODE_NONE;
else
- return sal_True;
+ return true;
}
-String ScDocumentLoader::GetTitle() const
+rtl::OUString ScDocumentLoader::GetTitle() const
{
if ( pDocShell )
return pDocShell->GetTitle();
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index f6543d62bfc8..e44cea5eaa28 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -7694,14 +7694,14 @@ void SAL_CALL ScTableSheetObj::link( const rtl::OUString& aUrl, const rtl::OUStr
ScDocument* pDoc = pDocSh->GetDocument();
SCTAB nTab = GetTab_Impl();
- String aFileString (aUrl);
- String aFilterString (aFilterName);
- String aOptString (aFilterOptions);
- String aSheetString (aSheetName);
+ rtl::OUString aFileString = aUrl;
+ rtl::OUString aFilterString = aFilterName;
+ rtl::OUString aOptString = aFilterOptions;
+ rtl::OUString aSheetString = aSheetName;
aFileString = ScGlobal::GetAbsDocName( aFileString, pDocSh );
- if ( !aFilterString.Len() )
- ScDocumentLoader::GetFilterName( aFileString, aFilterString, aOptString, sal_True, false );
+ if (aFilterString.isEmpty())
+ ScDocumentLoader::GetFilterName( aFileString, aFilterString, aOptString, true, false );
// remove application prefix from filter name here, so the filter options
// aren't reset when the filter name is changed in ScTableLink::DataChanged
@@ -7736,7 +7736,7 @@ void SAL_CALL ScTableSheetObj::link( const rtl::OUString& aUrl, const rtl::OUStr
if (pBase->ISA(ScTableLink))
{
ScTableLink* pTabLink = (ScTableLink*)pBase;
- if ( pTabLink->GetFileName() == aFileString )
+ if ( aFileString.equals(pTabLink->GetFileName()) )
pTabLink->Update(); // inkl. Paint&Undo
//! Der Dateiname sollte nur einmal vorkommen (?)