Kaydet (Commit) 9be8cc68 authored tarafından Matteo Casalin's avatar Matteo Casalin Kaydeden (comit) Michael Stahl

String to OUString and hide implementation details

Change-Id: I91ca70273b2262f8aee7e7bb8000d1271e727b18
Reviewed-on: https://gerrit.libreoffice.org/5617Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
Tested-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst 90f83bd7
...@@ -42,17 +42,13 @@ ...@@ -42,17 +42,13 @@
#include <com/sun/star/text/XTextFramesSupplier.hpp> #include <com/sun/star/text/XTextFramesSupplier.hpp>
#include <com/sun/star/text/XTextFrame.hpp> #include <com/sun/star/text/XTextFrame.hpp>
#include <comphelper/string.hxx> #include <comphelper/string.hxx>
#include "initui.hxx"
#include <frmui.hrc> #include <frmui.hrc>
#include <globals.hrc> #include <globals.hrc>
#include <SwStyleNameMapper.hxx> #include <SwStyleNameMapper.hxx>
using namespace ::com::sun::star; using namespace ::com::sun::star;
extern String* GetOldGrfCat();
extern String* GetOldTabCat();
extern String* GetOldFrmCat();
extern String* GetOldDrwCat();
class SwSequenceOptionDialog : public SvxStandardDialog class SwSequenceOptionDialog : public SvxStandardDialog
{ {
ListBox* m_pLbLevel; ListBox* m_pLbLevel;
...@@ -144,12 +140,12 @@ SwCaptionDialog::SwCaptionDialog( Window *pParent, SwView &rV ) : ...@@ -144,12 +140,12 @@ SwCaptionDialog::SwCaptionDialog( Window *pParent, SwView &rV ) :
m_pCategoryBox->InsertEntry(pType->GetName()); m_pCategoryBox->InsertEntry(pType->GetName());
} }
String* pString = 0; OUString sString;
sal_uInt16 nPoolId = 0; sal_uInt16 nPoolId = 0;
if (eType & nsSelectionType::SEL_GRF) if (eType & nsSelectionType::SEL_GRF)
{ {
nPoolId = RES_POOLCOLL_LABEL_ABB; nPoolId = RES_POOLCOLL_LABEL_ABB;
pString = ::GetOldGrfCat(); sString = ::GetOldGrfCat();
bCopyAttributes = sal_True; bCopyAttributes = sal_True;
sObjectName = rSh.GetFlyName(); sObjectName = rSh.GetFlyName();
//if not OLE //if not OLE
...@@ -163,7 +159,7 @@ SwCaptionDialog::SwCaptionDialog( Window *pParent, SwView &rV ) : ...@@ -163,7 +159,7 @@ SwCaptionDialog::SwCaptionDialog( Window *pParent, SwView &rV ) :
else if( eType & nsSelectionType::SEL_TBL ) else if( eType & nsSelectionType::SEL_TBL )
{ {
nPoolId = RES_POOLCOLL_LABEL_TABLE; nPoolId = RES_POOLCOLL_LABEL_TABLE;
pString = ::GetOldTabCat(); sString = ::GetOldTabCat();
uno::Reference< text::XTextTablesSupplier > xTables(xModel, uno::UNO_QUERY); uno::Reference< text::XTextTablesSupplier > xTables(xModel, uno::UNO_QUERY);
xNameAccess = xTables->getTextTables(); xNameAccess = xTables->getTextTables();
sObjectName = rSh.GetTableFmt()->GetName(); sObjectName = rSh.GetTableFmt()->GetName();
...@@ -171,7 +167,7 @@ SwCaptionDialog::SwCaptionDialog( Window *pParent, SwView &rV ) : ...@@ -171,7 +167,7 @@ SwCaptionDialog::SwCaptionDialog( Window *pParent, SwView &rV ) :
else if( eType & nsSelectionType::SEL_FRM ) else if( eType & nsSelectionType::SEL_FRM )
{ {
nPoolId = RES_POOLCOLL_LABEL_FRAME; nPoolId = RES_POOLCOLL_LABEL_FRAME;
pString = ::GetOldFrmCat(); sString = ::GetOldFrmCat();
uno::Reference< text::XTextFramesSupplier > xFrms(xModel, uno::UNO_QUERY); uno::Reference< text::XTextFramesSupplier > xFrms(xModel, uno::UNO_QUERY);
xNameAccess = xFrms->getTextFrames(); xNameAccess = xFrms->getTextFrames();
sObjectName = rSh.GetFlyName(); sObjectName = rSh.GetFlyName();
...@@ -179,17 +175,17 @@ SwCaptionDialog::SwCaptionDialog( Window *pParent, SwView &rV ) : ...@@ -179,17 +175,17 @@ SwCaptionDialog::SwCaptionDialog( Window *pParent, SwView &rV ) :
else if( eType == nsSelectionType::SEL_TXT ) else if( eType == nsSelectionType::SEL_TXT )
{ {
nPoolId = RES_POOLCOLL_LABEL_FRAME; nPoolId = RES_POOLCOLL_LABEL_FRAME;
pString = ::GetOldFrmCat(); sString = ::GetOldFrmCat();
} }
else if( eType & nsSelectionType::SEL_DRW ) else if( eType & nsSelectionType::SEL_DRW )
{ {
nPoolId = RES_POOLCOLL_LABEL_DRAWING; nPoolId = RES_POOLCOLL_LABEL_DRAWING;
pString = ::GetOldDrwCat(); sString = ::GetOldDrwCat();
} }
if( nPoolId ) if( nPoolId )
{ {
if( pString && pString->Len()) if (!sString.isEmpty())
m_pCategoryBox->SetText( *pString ); m_pCategoryBox->SetText( sString );
else else
m_pCategoryBox->SetText( m_pCategoryBox->SetText(
SwStyleNameMapper::GetUIName( nPoolId, aEmptyStr )); SwStyleNameMapper::GetUIName( nPoolId, aEmptyStr ));
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "tools/solar.h" #include "tools/solar.h"
#include "swdllapi.h" #include "swdllapi.h"
#include "rtl/ustring.hxx"
#include <vector> #include <vector>
...@@ -35,19 +36,17 @@ class SwThesaurus; ...@@ -35,19 +36,17 @@ class SwThesaurus;
*/ */
extern SwThesaurus* pThes; extern SwThesaurus* pThes;
extern String* pOldGrfCat; SW_DLLPUBLIC OUString GetOldGrfCat();
extern String* pOldTabCat; SW_DLLPUBLIC void SetOldGrfCat(OUString sStr);
extern String* pOldFrmCat; SW_DLLPUBLIC OUString GetOldTabCat();
SW_DLLPUBLIC void SetOldTabCat(OUString sStr);
extern String* pCurrGlosGroup; SW_DLLPUBLIC OUString GetOldFrmCat();
SW_DLLPUBLIC void SetOldFrmCat(OUString sStr);
SW_DLLPUBLIC String* GetOldGrfCat(); SW_DLLPUBLIC OUString GetOldDrwCat();
SW_DLLPUBLIC String* GetOldTabCat(); SW_DLLPUBLIC void SetOldDrwCat(OUString sStr);
SW_DLLPUBLIC String* GetOldFrmCat();
SW_DLLPUBLIC String* GetOldDrwCat(); SW_DLLPUBLIC OUString GetCurrGlosGroup();
SW_DLLPUBLIC void SetCurrGlosGroup(OUString sStr);
SW_DLLPUBLIC String* GetCurrGlosGroup();
SW_DLLPUBLIC void SetCurrGlosGroup(String* pStr);
extern std::vector<String>* pDBNameList; extern std::vector<String>* pDBNameList;
......
...@@ -159,16 +159,14 @@ SwNewGlosNameDlg::SwNewGlosNameDlg(Window* pParent, ...@@ -159,16 +159,14 @@ SwNewGlosNameDlg::SwNewGlosNameDlg(Window* pParent,
------------------------------------------------------------------------*/ ------------------------------------------------------------------------*/
String SwGlossaryDlg::GetCurrGroup() String SwGlossaryDlg::GetCurrGroup()
{ {
if( ::GetCurrGlosGroup() && ::GetCurrGlosGroup()->Len() ) if( !::GetCurrGlosGroup().isEmpty() )
return *(::GetCurrGlosGroup()); return ::GetCurrGlosGroup();
return SwGlossaries::GetDefName(); return SwGlossaries::GetDefName();
} }
void SwGlossaryDlg::SetActGroup(const String &rGrp) void SwGlossaryDlg::SetActGroup(const String &rGrp)
{ {
if( !::GetCurrGlosGroup() ) ::SetCurrGlosGroup(rGrp);
::SetCurrGlosGroup( new String );
*(::GetCurrGlosGroup()) = rGrp;
} }
SwGlossaryDlg::SwGlossaryDlg(SfxViewFrame* pViewFrame, SwGlossaryDlg::SwGlossaryDlg(SfxViewFrame* pViewFrame,
...@@ -200,10 +198,6 @@ SwGlossaryDlg::SwGlossaryDlg(SfxViewFrame* pViewFrame, ...@@ -200,10 +198,6 @@ SwGlossaryDlg::SwGlossaryDlg(SfxViewFrame* pViewFrame,
SvtLinguConfig aLocalLinguConfig; SvtLinguConfig aLocalLinguConfig;
// initialise static-pointer
if( !::GetCurrGlosGroup() )
::SetCurrGlosGroup(new String);
PopupMenu *pMenu = m_pEditBtn->GetPopupMenu(); PopupMenu *pMenu = m_pEditBtn->GetPopupMenu();
assert(pMenu); assert(pMenu);
pMenu->SetActivateHdl(LINK(this,SwGlossaryDlg,EnableHdl)); pMenu->SetActivateHdl(LINK(this,SwGlossaryDlg,EnableHdl));
...@@ -251,11 +245,10 @@ IMPL_LINK( SwGlossaryDlg, GrpSelect, SvTreeListBox *, pBox ) ...@@ -251,11 +245,10 @@ IMPL_LINK( SwGlossaryDlg, GrpSelect, SvTreeListBox *, pBox )
return 0; return 0;
SvTreeListEntry* pParent = pBox->GetParent(pEntry) ? pBox->GetParent(pEntry) : pEntry; SvTreeListEntry* pParent = pBox->GetParent(pEntry) ? pBox->GetParent(pEntry) : pEntry;
GroupUserData* pGroupData = (GroupUserData*)pParent->GetUserData(); GroupUserData* pGroupData = (GroupUserData*)pParent->GetUserData();
String *pGlosGroup = ::GetCurrGlosGroup(); ::SetCurrGlosGroup(pGroupData->sGroupName
(*pGlosGroup) = pGroupData->sGroupName; + OUString(GLOS_DELIM)
(*pGlosGroup) += GLOS_DELIM; + OUString::number(pGroupData->nPathIdx));
(*pGlosGroup) += OUString::number(pGroupData->nPathIdx); pGlossaryHdl->SetCurGroup(::GetCurrGlosGroup());
pGlossaryHdl->SetCurGroup(*pGlosGroup);
// set current text block // set current text block
bReadOnly = pGlossaryHdl->IsReadOnly(); bReadOnly = pGlossaryHdl->IsReadOnly();
EnableShortName( !bReadOnly ); EnableShortName( !bReadOnly );
...@@ -268,7 +261,7 @@ IMPL_LINK( SwGlossaryDlg, GrpSelect, SvTreeListBox *, pBox ) ...@@ -268,7 +261,7 @@ IMPL_LINK( SwGlossaryDlg, GrpSelect, SvTreeListBox *, pBox )
m_pShortNameEdit->SetText(*(String*)pEntry->GetUserData()); m_pShortNameEdit->SetText(*(String*)pEntry->GetUserData());
pEntry = pBox->GetParent(pEntry); pEntry = pBox->GetParent(pEntry);
m_pInsertBtn->Enable( !bIsDocReadOnly); m_pInsertBtn->Enable( !bIsDocReadOnly);
ShowAutoText(*::GetCurrGlosGroup(), m_pShortNameEdit->GetText()); ShowAutoText(::GetCurrGlosGroup(), m_pShortNameEdit->GetText());
} }
else else
ShowAutoText(aEmptyStr, aEmptyStr); ShowAutoText(aEmptyStr, aEmptyStr);
...@@ -277,10 +270,10 @@ IMPL_LINK( SwGlossaryDlg, GrpSelect, SvTreeListBox *, pBox ) ...@@ -277,10 +270,10 @@ IMPL_LINK( SwGlossaryDlg, GrpSelect, SvTreeListBox *, pBox )
if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) ) if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) )
{ {
SfxRequest aReq( pSh->GetView().GetViewFrame(), FN_SET_ACT_GLOSSARY ); SfxRequest aReq( pSh->GetView().GetViewFrame(), FN_SET_ACT_GLOSSARY );
String sTemp(*::GetCurrGlosGroup()); OUString sTemp(::GetCurrGlosGroup());
// the zeroth path is not being recorded! // the zeroth path is not being recorded!
if('0' == sTemp.GetToken(1, GLOS_DELIM).GetChar(0)) if (sTemp.getToken(1, GLOS_DELIM).startsWith("0"))
sTemp = sTemp.GetToken(0, GLOS_DELIM); sTemp = sTemp.getToken(0, GLOS_DELIM);
aReq.AppendItem(SfxStringItem(FN_SET_ACT_GLOSSARY, sTemp)); aReq.AppendItem(SfxStringItem(FN_SET_ACT_GLOSSARY, sTemp));
aReq.Done(); aReq.Done();
} }
...@@ -294,10 +287,10 @@ void SwGlossaryDlg::Apply() ...@@ -294,10 +287,10 @@ void SwGlossaryDlg::Apply()
if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) ) if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) )
{ {
SfxRequest aReq( pSh->GetView().GetViewFrame(), FN_INSERT_GLOSSARY ); SfxRequest aReq( pSh->GetView().GetViewFrame(), FN_INSERT_GLOSSARY );
String sTemp(*::GetCurrGlosGroup()); OUString sTemp(::GetCurrGlosGroup());
// the zeroth path is not being recorded! // the zeroth path is not being recorded!
if('0' == sTemp.GetToken(1, GLOS_DELIM).GetChar(0)) if (sTemp.getToken(1, GLOS_DELIM).startsWith("0"))
sTemp = sTemp.GetToken(0, GLOS_DELIM); sTemp = sTemp.getToken(0, GLOS_DELIM);
aReq.AppendItem(SfxStringItem(FN_INSERT_GLOSSARY, sTemp)); aReq.AppendItem(SfxStringItem(FN_INSERT_GLOSSARY, sTemp));
aReq.AppendItem(SfxStringItem(FN_PARAM_1, aGlosName)); aReq.AppendItem(SfxStringItem(FN_PARAM_1, aGlosName));
aReq.Done(); aReq.Done();
...@@ -454,10 +447,10 @@ IMPL_LINK( SwGlossaryDlg, MenuHdl, Menu *, pMn ) ...@@ -454,10 +447,10 @@ IMPL_LINK( SwGlossaryDlg, MenuHdl, Menu *, pMn )
if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) ) if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) )
{ {
SfxRequest aReq(pSh->GetView().GetViewFrame(), FN_NEW_GLOSSARY); SfxRequest aReq(pSh->GetView().GetViewFrame(), FN_NEW_GLOSSARY);
String sTemp(*::GetCurrGlosGroup()); OUString sTemp(::GetCurrGlosGroup());
// the zeroth path is not being recorded! // the zeroth path is not being recorded!
if('0' == sTemp.GetToken(1, GLOS_DELIM).GetChar(0)) if (sTemp.getToken(1, GLOS_DELIM).startsWith("0"))
sTemp = sTemp.GetToken(0, GLOS_DELIM); sTemp = sTemp.getToken(0, GLOS_DELIM);
aReq.AppendItem(SfxStringItem(FN_NEW_GLOSSARY, sTemp)); aReq.AppendItem(SfxStringItem(FN_NEW_GLOSSARY, sTemp));
aReq.AppendItem(SfxStringItem(FN_PARAM_1, aShortName)); aReq.AppendItem(SfxStringItem(FN_PARAM_1, aShortName));
aReq.AppendItem(SfxStringItem(FN_PARAM_2, aStr)); aReq.AppendItem(SfxStringItem(FN_PARAM_2, aStr));
...@@ -674,8 +667,8 @@ void SwGlossaryDlg::Init() ...@@ -674,8 +667,8 @@ void SwGlossaryDlg::Init()
// display text block regions // display text block regions
const sal_uInt16 nCnt = pGlossaryHdl->GetGroupCnt(); const sal_uInt16 nCnt = pGlossaryHdl->GetGroupCnt();
SvTreeListEntry* pSelEntry = 0; SvTreeListEntry* pSelEntry = 0;
const String sSelStr(::GetCurrGlosGroup()->GetToken(0, GLOS_DELIM)); const OUString sSelStr(::GetCurrGlosGroup().getToken(0, GLOS_DELIM));
const sal_uInt16 nSelPath = static_cast< sal_uInt16 >(::GetCurrGlosGroup()->GetToken(1, GLOS_DELIM).ToInt32()); const sal_uInt16 nSelPath = static_cast< sal_uInt16 >(::GetCurrGlosGroup().getToken(1, GLOS_DELIM).toInt32());
// #i66304# - "My AutoText" comes from mytexts.bau, but should be translated // #i66304# - "My AutoText" comes from mytexts.bau, but should be translated
const OUString sMyAutoTextEnglish("My AutoText"); const OUString sMyAutoTextEnglish("My AutoText");
const OUString sMyAutoTextTranslated(SW_RES(STR_MY_AUTOTEXT)); const OUString sMyAutoTextTranslated(SW_RES(STR_MY_AUTOTEXT));
...@@ -1073,8 +1066,7 @@ void SwGlossaryDlg::ShowPreview() ...@@ -1073,8 +1066,7 @@ void SwGlossaryDlg::ShowPreview()
EX_SHOW_ONLINE_LAYOUT, &aLink ); EX_SHOW_ONLINE_LAYOUT, &aLink );
} }
if (::GetCurrGlosGroup()) ShowAutoText(::GetCurrGlosGroup(), m_pShortNameEdit->GetText());
ShowAutoText(*::GetCurrGlosGroup(), m_pShortNameEdit->GetText());
}; };
IMPL_LINK_NOARG(SwGlossaryDlg, PreviewLoadedHdl) IMPL_LINK_NOARG(SwGlossaryDlg, PreviewLoadedHdl)
......
...@@ -37,17 +37,13 @@ ...@@ -37,17 +37,13 @@
#include "edtwin.hxx" #include "edtwin.hxx"
#include <SwStyleNameMapper.hxx> #include <SwStyleNameMapper.hxx>
#include "initui.hxx"
#include "swabstdlg.hxx" #include "swabstdlg.hxx"
#include "frmui.hrc" #include "frmui.hrc"
#include "misc.hrc" #include "misc.hrc"
#include "view.hrc" #include "view.hrc"
extern String* pOldGrfCat;
extern String* pOldTabCat;
extern String* pOldFrmCat;
extern String* pOldDrwCat;
void SwView::ExecDlgExt(SfxRequest &rReq) void SwView::ExecDlgExt(SfxRequest &rReq)
{ {
Window *pMDI = &GetViewFrame()->GetWindow(); Window *pMDI = &GetViewFrame()->GetWindow();
...@@ -192,25 +188,16 @@ void SwView::InsertCaption(const InsCaptionOpt *pOpt) ...@@ -192,25 +188,16 @@ void SwView::InsertCaption(const InsCaptionOpt *pOpt)
} }
// rember category // rember category
String** ppStr = 0;
if (eType & nsSelectionType::SEL_GRF) if (eType & nsSelectionType::SEL_GRF)
ppStr = &pOldGrfCat; SetOldGrfCat(rName);
else if( eType & nsSelectionType::SEL_TBL) else if( eType & nsSelectionType::SEL_TBL)
ppStr = &pOldTabCat; SetOldTabCat(rName);
else if( eType & nsSelectionType::SEL_FRM) else if( eType & nsSelectionType::SEL_FRM)
ppStr = &pOldFrmCat; SetOldFrmCat(rName);
else if( eType == nsSelectionType::SEL_TXT) else if( eType == nsSelectionType::SEL_TXT)
ppStr = &pOldFrmCat; SetOldFrmCat(rName);
else if( eType & nsSelectionType::SEL_DRW) else if( eType & nsSelectionType::SEL_DRW)
ppStr = &pOldDrwCat; SetOldDrwCat(rName);
if( ppStr )
{
if( !*ppStr )
*ppStr = new String( rName );
else
**ppStr = rName;
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -42,35 +42,96 @@ SwGlossaries* pGlossaries = 0; ...@@ -42,35 +42,96 @@ SwGlossaries* pGlossaries = 0;
// Provides all needed paths. Is initialized by UI. // Provides all needed paths. Is initialized by UI.
SwGlossaryList* pGlossaryList = 0; SwGlossaryList* pGlossaryList = 0;
String* pOldGrfCat = 0; namespace
String* pOldTabCat = 0; {
String* pOldFrmCat = 0;
String* pOldDrwCat = 0; enum CachedStringID
String* pCurrGlosGroup = 0; {
OldGrfCat,
OldTabCat,
OldFrmCat,
OldDrwCat,
CurrGlosGroup,
CachedStrings
};
OUString *StringCache[CachedStrings] = {0};
inline OUString GetCachedString(CachedStringID id)
{
return StringCache[id] ? *StringCache[id] : OUString();
}
inline void SetCachedString(CachedStringID id, OUString sStr)
{
if (StringCache[id])
{
*StringCache[id] = sStr;
}
else
{
StringCache[id] = new OUString(sStr);
}
}
void ClearStringCache()
{
for (int i=0; i<CachedStrings; ++i)
{
delete StringCache[i];
}
}
}
OUString GetOldGrfCat()
{
return GetCachedString(OldGrfCat);
}
void SetOldGrfCat(OUString sStr)
{
SetCachedString(OldGrfCat, sStr);
}
OUString GetOldTabCat()
{
return GetCachedString(OldTabCat);
}
void SetOldTabCat(OUString sStr)
{
SetCachedString(OldTabCat, sStr);
}
String* GetOldGrfCat() OUString GetOldFrmCat()
{ {
return pOldGrfCat; return GetCachedString(OldFrmCat);
} }
String* GetOldTabCat()
void SetOldFrmCat(OUString sStr)
{ {
return pOldTabCat; SetCachedString(OldFrmCat, sStr);
} }
String* GetOldFrmCat()
OUString GetOldDrwCat()
{ {
return pOldFrmCat; return GetCachedString(OldDrwCat);
} }
String* GetOldDrwCat()
void SetOldDrwCat(OUString sStr)
{ {
return pOldDrwCat; SetCachedString(OldDrwCat, sStr);
} }
String* GetCurrGlosGroup()
OUString GetCurrGlosGroup()
{ {
return pCurrGlosGroup; return GetCachedString(CurrGlosGroup);
} }
void SetCurrGlosGroup(String* pStr)
void SetCurrGlosGroup(OUString sStr)
{ {
pCurrGlosGroup = pStr; SetCachedString(CurrGlosGroup, sStr);
} }
std::vector<String>* pDBNameList = 0; std::vector<String>* pDBNameList = 0;
...@@ -97,11 +158,7 @@ void _FinitUI() ...@@ -97,11 +158,7 @@ void _FinitUI()
delete SwFieldType::pFldNames; delete SwFieldType::pFldNames;
delete pOldGrfCat; ClearStringCache();
delete pOldTabCat;
delete pOldFrmCat;
delete pOldDrwCat;
delete pCurrGlosGroup;
delete pDBNameList; delete pDBNameList;
delete pGlossaryList; delete pGlossaryList;
delete pAuthFieldNameList; delete pAuthFieldNameList;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment