tdf#119738 - Set default image caption to illustration if already being used
Change-Id: I8371bd4184734857a6c5578dc5c235760f83cc36
Reviewed-on: https://gerrit.libreoffice.org/60787
Tested-by: Jenkins
Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx
index ae3db0670..b5c2999 100644
--- a/sw/inc/view.hxx
+++ b/sw/inc/view.hxx
@@ -644,6 +644,37 @@
/// See SfxViewShell::NotifyCursor().
void NotifyCursor(SfxViewShell* pViewShell) const override;
void ShowUIElement(const OUString& sElementURL) const;
enum CachedStringID
{
OldGrfCat,
OldTabCat,
OldFrameCat,
OldDrwCat,
CachedStrings
};
OUString m_StringCache[CachedStrings];
const OUString& GetCachedString(CachedStringID id)
{
return m_StringCache[id];
}
void SetCachedString(CachedStringID id, const OUString& sStr)
{
m_StringCache[id] = sStr;
}
const OUString& GetOldGrfCat();
void SetOldGrfCat(const OUString& sStr);
const OUString& GetOldTabCat();
void SetOldTabCat(const OUString& sStr);
const OUString& GetOldFrameCat();
void SetOldFrameCat(const OUString& sStr);
const OUString& GetOldDrwCat();
void SetOldDrwCat(const OUString& sStr);
};
inline long SwView::GetXScroll() const
diff --git a/sw/source/ui/frmdlg/cption.cxx b/sw/source/ui/frmdlg/cption.cxx
index 2b96b74..3f650c1 100644
--- a/sw/source/ui/frmdlg/cption.cxx
+++ b/sw/source/ui/frmdlg/cption.cxx
@@ -161,7 +161,15 @@
if (eType & SelectionType::Graphic)
{
nPoolId = RES_POOLCOLL_LABEL_FIGURE;
sString = ::GetOldGrfCat();
SwSetExpFieldType* pTypeIll= static_cast<SwSetExpFieldType*>(rSh.GetFieldType(SwFieldIds::SetExp, SwResId(STR_POOLCOLL_LABEL_ABB)));
if(rSh.IsUsed(*pTypeIll)) //default to illustration for legacy docs
{
nPoolId = RES_POOLCOLL_LABEL_ABB;
}
sString = rView.GetOldGrfCat();
bCopyAttributes = true;
//if not OLE
if(!xNameAccess.is())
@@ -174,26 +182,26 @@
else if( eType & SelectionType::Table )
{
nPoolId = RES_POOLCOLL_LABEL_TABLE;
sString = ::GetOldTabCat();
sString = rView.GetOldTabCat();
uno::Reference< text::XTextTablesSupplier > xTables(xModel, uno::UNO_QUERY);
xNameAccess = xTables->getTextTables();
}
else if( eType & SelectionType::Frame )
{
nPoolId = RES_POOLCOLL_LABEL_FRAME;
sString = ::GetOldFrameCat();
sString = rView.GetOldFrameCat();
uno::Reference< text::XTextFramesSupplier > xFrames(xModel, uno::UNO_QUERY);
xNameAccess = xFrames->getTextFrames();
}
else if( eType == SelectionType::Text )
{
nPoolId = RES_POOLCOLL_LABEL_FRAME;
sString = ::GetOldFrameCat();
sString = rView.GetOldFrameCat();
}
else if( eType & SelectionType::DrawObject )
{
nPoolId = RES_POOLCOLL_LABEL_DRAWING;
sString = ::GetOldDrwCat();
sString = rView.GetOldDrwCat();
}
if( nPoolId )
{
diff --git a/sw/source/uibase/inc/initui.hxx b/sw/source/uibase/inc/initui.hxx
index 246f7d2..2cb010f 100644
--- a/sw/source/uibase/inc/initui.hxx
+++ b/sw/source/uibase/inc/initui.hxx
@@ -35,15 +35,6 @@
*/
extern SwThesaurus* pThes;
SW_DLLPUBLIC const OUString& GetOldGrfCat();
SW_DLLPUBLIC void SetOldGrfCat(const OUString& sStr);
SW_DLLPUBLIC const OUString& GetOldTabCat();
SW_DLLPUBLIC void SetOldTabCat(const OUString& sStr);
SW_DLLPUBLIC const OUString& GetOldFrameCat();
SW_DLLPUBLIC void SetOldFrameCat(const OUString& sStr);
SW_DLLPUBLIC const OUString& GetOldDrwCat();
SW_DLLPUBLIC void SetOldDrwCat(const OUString& sStr);
SW_DLLPUBLIC const OUString& GetCurrGlosGroup();
SW_DLLPUBLIC void SetCurrGlosGroup(const OUString& sStr);
diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx
index 1596460..6e28013 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -2463,4 +2463,45 @@
m_pViewImpl->ExecuteScan(rReq) ;
}
const OUString& SwView::GetOldGrfCat()
{
return GetCachedString(OldGrfCat);
}
void SwView::SetOldGrfCat(const OUString& sStr)
{
SetCachedString(OldGrfCat, sStr);
}
const OUString& SwView::GetOldTabCat()
{
return GetCachedString(OldTabCat);
}
void SwView::SetOldTabCat(const OUString& sStr)
{
SetCachedString(OldTabCat, sStr);
}
const OUString& SwView::GetOldFrameCat()
{
return GetCachedString(OldFrameCat);
}
void SwView::SetOldFrameCat(const OUString& sStr)
{
SetCachedString(OldFrameCat, sStr);
}
const OUString& SwView::GetOldDrwCat()
{
return GetCachedString(OldDrwCat);
}
void SwView::SetOldDrwCat(const OUString& sStr)
{
SwView::SetCachedString(OldDrwCat, sStr);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/utlui/initui.cxx b/sw/source/uibase/utlui/initui.cxx
index 2b8d43b..b7a7364 100644
--- a/sw/source/uibase/utlui/initui.cxx
+++ b/sw/source/uibase/utlui/initui.cxx
@@ -45,87 +45,17 @@
namespace
{
enum CachedStringID
{
OldGrfCat,
OldTabCat,
OldFrameCat,
OldDrwCat,
CurrGlosGroup,
CachedStrings
};
OUString StringCache[CachedStrings];
const OUString& GetCachedString(CachedStringID id)
{
return StringCache[id];
}
void SetCachedString(CachedStringID id, const OUString& sStr)
{
StringCache[id] = sStr;
}
void ClearStringCache()
{
for (auto & s : StringCache)
{
s.clear();
}
}
}
const OUString& GetOldGrfCat()
{
return GetCachedString(OldGrfCat);
}
void SetOldGrfCat(const OUString& sStr)
{
SetCachedString(OldGrfCat, sStr);
}
const OUString& GetOldTabCat()
{
return GetCachedString(OldTabCat);
}
void SetOldTabCat(const OUString& sStr)
{
SetCachedString(OldTabCat, sStr);
}
const OUString& GetOldFrameCat()
{
return GetCachedString(OldFrameCat);
}
void SetOldFrameCat(const OUString& sStr)
{
SetCachedString(OldFrameCat, sStr);
}
const OUString& GetOldDrwCat()
{
return GetCachedString(OldDrwCat);
}
void SetOldDrwCat(const OUString& sStr)
{
SetCachedString(OldDrwCat, sStr);
OUString CurrGlosGroup;
}
const OUString& GetCurrGlosGroup()
{
return GetCachedString(CurrGlosGroup);
return CurrGlosGroup;
}
void SetCurrGlosGroup(const OUString& sStr)
{
SetCachedString(CurrGlosGroup, sStr);
CurrGlosGroup = sStr;
}
namespace
@@ -149,7 +79,6 @@
delete SwFieldType::s_pFieldNames;
ClearStringCache();
delete pGlossaryList;
delete pAuthFieldNameList;
delete pAuthFieldTypeList;