summaryrefslogtreecommitdiffstats
path: root/filter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-11-09 09:35:25 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-11-09 12:00:49 +0100
commite5a14bf90bad0696478bbc1504680aae1af7c2e2 (patch)
treeeb0f273d7195684c0c8f601e6727479b1a8dd37a /filter
parentStartElement->startFastElement in text fields (diff)
downloadcore-e5a14bf90bad0696478bbc1504680aae1af7c2e2.tar.gz
core-e5a14bf90bad0696478bbc1504680aae1af7c2e2.zip
ofz#26973 shave some time off timeout
36s -> 23s Change-Id: I28451aa17cc724910f93fe53ee1247044a7c2f5c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105474 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'filter')
-rw-r--r--filter/source/graphicfilter/icgm/actimpr.cxx4
-rw-r--r--filter/source/graphicfilter/icgm/bundles.cxx105
-rw-r--r--filter/source/graphicfilter/icgm/bundles.hxx26
3 files changed, 38 insertions, 97 deletions
diff --git a/filter/source/graphicfilter/icgm/actimpr.cxx b/filter/source/graphicfilter/icgm/actimpr.cxx
index 728c74b44c03..48a71609519e 100644
--- a/filter/source/graphicfilter/icgm/actimpr.cxx
+++ b/filter/source/graphicfilter/icgm/actimpr.cxx
@@ -363,7 +363,9 @@ void CGMImpressOutAct::ImplSetTextBundle( const uno::Reference< beans::XProperty
if ( pFontEntry )
{
nFontType = pFontEntry->nFontType;
- aFontDescriptor.Name = OUString::createFromAscii( reinterpret_cast<char*>(pFontEntry->pFontName.get()) );
+ aFontDescriptor.Name = OUString(reinterpret_cast<char*>(pFontEntry->aFontName.data()),
+ pFontEntry->aFontName.size(),
+ RTL_TEXTENCODING_ASCII_US);
}
aFontDescriptor.Height = sal_Int16( mpCGM->pElement->nCharacterHeight * 1.50 );
if ( nFontType & 1 )
diff --git a/filter/source/graphicfilter/icgm/bundles.cxx b/filter/source/graphicfilter/icgm/bundles.cxx
index 357901ad1048..89ce93e31bcf 100644
--- a/filter/source/graphicfilter/icgm/bundles.cxx
+++ b/filter/source/graphicfilter/icgm/bundles.cxx
@@ -28,67 +28,20 @@ void Bundle::SetColor( sal_uInt32 nColor )
mnColor = nColor;
}
-FontEntry::FontEntry() :
- nFontType ( 0 )
+CGMFList::CGMFList()
+ : nFontNameCount(0)
+ , nCharSetCount(0)
{
}
-FontEntry::~FontEntry()
-{
-}
-
-CGMFList::CGMFList() :
- nFontNameCount ( 0 ),
- nCharSetCount ( 0 ),
- nFontsAvailable ( 0 )
-{
- aFontEntryList.clear();
-}
-
-CGMFList::~CGMFList()
-{
- ImplDeleteList();
-}
-
-CGMFList& CGMFList::operator=( const CGMFList& rSource )
-{
- if (this != &rSource)
- {
- ImplDeleteList();
- nFontsAvailable = rSource.nFontsAvailable;
- nFontNameCount = rSource.nFontNameCount;
- nCharSetCount = rSource.nCharSetCount;
- for (auto const & pPtr : rSource.aFontEntryList)
- {
- std::unique_ptr<FontEntry> pCFontEntry(new FontEntry);
- if ( pPtr->pFontName )
- {
- sal_uInt32 nSize = strlen( reinterpret_cast<char*>(pPtr->pFontName.get()) ) + 1;
- pCFontEntry->pFontName.reset( new sal_Int8[ nSize ] );
- memcpy( pCFontEntry->pFontName.get(), pPtr->pFontName.get(), nSize );
- }
- if ( pPtr->pCharSetValue )
- {
- sal_uInt32 nSize = strlen( reinterpret_cast<char*>(pPtr->pCharSetValue.get()) ) + 1;
- pCFontEntry->pCharSetValue.reset( new sal_Int8[ nSize ] );
- memcpy( pCFontEntry->pCharSetValue.get(), pPtr->pCharSetValue.get(), nSize );
- }
- pCFontEntry->nFontType = pPtr->nFontType;
- aFontEntryList.push_back( std::move(pCFontEntry) );
- }
- }
- return *this;
-}
-
FontEntry* CGMFList::GetFontEntry( sal_uInt32 nIndex )
{
sal_uInt32 nInd = nIndex;
if ( nInd )
nInd--;
- return ( nInd < aFontEntryList.size() ) ? aFontEntryList[ nInd ].get() : nullptr;
+ return ( nInd < aFontEntryList.size() ) ? &aFontEntryList[nInd] : nullptr;
}
-
static sal_Int8* ImplSearchEntry( sal_Int8* pSource, sal_Int8 const * pDest, sal_uInt32 nComp, sal_uInt32 nSize )
{
while ( nComp-- >= nSize )
@@ -109,24 +62,26 @@ static sal_Int8* ImplSearchEntry( sal_Int8* pSource, sal_Int8 const * pDest, sal
void CGMFList::InsertName( sal_uInt8 const * pSource, sal_uInt32 nSize )
{
FontEntry* pFontEntry;
- if ( nFontsAvailable == nFontNameCount )
+ if (nFontNameCount == aFontEntryList.size())
{
- nFontsAvailable++;
- pFontEntry = new FontEntry;
- aFontEntryList.push_back( std::unique_ptr<FontEntry>(pFontEntry) );
+ aFontEntryList.push_back(FontEntry());
+ pFontEntry = &aFontEntryList.back();
}
else
{
- pFontEntry = aFontEntryList[ nFontNameCount ].get();
+ pFontEntry = &aFontEntryList[nFontNameCount];
}
nFontNameCount++;
- std::unique_ptr<sal_Int8[]> pBuf(new sal_Int8[ nSize ]);
- memcpy( pBuf.get(), pSource, nSize );
- sal_Int8* pFound = ImplSearchEntry( pBuf.get(), reinterpret_cast<sal_Int8 const *>("ITALIC"), nSize, 6 );
- if ( pFound )
+
+ if (nSize == 0)
+ return;
+
+ std::vector<sal_Int8> aBuf(pSource, pSource + nSize);
+ sal_Int8* pFound = ImplSearchEntry(aBuf.data(), reinterpret_cast<sal_Int8 const *>("ITALIC"), nSize, 6);
+ if (pFound)
{
pFontEntry->nFontType |= 1;
- sal_uInt32 nPrev = pFound - pBuf.get();
+ sal_uInt32 nPrev = pFound - aBuf.data();
sal_uInt32 nToCopyOfs = 6;
if ( nPrev && ( pFound[ -1 ] == '-' || pFound[ -1 ] == ' ' ) )
{
@@ -141,12 +96,12 @@ void CGMFList::InsertName( sal_uInt8 const * pSource, sal_uInt32 nSize )
}
nSize -= nToCopyOfs;
}
- pFound = ImplSearchEntry( pBuf.get(), reinterpret_cast<sal_Int8 const *>("BOLD"), nSize, 4 );
+ pFound = ImplSearchEntry(aBuf.data(), reinterpret_cast<sal_Int8 const *>("BOLD"), nSize, 4);
if ( pFound )
{
pFontEntry->nFontType |= 2;
- sal_uInt32 nPrev = pFound - pBuf.get();
+ sal_uInt32 nPrev = pFound - aBuf.data();
sal_uInt32 nToCopyOfs = 4;
if ( nPrev && ( pFound[ -1 ] == '-' || pFound[ -1 ] == ' ' ) )
{
@@ -161,35 +116,27 @@ void CGMFList::InsertName( sal_uInt8 const * pSource, sal_uInt32 nSize )
}
nSize -= nToCopyOfs;
}
- pFontEntry->pFontName.reset( new sal_Int8[ nSize + 1 ] );
- pFontEntry->pFontName[ nSize ] = 0;
- memcpy( pFontEntry->pFontName.get(), pBuf.get(), nSize );
+ pFontEntry->aFontName.assign(aBuf.data(), aBuf.data() + nSize);
}
-
void CGMFList::InsertCharSet( sal_uInt8 const * pSource, sal_uInt32 nSize )
{
FontEntry* pFontEntry;
- if ( nFontsAvailable == nCharSetCount )
+ if (nCharSetCount == aFontEntryList.size())
{
- nFontsAvailable++;
- pFontEntry = new FontEntry;
- aFontEntryList.push_back( std::unique_ptr<FontEntry>(pFontEntry) );
+ aFontEntryList.push_back(FontEntry());
+ pFontEntry = &aFontEntryList.back();
}
else
{
- pFontEntry = aFontEntryList[ nCharSetCount ].get();
+ pFontEntry = &aFontEntryList[nCharSetCount];
}
nCharSetCount++;
- pFontEntry->pCharSetValue.reset( new sal_Int8[ nSize + 1 ] );
- pFontEntry->pCharSetValue[ nSize ] = 0;
- memcpy( pFontEntry->pCharSetValue.get(), pSource, nSize );
-}
+ if (nSize == 0)
+ return;
-void CGMFList::ImplDeleteList()
-{
- aFontEntryList.clear();
+ pFontEntry->aCharSetValue.assign(pSource, pSource + nSize);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/graphicfilter/icgm/bundles.hxx b/filter/source/graphicfilter/icgm/bundles.hxx
index d4cd01839acc..a884937f8dae 100644
--- a/filter/source/graphicfilter/icgm/bundles.hxx
+++ b/filter/source/graphicfilter/icgm/bundles.hxx
@@ -138,38 +138,30 @@ public:
};
-class FontEntry
+struct FontEntry
{
-public:
- std::unique_ptr<sal_Int8[]>
- pFontName;
- std::unique_ptr<sal_Int8[]>
- pCharSetValue;
+ std::vector<sal_Int8> aFontName;
+ std::vector<sal_Int8> aCharSetValue;
sal_uInt32 nFontType; // bit 0 = 1 -> Italic,
// bit 1 = 1 -> Bold
-
- FontEntry();
- ~FontEntry();
+ FontEntry()
+ : nFontType(0)
+ {
+ }
};
class CGMFList
{
sal_uInt32 nFontNameCount;
sal_uInt32 nCharSetCount;
- ::std::vector< std::unique_ptr<FontEntry> >
- aFontEntryList;
- sal_uInt32 nFontsAvailable;
-
- void ImplDeleteList();
+ std::vector<FontEntry> aFontEntryList;
public:
- CGMFList();
- ~CGMFList();
+ CGMFList();
FontEntry* GetFontEntry( sal_uInt32 );
void InsertName( sal_uInt8 const * pSource, sal_uInt32 nSize );
void InsertCharSet( sal_uInt8 const * pSource, sal_uInt32 nSize );
- CGMFList& operator=( const CGMFList& rFontList );
};
#endif