core.git: sdext/source
sdext/source/pdfimport/wrapper/wrapper.cxx | 16 ++-- 1 file changed, 10 insertions(+), 6 deletions(-) New commits: commit 65a57e5c7c3770d788e076303a7182de43a17cbf Author: Mike Kaganski AuthorDate: Thu Apr 4 10:50:56 2024 +0500 Commit: Mike Kaganski CommitDate: Thu Apr 4 09:21:49 2024 +0200 A small refactor Change-Id: I299cc7c2850a71ee563824c6361707d894f5ddcc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165773 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index 6a17d295eae1..86c0d3cf806f 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -61,6 +61,7 @@ #include #include #include +#include #include using namespace com::sun::star; @@ -1081,10 +1082,13 @@ bool xpdf_ImportFromFile(const OUString& rURL, // spawn separate process to keep LGPL/GPL code apart. -OUString aOptFlag("-o"); -rtl_uString* args[] = { aSysUPath.pData, - aOptFlag.pData, rFilterOptions.pData }; -sal_Int32 nArgs = rFilterOptions.isEmpty() ? std::size(args) - 2 : std::size(args); +constexpr OUString aOptFlag(u"-o"_ustr); +std::vector args({ aSysUPath.pData }); +if (!rFilterOptions.isEmpty()) +{ +args.push_back(aOptFlag.pData); +args.push_back(rFilterOptions.pData); +} oslProcessaProcess; oslFileHandle pIn = nullptr; @@ -1093,8 +1097,8 @@ bool xpdf_ImportFromFile(const OUString& rURL, oslSecurity pSecurity = osl_getCurrentSecurity (); oslProcessError eErr = osl_executeProcess_WithRedirectedIO(converterURL.pData, -args, -nArgs, +args.data(), +args.size(), osl_Process_SEARCHPATH|osl_Process_HIDDEN, pSecurity, nullptr, nullptr, 0,
core.git: sdext/source
sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx |2 +- sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) New commits: commit 9e47e217126d421e51e167da0d94a5d7c2f078ed Author: Mike Kaganski AuthorDate: Thu Apr 4 10:29:48 2024 +0500 Commit: Mike Kaganski CommitDate: Thu Apr 4 09:05:12 2024 +0200 Drop a bit of redundancy POPPLER_CHECK_VERSION(0, 23, 0) implies POPPLER_CHECK_VERSION(0, 24, 0) Change-Id: I48f3763ef115719a3e3615623bfb40f7c79b8df4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165772 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index 603155a2036e..57164f27cb42 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -626,7 +626,7 @@ PDFOutDev::~PDFOutDev() } void PDFOutDev::startPage(int /*pageNum*/, GfxState* state -#if POPPLER_CHECK_VERSION(0, 23, 0) || POPPLER_CHECK_VERSION(0, 24, 0) +#if POPPLER_CHECK_VERSION(0, 23, 0) , XRef* /*xref*/ #endif ) diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx index 2a8078422def..6a35d119314b 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx @@ -179,7 +179,7 @@ namespace pdfi // Start a page. virtual void startPage(int pageNum, GfxState *state -#if POPPLER_CHECK_VERSION(0, 23, 0) || POPPLER_CHECK_VERSION(0, 24, 0) +#if POPPLER_CHECK_VERSION(0, 23, 0) , XRef *xref #endif ) override;
core.git: sdext/source
sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx | 82 +++-- 1 file changed, 61 insertions(+), 21 deletions(-) New commits: commit 7b9905df455b47977968a185a7c43f35541e018b Author: Mike Kaganski AuthorDate: Wed Apr 3 12:40:06 2024 +0500 Commit: Mike Kaganski CommitDate: Wed Apr 3 22:11:17 2024 +0200 tdf#160260: make poppler wrapper executable Unicode-aware on Windows Change-Id: I76dc31ee14d1794fa73f990e641540ff941c7201 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165735 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx index e924547e9357..383f6810b2a2 100644 --- a/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx @@ -21,6 +21,8 @@ #ifdef _WIN32 # include # include /*_O_BINARY*/ +#define WIN32_LEAN_AND_MEAN +#include #endif #ifndef SYSTEM_POPPLER #include // std::string @@ -30,24 +32,58 @@ FILE* g_binary_out=stderr; -static const char *ownerPassword = ""; -static const char *userPassword = ""; -static const char *outputFile= ""; -static const char *options = ""; +#ifdef _WIN32 + +// Use Unicode API + +static const wchar_t *ownerPassword = nullptr; +static const wchar_t *userPassword = nullptr; +static const wchar_t *outputFile= nullptr; +static const wchar_t *options = L""; + +#define TO_STRING_VIEW(s) std::wstring_view(L##s) +using my_string = std::wstring; + +// Poppler expects UTF-8 strings on Windows - see its openFile in poppler/goo/gfile.cc. +static std::string myStringToStdString(std::wstring_view s) +{ +int len = WideCharToMultiByte(CP_UTF8, 0, s.data(), s.size(), nullptr, 0, nullptr, nullptr); +char* buff = static_cast(_alloca(len * sizeof(char))); +len = WideCharToMultiByte(CP_UTF8, 0, s.data(), s.size(), buff, len, nullptr, nullptr); +return std::string(buff, len); +} + +#else // ! _WIN32 + +static const char *ownerPassword = nullptr; +static const char *userPassword = nullptr; +static const char *outputFile= nullptr; +static const char *options = ""; +#define TO_STRING_VIEW(s) std::string_view(s) +using my_string = std::string; + +static std::string myStringToStdString(std::string&& s) { return std::move(s); } + +#endif + +#ifdef _WIN32 +int wmain(int argc, wchar_t **argv) +#else int main(int argc, char **argv) +#endif { -int k = 0; +int k = 1; while (k < argc) { -if (!strcmp(argv[k], "-f")) +if (argv[k] == TO_STRING_VIEW("-f")) { outputFile = argv[k+1]; argc -= 2; for (int j = k; j < argc; ++j) argv[j] = argv[j+2]; } -else if (!strcmp(argv[k], "-o")) +else if (argv[k] == TO_STRING_VIEW("-o")) { options = argv[k+1]; argc -= 2; @@ -55,14 +91,14 @@ int main(int argc, char **argv) argv[j] = argv[j+2]; } -else if (!strcmp(argv[k], "-opw")) +else if (argv[k] == TO_STRING_VIEW("-opw")) { ownerPassword = argv[k+1]; argc -= 2; for (int j = k; j < argc; ++j) argv[j] = argv[j+2]; } -else if (!strcmp(argv[k], "-upw")) +else if (argv[k] == TO_STRING_VIEW("-upw")) { userPassword = argv[k+1]; argc -= 2; @@ -79,10 +115,10 @@ int main(int argc, char **argv) /* Creates an absolute path to the poppler_data directory, by taking the path * to the xpdfimport executable (provided in argv[0], and concatenating a * relative path to the poppler_data directory from the program directory. */ -const std::string execPath = argv[0]; -const std::size_t filenameStartPos = execPath.find_last_of("/\")+1; -const std::string programPath = execPath.substr(0,filenameStartPos); -const std::string popplerDataPath = programPath + "../" LIBO_SHARE_FOLDER "/xpdfimport/poppler_data"; +const my_string execPath = argv[0]; +const std::size_t filenameStartPos = execPath.find_last_of(TO_STRING_VIEW("/\")) + 1; +const my_string programPath = execPath.substr(0, filenameStartPos); +const std::string popplerDataPath = myStringToStdString(programPath + my_string(TO_STRING_VIEW("../" LIBO_SHARE_FOLDER "/xpdfimport/poppler_data"))); const char* datadir = popplerDataPath.c_str(); #endif @@ -115,22 +151,26 @@ int main(int argc, char **argv) } // PDFDoc takes over ownership for all strings below -GooString* pFileName= new GooString(argv[1]); -GooString* pErrFileName = new GooString(argv[2]); +GooString* pFileName = new GooString(myStringToStdString(argv[1])); +GooString* pErrFileName = new GooString(myStringToStdString(argv[2])); // check for password string(s) GooString* pOwnerPasswordStr( aPwBuf[0] != 0
core.git: sdext/source
sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx | 42 -- 1 file changed, 20 insertions(+), 22 deletions(-) New commits: commit 1a7f06f01315992b9dfb05e1f9c46307cd72dac8 Author: Dr. David Alan Gilbert AuthorDate: Mon Mar 4 01:56:56 2024 + Commit: Noel Grandin CommitDate: Thu Mar 7 07:04:08 2024 +0100 sdext.pdfimport: Use std::unique_ptr as per Noel's suggestion - this also ends up fixing some leaks as well. Change-Id: Ia6099afc1955c341256ec0de5a0f839c005d9b76 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164446 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index ec2632b74899..603155a2036e 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -453,8 +453,8 @@ static void flipSplashBitmap(SplashBitmap *pBitmap) auto nRowSize = static_cast(pBitmap->getRowSize()); auto nAlphaRowSize = static_cast(pBitmap->getAlphaRowSize()); -auto aTmpRow = new unsigned char[nRowSize]; -auto aTmpAlphaRow = new unsigned char[nAlphaRowSize]; +std::unique_ptr aTmpRow(new unsigned char[nRowSize]); +std::unique_ptr aTmpAlphaRow(new unsigned char[nAlphaRowSize]); auto pBitmapData = pBitmap->getDataPtr(); auto pAlphaData = pBitmap->getAlphaPtr(); @@ -470,16 +470,14 @@ static void flipSplashBitmap(SplashBitmap *pBitmap) nCur++, pCurRowA+=nRowSize, pCurRowB-=nRowSize, pCurAlphaA+=nAlphaRowSize, pCurAlphaB-=nAlphaRowSize) { -memcpy(aTmpRow, pCurRowA, nRowSize); +memcpy(aTmpRow.get(), pCurRowA, nRowSize); memcpy(pCurRowA, pCurRowB, nRowSize); -memcpy(pCurRowB, aTmpRow, nRowSize); +memcpy(pCurRowB, aTmpRow.get(), nRowSize); -memcpy(aTmpAlphaRow, pCurAlphaA, nAlphaRowSize); +memcpy(aTmpAlphaRow.get(), pCurAlphaA, nAlphaRowSize); memcpy(pCurAlphaA, pCurAlphaB, nAlphaRowSize); -memcpy(pCurAlphaB, aTmpAlphaRow, nAlphaRowSize); +memcpy(pCurAlphaB, aTmpAlphaRow.get(), nAlphaRowSize); } -delete[] aTmpRow; -delete[] aTmpAlphaRow; } int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, const GfxState* state ) const @@ -1268,13 +1266,15 @@ poppler_bool PDFOutDev::tilingPatternFill(GfxState *state, Gfx *, Catalog *, auto pSplashGfx = new Gfx(m_pDoc, pSplashOut, pResDict, , nullptr); pSplashGfx->display(aStr); -auto pSplashBitmap = pSplashOut->takeBitmap(); +std::unique_ptr pSplashBitmap(pSplashOut->takeBitmap()); +// Poppler tells us to free the splash device immediately after taking the +// bitmap delete pSplashGfxState; delete pSplashGfx; delete pSplashOut; // Add a vertical flip, we can't do this in LO for an image filled poly -flipSplashBitmap(pSplashBitmap); +flipSplashBitmap(pSplashBitmap.get()); auto nBitmapWidth = static_cast(pSplashBitmap->getWidth()); auto nBitmapHeight = static_cast(pSplashBitmap->getHeight()); @@ -1300,23 +1300,21 @@ poppler_bool PDFOutDev::tilingPatternFill(GfxState *state, Gfx *, Catalog *, } } -auto pRgbStr = new MemStream(pBitmapData, 0, -nBitmapWidth * nBitmapHeight * 3, Object(objNull)); -auto pAlphaStr = new MemStream(reinterpret_cast(pSplashBitmap->getAlphaPtr()), 0, -nBitmapWidth * nBitmapHeight, Object(objNull)); +std::unique_ptr pRgbStr(new MemStream(pBitmapData, 0, +nBitmapWidth * nBitmapHeight * 3, Object(objNull))); +std::unique_ptr pAlphaStr(new MemStream(reinterpret_cast(pSplashBitmap->getAlphaPtr()), +0, nBitmapWidth * nBitmapHeight, Object(objNull))); auto aDecode = Object(objNull); -auto pRgbIdentityColorMap = new GfxImageColorMap(8, , new GfxDeviceRGBColorSpace()); -auto pGrayIdentityColorMap = new GfxImageColorMap(8, , new GfxDeviceGrayColorSpace()); +std::unique_ptr pRgbIdentityColorMap(new GfxImageColorMap(8, , +new GfxDeviceRGBColorSpace())); +std::unique_ptr pGrayIdentityColorMap(new GfxImageColorMap(8, , +new GfxDeviceGrayColorSpace())); OutputBuffer aBuf; initBuf(aBuf); -writePng_(aBuf, pRgbStr, nBitmapWidth, nBitmapHeight, pRgbIdentityColorMap, -pAlphaStr, nBitmapWidth, nBitmapHeight, pGrayIdentityColorMap); +writePng_(aBuf, pRgbStr.get(), nBitmapWidth, nBitmapHeight, pRgbIdentityColorMap.get(), +pAlphaStr.get(), nBitmapWidth, nBitmapHeight, pGrayIdentityColorMap.get()); writeBinaryBuffer(aBuf); -delete pAlphaStr; -delete pRgbStr; -delete pSplashBitmap; - // If we return false here we can fall back to the slow path return true; }
core.git: sdext/source
sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit cf776a6fa697924deb7df5c0561e12bbd7cda16a Author: Dr. David Alan Gilbert AuthorDate: Sun Feb 18 22:01:43 2024 + Commit: Noel Grandin CommitDate: Thu Feb 29 08:28:48 2024 +0100 tdf#113050 sdext.pdfimport: Enable tilingPatternFill Now we've got everything wired up, turn it on. Change-Id: I2333e5163493ef0312619f54d2f90ae266fc655b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163575 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx index f38bf423423b..2a8078422def 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx @@ -284,7 +284,7 @@ namespace pdfi static void setPageNum( int nNumPages ); void setSkipImages ( bool bSkipImages ); #if POPPLER_CHECK_VERSION(21, 3, 0) -poppler_bool useTilingPatternFill() override { return false; }; +poppler_bool useTilingPatternFill() override { return true; }; poppler_bool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, GfxTilingPattern *tPat, const double *mat, int x0, int y0, int x1, int y1,
core.git: sdext/source
sdext/source/pdfimport/tree/drawtreevisiting.cxx |2 ++ sdext/source/pdfimport/tree/pdfiprocessor.cxx |7 ++- sdext/source/pdfimport/tree/writertreevisiting.cxx |3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) New commits: commit 81fbaf4bb9ddc385d4452257d731e4097dfed079 Author: Dr. David Alan Gilbert AuthorDate: Thu Feb 15 00:18:01 2024 + Commit: Noel Grandin CommitDate: Thu Feb 29 08:28:31 2024 +0100 tdf#113050 sdext.pdfimport: Set and write TileWidth/Height Set the tile width/height from the step size and write it into the draw:fill-image-width/height properties. Change-Id: I70d69a6d5e77929bd14282731dd68d3bcafa9c1a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163574 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx index 2c02adde8874..7897dbae9d08 100644 --- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx +++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx @@ -826,6 +826,8 @@ void DrawXmlFinalizer::visit( PolyPolyElement& elem, const std::list< std::uniqu aGCProps[ "draw:fill-image-name" ] = m_rStyleContainer.getStyleName( m_rStyleContainer.getStyleId(style)); +aGCProps[ "draw:fill-image-width" ] = unitMMString(convPx2mm(elem.TileWidth)); +aGCProps[ "draw:fill-image-height" ] = unitMMString(convPx2mm(elem.TileHeight)); } diff --git a/sdext/source/pdfimport/tree/pdfiprocessor.cxx b/sdext/source/pdfimport/tree/pdfiprocessor.cxx index 6f4b45f21a40..2483144250b8 100644 --- a/sdext/source/pdfimport/tree/pdfiprocessor.cxx +++ b/sdext/source/pdfimport/tree/pdfiprocessor.cxx @@ -428,12 +428,17 @@ void PDFIProcessor::tilingPatternFill(int nX0, int nY0, int nX1, int nY1, } // TODO: That clipping might shift the fill pattern offsets +double transformedxStep = nxStep * rMat.m00 + nyStep * rMat.m01; +double transformedyStep = nxStep * rMat.m10 + nyStep * rMat.m11; + auto pPolyElement = ElementFactory::createPolyPolyElement( m_pCurElement, getGCId(getCurrentContext()), aB2DPoly, PATH_EOFILL, // Hmm how do I know if this should be EO or not? -nTile, 0, 0 ); +nTile, +transformedxStep * aScale.getX(), +transformedyStep * -aScale.getY()); pPolyElement->updateGeometry(); pPolyElement->ZOrder = m_nNextZOrder++; } diff --git a/sdext/source/pdfimport/tree/writertreevisiting.cxx b/sdext/source/pdfimport/tree/writertreevisiting.cxx index 746fc9e77eb2..9012aaa21038 100644 --- a/sdext/source/pdfimport/tree/writertreevisiting.cxx +++ b/sdext/source/pdfimport/tree/writertreevisiting.cxx @@ -1004,7 +1004,8 @@ void WriterXmlFinalizer::visit( PolyPolyElement& elem, const std::list< std::uni aGCProps[ "draw:fill-image-name" ] = m_rStyleContainer.getStyleName( m_rStyleContainer.getStyleId(style)); - +aGCProps[ "draw:fill-image-width" ] = unitMMString(convPx2mm(elem.TileWidth)); +aGCProps[ "draw:fill-image-height" ] = unitMMString(convPx2mm(elem.TileHeight)); } // TODO(F1): check whether stuff could be emulated by gradient/bitmap/hatch
core.git: sdext/source
sdext/source/pdfimport/inc/genericelements.hxx | 11 --- sdext/source/pdfimport/tree/genericelements.cxx |8 ++-- sdext/source/pdfimport/tree/pdfiprocessor.cxx |8 3 files changed, 18 insertions(+), 9 deletions(-) New commits: commit 784696e47c7f28dac111b95e61f06a9a1f7cdc97 Author: Dr. David Alan Gilbert AuthorDate: Wed Feb 14 00:25:13 2024 + Commit: Noel Grandin CommitDate: Thu Feb 29 08:28:08 2024 +0100 tdf#113050 sdext.pdfimport: Add TileWidth and TileHeight fields We need to scale the tiled image that fills our polygon, so add width and height fields, we'll fill in and process them in subsequent patches. Change-Id: Ib066170ccbc0f4a4c971e1d6df72c3f7df14 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163573 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/inc/genericelements.hxx b/sdext/source/pdfimport/inc/genericelements.hxx index 4332d4f1372b..705773b9893a 100644 --- a/sdext/source/pdfimport/inc/genericelements.hxx +++ b/sdext/source/pdfimport/inc/genericelements.hxx @@ -213,7 +213,8 @@ namespace pdfi friend class ElementFactory; PolyPolyElement( Element* pParent, sal_Int32 nGCId, const basegfx::B2DPolyPolygon& rPolyPoly, - sal_Int8 nAction, ImageId nFillImage ); + sal_Int8 nAction, ImageId nFillImage, + double nTileWidth, double nTileHeight ); public: virtual void visitedBy( ElementTreeVisitor&, const std::list< std::unique_ptr >::const_iterator& rParentIt ) override; @@ -226,6 +227,8 @@ namespace pdfi basegfx::B2DPolyPolygon PolyPoly; sal_Int8Action; ImageId FillImage; +double TileWidth; +double TileHeight; }; struct ImageElement final : public DrawElement @@ -300,8 +303,10 @@ namespace pdfi createPolyPolyElement( Element* pParent, sal_Int32 nGCId, const basegfx::B2DPolyPolygon& rPolyPoly, - sal_Int8 nAction, ImageId nFillImage ) -{ return new PolyPolyElement( pParent, nGCId, rPolyPoly, nAction, nFillImage ); } + sal_Int8 nAction, ImageId nFillImage, + double nTileWidth, double nTileHeight ) +{ return new PolyPolyElement( pParent, nGCId, rPolyPoly, nAction, + nFillImage, nTileWidth, nTileHeight ); } static ImageElement* createImageElement( Element* pParent, sal_Int32 nGCId, ImageId nImage ) { return new ImageElement( pParent, nGCId, nImage ); } diff --git a/sdext/source/pdfimport/tree/genericelements.cxx b/sdext/source/pdfimport/tree/genericelements.cxx index 100e145608aa..aec9c999fcf6 100644 --- a/sdext/source/pdfimport/tree/genericelements.cxx +++ b/sdext/source/pdfimport/tree/genericelements.cxx @@ -125,11 +125,15 @@ PolyPolyElement::PolyPolyElement( Element* pParent, sal_Int32 nGCId, const basegfx::B2DPolyPolygon& rPolyPoly, sal_Int8 nAction, - ImageIdnFillImage ) + ImageIdnFillImage, + double nTileWidth, + double nTileHeight ) : DrawElement( pParent, nGCId ), PolyPoly( rPolyPoly ), Action( nAction ), - FillImage( nFillImage ) + FillImage( nFillImage ), + TileWidth( nTileWidth ), + TileHeight( nTileHeight ) { } diff --git a/sdext/source/pdfimport/tree/pdfiprocessor.cxx b/sdext/source/pdfimport/tree/pdfiprocessor.cxx index 0ef30a176ed2..6f4b45f21a40 100644 --- a/sdext/source/pdfimport/tree/pdfiprocessor.cxx +++ b/sdext/source/pdfimport/tree/pdfiprocessor.cxx @@ -433,7 +433,7 @@ void PDFIProcessor::tilingPatternFill(int nX0, int nY0, int nX1, int nY1, getGCId(getCurrentContext()), aB2DPoly, PATH_EOFILL, // Hmm how do I know if this should be EO or not? -nTile ); +nTile, 0, 0 ); pPolyElement->updateGeometry(); pPolyElement->ZOrder = m_nNextZOrder++; } @@ -448,7 +448,7 @@ void PDFIProcessor::strokePath( const uno::Reference< rendering::XPolyPolygon2D getGCId(getCurrentContext()), aPoly, PATH_STROKE, --1 ); +-1, 0, 0 ); pPoly->updateGeometry(); pPoly->ZOrder = m_nNextZOrder++; } @@ -463,7 +463,7 @@ void PDFIProcessor::fillPath( const uno::Reference< rendering::XPolyPolygon2D >&
core.git: sdext/source
sdext/source/pdfimport/tree/drawtreevisiting.cxx | 21 - sdext/source/pdfimport/tree/writertreevisiting.cxx | 21 - 2 files changed, 40 insertions(+), 2 deletions(-) New commits: commit 4b295b1b77b33c9a5b5fcfab58132ca0dcb7f90b Author: Dr. David Alan Gilbert AuthorDate: Mon Feb 12 01:24:07 2024 + Commit: Noel Grandin CommitDate: Thu Feb 29 08:27:48 2024 +0100 tdf#113050 sdext.pdfimport: Create the fill-image style and use it In a poly which is being image filled, we need to create a style with the actual image definition in the 'Contents' and then set the (automatically created) name of this in the prop on the main style. Also we need to set draw:fill to "bitmap" rather than "solid" Change-Id: I253704519011e98fd106331ccfb139ad93ef6dee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163572 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx index 5aae54415800..2c02adde8874 100644 --- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx +++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx @@ -817,10 +817,29 @@ void DrawXmlFinalizer::visit( PolyPolyElement& elem, const std::list< std::uniqu aGCProps[ "draw:stroke" ] = "none"; } +if (elem.FillImage != -1) +{ +PropertyMap props; +// The image isn't actually in a prop, it's in an extra chunk inside. +StyleContainer::Style style("draw:fill-image"_ostr, std::move(props)); +style.Contents = m_rProcessor.getImages().asBase64EncodedString(elem.FillImage); +aGCProps[ "draw:fill-image-name" ] = +m_rStyleContainer.getStyleName( +m_rStyleContainer.getStyleId(style)); + +} + // TODO(F1): check whether stuff could be emulated by gradient/bitmap/hatch if( elem.Action & (PATH_FILL | PATH_EOFILL) ) { -aGCProps[ "draw:fill" ] = "solid"; +if (elem.FillImage == -1) +{ +aGCProps[ "draw:fill" ] = "solid"; +} +else +{ +aGCProps[ "draw:fill" ] = "bitmap"; +} aGCProps[ "draw:fill-color" ] = getColorString(rGC.FillColor); if (rGC.FillColor.Alpha != 1.0) aGCProps["draw:opacity"] = getPercentString(rGC.FillColor.Alpha * 100.0); diff --git a/sdext/source/pdfimport/tree/writertreevisiting.cxx b/sdext/source/pdfimport/tree/writertreevisiting.cxx index 9ecce8f48be4..746fc9e77eb2 100644 --- a/sdext/source/pdfimport/tree/writertreevisiting.cxx +++ b/sdext/source/pdfimport/tree/writertreevisiting.cxx @@ -995,10 +995,29 @@ void WriterXmlFinalizer::visit( PolyPolyElement& elem, const std::list< std::uni aGCProps[ "draw:stroke" ] = "none"; } +if (elem.FillImage != -1) +{ +PropertyMap props; +// The image isn't actually in a prop, it's in an extra chunk inside. +StyleContainer::Style style("draw:fill-image"_ostr, std::move(props)); +style.Contents = m_rProcessor.getImages().asBase64EncodedString(elem.FillImage); +aGCProps[ "draw:fill-image-name" ] = +m_rStyleContainer.getStyleName( +m_rStyleContainer.getStyleId(style)); + +} + // TODO(F1): check whether stuff could be emulated by gradient/bitmap/hatch if( elem.Action & (PATH_FILL | PATH_EOFILL) ) { -aGCProps[ "draw:fill" ] = "solid"; +if (elem.FillImage == -1) +{ +aGCProps[ "draw:fill" ] = "solid"; +} +else +{ +aGCProps[ "draw:fill" ] = "bitmap"; +} aGCProps[ "draw:fill-color" ] = getColorString( rGC.FillColor ); } else
core.git: sdext/source
sdext/source/pdfimport/inc/pdfiprocessor.hxx |1 + 1 file changed, 1 insertion(+) New commits: commit 9f21f816a16914e06ff141a800a63f0966e387b2 Author: Dr. David Alan Gilbert AuthorDate: Mon Feb 12 01:29:38 2024 + Commit: Noel Grandin CommitDate: Thu Feb 29 08:26:58 2024 +0100 tdf#113050 sdext.pdfimport: Expose the ImageContainer const I need the finalisers to be able to read an image, they have a ref to the processor but not the emitter; so allow the container to be read via the processor reference. Change-Id: Ifd3b2af1d456561ad42ae3e7c664f03b2e0c971c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163571 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/inc/pdfiprocessor.hxx b/sdext/source/pdfimport/inc/pdfiprocessor.hxx index 40cdbfdd48c9..89a09d1780bf 100644 --- a/sdext/source/pdfimport/inc/pdfiprocessor.hxx +++ b/sdext/source/pdfimport/inc/pdfiprocessor.hxx @@ -71,6 +71,7 @@ namespace pdfi const GraphicsContext& getGraphicsContext( sal_Int32 nGCId ) const; GraphicsContext& getCurrentContext() { return m_aGCStack.back(); } const GraphicsContext& getCurrentContext() const { return m_aGCStack.back(); } +const ImageContainer& getImages() const { return m_aImages; }; const css::uno::Reference< css::task::XStatusIndicator >& getStatusIndicator() const { return m_xStatusIndicator; }
core.git: sdext/source
sdext/source/pdfimport/inc/genericelements.hxx |7 --- sdext/source/pdfimport/tree/genericelements.cxx |6 -- sdext/source/pdfimport/tree/pdfiprocessor.cxx | 15 ++- 3 files changed, 18 insertions(+), 10 deletions(-) New commits: commit 2bf5664823e7ef71d917fe95a2c3d92e46d77c32 Author: Dr. David Alan Gilbert AuthorDate: Mon Feb 12 01:14:06 2024 + Commit: Noel Grandin CommitDate: Thu Feb 29 08:26:40 2024 +0100 tdf#113050 sdext.pdfimport: Add FillImage field to PolyPolyElement Use -1 to mean the existing solid fill, otherwise it's the ID of the image to use as the fill. Change-Id: I596c26145f5285f75af631a3bb7ddf09600982a6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163570 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/inc/genericelements.hxx b/sdext/source/pdfimport/inc/genericelements.hxx index 6d1459a1f032..4332d4f1372b 100644 --- a/sdext/source/pdfimport/inc/genericelements.hxx +++ b/sdext/source/pdfimport/inc/genericelements.hxx @@ -213,7 +213,7 @@ namespace pdfi friend class ElementFactory; PolyPolyElement( Element* pParent, sal_Int32 nGCId, const basegfx::B2DPolyPolygon& rPolyPoly, - sal_Int8 nAction ); + sal_Int8 nAction, ImageId nFillImage ); public: virtual void visitedBy( ElementTreeVisitor&, const std::list< std::unique_ptr >::const_iterator& rParentIt ) override; @@ -225,6 +225,7 @@ namespace pdfi basegfx::B2DPolyPolygon PolyPoly; sal_Int8Action; +ImageId FillImage; }; struct ImageElement final : public DrawElement @@ -299,8 +300,8 @@ namespace pdfi createPolyPolyElement( Element* pParent, sal_Int32 nGCId, const basegfx::B2DPolyPolygon& rPolyPoly, - sal_Int8 nAction) -{ return new PolyPolyElement( pParent, nGCId, rPolyPoly, nAction ); } + sal_Int8 nAction, ImageId nFillImage ) +{ return new PolyPolyElement( pParent, nGCId, rPolyPoly, nAction, nFillImage ); } static ImageElement* createImageElement( Element* pParent, sal_Int32 nGCId, ImageId nImage ) { return new ImageElement( pParent, nGCId, nImage ); } diff --git a/sdext/source/pdfimport/tree/genericelements.cxx b/sdext/source/pdfimport/tree/genericelements.cxx index 1d11cd0d914e..100e145608aa 100644 --- a/sdext/source/pdfimport/tree/genericelements.cxx +++ b/sdext/source/pdfimport/tree/genericelements.cxx @@ -124,10 +124,12 @@ void ImageElement::visitedBy( ElementTreeVisitor& rVisi PolyPolyElement::PolyPolyElement( Element* pParent, sal_Int32 nGCId, const basegfx::B2DPolyPolygon& rPolyPoly, - sal_Int8 nAction ) + sal_Int8 nAction, + ImageIdnFillImage ) : DrawElement( pParent, nGCId ), PolyPoly( rPolyPoly ), - Action( nAction ) + Action( nAction ), + FillImage( nFillImage ) { } diff --git a/sdext/source/pdfimport/tree/pdfiprocessor.cxx b/sdext/source/pdfimport/tree/pdfiprocessor.cxx index 32280f8fd110..0ef30a176ed2 100644 --- a/sdext/source/pdfimport/tree/pdfiprocessor.cxx +++ b/sdext/source/pdfimport/tree/pdfiprocessor.cxx @@ -389,9 +389,10 @@ void PDFIProcessor::tilingPatternFill(int nX0, int nY0, int nX1, int nY1, double nxStep, double nyStep, int /* nPaintType */, css::geometry::AffineMatrix2D& rMat, - const css::uno::Sequence& /*xTile*/) + const css::uno::Sequence& xTile) { const GraphicsContext& rGC(getCurrentContext()); +auto nTile = m_aImages.addImage(xTile); basegfx::B2DTuple aScale, aTranslation; double fRotate, fShearX; @@ -431,7 +432,8 @@ void PDFIProcessor::tilingPatternFill(int nX0, int nY0, int nX1, int nY1, m_pCurElement, getGCId(getCurrentContext()), aB2DPoly, -PATH_EOFILL ); // Hmm how do I know if this should be EO or not? +PATH_EOFILL, // Hmm how do I know if this should be EO or not? +nTile ); pPolyElement->updateGeometry(); pPolyElement->ZOrder = m_nNextZOrder++; } @@ -445,7 +447,8 @@ void PDFIProcessor::strokePath( const uno::Reference< rendering::XPolyPolygon2D m_pCurElement, getGCId(getCurrentContext()), aPoly, -PATH_STROKE ); +PATH_STROKE, +-1 );
core.git: sdext/source
sdext/source/pdfimport/inc/imagecontainer.hxx |1 sdext/source/pdfimport/tree/imagecontainer.cxx | 31 + 2 files changed, 32 insertions(+) New commits: commit d7e5eae44e18ab89e85a0e6ed633853ede70ec71 Author: Dr. David Alan Gilbert AuthorDate: Mon Feb 12 00:44:31 2024 + Commit: Noel Grandin CommitDate: Thu Feb 29 08:26:04 2024 +0100 tdf#113050 sdext.pdfimport: Add ImageContainer::asBase64EncodedString' For fill-images we need the image as a string. Change-Id: I4a8429563b0e19ad977b4e933a0ffee378dab244 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163569 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/inc/imagecontainer.hxx b/sdext/source/pdfimport/inc/imagecontainer.hxx index d21ed7504f63..03672e8ca8b2 100644 --- a/sdext/source/pdfimport/inc/imagecontainer.hxx +++ b/sdext/source/pdfimport/inc/imagecontainer.hxx @@ -42,6 +42,7 @@ namespace pdfi ImageId addImage( const css::uno::Sequence< css::beans::PropertyValue>& xBitmap ); void writeBase64EncodedStream( ImageId nImageId, EmitContext& rContext ); +OUString asBase64EncodedString( ImageId nId ) const; }; } diff --git a/sdext/source/pdfimport/tree/imagecontainer.cxx b/sdext/source/pdfimport/tree/imagecontainer.cxx index a7154164d771..b9f7ef52e061 100644 --- a/sdext/source/pdfimport/tree/imagecontainer.cxx +++ b/sdext/source/pdfimport/tree/imagecontainer.cxx @@ -141,6 +141,37 @@ void ImageContainer::writeBase64EncodedStream( ImageId nId, EmitContext& rContex rContext.rEmitter.write( encodeBase64( aData.getConstArray(), aData.getLength() )); } +OUString ImageContainer::asBase64EncodedString( ImageId nId ) const +{ +OSL_ASSERT( nId >= 0 && o3tl::make_unsigned(nId) < m_aImages.size() ); + +const uno::Sequence& rEntry( m_aImages[nId] ); + +// find "InputSequence" property +const beans::PropertyValue* pAry(rEntry.getConstArray()); +const sal_Int32 nLen(rEntry.getLength()); +const beans::PropertyValue* pValue( +std::find_if(pAry, pAry+nLen, +[] (beans::PropertyValue const& v) -> bool { +return v.Name == "InputSequence"; +})); + +if (pValue == pAry + nLen ) +{ +SAL_WARN("sdext.pdfimport", "InputSequence not found"); +return ""; +} + +uno::Sequence aData; +if( !(pValue->Value >>= aData) ) +{ +SAL_WARN("sdext.pdfimport", "Wrong data type"); +return ""; +} + +return encodeBase64( aData.getConstArray(), aData.getLength() ); +} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
core.git: sdext/source
sdext/source/pdfimport/tree/style.cxx |4 1 file changed, 4 insertions(+) New commits: commit ff160e93d32c62e09b28393979b3535e01057cdc Author: Dr. David Alan Gilbert AuthorDate: Mon Feb 12 00:38:42 2024 + Commit: Noel Grandin CommitDate: Thu Feb 29 08:25:35 2024 +0100 tdf#113050 sdext.pdfimport: In styles wrap 'Contents' For draw:fill-image we need output like: Base64stuff https://gerrit.libreoffice.org/c/core/+/163568 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/tree/style.cxx b/sdext/source/pdfimport/tree/style.cxx index b97b1d3e9cdf..969fdc0e9648 100644 --- a/sdext/source/pdfimport/tree/style.cxx +++ b/sdext/source/pdfimport/tree/style.cxx @@ -197,7 +197,11 @@ void StyleContainer::impl_emitStyle( sal_Int32 nStyleId, for(sal_Int32 nSubStyle : rStyle.SubStyles) impl_emitStyle( nSubStyle, rContext, rContainedElemVisitor ); if( !rStyle.Contents.isEmpty() ) +{ +rContext.rEmitter.beginTag( "office:binary-data", PropertyMap() ); rContext.rEmitter.write( rStyle.Contents ); +rContext.rEmitter.endTag( "office:binary-data" ); +} if( rStyle.ContainedElement ) rStyle.ContainedElement->visitedBy( rContainedElemVisitor, std::list>::iterator() );
core.git: sdext/source
sdext/source/pdfimport/tree/style.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit bc5bd022a9ea8128bd5e9ba02bda48332dccbbe4 Author: Dr. David Alan Gilbert AuthorDate: Sat Feb 10 01:00:18 2024 + Commit: Noel Grandin CommitDate: Thu Feb 29 08:25:08 2024 +0100 tdf#113050 sdext.pdfimport: In styles Specialise draw:fill-image Like stroke-dash, draw:fill-image needs the name setting in the draw:name attribute. Change-Id: Ib9c888765af8bfb0849f0f1ef15f9774808a1661 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163567 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/tree/style.cxx b/sdext/source/pdfimport/tree/style.cxx index 3f1d20eb4244..b97b1d3e9cdf 100644 --- a/sdext/source/pdfimport/tree/style.cxx +++ b/sdext/source/pdfimport/tree/style.cxx @@ -190,7 +190,7 @@ void StyleContainer::impl_emitStyle( sal_Int32 nStyleId, PropertyMap aProps( rStyle.Properties ); if( !rStyle.IsSubStyle ) aProps[ "style:name" ] = getStyleName( nStyleId ); -if (rStyle.Name == "draw:stroke-dash") +if (rStyle.Name == "draw:stroke-dash" || rStyle.Name == "draw:fill-image") aProps[ "draw:name" ] = aProps[ "style:name" ]; rContext.rEmitter.beginTag( rStyle.Name.getStr(), aProps );
core.git: sdext/source
sdext/source/pdfimport/tree/pdfiprocessor.cxx | 52 -- 1 file changed, 48 insertions(+), 4 deletions(-) New commits: commit 2350357d5cc2ac1787816ce887af6e9f36b8d252 Author: Dr. David Alan Gilbert AuthorDate: Fri Feb 9 02:42:30 2024 + Commit: Noel Grandin CommitDate: Thu Feb 29 08:24:48 2024 +0100 tdf#113050 sdext.pdfimport: Create poly for tiling pattern Create a poly for the tiling pattern fill. Change-Id: Iaeadfe51bed6d4de87f36b3a78145829ea8443e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163566 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/tree/pdfiprocessor.cxx b/sdext/source/pdfimport/tree/pdfiprocessor.cxx index cf65223f167a..32280f8fd110 100644 --- a/sdext/source/pdfimport/tree/pdfiprocessor.cxx +++ b/sdext/source/pdfimport/tree/pdfiprocessor.cxx @@ -28,6 +28,8 @@ #include +#include + #include #include #include @@ -383,13 +385,55 @@ void PDFIProcessor::drawAlphaMaskedImage(const uno::Sequence& /*xTile*/) { -// TODO +const GraphicsContext& rGC(getCurrentContext()); + +basegfx::B2DTuple aScale, aTranslation; +double fRotate, fShearX; +auto rTfm = rGC.Transformation; +rTfm.decompose(aScale, aTranslation, fRotate, fShearX); + +// Build a poly covering the whole fill area +double np0x = nX0 * nxStep; +double np0y = nY0 * nyStep; +double np1x = nX1 * nxStep; +double np1y = nY1 * nyStep; + +// Transform with the rMat passed in +double tmpx, tmpy; +tmpx = np0x * rMat.m00 + np0y * rMat.m01 + rMat.m02; +tmpy = np0x * rMat.m10 + np0y * rMat.m11 + rMat.m12; +np0x = tmpx; +np0y = tmpy; +tmpx = np1x * rMat.m00 + np1y * rMat.m01 + rMat.m02; +tmpy = np1x * rMat.m10 + np1y * rMat.m11 + rMat.m12; +np1x = tmpx; +np1y = tmpy; + +auto aB2DPoly = basegfx::B2DPolyPolygon(basegfx::utils::createPolygonFromRect(basegfx::B2DRange(np0x, np0y, np1x, np1y))); +aB2DPoly.transform(getCurrentContext().Transformation); + +// Clip against current clip path, if any +basegfx::B2DPolyPolygon aCurClip = getCurrentContext().Clip; +if( aCurClip.count() ) { +aB2DPoly = basegfx::utils::clipPolyPolygonOnPolyPolygon( aB2DPoly, aCurClip, + true, /* bInside, keep parts inside the clip */ + false /* bStroke, filled not stroked */ ); +} +// TODO: That clipping might shift the fill pattern offsets + +auto pPolyElement = ElementFactory::createPolyPolyElement( +m_pCurElement, +getGCId(getCurrentContext()), +aB2DPoly, +PATH_EOFILL ); // Hmm how do I know if this should be EO or not? +pPolyElement->updateGeometry(); +pPolyElement->ZOrder = m_nNextZOrder++; } void PDFIProcessor::strokePath( const uno::Reference< rendering::XPolyPolygon2D >& rPath )
core.git: sdext/source
sdext/source/pdfimport/wrapper/keyword_list |1 sdext/source/pdfimport/wrapper/wrapper.cxx | 33 2 files changed, 34 insertions(+) New commits: commit ec0b9062dc8dba82509183eb865da55827bde4d5 Author: Dr. David Alan Gilbert AuthorDate: Wed Jan 24 02:10:18 2024 + Commit: Noel Grandin CommitDate: Thu Feb 29 08:23:54 2024 +0100 tdf#113050 sdext.pdfimport Tiling pattern fill parser Add a parser for the TilingPatternFill entry from the poppler wrapper. This doesn't get triggered yet until the wrapper enables the tilingPatternFill. Change-Id: I34ab84ba1ab9d6773f33d667b324bef5d6c6e409 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163564 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/wrapper/keyword_list b/sdext/source/pdfimport/wrapper/keyword_list index bf15ddb2460f..4d1e6d2d4013 100644 --- a/sdext/source/pdfimport/wrapper/keyword_list +++ b/sdext/source/pdfimport/wrapper/keyword_list @@ -38,6 +38,7 @@ setTextRenderMode,SETTEXTRENDERMODE setTransformation,SETTRANSFORMATION startPage,STARTPAGE strokePath,STROKEPATH +tilingPatternFill,TILINGPATTERNFILL updateBlendMode,UPDATEBLENDMODE updateCtm,UPDATECTM updateFillColor,UPDATEFILLCOLOR diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index ade4dc5edb6b..6094bfabcbbc 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -107,6 +107,7 @@ enum parseKey { SETTRANSFORMATION, STARTPAGE, STROKEPATH, +TILINGPATTERNFILL, UPDATEBLENDMODE, UPDATECTM, UPDATEFILLCOLOR, @@ -195,6 +196,7 @@ public: void readLink(); void readMaskedImage(); void readSoftMaskedImage(); +void readTilingPatternFill(); }; /** Unescapes line-ending characters in input string. These @@ -813,6 +815,35 @@ void LineParser::readSoftMaskedImage() m_parser.m_pSink->drawAlphaMaskedImage( aImage, aMask ); } +void LineParser::readTilingPatternFill() +{ +sal_Int32 nX0, nY0, nX1, nY1, nPaintType; +double nXStep, nYStep; +geometry::AffineMatrix2D aMat; +readInt32(nX0); +readInt32(nY0); +readInt32(nX1); +readInt32(nY1); + +readDouble(nXStep); +readDouble(nYStep); + +readInt32(nPaintType); + +readDouble(aMat.m00); +readDouble(aMat.m10); +readDouble(aMat.m01); +readDouble(aMat.m11); +readDouble(aMat.m02); +readDouble(aMat.m12); + +// The tile is an image with alpha +[[maybe_unused]]const uno::Sequence aTile ( readImageImpl() ); +(void)aTile; // Unused until later patch +// TODO +// use the parsed data +} + void Parser::parseLine( std::string_view aLine ) { OSL_PRECOND( m_pSink, "Invalid sink" ); @@ -865,6 +896,8 @@ void Parser::parseLine( std::string_view aLine ) } case STROKEPATH: m_pSink->strokePath(lp.readPath()); break; +case TILINGPATTERNFILL: +lp.readTilingPatternFill(); break; case UPDATECTM: lp.readTransformation(); break; case UPDATEFILLCOLOR:
core.git: sdext/source
sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx | 44 +- 1 file changed, 42 insertions(+), 2 deletions(-) New commits: commit b7a63d26466bac7eb7b25233a5a53788bed88c81 Author: Dr. David Alan Gilbert AuthorDate: Sun Feb 18 22:00:37 2024 + Commit: Noel Grandin CommitDate: Thu Feb 29 08:23:28 2024 +0100 tdf#113050 sdext.pdfimport: Flip bitmap We need to flip the bitmap between the wrapper and LO, but there's no easy way to do this in a Poly image fill in LO, so do it as a simple bitmap flip in the wrapper. Change-Id: Ifd84d37926c21edf30654d3884be975849a6dca3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163563 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index 57eb30092141..ec2632b74899 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -432,8 +432,6 @@ static void writeImage_( OutputBuffer& o_rOutputBuf, } // forwarders - - static void writeImageLF( OutputBuffer& o_rOutputBuf, Stream* str, int width, @@ -445,6 +443,45 @@ static void writeMaskLF( OutputBuffer& o_rOutputBuf, int height, bool bInvert ) { writeMask_(o_rOutputBuf,str,width,height,bInvert); } +// Vertically flip the bitmap +static void flipSplashBitmap(SplashBitmap *pBitmap) +{ +if (pBitmap->getRowSize() <= 0) +return; + +auto nBitmapHeight = static_cast(pBitmap->getHeight()); +auto nRowSize = static_cast(pBitmap->getRowSize()); +auto nAlphaRowSize = static_cast(pBitmap->getAlphaRowSize()); + +auto aTmpRow = new unsigned char[nRowSize]; +auto aTmpAlphaRow = new unsigned char[nAlphaRowSize]; + +auto pBitmapData = pBitmap->getDataPtr(); +auto pAlphaData = pBitmap->getAlphaPtr(); + +// Set up pairs of pointers working from each end of the bitmap +auto pCurRowA = pBitmapData; +auto pCurAlphaA = pAlphaData; +auto pCurRowB = pBitmapData+nRowSize*(nBitmapHeight-1); +auto pCurAlphaB = pAlphaData+nAlphaRowSize*(nBitmapHeight-1); + +for (size_t nCur = 0; + nCur < nBitmapHeight/2; + nCur++, pCurRowA+=nRowSize, pCurRowB-=nRowSize, + pCurAlphaA+=nAlphaRowSize, pCurAlphaB-=nAlphaRowSize) +{ +memcpy(aTmpRow, pCurRowA, nRowSize); +memcpy(pCurRowA, pCurRowB, nRowSize); +memcpy(pCurRowB, aTmpRow, nRowSize); + +memcpy(aTmpAlphaRow, pCurAlphaA, nAlphaRowSize); +memcpy(pCurAlphaA, pCurAlphaB, nAlphaRowSize); +memcpy(pCurAlphaB, aTmpAlphaRow, nAlphaRowSize); +} +delete[] aTmpRow; +delete[] aTmpAlphaRow; +} + int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, const GfxState* state ) const { FontAttributes aNewFont; @@ -1236,6 +1273,9 @@ poppler_bool PDFOutDev::tilingPatternFill(GfxState *state, Gfx *, Catalog *, delete pSplashGfx; delete pSplashOut; +// Add a vertical flip, we can't do this in LO for an image filled poly +flipSplashBitmap(pSplashBitmap); + auto nBitmapWidth = static_cast(pSplashBitmap->getWidth()); auto nBitmapHeight = static_cast(pSplashBitmap->getHeight());
core.git: sdext/source
sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx | 64 +- 1 file changed, 62 insertions(+), 2 deletions(-) New commits: commit 8ac5f40b330c6cd248073b8686c05f566ecd7195 Author: Dr. David Alan Gilbert AuthorDate: Sun Feb 18 21:45:42 2024 + Commit: Noel Grandin CommitDate: Thu Feb 29 08:22:38 2024 +0100 tdf#113050 sdext.pdfimport: Write the tiling pattern image Render the tile down to a common format using Splash and write it to the stream. Change-Id: Iccc451d1a02ed2ad77538883ab3fe5542fc633e2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163562 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index e7afe67afef4..57eb30092141 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -1182,13 +1182,15 @@ void PDFOutDev::setSkipImages( bool bSkipImages ) } #if POPPLER_CHECK_VERSION(21, 3, 0) -poppler_bool PDFOutDev::tilingPatternFill(GfxState *, Gfx *, Catalog *, +poppler_bool PDFOutDev::tilingPatternFill(GfxState *state, Gfx *, Catalog *, GfxTilingPattern *tPat, const double *mat, int x0, int y0, int x1, int y1, double xStep, double yStep) { const double *pBbox = tPat->getBBox(); const int nPaintType = tPat->getPaintType(); +Dict *pResDict = tPat->getResDict(); +Object *aStr = tPat->getContentStream(); double nWidth = pBbox[2] - pBbox[0]; double nHeight = pBbox[3] - pBbox[1]; @@ -1215,7 +1217,65 @@ poppler_bool PDFOutDev::tilingPatternFill(GfxState *, Gfx *, Catalog *, normalize(mat[4]), normalize(mat[5]) ); -// TODO: Write the image +PDFRectangle aBox; +aBox.x1 = pBbox[0]; +aBox.y1 = pBbox[1]; +aBox.x2 = pBbox[2]; +aBox.y2 = pBbox[3]; + +const int nDPI = 72; // GfxState seems to have 72.0 as magic for some reason +auto pSplashGfxState = new GfxState(nDPI, nDPI, , 0, false); +auto pSplashOut = new SplashOutputDev(splashModeRGB8, 1, false, nullptr); +pSplashOut->setEnableFreeType(false); +pSplashOut->startPage(0 /* pageNum */, pSplashGfxState, nullptr /* xref */); + +auto pSplashGfx = new Gfx(m_pDoc, pSplashOut, pResDict, , nullptr); +pSplashGfx->display(aStr); +auto pSplashBitmap = pSplashOut->takeBitmap(); +delete pSplashGfxState; +delete pSplashGfx; +delete pSplashOut; + +auto nBitmapWidth = static_cast(pSplashBitmap->getWidth()); +auto nBitmapHeight = static_cast(pSplashBitmap->getHeight()); + +char *pBitmapData = reinterpret_cast(pSplashBitmap->getDataPtr()); +if (nPaintType == 2) +{ +// My understanding is Type 2 fills are just bitmaps of *what* to fill +// in the current fill colour. +// sending it to LO as a flat colour image with the alpha map is easiest +GfxRGB aCurFill; +unsigned char r,g,b; +state->getFillColorSpace()->getRGB(state->getFillColor(), ); +r = colToByte(aCurFill.r); +g = colToByte(aCurFill.g); +b = colToByte(aCurFill.b); + +for(size_t i=0; i < (nBitmapWidth * nBitmapHeight * 3); i+=3) +{ +pBitmapData[i ] = r; +pBitmapData[i+1] = g; +pBitmapData[i+2] = b; +} +} + +auto pRgbStr = new MemStream(pBitmapData, 0, +nBitmapWidth * nBitmapHeight * 3, Object(objNull)); +auto pAlphaStr = new MemStream(reinterpret_cast(pSplashBitmap->getAlphaPtr()), 0, +nBitmapWidth * nBitmapHeight, Object(objNull)); +auto aDecode = Object(objNull); +auto pRgbIdentityColorMap = new GfxImageColorMap(8, , new GfxDeviceRGBColorSpace()); +auto pGrayIdentityColorMap = new GfxImageColorMap(8, , new GfxDeviceGrayColorSpace()); + +OutputBuffer aBuf; initBuf(aBuf); +writePng_(aBuf, pRgbStr, nBitmapWidth, nBitmapHeight, pRgbIdentityColorMap, +pAlphaStr, nBitmapWidth, nBitmapHeight, pGrayIdentityColorMap); +writeBinaryBuffer(aBuf); + +delete pAlphaStr; +delete pRgbStr; +delete pSplashBitmap; // If we return false here we can fall back to the slow path return true;
core.git: sdext/source
sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx | 64 +- sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx |7 + 2 files changed, 70 insertions(+), 1 deletion(-) New commits: commit 8e4a351f12d777ad9102086298741d0a97e5eeb9 Author: Dr. David Alan Gilbert AuthorDate: Mon Jan 15 02:09:39 2024 + Commit: Noel Grandin CommitDate: Thu Feb 29 08:21:09 2024 +0100 tdf#113050 sdext.pdfimport: Write the tiling pattern header Add the 'tilingPatternFill' hook to our output device, but don't enable it yet; we can do that at the end of the series. Change-Id: Id52b023c3025f5addce1ab09663da9b8bd8a75e4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163561 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index 2517618e1019..e7afe67afef4 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -20,6 +20,25 @@ #include "pdfioutdev_gpl.hxx" #include "pnghelper.hxx" +#if defined __GNUC__ || defined __clang__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunused-parameter" +#elif defined _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4100) // unreferenced formal parameter +#pragma warning(disable : 4121) // alignment of a member was sensitive to packing in Gfx.h/Operator +#endif + +#include +#include +#include +#if defined __GNUC__ || defined __clang__ +# pragma GCC diagnostic pop +#elif defined _MSC_VER +#pragma warning(pop) +#endif + + #include #include #include @@ -426,7 +445,6 @@ static void writeMaskLF( OutputBuffer& o_rOutputBuf, int height, bool bInvert ) { writeMask_(o_rOutputBuf,str,width,height,bInvert); } - int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, const GfxState* state ) const { FontAttributes aNewFont; @@ -1163,6 +1181,50 @@ void PDFOutDev::setSkipImages( bool bSkipImages ) m_bSkipImages = bSkipImages; } +#if POPPLER_CHECK_VERSION(21, 3, 0) +poppler_bool PDFOutDev::tilingPatternFill(GfxState *, Gfx *, Catalog *, + GfxTilingPattern *tPat, const double *mat, + int x0, int y0, int x1, int y1, + double xStep, double yStep) +{ +const double *pBbox = tPat->getBBox(); +const int nPaintType = tPat->getPaintType(); +double nWidth = pBbox[2] - pBbox[0]; +double nHeight = pBbox[3] - pBbox[1]; + +// If our wrapper is skipping images then we don't need to do anything +// but return 'true' so that Poppler doesn't do the slow method +if (m_bSkipImages) +return true; + +// Copied from the Cairo output dev; I think this is patterns +// with gaps, let poppler do the slow method for now. +if (xStep != nWidth || yStep != nHeight) +return false; + +printf( "tilingPatternFill %d %d %d %d %f %f " +"%d " +"%f %f %f %f %f %f", // No ending space! + +x0, y0, x1, y1, normalize(xStep), normalize(yStep), + +nPaintType, + +normalize(mat[0]), normalize(mat[1]), +normalize(mat[2]), normalize(mat[3]), +normalize(mat[4]), normalize(mat[5]) +); + +// TODO: Write the image + +// If we return false here we can fall back to the slow path +return true; +} + +// This could be implemented for earlier versions, but the interface keeps +// changing a little; not having it is only a problem for inputs with +// large patterns. +#endif } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx index b34fad1ba90a..f38bf423423b 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx @@ -283,6 +283,13 @@ namespace pdfi static void setPageNum( int nNumPages ); void setSkipImages ( bool bSkipImages ); +#if POPPLER_CHECK_VERSION(21, 3, 0) +poppler_bool useTilingPatternFill() override { return false; }; +poppler_bool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, + GfxTilingPattern *tPat, const double *mat, + int x0, int y0, int x1, int y1, + double xStep, double yStep) override; +#endif }; }
core.git: sdext/source
sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) New commits: commit 1637610478c4493c29a29286b66250ef47507681 Author: Thorsten Behrens AuthorDate: Sat Jan 13 21:40:09 2024 +0100 Commit: Thorsten Behrens CommitDate: Sat Jan 13 23:52:08 2024 +0100 Fix obscure xpdfimport crash on missing fonts Invert logic, such that the case WMode == 0 and no font set now run the former else branch. Happened here for an obscure pdf I was missing some fonts for. Change-Id: I2825c914a04f6a95d459eeeffb8091ed8f1819dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162029 Tested-by: Jenkins Reviewed-by: Thorsten Behrens diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index 3ad139b65fa3..2517618e1019 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -956,18 +956,18 @@ void PDFOutDev::drawChar(GfxState *state, double x, double y, double csdx = 0.0; double csdy = 0.0; -if (state->getFont()->getWMode()) +if (!state->getFont() || !state->getFont()->getWMode()) { -csdy = state->getCharSpace(); +csdx = state->getCharSpace(); if (*u == ' ') -csdy += state->getWordSpace(); +csdx += state->getWordSpace(); +csdx *= state->getHorizScaling(); } else { -csdx = state->getCharSpace(); +csdy = state->getCharSpace(); if (*u == ' ') -csdx += state->getWordSpace(); -csdx *= state->getHorizScaling(); +csdy += state->getWordSpace(); } double cstdx = 0.0;
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/tree/writertreevisiting.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 5589659829f8a1cef8ca1c8a468732105bbe231b Author: Kevin Suo AuthorDate: Wed Nov 22 16:11:33 2023 +0800 Commit: Kevin Suo CommitDate: Tue Nov 28 03:08:39 2023 +0100 tdf#157589 tdf#153969: Revert "sdext.pdfimport Writer: Do not visit... ... DrawElement twice in WriterXmlEmitter" This reverts commit 9ea9d3ccc0f8e4833e745d9655b61d42d6d8fe83. The reason for the revert: It causes regressions as indicated in tdf#157589 and tdf#153969. That commit may be my misunderstanding of the code. Change-Id: Idd188bf83721d309623a7f8484d064327a3a23af Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159811 Tested-by: Jenkins Reviewed-by: Kevin Suo diff --git a/sdext/source/pdfimport/tree/writertreevisiting.cxx b/sdext/source/pdfimport/tree/writertreevisiting.cxx index 7941f7d35709..9ecce8f48be4 100644 --- a/sdext/source/pdfimport/tree/writertreevisiting.cxx +++ b/sdext/source/pdfimport/tree/writertreevisiting.cxx @@ -413,7 +413,7 @@ void WriterXmlEmitter::visit( DocumentElement& elem, const std::list< std::uniqu // only DrawElement types for( auto it = elem.Children.begin(); it != elem.Children.end(); ++it ) { -if( dynamic_cast(it->get()) != nullptr ) +if( dynamic_cast(it->get()) == nullptr ) (*it)->visitedBy( *this, it ); }
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/pdfparse/pdfparse.cxx | 19 --- 1 file changed, 12 insertions(+), 7 deletions(-) New commits: commit ba26d5f5e0529d7accf6f268559b8d659ba7c6c2 Author: Mike Kaganski AuthorDate: Tue Oct 31 20:43:52 2023 +0300 Commit: Mike Kaganski CommitDate: Tue Oct 31 21:11:34 2023 +0100 tdf#106057: Don't fail PDFReader::read, when several entries in stack It may happen in case of several trailers, which is OK. The calling code will check the type of the returned object anyway. Change-Id: I17b2f4b7cf0e0640f949565291ee5a905ef2411e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158737 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/sdext/source/pdfimport/pdfparse/pdfparse.cxx b/sdext/source/pdfimport/pdfparse/pdfparse.cxx index baa322c1aa3c..cdd3ac13ff35 100644 --- a/sdext/source/pdfimport/pdfparse/pdfparse.cxx +++ b/sdext/source/pdfimport/pdfparse/pdfparse.cxx @@ -601,21 +601,26 @@ std::unique_ptr PDFReader::read( const char* pFileName ) pRet.reset(aGrammar.m_aObjectStack.back()); aGrammar.m_aObjectStack.pop_back(); } -#if OSL_DEBUG_LEVEL > 0 else if( nEntries > 1 ) { +// It is possible that there are multiple trailers, which is OK. +// But still keep the warnings, just in case. SAL_WARN("sdext.pdfimport.pdfparse", "error got " << nEntries << " stack objects in parse"); -for( unsigned int i = 0; i < nEntries; i++ ) +for (;;) { -SAL_WARN("sdext.pdfimport.pdfparse", typeid(*aGrammar.m_aObjectStack[i]).name()); -PDFObject* pObj = dynamic_cast(aGrammar.m_aObjectStack[i]); +PDFEntry* pEntry = aGrammar.m_aObjectStack.back(); +aGrammar.m_aObjectStack.pop_back(); +SAL_WARN("sdext.pdfimport.pdfparse", typeid(*pEntry).name()); +PDFObject* pObj = dynamic_cast(pEntry); if( pObj ) SAL_WARN("sdext.pdfimport.pdfparse", " -> object " << pObj->m_nNumber << " generation " << pObj->m_nGeneration); -else -SAL_WARN("sdext.pdfimport.pdfparse", "(type " << typeid(*aGrammar.m_aObjectStack[i]).name() << ")"); +if (aGrammar.m_aObjectStack.empty()) +{ +pRet.reset(pEntry); // The first entry references all others - see PDFGrammar dtor +break; +} } } -#endif return pRet; }
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/pdfparse/pdfparse.cxx | 76 --- 1 file changed, 76 deletions(-) New commits: commit 046e9545956d8ad1d69345d6b4a4c0a33714d179 Author: Mike Kaganski AuthorDate: Tue Oct 31 20:09:35 2023 +0300 Commit: Mike Kaganski CommitDate: Tue Oct 31 21:01:10 2023 +0100 Try to revert to use of file_iterator from boost on Windows It was disabled in commit ef8d59c5b909d5a9b956934ab1120f90b90a4e10 (vcl108: #i106853# work around broken file_iterator on Windows, 2009-12-01), referencing boost 1.39. It seems to work fine now, so let's revert it, and hope it doesn't break something. Change-Id: I208aa87eca146a29ffc2f36a48810ecda5df0f00 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158736 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/sdext/source/pdfimport/pdfparse/pdfparse.cxx b/sdext/source/pdfimport/pdfparse/pdfparse.cxx index 7cef299e8eaa..baa322c1aa3c 100644 --- a/sdext/source/pdfimport/pdfparse/pdfparse.cxx +++ b/sdext/source/pdfimport/pdfparse/pdfparse.cxx @@ -558,83 +558,8 @@ public: } -#ifdef _WIN32 -std::unique_ptr PDFReader::read( const char* pBuffer, unsigned int nLen ) -{ -PDFGrammar aGrammar( pBuffer ); - -try -{ -#if OSL_DEBUG_LEVEL > 0 -boost::spirit::classic::parse_info aInfo = -#endif -boost::spirit::classic::parse( pBuffer, - pBuffer+nLen, - aGrammar, - boost::spirit::classic::space_p ); -#if OSL_DEBUG_LEVEL > 0 -SAL_INFO("sdext.pdfimport.pdfparse", "parseinfo: stop = " << aInfo.stop << " (buff=" << pBuffer << ", offset = " << aInfo.stop - pBuffer << "), hit = " << (aInfo.hit ? OUString("true") : OUString("false")) << ", full = " << (aInfo.full ? OUString("true") : OUString("false")) << ", length = " << static_cast(aInfo.length) ); -#endif -} -catch( const parser_error& rError ) -{ -#if OSL_DEBUG_LEVEL > 0 -OString aTmp; -unsigned int nElem = aGrammar.m_aObjectStack.size(); -for( unsigned int i = 0; i < nElem; i++ ) -aTmp += OString::Concat(" ") + typeid( *(aGrammar.m_aObjectStack[i]) ).name(); - -SAL_WARN("sdext.pdfimport.pdfparse", "parse error: " << rError.descriptor << " at buffer pos " << rError.where - pBuffer << ", object stack: " << aTmp); -#else -(void)rError; -#endif -} - -std::unique_ptr pRet; -unsigned int nEntries = aGrammar.m_aObjectStack.size(); -if( nEntries == 1 ) -{ -pRet.reset(aGrammar.m_aObjectStack.back()); -aGrammar.m_aObjectStack.pop_back(); -} -#if OSL_DEBUG_LEVEL > 0 -else if( nEntries > 1 ) -SAL_WARN("sdext.pdfimport.pdfparse", "error got " << nEntries << " stack objects in parse" ); -#endif - -return pRet; -} -#endif - std::unique_ptr PDFReader::read( const char* pFileName ) { -#ifdef _WIN32 -/* #i106583# - since converting to boost 1.39 file_iterator does not work anymore on all Windows systems - C++ stdlib istream_iterator does not allow "-" apparently - using spirit 2.0 doesn't work in our environment with the MSC - - So for the time being bite the bullet and read the whole file. - FIXME: give Spirit 2.x another try when we upgrade boost again. -*/ -std::unique_ptr pRet; -FILE* fp = fopen( pFileName, "rb" ); -if( fp ) -{ -fseek( fp, 0, SEEK_END ); -unsigned int nLen = static_cast(ftell( fp )); -fseek( fp, 0, SEEK_SET ); -char* pBuf = static_cast(std::malloc( nLen )); -if( pBuf ) -{ -fread( pBuf, 1, nLen, fp ); -pRet = read( pBuf, nLen ); -std::free( pBuf ); -} -fclose( fp ); -} -return pRet; -#else file_iterator<> file_start( pFileName ); if( ! file_start ) return nullptr; @@ -692,7 +617,6 @@ std::unique_ptr PDFReader::read( const char* pFileName ) } #endif return pRet; -#endif // WIN32 } #if defined(_MSC_VER)
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/filterdet.cxx | 39 +++ 1 file changed, 39 insertions(+) New commits: commit 9dd0af943df70d7797196ee8f9717596f28b1849 Author: Caolán McNamara AuthorDate: Tue Sep 26 15:52:17 2023 +0100 Commit: Caolán McNamara CommitDate: Thu Sep 28 10:14:49 2023 +0200 cool#7307 short-circuit pdf parsing during detect if no 'AdditionalStreams' looks to me that we ignore the contents of the AdditionalStream and re-parse to get it in the final importer, in which case we could presumably parse the mimetype in AdditionalStream here and drop the extraction of the stream. Change-Id: I28e42c2b2fe8d4e10591e523260b08a0d0f7ca28 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157287 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/sdext/source/pdfimport/filterdet.cxx b/sdext/source/pdfimport/filterdet.cxx index ef29e8a2c022..5f6392e18983 100644 --- a/sdext/source/pdfimport/filterdet.cxx +++ b/sdext/source/pdfimport/filterdet.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -512,6 +513,40 @@ bool checkDocChecksum( const OUString& rInPDFFileURL, && (0 == memcmp(nChecksum.data(), nTestChecksum, nChecksum.size())); } +/* https://github.com/CollaboraOnline/online/issues/7307 + + Light-weight detection to determine if this is a hybrid + pdf document worth parsing to get its AdditionalStream + and mimetype. + + TODO: a) do we really ignore the contents of the AdditionalStream + and re-parse to get it in the final importer? + b) in which case we could presumably parse the mimetype in + AdditionalStream here and drop the extraction of the stream. +*/ +static bool detectHasAdditionalStreams(const OUString& rSysUPath) +{ +SvFileStream aHybridDetect(rSysUPath, StreamMode::READ); +std::vector aTrailingLines; +const sal_uInt64 nLen = aHybridDetect.remainingSize(); +aHybridDetect.Seek(nLen - std::min(nLen, 4096)); +OString aLine; +while (aHybridDetect.ReadLine(aLine)) +aTrailingLines.push_back(aLine); +bool bAdditionalStreams(false); +for (auto it = aTrailingLines.rbegin(); it != aTrailingLines.rend(); ++it) +{ +if (*it == "trailer") +break; +if (it->startsWith("/AdditionalStreams ")) +{ +bAdditionalStreams = true; +break; +} +} +return bAdditionalStreams; +} + uno::Reference< io::XStream > getAdditionalStream( const OUString& rInPDFFileURL, OUString& rOutMimetype, OUString& io_rPwd, @@ -524,6 +559,10 @@ uno::Reference< io::XStream > getAdditionalStream( const OUString& OUString aSysUPath; if( osl_getSystemPathFromFileURL( rInPDFFileURL.pData, ) != osl_File_E_None ) return xEmbed; + +if (!detectHasAdditionalStreams(aSysUPath)) +return xEmbed; + aPDFFile = OUStringToOString( aSysUPath, osl_getThreadTextEncoding() ); std::unique_ptr pEntry( pdfparse::PDFReader::read( aPDFFile.getStr() ));
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/pdfiadaptor.cxx |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) New commits: commit 116adf5341c681e4044f9fe940d0d143eeabc457 Author: Mike Kaganski AuthorDate: Sun Apr 23 20:14:38 2023 +0300 Commit: Mike Kaganski CommitDate: Sun Apr 30 17:45:22 2023 +0200 Use getXWeak in sdext Change-Id: I24563de37b98cad57823fe936e5bfa7e10e8a2c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150866 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/sdext/source/pdfimport/pdfiadaptor.cxx b/sdext/source/pdfimport/pdfiadaptor.cxx index 9cca84cdf92f..0d5bad2d6373 100644 --- a/sdext/source/pdfimport/pdfiadaptor.cxx +++ b/sdext/source/pdfimport/pdfiadaptor.cxx @@ -329,7 +329,7 @@ sdext_PDFIRawAdaptor_Writer_get_implementation( rtl::Reference pAdaptor = new pdfi::PDFIRawAdaptor( "org.libreoffice.comp.documents.WriterPDFImport", context ); pAdaptor->setTreeVisitorFactory(pdfi::createWriterTreeVisitorFactory()); pAdaptor->acquire(); -return static_cast(pAdaptor.get()); +return getXWeak(pAdaptor.get()); } extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* @@ -339,7 +339,7 @@ sdext_PDFIRawAdaptor_Draw_get_implementation( rtl::Reference pAdaptor = new pdfi::PDFIRawAdaptor( "org.libreoffice.comp.documents.DrawPDFImport", context ); pAdaptor->setTreeVisitorFactory(pdfi::createDrawTreeVisitorFactory()); pAdaptor->acquire(); -return static_cast(pAdaptor.get()); +return getXWeak(pAdaptor.get()); } extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* @@ -349,7 +349,7 @@ sdext_PDFIRawAdaptor_Impress_get_implementation( rtl::Reference pAdaptor = new pdfi::PDFIRawAdaptor( "org.libreoffice.comp.documents.ImpressPDFImport", context ); pAdaptor->setTreeVisitorFactory(pdfi::createImpressTreeVisitorFactory()); pAdaptor->acquire(); -return static_cast(pAdaptor.get()); +return getXWeak(pAdaptor.get()); } extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/filterdet.cxx |3 --- 1 file changed, 3 deletions(-) New commits: commit b9249d7c4db6e20dcc1bcca88b350e9ee547c992 Author: Caolán McNamara AuthorDate: Thu Jan 26 14:02:10 2023 + Commit: Caolán McNamara CommitDate: Thu Jan 26 14:58:46 2023 + cid#1520592 Logically dead code Change-Id: If0e52b474369657e0ed602f859d180f829865f9c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146176 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/sdext/source/pdfimport/filterdet.cxx b/sdext/source/pdfimport/filterdet.cxx index 24bff08ccb6f..69aa90a26b9b 100644 --- a/sdext/source/pdfimport/filterdet.cxx +++ b/sdext/source/pdfimport/filterdet.cxx @@ -357,9 +357,6 @@ OUString SAL_CALL PDFDetector::detect( uno::Sequence< beans::PropertyValue >& rF aOutFilterName = "calc_pdf_addstream_import"; } -if (!bSuccess) -return OUString(); - if (!aOutFilterName.isEmpty()) { if( nFilterNamePos == -1 )
[Libreoffice-commits] core.git: sdext/source
sdext/source/minimizer/optimizerdialog.cxx | 10 +- sdext/source/minimizer/optimizerdialog.hxx |6 ++ 2 files changed, 11 insertions(+), 5 deletions(-) New commits: commit 4e0970bebd06ba988a59213b827a1c0a44c76ac2 Author: Caolán McNamara AuthorDate: Sat Dec 17 20:57:46 2022 + Commit: Caolán McNamara CommitDate: Sat Dec 17 21:51:42 2022 + cid#1517773 silence Wrapper object use after free Change-Id: I6652bfd32eb604ebb2a5b7deb573d9c979ec6d5e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144391 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/sdext/source/minimizer/optimizerdialog.cxx b/sdext/source/minimizer/optimizerdialog.cxx index 351c98df6c41..68aaf2662fb5 100644 --- a/sdext/source/minimizer/optimizerdialog.cxx +++ b/sdext/source/minimizer/optimizerdialog.cxx @@ -61,6 +61,7 @@ IntroPage::IntroPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog) , mxComboBox(m_xBuilder->weld_combo_box("LB_SETTINGS")) , mxButton(m_xBuilder->weld_button("STR_REMOVE")) { +rOptimizerDialog.SetIntroPage(this); mxComboBox->connect_changed(LINK(this, IntroPage, ComboBoxActionPerformed)); mxButton->connect_clicked(LINK(this, IntroPage, ButtonActionPerformed)); } @@ -83,6 +84,7 @@ SlidesPage::SlidesPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog , mxComboBox(m_xBuilder->weld_combo_box("LB_SLIDES")) , mxClearNodes(m_xBuilder->weld_check_button("STR_DELETE_NOTES_PAGES")) { +rOptimizerDialog.SetSlidesPage(this); mxMasterSlides->connect_toggled(LINK(this, SlidesPage, UnusedMasterPagesActionPerformed)); mxHiddenSlides->connect_toggled(LINK(this, SlidesPage, UnusedHiddenSlidesActionPerformed)); mxUnusedSlides->connect_toggled(LINK(this, SlidesPage, UnusedSlidesActionPerformed)); @@ -116,6 +118,7 @@ ImagesPage::ImagesPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog , m_xRemoveCropArea(m_xBuilder->weld_check_button("STR_REMOVE_CROP_AREA")) , m_xEmbedLinkedGraphics(m_xBuilder->weld_check_button("STR_EMBED_LINKED_GRAPHICS")) { +rOptimizerDialog.SetImagesPage(this); m_xRemoveCropArea->connect_toggled(LINK(this, ImagesPage, RemoveCropAreaActionPerformed)); m_xEmbedLinkedGraphics->connect_toggled(LINK(this, ImagesPage, EmbedLinkedGraphicsActionPerformed)); m_xResolution->connect_changed(LINK(this, ImagesPage, ComboBoxActionPerformed)); @@ -146,6 +149,7 @@ ObjectsPage::ObjectsPage(weld::Container* pPage, OptimizerDialog& rOptimizerDial , m_xForeignOLEObjects(m_xBuilder->weld_radio_button("STR_ALIEN_OLE_OBJECTS_ONLY")) , m_xLabel(m_xBuilder->weld_label("STR_OLE_OBJECTS_DESC")) { +rOptimizerDialog.SetObjectsPage(this); m_xCreateStaticImage->connect_toggled(LINK(this, ObjectsPage, OLEOptimizationActionPerformed)); m_xAllOLEObjects->connect_toggled(LINK(this, ObjectsPage, OLEActionPerformed)); m_xForeignOLEObjects->connect_toggled(LINK(this, ObjectsPage, OLEActionPerformed)); @@ -180,6 +184,7 @@ SummaryPage::SummaryPage(weld::Container* pPage, OptimizerDialog& rOptimizerDial , m_xComboBox(m_xBuilder->weld_combo_box("MY_SETTINGS")) , m_xSaveSettings(m_xBuilder->weld_check_button("STR_SAVE_SETTINGS")) { +rOptimizerDialog.SetSummaryPage(this); m_xApplyToCurrent->connect_toggled(LINK(this, SummaryPage, SaveAsNewActionPerformed)); m_xSaveToNew->connect_toggled(LINK(this, SummaryPage, SaveAsNewActionPerformed)); m_xSaveSettings->connect_toggled(LINK(this, SummaryPage, SaveSettingsActionPerformed)); @@ -316,23 +321,18 @@ std::unique_ptr OptimizerDialog::createPage(vcl::WizardTypes::Wizar { case ITEM_ID_INTRODUCTION: xRet.reset(new IntroPage(pPageContainer, *this)); -mpPage0 = static_cast(xRet.get()); break; case ITEM_ID_SLIDES: xRet.reset(new SlidesPage(pPageContainer, *this)); -mpPage1 = static_cast(xRet.get()); break; case ITEM_ID_GRAPHIC_OPTIMIZATION: xRet.reset(new ImagesPage(pPageContainer, *this)); -mpPage2 = static_cast(xRet.get()); break; case ITEM_ID_OLE_OPTIMIZATION: xRet.reset(new ObjectsPage(pPageContainer, *this)); -mpPage3 = static_cast(xRet.get()); break; case ITEM_ID_SUMMARY: xRet.reset(new SummaryPage(pPageContainer, *this)); -mpPage4 = static_cast(xRet.get()); break; } diff --git a/sdext/source/minimizer/optimizerdialog.hxx b/sdext/source/minimizer/optimizerdialog.hxx index e36e5fe43262..88c01b54300b 100644 --- a/sdext/source/minimizer/optimizerdialog.hxx +++ b/sdext/source/minimizer/optimizerdialog.hxx @@ -231,6 +231,12 @@ public: void UpdateControlStates( sal_Int16 nStep = -1 ); +void SetIntroPage(IntroPage* pPage0) { mpPage0 = pPage0; } +void SetSlidesPage(SlidesPage* pPage1) { mpPage1 =
[Libreoffice-commits] core.git: sdext/source
sdext/source/minimizer/optimizerdialog.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 705b2924a14841883b4a8cac549f7af326d7a185 Author: Andrea Gelmini AuthorDate: Tue Dec 6 22:34:11 2022 +0100 Commit: Noel Grandin CommitDate: Thu Dec 8 08:04:14 2022 + Removed useless semicolon Change-Id: I0c931d5f856bda5b6ec91d813fe92fbc72ff1aae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143747 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/minimizer/optimizerdialog.cxx b/sdext/source/minimizer/optimizerdialog.cxx index 1d54b6c8ede1..351c98df6c41 100644 --- a/sdext/source/minimizer/optimizerdialog.cxx +++ b/sdext/source/minimizer/optimizerdialog.cxx @@ -334,7 +334,7 @@ std::unique_ptr OptimizerDialog::createPage(vcl::WizardTypes::Wizar xRet.reset(new SummaryPage(pPageContainer, *this)); mpPage4 = static_cast(xRet.get()); break; -}; +} m_xAssistant->set_page_title(sIdent, getStateDisplayName(nState));
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/inc/pdfiprocessor.hxx |1 + sdext/source/pdfimport/tree/drawtreevisiting.hxx |2 -- 2 files changed, 1 insertion(+), 2 deletions(-) New commits: commit 83e58fc9f19a8da751cabdc0440aded62dc67fea Author: Kevin Suo AuthorDate: Fri Dec 2 19:22:11 2022 +0800 Commit: Stephan Bergmann CommitDate: Wed Dec 7 07:33:41 2022 + sdext: move the include of XComponentContext.hpp to where it is used ... and remove unsed include. XComponentContext.hpp is used in pdfiprocessor.hxx but not in drawtreevisiting.hxx. XMultiServiceFactory.hpp is not used drawtreevisiting.hxx. Change-Id: Ic98cbcdcacd07cf2163e02ac569781f70edd953c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143570 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/sdext/source/pdfimport/inc/pdfiprocessor.hxx b/sdext/source/pdfimport/inc/pdfiprocessor.hxx index 7cbe7d7a5104..3fdc146716b3 100644 --- a/sdext/source/pdfimport/inc/pdfiprocessor.hxx +++ b/sdext/source/pdfimport/inc/pdfiprocessor.hxx @@ -20,6 +20,7 @@ #ifndef INCLUDED_SDEXT_SOURCE_PDFIMPORT_INC_PDFIPROCESSOR_HXX #define INCLUDED_SDEXT_SOURCE_PDFIMPORT_INC_PDFIPROCESSOR_HXX +#include #include #include #include diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.hxx b/sdext/source/pdfimport/tree/drawtreevisiting.hxx index 81bfd927354b..e3ea8e537ff5 100644 --- a/sdext/source/pdfimport/tree/drawtreevisiting.hxx +++ b/sdext/source/pdfimport/tree/drawtreevisiting.hxx @@ -24,8 +24,6 @@ #include #include -#include -#include namespace pdfi {
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/inc/genericelements.hxx |4 +--- sdext/source/pdfimport/tree/genericelements.cxx |4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) New commits: commit c9e961e6803a70587bd4686d05abdd4ac11de434 Author: Kevin Suo AuthorDate: Mon Dec 5 17:37:39 2022 +0800 Commit: Kevin Suo CommitDate: Tue Dec 6 03:42:27 2022 + "using namespace com::sun::star" -> css in header file See Stephan Bergmann's comment the following change (thanks!): https://gerrit.libreoffice.org/c/core/+/143598 Change-Id: I409b823439979c64cadcb582d8fb4dec4ff412b9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143664 Tested-by: Jenkins Reviewed-by: Kevin Suo diff --git a/sdext/source/pdfimport/inc/genericelements.hxx b/sdext/source/pdfimport/inc/genericelements.hxx index 37b448d2b613..6d1459a1f032 100644 --- a/sdext/source/pdfimport/inc/genericelements.hxx +++ b/sdext/source/pdfimport/inc/genericelements.hxx @@ -32,8 +32,6 @@ #include -using namespace com::sun::star; - namespace pdfi { class XmlEmitter; @@ -313,7 +311,7 @@ namespace pdfi { return std::make_shared(); } }; -bool isComplex(const uno::Reference& rBreakIterator, TextElement* const pTextElem); +bool isComplex(const css::uno::Reference& rBreakIterator, TextElement* const pTextElem); } #endif diff --git a/sdext/source/pdfimport/tree/genericelements.cxx b/sdext/source/pdfimport/tree/genericelements.cxx index c3c816aecdf2..1d11cd0d914e 100644 --- a/sdext/source/pdfimport/tree/genericelements.cxx +++ b/sdext/source/pdfimport/tree/genericelements.cxx @@ -431,12 +431,12 @@ void DocumentElement::visitedBy( ElementTreeVisitor& rV rVisitor.visit(*this, rParentIt); } -bool isComplex(const uno::Reference& rBreakIterator, TextElement* const pTextElem) { +bool isComplex(const css::uno::Reference& rBreakIterator, TextElement* const pTextElem) { OUString str(pTextElem->Text.toString()); for(int i=0; i< str.getLength(); i++) { sal_Int16 nType = rBreakIterator->getScriptType(str, i); -if (nType == i18n::ScriptType::COMPLEX) +if (nType == css::i18n::ScriptType::COMPLEX) { return true; }
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/wrapper/wrapper.cxx |4 1 file changed, 4 insertions(+) New commits: commit 00bf67a99dcdb1549401f0b656e872e5c9762dc5 Author: Kevin Suo AuthorDate: Sat Dec 3 19:54:59 2022 +0800 Commit: Noel Grandin CommitDate: Sun Dec 4 14:56:40 2022 + tdf#147246 sdext: font name returned by font descriptor may be... ... e.g. "NotoSerifCJKjp-Regular-VKana". Change-Id: I9818579c7678b0dad5ec2d2217ae59d573de88b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143609 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index da506d9ceef8..e3e1c3aa8d04 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -630,6 +630,10 @@ void LineParser::readFont() aResult.familyName = aResult.familyName.copy(7, aResult.familyName.getLength() - 7); parseFontFamilyName(aResult); } +if (aResult.familyName.endsWithIgnoreAsciiCase("-VKana")) +{ +parseFontFamilyName(aResult); +} // Font weight if (aFontReadResult.GetWeight() == WEIGHT_THIN)
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/inc/genericelements.hxx |5 + sdext/source/pdfimport/tree/drawtreevisiting.cxx | 20 +++- sdext/source/pdfimport/tree/genericelements.cxx | 15 ++- 3 files changed, 22 insertions(+), 18 deletions(-) New commits: commit 842e3b988aca27d7c9f71ce1efc6653271cc3430 Author: Kevin Suo AuthorDate: Fri Dec 2 22:53:27 2022 +0800 Commit: Noel Grandin CommitDate: Sun Dec 4 14:54:34 2022 + tdf#152083 related: make the isComplex check block as a separate function This is used to check whether a TextElement is rtl. We will need this in WriterXmlOptimizer::optimizeTextElements() as well, in a separate commit. Change-Id: Iee2ff5990450421153bb7c5afe9526c555f2d0ba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143598 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/inc/genericelements.hxx b/sdext/source/pdfimport/inc/genericelements.hxx index 1fec2e6f4042..37b448d2b613 100644 --- a/sdext/source/pdfimport/inc/genericelements.hxx +++ b/sdext/source/pdfimport/inc/genericelements.hxx @@ -25,12 +25,15 @@ #include #include +#include #include #include #include #include +using namespace com::sun::star; + namespace pdfi { class XmlEmitter; @@ -309,6 +312,8 @@ namespace pdfi static std::shared_ptr createDocumentElement() { return std::make_shared(); } }; + +bool isComplex(const uno::Reference& rBreakIterator, TextElement* const pTextElem); } #endif diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx index 64aca46ce18b..b94a302a5583 100644 --- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx +++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx @@ -682,17 +682,10 @@ void DrawXmlOptimizer::optimizeTextElements(Element& rParent) if( pCur ) { TextElement* pNext = (*next)->dynCastAsTextElement(); -bool isComplex = false; -OUString str(pCur->Text.toString()); -for(int i=0; i< str.getLength(); i++) -{ -sal_Int16 nType = GetBreakIterator()->getScriptType( str, i ); -if (nType == css::i18n::ScriptType::COMPLEX) -isComplex = true; -} +OUString str; bool bPara = strspn("ParagraphElement", typeid(rParent).name()); ParagraphElement* pPara = dynamic_cast(); -if (bPara && pPara && isComplex) +if (bPara && pPara && isComplex(GetBreakIterator(), pCur)) pPara->bRtl = true; if( pNext ) { @@ -756,14 +749,7 @@ void DrawXmlOptimizer::optimizeTextElements(Element& rParent) pCur->Text.append( pNext->Text ); } -str = pCur->Text.toString(); -for(int i=0; i< str.getLength(); i++) -{ -sal_Int16 nType = GetBreakIterator()->getScriptType( str, i ); -if (nType == css::i18n::ScriptType::COMPLEX) -isComplex = true; -} -if (bPara && pPara && isComplex) +if (bPara && pPara && isComplex(GetBreakIterator(), pCur)) pPara->bRtl = true; // append eventual children to current element // and clear children (else the children just diff --git a/sdext/source/pdfimport/tree/genericelements.cxx b/sdext/source/pdfimport/tree/genericelements.cxx index 7f751e18ba5c..c3c816aecdf2 100644 --- a/sdext/source/pdfimport/tree/genericelements.cxx +++ b/sdext/source/pdfimport/tree/genericelements.cxx @@ -22,7 +22,8 @@ #include #include - +#include +#include #include #include #include @@ -430,6 +431,18 @@ void DocumentElement::visitedBy( ElementTreeVisitor& rV rVisitor.visit(*this, rParentIt); } +bool isComplex(const uno::Reference& rBreakIterator, TextElement* const pTextElem) { +OUString str(pTextElem->Text.toString()); +for(int i=0; i< str.getLength(); i++) +{ +sal_Int16 nType = rBreakIterator->getScriptType(str, i); +if (nType == i18n::ScriptType::COMPLEX) +{ +return true; +} +} +return false; +} }
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/tree/drawtreevisiting.cxx |2 +- sdext/source/pdfimport/tree/writertreevisiting.cxx |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) New commits: commit d423e18de7c48df359d2d2d1b5b8f5cceac4d96a Author: Kevin Suo AuthorDate: Sat Dec 3 18:43:02 2022 +0800 Commit: Noel Grandin CommitDate: Sat Dec 3 14:07:03 2022 + tdf#147246 sdext.pdfimport: "font-family-asia" -> "font-family-asian" This was a typo which causes the asian font in pdf (e.g. Chinese) always shown as the system default font on pdfimport. Change-Id: Ic118f8585fb40dfc4bc5bc12651da95bc7961ae4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143607 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx index 8338ba6dbfde..64aca46ce18b 100644 --- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx +++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx @@ -878,7 +878,7 @@ void DrawXmlFinalizer::visit( TextElement& elem, const std::list< std::unique_pt // TODO: tdf#143095: use system font name rather than PSName SAL_INFO("sdext.pdfimport", "The font used in xml is: " << rFont.familyName); aFontProps[ "fo:font-family" ] = rFont.familyName; -aFontProps[ "style:font-family-asia" ] = rFont.familyName; +aFontProps[ "style:font-family-asian" ] = rFont.familyName; aFontProps[ "style:font-family-complex" ] = rFont.familyName; // bold diff --git a/sdext/source/pdfimport/tree/writertreevisiting.cxx b/sdext/source/pdfimport/tree/writertreevisiting.cxx index cc2cee18eb6a..de44dcf711b4 100644 --- a/sdext/source/pdfimport/tree/writertreevisiting.cxx +++ b/sdext/source/pdfimport/tree/writertreevisiting.cxx @@ -976,7 +976,7 @@ void WriterXmlFinalizer::visit( TextElement& elem, const std::list< std::unique_ // TODO: tdf#143095: use system font name rather than PSName SAL_INFO("sdext.pdfimport", "The font used in xml is: " << rFont.familyName); aFontProps[ "fo:font-family" ] = rFont.familyName; -aFontProps[ "style:font-family-asia" ] = rFont.familyName; +aFontProps[ "style:font-family-asian" ] = rFont.familyName; aFontProps[ "style:font-family-complex" ] = rFont.familyName; // bold
[Libreoffice-commits] core.git: sdext/source
sdext/source/presenter/PresenterScreen.cxx |6 -- 1 file changed, 4 insertions(+), 2 deletions(-) New commits: commit 9db4f60bfc5aa90a9062e429a07889b60ae99e9c Author: Daniel Lohmann AuthorDate: Sun Nov 27 19:54:15 2022 +0100 Commit: Samuel Mehrbrodt CommitDate: Thu Dec 1 10:53:32 2022 +0100 tdf#92717 Presenter screen on one monitor If the presenter screen should be shown as normal window (not a full screen window) the presenter screen can also be shown on one monitor, as then the presenter screen can be minimized. This is a follow up to a15bcda0e21be04bec424172192f2416b7f52422 Change-Id: I6fd19aa120a0b0e894b156b4bd10059741f91dc5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143355 Reviewed-by: Samuel Mehrbrodt Tested-by: Samuel Mehrbrodt diff --git a/sdext/source/presenter/PresenterScreen.cxx b/sdext/source/presenter/PresenterScreen.cxx index c4f2cda50f3e..cf24a26f7bf1 100644 --- a/sdext/source/presenter/PresenterScreen.cxx +++ b/sdext/source/presenter/PresenterScreen.cxx @@ -465,17 +465,19 @@ sal_Int32 PresenterScreen::GetPresenterScreenNumber ( // There is either only one screen or the full screen // presentation spans all available screens. The presenter // screen is shown only when a special flag in the configuration -// is set. +// is set or when the presenter screen will be shown as +// non-full screen window Reference xContext (mxContextWeak); PresenterConfigurationAccess aConfiguration ( xContext, "/org.openoffice.Office.PresenterScreen/", PresenterConfigurationAccess::READ_ONLY); bool bStartAlways (false); +bool bPresenterScreenFullScreen = isPresenterScreenFullScreen(xContext); if (aConfiguration.GetConfigurationNode( "Presenter/StartAlways") >>= bStartAlways) { -if (bStartAlways) +if (bStartAlways || !bPresenterScreenFullScreen) return GetPresenterScreenFromScreen(nScreenNumber); } return -1;
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/tree/drawtreevisiting.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit cea9ca3b77ef7f8f11c3eae0786986028161301c Author: Caolán McNamara AuthorDate: Sun Nov 27 16:23:10 2022 + Commit: Caolán McNamara CommitDate: Sun Nov 27 20:14:07 2022 +0100 cid#982469 Unchecked dynamic_cast Change-Id: I48904acdd34d7b546a8099f265693e2d46c5d2aa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143347 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx index 2356ddc254c4..2e56bb449662 100644 --- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx +++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx @@ -706,7 +706,7 @@ void DrawXmlOptimizer::optimizeTextElements(Element& rParent) ) { pCur->updateGeometryWith( pNext ); -if (pPara->bRtl) +if (pPara && pPara->bRtl) { // Tdf#152083: If RTL, reverse the text in pNext so that its correct order is // restored when the combined text is reversed in DrawXmlEmitter::visit.
[Libreoffice-commits] core.git: sdext/source
dev/null |binary 1 file changed New commits: commit 9206895999f36a8199862912afe0ca91462e914a Author: Xisco Fauli AuthorDate: Fri Nov 25 10:22:08 2022 +0100 Commit: Xisco Fauli CommitDate: Fri Nov 25 15:18:05 2022 +0100 sdext: remove unused document it was added in bc48dbe08db537f41e42839a0493317298606413 "sdext.pdfimport: Use string() in xpath for testTdf104597_textrun" for no reason Change-Id: I58abed336cb4c8ca5cfe488f81fbf2332ff43c34 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143278 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/sdext/source/pdfimport/test/testdocs/testTdf152083_rtl-ligatures.pdf b/sdext/source/pdfimport/test/testdocs/testTdf152083_rtl-ligatures.pdf deleted file mode 100644 index 635004c2e302.. Binary files a/sdext/source/pdfimport/test/testdocs/testTdf152083_rtl-ligatures.pdf and /dev/null differ
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/test/tests.cxx| 11 ++--- sdext/source/pdfimport/tree/drawtreevisiting.cxx | 46 ++- 2 files changed, 49 insertions(+), 8 deletions(-) New commits: commit 3a2f0e4772e7b4646dd518b33aeafb6fd7025179 Author: Kevin Suo AuthorDate: Sun Nov 20 00:10:14 2022 +0800 Commit: Noel Grandin CommitDate: Fri Nov 25 08:44:02 2022 +0100 Resolves tdf#152083: Ligatures are incorrectly reversed in Draw pdf import For the string "بسم الله الرحمن الرحیم", the xpdfimport generates the following drawChar tokens: drawChar 438.50 723.30 446.744000 723.30 1.00 0.00 0.00 1.00 12.00 م drawChar 446.696000 723.30 450.908000 723.30 1.00 0.00 0.00 1.00 12.00 ی drawChar 450.896000 723.30 458.804000 723.30 1.00 0.00 0.00 1.00 12.00 ح drawChar 458.792000 723.30 463.784000 723.30 1.00 0.00 0.00 1.00 12.00 ر drawChar 463.688000 723.30 467.048000 723.30 1.00 0.00 0.00 1.00 12.00 ل drawChar 467.072000 723.30 469.964000 723.30 1.00 0.00 0.00 1.00 12.00 ا drawChar 469.964000 723.30 473.708000 723.30 1.00 0.00 0.00 1.00 12.00 drawChar 473.756000 723.30 482.78 723.30 1.00 0.00 0.00 1.00 12.00 ن drawChar 482.756000 723.30 490.028000 723.30 1.00 0.00 0.00 1.00 12.00 م drawChar 490.04 723.30 497.948000 723.30 1.00 0.00 0.00 1.00 12.00 ح drawChar 497.936000 723.30 502.928000 723.30 1.00 0.00 0.00 1.00 12.00 ر drawChar 502.928000 723.30 506.288000 723.30 1.00 0.00 0.00 1.00 12.00 ل drawChar 506.312000 723.30 509.204000 723.30 1.00 0.00 0.00 1.00 12.00 ا drawChar 509.108000 723.30 512.852000 723.30 1.00 0.00 0.00 1.00 12.00 drawChar 512.90 723.30 527.216000 723.30 1.00 0.00 0.00 1.00 12.00 الله drawChar 527.204000 723.30 530.948000 723.30 1.00 0.00 0.00 1.00 12.00 drawChar 530.996000 723.30 539.24 723.30 1.00 0.00 0.00 1.00 12.00 م drawChar 539.288000 723.30 552.02 723.30 1.00 0.00 0.00 1.00 12.00 س drawChar 551.888000 723.30 555.236000 723.30 1.00 0.00 0.00 1.00 12.00 ب Previously, all the above are combined to a single text frame in DrawXmlOptimizer::optimizeTextElements, and then the text in the text frame is reversed (commit 69e9925ded584113e52f84ef0ed7c224079fa061, and further improved by commit 50d73574b6c3d71f9a539c895a15d6fcda22390b). The problem is that, the single token "الله" was already in correct order. Thus when it is reversed together with others, the order for itself would be wrong. Fix this by doing a pre-reverse. The space char needs special treatment, as observed in tdf104597_textrun.pdf. Change-Id: If0bd716cc2d68820436d0e3f0f161ffb9cb4397a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142978 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx index c199c2cc4547..7c10c85b29a5 100644 --- a/sdext/source/pdfimport/test/tests.cxx +++ b/sdext/source/pdfimport/test/tests.cxx @@ -798,15 +798,14 @@ namespace // Test for امُ عَلَيْكَ OString xpath = "string(//draw:frame[@draw:transform='matrix(917. 0 0 917. 14821.958333 2159.23861112778)']/draw:text-box/text:p/text:span)"; OUString sContent = getXPathContent(pXmlDoc, xpath); -CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"اُم َعَلْيَك"), sContent.replaceAll("\n\n", " ").replaceAll("\n", "")); +CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"امُ عَلَيَْك"), sContent.replaceAll("\n\n", " ").replaceAll("\n", "")); -// Test for ٱلسََّل . It appears in the 3rd frame, i.e. after the امُ عَلَيْكَ which is in the 2nd frame (from left to right) +// Test for ٱلسََّل . It appears in the 3rd frame, i.e. after the امُ عَلَيَْك which is in the 2nd frame (from left to right) // thus these two frames together appear as ٱلسََّل امُ عَلَيْكَ in Draw. // FIXME: Should be ٱلسَّلَامُ عَلَيْكَ (i.e. the two text frames should be merged into one so that the ل and the ا will show as لَا rather than ل ا) -// Note: this is commented due to ٱلسََّل is currently shown as ٱلَّسَل and will be fixed in a separate commit. -//xpath = "string(//draw:frame[@draw:transform='matrix(917. 0 0 917. 17420.17
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/test/testdocs/testTdf152083_rtl-ligatures.pdf |binary sdext/source/pdfimport/test/tests.cxx| 54 +- 2 files changed, 28 insertions(+), 26 deletions(-) New commits: commit bc48dbe08db537f41e42839a0493317298606413 Author: Kevin Suo AuthorDate: Sat Nov 19 19:01:04 2022 +0800 Commit: Noel Grandin CommitDate: Sun Nov 20 12:00:08 2022 +0100 sdext.pdfimport: Use string() in xpath for testTdf104597_textrun ...and remove the TODO comments. Also, comment out the test for string ٱلسََّل which is related to tdf#152083 and will be fixed in a separate commit. Change-Id: I075145be1ff58c16e976c710fbf8f55fc6752af1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142962 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/test/testdocs/testTdf152083_rtl-ligatures.pdf b/sdext/source/pdfimport/test/testdocs/testTdf152083_rtl-ligatures.pdf new file mode 100644 index ..635004c2e302 Binary files /dev/null and b/sdext/source/pdfimport/test/testdocs/testTdf152083_rtl-ligatures.pdf differ diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx index 786815941445..c199c2cc4547 100644 --- a/sdext/source/pdfimport/test/tests.cxx +++ b/sdext/source/pdfimport/test/tests.cxx @@ -796,28 +796,33 @@ namespace xmlDocUniquePtr pXmlDoc(xmlParseDoc(reinterpret_cast(aOutput.getStr(; // Test for امُ عَلَيْكَ -// TODO: How to get the "عَلَيْكَ" in xpath, as shown after the tag? -OString xpath = "//draw:frame[@draw:transform='matrix(917. 0 0 917. 14821.958333 2159.23861112778)']/draw:text-box/text:p/text:span"; -OUString sContent = getXPathContent(pXmlDoc, xpath); // u"\nا\nُ\nم\n" -CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"اُم"), sContent.replaceAll("\n", "")); - -// Test for ٱلَّسَل . It appears in the 3rd frame, i.e. after the امُ عَلَيْكَ which is in the 2nd frame (from left to right) -// thus these two frames together appear as ٱلَّسَل امُ عَلَيْكَ in Draw. -xpath = "//draw:frame[@draw:transform='matrix(917. 0 0 917. 17420.17 2159.23861112778)']/draw:text-box/text:p/text:span"; +OString xpath = "string(//draw:frame[@draw:transform='matrix(917. 0 0 917. 14821.958333 2159.23861112778)']/draw:text-box/text:p/text:span)"; +OUString sContent = getXPathContent(pXmlDoc, xpath); +CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"اُم َعَلْيَك"), sContent.replaceAll("\n\n", " ").replaceAll("\n", "")); + +// Test for ٱلسََّل . It appears in the 3rd frame, i.e. after the امُ عَلَيْكَ which is in the 2nd frame (from left to right) +// thus these two frames together appear as ٱلسََّل امُ عَلَيْكَ in Draw. +// FIXME: Should be ٱلسَّلَامُ عَلَيْكَ (i.e. the two text frames should be merged into one so that the ل and the ا will show as لَا rather than ل ا) +// Note: this is commented due to ٱلسََّل is currently shown as ٱلَّسَل and will be fixed in a separate commit. +//xpath = "string(//draw:frame[@draw:transform='matrix(917. 0 0 917. 17420.17 2159.23861112778)']/draw:text-box/text:p/text:span)"; +//sContent = getXPathContent(pXmlDoc, xpath); +//CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"ٱلسََّل"), sContent.replaceAll("\n\n", " ").replaceAll("\n", "")); + +// Test for "LibreOffice RTL" +xpath = "string(//draw:frame[@draw:transform='matrix(917. 0 0 917. 12779.375 5121.79583335)']/draw:text-box/text:p/text:span)"; sContent = getXPathContent(pXmlDoc, xpath); -CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"ٱلَّسَل"), sContent.replaceAll("\n", "")); +CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"LibreOffice RTL"), sContent.replaceAll("\n\n", " ").replaceAll("\n", "")); -// Test for "LibreOffice LTR" -// TODO: How to get the "LTR" as shown after the tag? -xpath = "//draw:frame[@draw:transform='matrix(917. 0 0 917. 12779.375 5121.79583335)']/draw:text-box/text:p/text:span"; +// Test for "LibreOffice LTR (test)" +xpath = "string(//draw:frame[last()-1]/draw:text-box/text:p/text:span[last()])"; sContent = getXPathContent(pXmlDoc, xpath); -CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"LibreOffice"), sContent.replaceAll("\n", "")); +CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"LibreOffice LTR (test)"), sContent.replaceAll("\n\n", " ").replaceAll("\n", "")); /* Test for
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/test/testdocs/testSpace.pdf |binary sdext/source/pdfimport/test/tests.cxx | 38 + sdext/source/pdfimport/tree/writertreevisiting.cxx | 28 +-- 3 files changed, 63 insertions(+), 3 deletions(-) New commits: commit c2e2997f452b93b400d541c2d0b2ee396a889007 Author: Kevin Suo AuthorDate: Wed Oct 19 19:08:27 2022 +0800 Commit: Noel Grandin CommitDate: Tue Nov 8 08:40:29 2022 +0100 sdext.pdfimport - Wirter: add handling for continuous space characters This was done for Draw in sdext/source/pdfimport/tree/drawtreevisiting.cxx, but was not done for Writer. Without this, continuous spaces in PDF will show only one space on pdfimport using the Writer pdfimport filter. Change-Id: I2279d9b1750e07f5743aeba80a3fd553bc037d13 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141527 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/test/testdocs/testSpace.pdf b/sdext/source/pdfimport/test/testdocs/testSpace.pdf new file mode 100644 index ..3c94f31ea15b Binary files /dev/null and b/sdext/source/pdfimport/test/testdocs/testSpace.pdf differ diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx index 71661ae9e6d5..786815941445 100644 --- a/sdext/source/pdfimport/test/tests.cxx +++ b/sdext/source/pdfimport/test/tests.cxx @@ -841,6 +841,43 @@ namespace #endif } +void testSpaces() +{ +#if HAVE_FEATURE_POPPLER +rtl::Reference xAdaptor(new pdfi::PDFIRawAdaptor(OUString(), getComponentContext())); +xAdaptor->setTreeVisitorFactory(createWriterTreeVisitorFactory()); + +OString aOutput; + xAdaptor->odfConvert(m_directories.getURLFromSrc(u"/sdext/source/pdfimport/test/testdocs/testSpace.pdf"), +new OutputWrapString(aOutput), +nullptr); +xmlDocUniquePtr pXmlDoc(xmlParseDoc(reinterpret_cast(aOutput.getStr(; + +// Space test: there are 10 spaces, each space is expressed as a , +// thus the 10th text:s should exist and the attribute "text:c" should be "1". +OString xpath = "//draw:frame[@draw:z-index='1'][1]/draw:text-box/text:p/text:span/text:s[10]"; +OUString sContent = getXPath(pXmlDoc, xpath, "c"); +CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString("1"), sContent); + +// Tab test: there are 10 tabs. Text before and after the tabs are shown in different draw frames. +// With the Liberation Serif font, the horizontal position of the first frame is 20.03mm and the +// second frame is 94.12mm. +xpath = "//draw:frame[@draw:z-index='2'][1]"; +sContent = getXPath(pXmlDoc, xpath, "transform"); +CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString("translate( 20.03mm 25.05mm )"), sContent); +xpath = "//draw:frame[@draw:z-index='3'][1]"; +sContent = getXPath(pXmlDoc, xpath, "transform"); +CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString("translate( 94.12mm 25.05mm )"), sContent); + +// Non-breaking space test: there are 10 NBSpaces, which are treated as the same as normal space in PDF, +// thus each is expressed as a . +// The 10th text:s should exist and the attribute "text:c" should be "1". +xpath = "//draw:frame[@draw:z-index='4'][1]/draw:text-box/text:p/text:span/text:s[10]"; +sContent = getXPath(pXmlDoc, xpath, "c"); +CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString("1"), sContent); +#endif +} + CPPUNIT_TEST_SUITE(PDFITest); CPPUNIT_TEST(testXPDFParser); CPPUNIT_TEST(testOdfWriterExport); @@ -853,6 +890,7 @@ namespace CPPUNIT_TEST(testTdf78427_FontWeight_MyraidProSemibold); CPPUNIT_TEST(testTdf143959_nameFromFontFile); CPPUNIT_TEST(testTdf104597_textrun); +CPPUNIT_TEST(testSpaces); CPPUNIT_TEST_SUITE_END(); }; diff --git a/sdext/source/pdfimport/tree/writertreevisiting.cxx b/sdext/source/pdfimport/tree/writertreevisiting.cxx index deabf365088b..510689be1588 100644 --- a/sdext/source/pdfimport/tree/writertreevisiting.cxx +++ b/sdext/source/pdfimport/tree/writertreevisiting.cxx @@ -81,7 +81,11 @@ void WriterXmlEmitter::visit( TextElement& elem, const std::list< std::unique_pt if( elem.Text.isEmpty() ) return; -PropertyMap aProps; +PropertyMap aProps = {}; +const sal_Unicode strSpace = 0x0020; +const sal_Unicode strNbSpace = 0x00A0; +const sal_Unicode tabSpace = 0x0009; + if( elem.StyleId != -1 ) { aProps[ OUString( "text:style-name" ) ] = @@ -111,8 +115,26 @@ void WriterXmlEmitter::visit( TextElement& elem, const std::list< std::unique_pt str =
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/tree/writertreevisiting.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 9ea9d3ccc0f8e4833e745d9655b61d42d6d8fe83 Author: Kevin Suo AuthorDate: Sun Oct 23 19:10:29 2022 +0800 Commit: Noel Grandin CommitDate: Sun Nov 6 12:43:07 2022 +0100 sdext.pdfimport Writer: Do not visit DrawElement twice in WriterXmlEmitter Discovered when working on commit f6004e1c457ddab5e0c91e6159875d25130b108a. To reproduce, you can print the content of aOutput2 above the line: https://opengrok.libreoffice.org/xref/core/sdext/source/pdfimport/test/tests.cxx?r=f6004e1c#836, and then you get the xml content as shown in: https://bugs.documentfoundation.org/attachment.cgi?id=183217, in which you can see that there are duplicated draw:frame(s) with identical draw:z-index. To dig into the problem, you may take a look at the following code block: 1for( const auto& rxChild : elem.Children ) 2{ 3PageElement* pPage = dynamic_cast(rxChild.get()); 4if( pPage ) 5{ 6for( auto child_it = pPage->Children.begin(); child_it != pPage->Children.end(); ++child_it ) 7{ 8if( dynamic_cast(child_it->get()) != nullptr ) 9(*child_it)->visitedBy( *this, child_it ); 10 } 11 } 12 } 13 14 for( auto it = elem.Children.begin(); it != elem.Children.end(); ++it ) 15 { 16 if( dynamic_cast(it->get()) != nullptr ) 17 (*it)->visitedBy( *this, it ); 18 } In the for loop in lines 1:12: * "elem" is a "DocumentElement" which is derived from "Element". It's childen are PageElement(s). * "pPage" is a "PageElement" which is also derived from "Element". It's childen are DrawElement(s). * "child_it", as in the for loop in lines 6:10, is a "DrawElement" which is derived from "GraphicalElement", whereas "GraphicalElement" is derived from "Element". In this block, the code goes through each of the pages and visit the DrawElements there. The code in lines 14:18 seems to assume that, a DrawElement, in addition to be a child of PageElement, may also be a child of DocumentElement. See the comment in souce code. Yes, it may be. For such DrawElement(s), the visiting is done in lines 14:18 separately. Note that The above code uses dynamic_cast to determine whether a node is a DrawElement or not. The problem is that, in determining whether the node during the 2nd visiting is a DrawElement, it accidently used "== nullptr". This may be an inadvertent error. If the dynamic_cast is a nullprt, then it is not a DrawElement and the visiting should not be done there. Resolve this by using "!= nullptr" in the second dynamic_cast checking. Change-Id: I066100e98039d505d8b10c390954e014b78cff4f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141680 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/tree/writertreevisiting.cxx b/sdext/source/pdfimport/tree/writertreevisiting.cxx index 2ece5307bd53..deabf365088b 100644 --- a/sdext/source/pdfimport/tree/writertreevisiting.cxx +++ b/sdext/source/pdfimport/tree/writertreevisiting.cxx @@ -382,7 +382,7 @@ void WriterXmlEmitter::visit( DocumentElement& elem, const std::list< std::uniqu // only DrawElement types for( auto it = elem.Children.begin(); it != elem.Children.end(); ++it ) { -if( dynamic_cast(it->get()) == nullptr ) +if( dynamic_cast(it->get()) != nullptr ) (*it)->visitedBy( *this, it ); }
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/test/tests.cxx | 28 +++- 1 file changed, 11 insertions(+), 17 deletions(-) New commits: commit 8ae0ce1bfa9fe6fa7fa54bafb5541c3f78d9e9b5 Author: Kevin Suo AuthorDate: Fri Oct 21 00:40:19 2022 +0800 Commit: Noel Grandin CommitDate: Mon Oct 24 09:13:11 2022 +0200 sdext.pdfimport: refactor this unit test and active it for Windows This unit test was disabled for Windows build in commit fc45e54be6ba5d4685ae4ef3c3ea696fc99cccd4, due to the "crashes on the windows jenkins boxes". In this patch, I: 1. Rename the test name to show its purpose for easier reading; 2. Test the whole string all at once using xpath, rather than use indexOf(). This way we can not only test the existance of the characters, but also the order they appear. 3. Activate it for Windows build and hope it passes on Jenkins. 4. Remove the std::cout debug code, and use CPPUNIT_ASSERT_EQUAL_MESSAGE instead, so that the xml content (i.e. aOutput) is only shown when the assertion fails. 5. Move the test document to testdocs directory. Change-Id: I39084eb4ddc451ecac5183213b7e6166facf617b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141601 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/test/testTdf141709.pdf b/sdext/source/pdfimport/test/testdocs/testTdf141709_chinesechar.pdf similarity index 100% rename from sdext/source/pdfimport/test/testTdf141709.pdf rename to sdext/source/pdfimport/test/testdocs/testTdf141709_chinesechar.pdf diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx index 7cff15a36d0f..71661ae9e6d5 100644 --- a/sdext/source/pdfimport/test/tests.cxx +++ b/sdext/source/pdfimport/test/tests.cxx @@ -556,32 +556,26 @@ namespace #endif } -void testTdf141709() +void testTdf141709_chinesechar() { // this test crashes on the windows jenkins boxes, but no-one can catch it locally -#if HAVE_FEATURE_POPPLER && !defined(_WIN32) +#if HAVE_FEATURE_POPPLER rtl::Reference xAdaptor(new pdfi::PDFIRawAdaptor(OUString(), getComponentContext())); xAdaptor->setTreeVisitorFactory(createDrawTreeVisitorFactory()); OString aOutput; CPPUNIT_ASSERT_MESSAGE("Exporting to ODF", - xAdaptor->odfConvert(m_directories.getURLFromSrc(u"/sdext/source/pdfimport/test/testTdf141709.pdf"), + xAdaptor->odfConvert(m_directories.getURLFromSrc(u"/sdext/source/pdfimport/test/testdocs/testTdf141709_chinesechar.pdf"), new OutputWrapString(aOutput), nullptr)); -std::cout << aOutput << std::endl; +xmlDocUniquePtr pXmlDoc(xmlParseDoc(reinterpret_cast(aOutput.getStr(; // This ensures that the imported text contains all of the characters -CPPUNIT_ASSERT(aOutput.indexOf("敏") != -1); -CPPUNIT_ASSERT(aOutput.indexOf("捷") != -1); -CPPUNIT_ASSERT(aOutput.indexOf("的") != -1); -CPPUNIT_ASSERT(aOutput.indexOf("狐") != -1); -CPPUNIT_ASSERT(aOutput.indexOf("狸") != -1); -CPPUNIT_ASSERT(aOutput.indexOf("跨") != -1); -CPPUNIT_ASSERT(aOutput.indexOf("过") != -1); -CPPUNIT_ASSERT(aOutput.indexOf("慵") != -1); -CPPUNIT_ASSERT(aOutput.indexOf("懒") != -1); -CPPUNIT_ASSERT(aOutput.indexOf("的") != -1); -CPPUNIT_ASSERT(aOutput.indexOf("狗") != -1); -CPPUNIT_ASSERT(aOutput.indexOf("。") != -1); +OString xpath = "//draw:frame[@draw:z-index='3'][1]/draw:text-box/text:p/text:span[1]"; +OUString sContent = getXPathContent(pXmlDoc, xpath).replaceAll("\n", ""); +CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"敏捷的狐狸跨过慵懒的"), sContent); +xpath = "//draw:frame[@draw:z-index='4'][1]/draw:text-box/text:p/text:span[1]"; +sContent = getXPathContent(pXmlDoc, xpath).replaceAll("\n", ""); +CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"狗。"), sContent); #endif } @@ -854,7 +848,7 @@ namespace CPPUNIT_TEST(testTdf96993); CPPUNIT_TEST(testTdf98421); CPPUNIT_TEST(testTdf105536); -CPPUNIT_TEST(testTdf141709); +CPPUNIT_TEST(testTdf141709_chinesechar); CPPUNIT_TEST(testTdf78427_FontFeatures); CPPUNIT_TEST(testTdf78427_FontWeight_MyraidProSemibold); CPPUNIT_TEST(testTdf143959_nameFromFontFile);
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/test/tests.cxx | 30 ++--- sdext/source/pdfimport/tree/writertreevisiting.cxx | 46 +++-- sdext/source/pdfimport/tree/writertreevisiting.hxx |4 + 3 files changed, 70 insertions(+), 10 deletions(-) New commits: commit f6004e1c457ddab5e0c91e6159875d25130b108a Author: Kevin Suo AuthorDate: Sat Oct 15 19:43:54 2022 +0800 Commit: Thorsten Behrens CommitDate: Wed Oct 19 21:34:13 2022 +0200 tdf#151546: RTL text is reversed (Writer pdfimport) This is a followup to commit 69e9925ded584113e52f84ef0ed7c224079fa061 for the fix of tdf#104597. The Writer pdf import filter code is similar than the Draw part. However, many fixes to the Draw part was not done in the Writer part historically. This patch ports the fix of text run in the Draw part to the Writer part. There is a todo related to continuous spaces issue which should be fixed separately. Also use CPPUNIT_ASSERT_EQUAL_MESSAGE for the output of xml content instread of using std::cout, in case of unit test failure. Change-Id: Id013700524750e6e5283d85eeab72d8075f16f1b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141420 Tested-by: Thorsten Behrens Reviewed-by: Thorsten Behrens diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx index 25c12a23901c..7cff15a36d0f 100644 --- a/sdext/source/pdfimport/test/tests.cxx +++ b/sdext/source/pdfimport/test/tests.cxx @@ -799,36 +799,54 @@ namespace new OutputWrapString(aOutput), nullptr)); -// std::cout << aOutput << std::endl; xmlDocUniquePtr pXmlDoc(xmlParseDoc(reinterpret_cast(aOutput.getStr(; // Test for امُ عَلَيْكَ // TODO: How to get the "عَلَيْكَ" in xpath, as shown after the tag? OString xpath = "//draw:frame[@draw:transform='matrix(917. 0 0 917. 14821.958333 2159.23861112778)']/draw:text-box/text:p/text:span"; OUString sContent = getXPathContent(pXmlDoc, xpath); // u"\nا\nُ\nم\n" -CPPUNIT_ASSERT_EQUAL(OUString(u"اُم"), sContent.replaceAll("\n", "")); +CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"اُم"), sContent.replaceAll("\n", "")); // Test for ٱلَّسَل . It appears in the 3rd frame, i.e. after the امُ عَلَيْكَ which is in the 2nd frame (from left to right) // thus these two frames together appear as ٱلَّسَل امُ عَلَيْكَ in Draw. xpath = "//draw:frame[@draw:transform='matrix(917. 0 0 917. 17420.17 2159.23861112778)']/draw:text-box/text:p/text:span"; sContent = getXPathContent(pXmlDoc, xpath); -CPPUNIT_ASSERT_EQUAL(OUString(u"ٱلَّسَل"), sContent.replaceAll("\n", "")); +CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"ٱلَّسَل"), sContent.replaceAll("\n", "")); // Test for "LibreOffice LTR" // TODO: How to get the "LTR" as shown after the tag? xpath = "//draw:frame[@draw:transform='matrix(917. 0 0 917. 12779.375 5121.79583335)']/draw:text-box/text:p/text:span"; sContent = getXPathContent(pXmlDoc, xpath); -CPPUNIT_ASSERT_EQUAL(OUString(u"LibreOffice"), sContent.replaceAll("\n", "")); +CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"LibreOffice"), sContent.replaceAll("\n", "")); /* Test for Chinese characters */ // Use last() instead of matrix below, because the matrix may be different on different OS due to fallback of Chinese fonts. xpath = "//draw:frame[last()]/draw:text-box/text:p/text:span"; sContent = getXPathContent(pXmlDoc, xpath); -CPPUNIT_ASSERT_EQUAL(OUString(u"中文测试,中文"), sContent.replaceAll("\n", "")); +CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"中文测试,中文"), sContent.replaceAll("\n", "")); + +// Test pdf text run in the Writer PDF import filter +xAdaptor->setTreeVisitorFactory(createWriterTreeVisitorFactory()); +OString aOutput2; + xAdaptor->odfConvert(m_directories.getURLFromSrc(u"/sdext/source/pdfimport/test/testdocs/tdf104597_textrun.pdf"), +new OutputWrapString(aOutput2), +nullptr); +// FIXME: the same draw:frame is duplicated in the xml output, +// e.g. there are two draw:frame with draw:z-index="3" with the same content. +xmlDocUniquePtr pXmlDoc2(xmlParseDoc(reinterpret_cast(aOutput2.getStr(; +xpath = "//draw:frame[@draw:z-index='3'][1]/draw:text-box/text:p/text:span"; +sContent = getXPathContent(pXmlDoc2, xpath).replaceAll("\n", ""); +CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput2.getStr(), OUString(u"ٱلَّسَل"),
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/test/testdocs/tdf104597_textrun.pdf |binary sdext/source/pdfimport/test/tests.cxx | 44 + sdext/source/pdfimport/tree/drawtreevisiting.cxx | 17 + sdext/source/pdfimport/tree/pdfiprocessor.cxx | 18 - 4 files changed, 48 insertions(+), 31 deletions(-) New commits: commit 69e9925ded584113e52f84ef0ed7c224079fa061 Author: Kevin Suo AuthorDate: Tue Oct 11 10:04:16 2022 +0800 Commit: Thorsten Behrens CommitDate: Thu Oct 13 21:38:12 2022 +0200 sdext.pdfimport: resolves tdf#104597: RTL script text runs are reversed For the simple Arabic string: ٱلسَّلَامُ عَلَيْك, the xpdfimport binary generates the follwing (drawchar) sequences: كَ يْ لَ عَ مُ ا لَ سَّ ل ٱ (i.e., in reversed order, one character by one character). Before this patch, after pdfimport the text shows up as لَسَّلٱ كَيْلَعَ مُا, which is reversed. It was surposed to combine these characters into text frames in DrawXmlOptimizer::optimizeTextElements(Element& rParent) (sdext/source/pdfimport/\ tree/drawtreevisiting.cxx:677), but actually it was not combined successfully there. The single characters were then passed to sdext/source/pdfimport/tree/drawtreevisiting\ .cxx:105, one by one, in the hope that the strings could be mirrored. The mirroring failed, because one single character, even after mirroring, always equals itself. The DrawXmlOptimizer::optimizeTextElements failed to combine the characters into one text frame, because the condition: (rCurGC.Transformation == rNextGC.Transformation || notTransformed(rNextGC)) would never be true, as at least its horizontal position is different. A further analysis indicates that we do not need to check the transformation here at all, as this is an optimizer for a TextElement and in case a character is transformed then it would already be in a different draw element (thus will never be combined with this TextElement). After the fix of DrawXmlOptimizer::optimizeTextElements which now successfully combines the characters, there is another issue in the old PDFIProcessor::mirrorString function. It seems to mirror the characters within a word, but if a string contains two words, then the two words are not successfully switched (e.g. for string "abc def" it produces "cba fed" rather than "fed cba"), which is not suitable for the case of RTL which requires all the characters been reversed. Fix this by using comphelper::string::reverseString. Change-Id: Ifa210836f1ddd56205ff0d243adfb4114794 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141231 Tested-by: Jenkins Reviewed-by: Thorsten Behrens diff --git a/sdext/source/pdfimport/test/testdocs/tdf104597_textrun.pdf b/sdext/source/pdfimport/test/testdocs/tdf104597_textrun.pdf new file mode 100644 index ..dcee96aa3169 Binary files /dev/null and b/sdext/source/pdfimport/test/testdocs/tdf104597_textrun.pdf differ diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx index 193ec2227620..25c12a23901c 100644 --- a/sdext/source/pdfimport/test/tests.cxx +++ b/sdext/source/pdfimport/test/tests.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -786,6 +787,48 @@ namespace #endif } +void testTdf104597_textrun() +{ +#if HAVE_FEATURE_POPPLER +rtl::Reference xAdaptor(new pdfi::PDFIRawAdaptor(OUString(), getComponentContext())); +xAdaptor->setTreeVisitorFactory(createDrawTreeVisitorFactory()); + +OString aOutput; +CPPUNIT_ASSERT_MESSAGE("Converting PDF to ODF XML", + xAdaptor->odfConvert(m_directories.getURLFromSrc(u"/sdext/source/pdfimport/test/testdocs/tdf104597_textrun.pdf"), +new OutputWrapString(aOutput), +nullptr)); + +// std::cout << aOutput << std::endl; +xmlDocUniquePtr pXmlDoc(xmlParseDoc(reinterpret_cast(aOutput.getStr(; + +// Test for امُ عَلَيْكَ +// TODO: How to get the "عَلَيْكَ" in xpath, as shown after the tag? +OString xpath = "//draw:frame[@draw:transform='matrix(917. 0 0 917. 14821.958333 2159.23861112778)']/draw:text-box/text:p/text:span"; +OUString sContent = getXPathContent(pXmlDoc, xpath); // u"\nا\nُ\nم\n" +CPPUNIT_ASSERT_EQUAL(OUString(u"اُم"), sContent.replaceAll("\n", "")); + +// Test for ٱلَّسَل . It appears in the 3rd frame, i.e. after the امُ عَلَيْكَ which is in the 2nd frame (from left to right) +// thus these two frames together appear as ٱلَّسَل امُ عَلَيْكَ in Draw. +xpath = "//draw:frame[@draw:transform='matrix(917. 0 0 917.
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx |9 - 1 file changed, 8 insertions(+), 1 deletion(-) New commits: commit b7d63694985bbb1cf86eb71769feadb28ce68c17 Author: Sam James AuthorDate: Fri Sep 2 04:31:18 2022 +0100 Commit: Michael Stahl CommitDate: Tue Sep 13 12:32:58 2022 +0200 Fix build with Poppler 22.09.0 With Poppler 22.09.0, LO fails to build with: ``` /var/tmp/portage/app-office/libreoffice-7.3.5.2/work/libreoffice-7.3.5.2/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx:682:36: error: too many arguments to function call, expected single argument 'start', have 3 arguments state->getLineDash(, , ); ~~ ^~~ /usr/include/poppler/GfxState.h:1506:32: note: 'getLineDash' declared here const std::vector (double *start) ^ 1 error generated. ``` Poppler changed the getLineDash interface: ``` -void getLineDash(double **dash, int *length, double *start) +const std::vector (double *start) ``` Signed-off-by: Sam James Change-Id: I29e18f20d7650a7fcac1bc8ab4aaa04aaa2ab8fb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139249 Tested-by: Jenkins Reviewed-by: Michael Stahl diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index f12478cb2f4d..3ad139b65fa3 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -678,8 +678,15 @@ void PDFOutDev::updateLineDash(GfxState *state) return; assert(state); -double* dashArray; int arrayLen; double startOffset; +int arrayLen; double startOffset; +#if POPPLER_CHECK_VERSION(22, 9, 0) +const std::vector = state->getLineDash(); +const double* dashArray = dash.data(); +arrayLen = dash.size(); +#else +double* dashArray; state->getLineDash(, , ); +#endif printf( "updateLineDash" ); if( arrayLen && dashArray )
[Libreoffice-commits] core.git: sdext/source
sdext/source/presenter/PresenterSlideSorter.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 4c511ac7d7a006d9a62a3685f3a962bb321017bd Author: Caolán McNamara AuthorDate: Tue Aug 16 09:12:12 2022 +0100 Commit: Caolán McNamara CommitDate: Tue Aug 16 17:37:14 2022 +0200 cid#1500417 Dereference after null check Change-Id: Ib186c453aafc9bc29fd5c7d82578ca4157aed31e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138345 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/sdext/source/presenter/PresenterSlideSorter.cxx b/sdext/source/presenter/PresenterSlideSorter.cxx index 441688fb8a6c..ef33a4dde634 100644 --- a/sdext/source/presenter/PresenterSlideSorter.cxx +++ b/sdext/source/presenter/PresenterSlideSorter.cxx @@ -1819,7 +1819,7 @@ void PresenterSlideSorter::CurrentSlideFrameRenderer::PaintCurrentSlideFrame ( rxCanvas, xClip, rSlideBoundingBox.X + rSlideBoundingBox.Width, -rSlideBoundingBox.Y - mpTopLeft->mnHeight); +rSlideBoundingBox.Y - mpTopRight->mnHeight); } if (mpBottomLeft) {
[Libreoffice-commits] core.git: sdext/source svx/source xmloff/source
sdext/source/pdfimport/tree/drawtreevisiting.cxx | 25 +++ svx/source/unodraw/unoshape.cxx |3 +- xmloff/source/draw/ximpshap.cxx |5 ++-- 3 files changed, 22 insertions(+), 11 deletions(-) New commits: commit e00225bc7744abd365f1cc7133d43026e9438f13 Author: Noel Grandin AuthorDate: Thu Jul 14 14:33:21 2022 +0200 Commit: Noel Grandin CommitDate: Thu Jul 14 19:12:33 2022 +0200 elide some temporary OUStrings Change-Id: I8539dd5d9490a14ebac0520486a8322ff86a6cb6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137081 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx index dfdec02539db..51ef5f232d85 100644 --- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx +++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx @@ -188,21 +188,30 @@ void DrawXmlEmitter::fillFrameProps( DrawElement& rElem, bool bWasTransformed ) { -rProps[ "draw:z-index" ] = OUString::number( rElem.ZOrder ); -rProps[ "draw:style-name"] = rEmitContext.rStyles.getStyleName( rElem.StyleId ); +static constexpr OUStringLiteral sDrawZIndex = u"draw:z-index"; +static constexpr OUStringLiteral sDrawStyleName = u"draw:style-name"; +static constexpr OUStringLiteral sDrawTextStyleName = u"draw:text-style-name"; +static constexpr OUStringLiteral sSvgX = u"svg:x"; +static constexpr OUStringLiteral sSvgY = u"svg:y"; +static constexpr OUStringLiteral sSvgWidth = u"svg:width"; +static constexpr OUStringLiteral sSvgHeight = u"svg:height"; +static constexpr OUStringLiteral sDrawTransform = u"draw:transform"; + +rProps[ sDrawZIndex ] = OUString::number( rElem.ZOrder ); +rProps[ sDrawStyleName ] = rEmitContext.rStyles.getStyleName( rElem.StyleId ); if (rElem.IsForText) -rProps["draw:text-style-name"] = rEmitContext.rStyles.getStyleName(rElem.TextStyleId); +rProps[ sDrawTextStyleName ] = rEmitContext.rStyles.getStyleName(rElem.TextStyleId); const GraphicsContext& rGC = rEmitContext.rProcessor.getGraphicsContext( rElem.GCId ); if (bWasTransformed) { -rProps[ "svg:x" ] = convertPixelToUnitString(rElem.x); -rProps[ "svg:y" ] = convertPixelToUnitString(rElem.y); -rProps[ "svg:width" ] = convertPixelToUnitString(rElem.w); -rProps[ "svg:height" ] = convertPixelToUnitString(rElem.h); +rProps[ sSvgX ] = convertPixelToUnitString(rElem.x); +rProps[ sSvgY ] = convertPixelToUnitString(rElem.y); +rProps[ sSvgWidth ] = convertPixelToUnitString(rElem.w); +rProps[ sSvgHeight ] = convertPixelToUnitString(rElem.h); } else { @@ -236,7 +245,7 @@ void DrawXmlEmitter::fillFrameProps( DrawElement& rElem, aBuf.append(mat.get(1, 2)); aBuf.append(")"); -rProps["draw:transform"] = aBuf.makeStringAndClear(); +rProps[ sDrawTransform ] = aBuf.makeStringAndClear(); } } diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 2280402dcb76..e559fe8b4b9f 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -143,8 +143,9 @@ namespace { class ShapePositionProvider : public PropertyValueProvider { public: +static constexpr OUStringLiteral sPosition = u"Position"; explicit ShapePositionProvider( SvxShape& _shape ) -:PropertyValueProvider( _shape, "Position" ) +:PropertyValueProvider( _shape, sPosition ) { } diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index 22c302205e02..2dc2e33fb91c 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -707,8 +707,9 @@ void SdXMLShapeContext::SetStyle( bool bSupportsStyle /* = true */) // SwTextBoxHelper::syncProperty, which indirectly calls SwTextBoxHelper::isTextBox) uno::Reference xPropertySetInfo = xPropSet->getPropertySetInfo(); -if (xPropertySetInfo->hasPropertyByName("TextBox")) -xPropSet->setPropertyValue("TextBox", uno::Any(mbTextBox)); +static constexpr OUStringLiteral sTextBox = u"TextBox"; +if (xPropertySetInfo->hasPropertyByName(sTextBox)) +xPropSet->setPropertyValue(sTextBox, uno::Any(mbTextBox)); // if this is an auto style, set its properties if(bAutoStyle && pDocStyle)
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/inc/pdfihelper.hxx |5 - 1 file changed, 4 insertions(+), 1 deletion(-) New commits: commit bcb1620b3e4929df1d06d57b4769650422fff16e Author: Noel Grandin AuthorDate: Thu Jul 14 09:43:22 2022 +0200 Commit: Noel Grandin CommitDate: Thu Jul 14 18:02:22 2022 +0200 speed up loading PDF file Change-Id: I3d892319f4af0c187455bc9c13b6edb0d52ac023 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137079 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/inc/pdfihelper.hxx b/sdext/source/pdfimport/inc/pdfihelper.hxx index 6b663b203e62..c6be1a6ba73e 100644 --- a/sdext/source/pdfimport/inc/pdfihelper.hxx +++ b/sdext/source/pdfimport/inc/pdfihelper.hxx @@ -64,9 +64,12 @@ namespace pdfi return fMM; } +/// round to 2 decimal places inline double convPx2mmPrec2( double fPix ) { -return rtl_math_round( convPx2mm( fPix ), 2, rtl_math_RoundingMode_Floor ); +constexpr double px2mm = 25.4/PDFI_OUTDEV_RESOLUTION; +double mm = fPix * ( px2mm * 100); +return std::floor(mm) / 100; } /// Convert color to "#FEFEFE" color notation
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/test/tests.cxx |6 ++ 1 file changed, 6 insertions(+) New commits: commit 5e1ab6a203843f98966956e706c888fd1f89e284 Author: Andras Timar AuthorDate: Mon Jul 11 23:38:00 2022 +0200 Commit: Andras Timar CommitDate: Tue Jul 12 09:08:12 2022 +0200 sdext: these tests won't run without poppler Change-Id: I61deb7d5271bf87ac1bb3aad54c430ace8fd3f9f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136975 Tested-by: Jenkins Reviewed-by: Andras Timar diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx index 77d98999d0d3..193ec2227620 100644 --- a/sdext/source/pdfimport/test/tests.cxx +++ b/sdext/source/pdfimport/test/tests.cxx @@ -586,6 +586,7 @@ namespace void testTdf78427_FontFeatures() { +#if HAVE_FEATURE_POPPLER rtl::Reference xAdaptor(new pdfi::PDFIRawAdaptor(OUString(), getComponentContext())); xAdaptor->setTreeVisitorFactory(createDrawTreeVisitorFactory()); @@ -712,10 +713,12 @@ namespace assertXPath(pXmlDoc, xpath, "font-weight", "normal"); assertXPathNoAttribute(pXmlDoc, xpath, "font-style"); assertXPath(pXmlDoc, xpath, "text-outline", "true"); +#endif } void testTdf78427_FontWeight_MyraidProSemibold() // Related to attachment 155937. { +#if HAVE_FEATURE_POPPLER rtl::Reference xAdaptor(new pdfi::PDFIRawAdaptor(OUString(), getComponentContext())); xAdaptor->setTreeVisitorFactory(createDrawTreeVisitorFactory()); @@ -745,10 +748,12 @@ namespace "\"]/style:text-properties"; // the font-weight and font-style should be 300 (Light) assertXPath(pXmlDoc, xpath, "font-weight", "300"); +#endif } void testTdf143959_nameFromFontFile() { +#if HAVE_FEATURE_POPPLER rtl::Reference xAdaptor(new pdfi::PDFIRawAdaptor(OUString(), getComponentContext())); xAdaptor->setTreeVisitorFactory(createDrawTreeVisitorFactory()); @@ -778,6 +783,7 @@ namespace getXPath(pXmlDoc, xpath, "font-family").replaceAll(u" ", u"")); CPPUNIT_ASSERT_EQUAL(OUString("bold"), getXPath(pXmlDoc, xpath, "font-weight")); +#endif } CPPUNIT_TEST_SUITE(PDFITest);
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/inc/genericelements.hxx |7 +++ sdext/source/pdfimport/tree/drawtreevisiting.cxx | 14 +++--- sdext/source/pdfimport/tree/genericelements.cxx| 14 +++--- sdext/source/pdfimport/tree/pdfiprocessor.cxx |6 +++--- sdext/source/pdfimport/tree/writertreevisiting.cxx | 12 ++-- 5 files changed, 30 insertions(+), 23 deletions(-) New commits: commit 3fe18ba1b0be041f66124324e96d9cb6d56ff5ce Author: Noel Grandin AuthorDate: Wed Jun 29 20:49:53 2022 +0200 Commit: Noel Grandin CommitDate: Fri Jul 1 08:16:49 2022 +0200 tdf#137544 reduce cost of dynamic_cast casting to TextElement is very hot here Change-Id: I3195da6f09edb270eebdc6f38a1bbb2405b74de6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136659 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/inc/genericelements.hxx b/sdext/source/pdfimport/inc/genericelements.hxx index 63325213f59a..1fec2e6f4042 100644 --- a/sdext/source/pdfimport/inc/genericelements.hxx +++ b/sdext/source/pdfimport/inc/genericelements.hxx @@ -92,6 +92,10 @@ namespace pdfi /// Union element geometry with given element void updateGeometryWith( const Element* pMergeFrom ); +/// To avoid some dynamic_cast cost +virtual const TextElement* dynCastAsTextElement() const { return nullptr; } +virtual TextElement* dynCastAsTextElement() { return nullptr; } + #if OSL_DEBUG_LEVEL > 0 // xxx refact TODO: move code to visitor virtual void emitStructure( int nLevel ); @@ -175,6 +179,9 @@ namespace pdfi public: virtual void visitedBy( ElementTreeVisitor&, const std::list< std::unique_ptr >::const_iterator& ) override; +virtual const TextElement* dynCastAsTextElement() const override { return this; } +virtual TextElement* dynCastAsTextElement() override { return this; } + OUStringBuffer Text; sal_Int32 FontId; }; diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx index ffc27c65f56c..dfdec02539db 100644 --- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx +++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx @@ -492,7 +492,7 @@ void DrawXmlOptimizer::visit( PageElement& elem, const std::list< std::unique_pt nCurLineElements = 0; for( const auto& rxChild : pCurPara->Children ) { -TextElement* pTestText = dynamic_cast(rxChild.get()); +TextElement* pTestText = rxChild->dynCastAsTextElement(); if( pTestText ) { fCurLineHeight = (fCurLineHeight*double(nCurLineElements) + pTestText->h)/double(nCurLineElements+1); @@ -526,12 +526,12 @@ void DrawXmlOptimizer::visit( PageElement& elem, const std::list< std::unique_pt // or perhaps the draw element begins a new paragraph else if( next_page_element != elem.Children.end() ) { -TextElement* pText = dynamic_cast(next_page_element->get()); +TextElement* pText = (*next_page_element)->dynCastAsTextElement(); if( ! pText ) { ParagraphElement* pPara = dynamic_cast(next_page_element->get()); if( pPara && ! pPara->Children.empty() ) -pText = dynamic_cast(pPara->Children.front().get()); +pText = pPara->Children.front()->dynCastAsTextElement(); } if( pText && // check there is a text pDraw->h < pText->h*1.5 && // and it is approx the same height @@ -560,9 +560,9 @@ void DrawXmlOptimizer::visit( PageElement& elem, const std::list< std::unique_pt } } -TextElement* pText = dynamic_cast(page_element->get()); +TextElement* pText = (*page_element)->dynCastAsTextElement(); if( ! pText && pLink && ! pLink->Children.empty() ) -pText = dynamic_cast(pLink->Children.front().get()); +pText = pLink->Children.front()->dynCastAsTextElement(); if( pText ) { Element* pGeo = pLink ? static_cast(pLink) : @@ -671,11 +671,11 @@ void DrawXmlOptimizer::optimizeTextElements(Element& rParent) while( next != rParent.Children.end() ) { bool bConcat = false; -TextElement* pCur = dynamic_cast(it->get()); +TextElement* pCur = (*it)->dynCastAsTextElement(); if( pCur ) { -TextElement* pNext = dynamic_cast(next->get()); +TextElement* pNext = (*next)->dynCastAsTextElement(); bool isComplex = false; OUString str(pCur->Text.toString()); for(int i=0; i< str.getLength(); i++) diff --git a/sdext/source/pdfimport/tree/genericelements.cxx
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/tree/genericelements.cxx | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) New commits: commit eefba50f5908d535bce81b5b0d3d883715b6575e Author: Noel Grandin AuthorDate: Wed Jun 29 16:36:16 2022 +0200 Commit: Noel Grandin CommitDate: Wed Jun 29 22:10:27 2022 +0200 tdf#137544 reduce work in sdext::PageElement::resolveUnderlines when opening complex pdf Change-Id: I67146a60d016964c96a3994c5a0334287f7bab0a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136654 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/tree/genericelements.cxx b/sdext/source/pdfimport/tree/genericelements.cxx index f4dee87c71cb..2eb789616b30 100644 --- a/sdext/source/pdfimport/tree/genericelements.cxx +++ b/sdext/source/pdfimport/tree/genericelements.cxx @@ -332,6 +332,14 @@ void PageElement::resolveUnderlines( PDFIProcessor const & rProc ) // FIXME: currently the algorithm used is quadratic // this could be solved by some sorting beforehand +std::vector textAndHypers; +textAndHypers.reserve(Children.size()); +for (auto const & p : Children) +{ +if (dynamic_cast< TextElement* >(p.get()) || dynamic_cast(p.get())) +textAndHypers.push_back(p.get()); +} + auto poly_it = Children.begin(); while( poly_it != Children.end() ) { @@ -372,9 +380,8 @@ void PageElement::resolveUnderlines( PDFIProcessor const & rProc ) u_y = r_x; r_x = l_x; l_x = u_y; } u_y = aPoly.getB2DPoint(0).getY(); -for( const auto& rxChild : Children ) +for( Element* pEle : textAndHypers ) { -Element* pEle = rxChild.get(); if( pEle->y <= u_y && pEle->y + pEle->h*1.1 >= u_y ) { // first: is the element underlined completely ? @@ -394,13 +401,13 @@ void PageElement::resolveUnderlines( PDFIProcessor const & rProc ) pText->FontId = rProc.getFontId( aAttr ); } } -else if( dynamic_cast< HyperlinkElement* >(pEle) ) +else // must be HyperlinkElement bRemovePoly = true; } // second: hyperlinks may be larger than their underline // since they are just arbitrary rectangles in the action definition -else if( dynamic_cast< HyperlinkElement* >(pEle) != nullptr && - l_x >= pEle->x && r_x <= pEle->x+pEle->w ) +else if( l_x >= pEle->x && r_x <= pEle->x+pEle->w && +dynamic_cast< HyperlinkElement* >(pEle) != nullptr ) { bRemovePoly = true; }
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/filterdet.cxx |5 - sdext/source/pdfimport/filterdet.hxx |4 sdext/source/pdfimport/inc/contentsink.hxx |8 - sdext/source/pdfimport/inc/pdfparse.hxx | 13 +- sdext/source/pdfimport/odf/odfemitter.cxx|7 - sdext/source/pdfimport/pdfparse/pdfparse.cxx |5 - sdext/source/pdfimport/sax/saxattrlist.hxx |5 - sdext/source/presenter/PresenterAccessibility.cxx| 27 +++--- sdext/source/presenter/PresenterAccessibility.hxx|4 sdext/source/presenter/PresenterBitmapContainer.cxx | 25 ++--- sdext/source/presenter/PresenterBitmapContainer.hxx | 12 +- sdext/source/presenter/PresenterButton.cxx | 25 ++--- sdext/source/presenter/PresenterButton.hxx | 12 +- sdext/source/presenter/PresenterController.cxx |9 +- sdext/source/presenter/PresenterController.hxx |4 sdext/source/presenter/PresenterCurrentSlideObserver.cxx |6 - sdext/source/presenter/PresenterCurrentSlideObserver.hxx |2 sdext/source/presenter/PresenterFrameworkObserver.cxx|5 - sdext/source/presenter/PresenterFrameworkObserver.hxx|2 sdext/source/presenter/PresenterHelpView.cxx | 11 +- sdext/source/presenter/PresenterHelpView.hxx |2 sdext/source/presenter/PresenterPaintManager.cxx |9 +- sdext/source/presenter/PresenterPaintManager.hxx |4 sdext/source/presenter/PresenterPaneBase.cxx |5 - sdext/source/presenter/PresenterPaneBase.hxx |2 sdext/source/presenter/PresenterPaneBorderPainter.cxx|7 - sdext/source/presenter/PresenterPaneFactory.cxx |5 - sdext/source/presenter/PresenterPaneFactory.hxx |2 sdext/source/presenter/PresenterProtocolHandler.cxx | 67 +++ sdext/source/presenter/PresenterScreen.cxx | 17 ++- sdext/source/presenter/PresenterScreen.hxx |2 sdext/source/presenter/PresenterScrollBar.cxx| 15 +-- sdext/source/presenter/PresenterScrollBar.hxx|4 sdext/source/presenter/PresenterSlideShowView.cxx| 13 +- sdext/source/presenter/PresenterSlideShowView.hxx|6 - sdext/source/presenter/PresenterSlideSorter.cxx | 13 +- sdext/source/presenter/PresenterSpritePane.cxx |1 sdext/source/presenter/PresenterTextView.cxx | 13 +- sdext/source/presenter/PresenterTextView.hxx | 10 +- sdext/source/presenter/PresenterTheme.cxx| 15 +-- sdext/source/presenter/PresenterTheme.hxx|4 sdext/source/presenter/PresenterTimer.cxx|7 - sdext/source/presenter/PresenterToolBar.cxx | 35 --- sdext/source/presenter/PresenterToolBar.hxx |6 - sdext/source/presenter/PresenterViewFactory.cxx |5 - sdext/source/presenter/PresenterViewFactory.hxx |2 sdext/source/presenter/PresenterWindowManager.cxx|9 +- sdext/source/presenter/PresenterWindowManager.hxx|4 48 files changed, 252 insertions(+), 223 deletions(-) New commits: commit 6c28906ff6b3cc2fc306d927010cf730e7ef5fbc Author: Noel Grandin AuthorDate: Fri Jun 24 15:56:32 2022 +0200 Commit: Noel Grandin CommitDate: Fri Jun 24 18:24:19 2022 +0200 clang-tidy modernize-pass-by-value in sdext Change-Id: Ieded279152946830b2619ac80c4a9639d616557a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136398 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/filterdet.cxx b/sdext/source/pdfimport/filterdet.cxx index 18751a00490a..0f22b1e256b6 100644 --- a/sdext/source/pdfimport/filterdet.cxx +++ b/sdext/source/pdfimport/filterdet.cxx @@ -37,6 +37,7 @@ #include #include #include +#include #include using namespace com::sun::star; @@ -182,9 +183,9 @@ unsigned int FileEmitContext::readOrigBytes( unsigned int nOrigOffset, unsigned } -PDFDetector::PDFDetector( const uno::Reference< uno::XComponentContext >& xContext) : +PDFDetector::PDFDetector( uno::Reference< uno::XComponentContext > xContext) : PDFDetectorBase( m_aMutex ), -m_xContext( xContext ) +m_xContext(std::move( xContext )) {} // XExtendedFilterDetection diff --git a/sdext/source/pdfimport/filterdet.hxx b/sdext/source/pdfimport/filterdet.hxx index 6c7d58ca048c..c5f8b0d58772 100644 --- a/sdext/source/pdfimport/filterdet.hxx +++ b/sdext/source/pdfimport/filterdet.hxx @@ -42,8 +42,8 @@ private: css::uno::XComponentContext > m_xContext; public: -explicit PDFDetector( const css::uno::Reference< -css::uno::XComponentContext >& xContext ); +explicit PDFDetector( css::uno::Reference< +
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx |7 --- 1 file changed, 4 insertions(+), 3 deletions(-) New commits: commit ad1ffc62e40c2409b610dfff25a8483b1f2556ad Author: Nathan Pratta Teodosio AuthorDate: Tue Jun 21 08:47:14 2022 -0300 Commit: Michael Stahl CommitDate: Fri Jun 24 11:12:53 2022 +0200 Follow-up for Poppler 22.06 update Change-Id: I8ee9f1a53cc4389e6a4d44e9765b478b5edfffd4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136342 Tested-by: Jenkins Reviewed-by: Michael Stahl diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index d9efa39d8a54..f12478cb2f4d 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -476,10 +476,10 @@ int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, const GfxState* st // we must write byte count to stdout before #if POPPLER_CHECK_VERSION(22, 6, 0) std::optional> pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef() ); -nSize = pBuf->size(); -if ( nSize > 0 ) +if ( pBuf ) { aNewFont.isEmbedded = true; +nSize = pBuf->size(); } #else char* pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef(), ); @@ -503,7 +503,8 @@ void PDFOutDev::writeFontFile( GfxFont* gfxFont ) const int nSize = 0; #if POPPLER_CHECK_VERSION(22, 6, 0) std::optional> pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef() ); -nSize = pBuf->size(); +if ( pBuf ) +nSize = pBuf->size(); if ( nSize == 0 ) return; #else
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx | 29 ++ sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx| 10 ++ 2 files changed, 39 insertions(+) New commits: commit 0d0469b4302dfe95b016a6f04b145834b79d5ed3 Author: Nathan Pratta Teodosio AuthorDate: Tue Jun 21 08:47:14 2022 -0300 Commit: Michael Stahl CommitDate: Thu Jun 23 14:29:13 2022 +0200 Update for Poppler 22.06 Change-Id: I8ee9f1a53cc4389e6a4d44e9765b478b5edfffd3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136261 Tested-by: Jenkins Reviewed-by: Michael Stahl diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index 02b6fe6a1b9e..d9efa39d8a54 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -474,12 +474,21 @@ int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, const GfxState* st { // TODO(P3): Unfortunately, need to read stream twice, since // we must write byte count to stdout before +#if POPPLER_CHECK_VERSION(22, 6, 0) +std::optional> pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef() ); +nSize = pBuf->size(); +if ( nSize > 0 ) +{ +aNewFont.isEmbedded = true; +} +#else char* pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef(), ); if( pBuf ) { aNewFont.isEmbedded = true; gfree(pBuf); } +#endif } m_aFontMap[ nNewId ] = aNewFont; @@ -492,13 +501,28 @@ void PDFOutDev::writeFontFile( GfxFont* gfxFont ) const return; int nSize = 0; +#if POPPLER_CHECK_VERSION(22, 6, 0) +std::optional> pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef() ); +nSize = pBuf->size(); +if ( nSize == 0 ) +return; +#else char* pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef(), ); if( !pBuf ) return; +#endif // ---sync point--- see SYNC STREAMS above fflush(stdout); +#if POPPLER_CHECK_VERSION(22, 6, 0) +if( fwrite(pBuf->data(), sizeof(*pBuf->data()), nSize, g_binary_out) != static_cast(nSize) ) +{ +exit(1); // error +} +// ---sync point--- see SYNC STREAMS above +fflush(g_binary_out); +#else if( fwrite(pBuf, sizeof(char), nSize, g_binary_out) != static_cast(nSize) ) { gfree(pBuf); @@ -507,6 +531,7 @@ void PDFOutDev::writeFontFile( GfxFont* gfxFont ) const // ---sync point--- see SYNC STREAMS above fflush(g_binary_out); gfree(pBuf); +#endif } #if POPPLER_CHECK_VERSION(0, 83, 0) @@ -759,7 +784,11 @@ void PDFOutDev::updateFont(GfxState *state) { assert(state); +#if POPPLER_CHECK_VERSION(22, 6, 0) +GfxFont *gfxFont = state->getFont().get(); +#else GfxFont *gfxFont = state->getFont(); +#endif if( !gfxFont ) return; diff --git a/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx index ad6320139473..e924547e9357 100644 --- a/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx @@ -138,6 +138,15 @@ int main(int argc, char **argv) _setmode( _fileno( g_binary_out ), _O_BINARY ); #endif +#if POPPLER_CHECK_VERSION(22, 6, 0) +PDFDoc aDoc( std::make_unique(pFileName), + std::optional(pOwnerPasswordStr), + std::optional(pUserPasswordStr) ); + +PDFDoc aErrDoc( std::make_unique(pErrFileName), + std::optional(pOwnerPasswordStr), + std::optional(pUserPasswordStr) ); +#else PDFDoc aDoc( pFileName, pOwnerPasswordStr, pUserPasswordStr ); @@ -145,6 +154,7 @@ int main(int argc, char **argv) PDFDoc aErrDoc( pErrFileName, pOwnerPasswordStr, pUserPasswordStr ); +#endif // Check various permissions for aDoc. PDFDoc = aDoc.isOk()? aDoc: aErrDoc;
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/test/tests.cxx |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) New commits: commit fc45e54be6ba5d4685ae4ef3c3ea696fc99cccd4 Author: Noel Grandin AuthorDate: Thu May 26 12:21:29 2022 +0200 Commit: Noel Grandin CommitDate: Thu May 26 14:28:54 2022 +0200 disable this sdext test on windows for now Change-Id: I06456afa84314b3348bce177c939f510e00aa743 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134993 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx index c8c3b9e28a8f..77d98999d0d3 100644 --- a/sdext/source/pdfimport/test/tests.cxx +++ b/sdext/source/pdfimport/test/tests.cxx @@ -557,7 +557,8 @@ namespace void testTdf141709() { -#if HAVE_FEATURE_POPPLER +// this test crashes on the windows jenkins boxes, but no-one can catch it locally +#if HAVE_FEATURE_POPPLER && !defined(_WIN32) rtl::Reference xAdaptor(new pdfi::PDFIRawAdaptor(OUString(), getComponentContext())); xAdaptor->setTreeVisitorFactory(createDrawTreeVisitorFactory());
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/misc/pwdinteract.cxx |4 ++-- sdext/source/pdfimport/wrapper/wrapper.cxx |6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) New commits: commit b0f42b588f52268b8cfad527ba76fdbd125ea5ea Author: Stephan Bergmann AuthorDate: Tue May 3 23:22:21 2022 +0200 Commit: Stephan Bergmann CommitDate: Wed May 4 08:10:52 2022 +0200 Just use Any ctor instead of makeAny in sdext Change-Id: I78f6972f0fe94423e00f2c3766df694d8e118439 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133784 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/sdext/source/pdfimport/misc/pwdinteract.cxx b/sdext/source/pdfimport/misc/pwdinteract.cxx index b80f6a60237e..79ef78181600 100644 --- a/sdext/source/pdfimport/misc/pwdinteract.cxx +++ b/sdext/source/pdfimport/misc/pwdinteract.cxx @@ -73,7 +73,7 @@ private: PDFPasswordRequest::PDFPasswordRequest( bool bFirstTry, const OUString& rName ) : m_aRequest( -uno::makeAny( +uno::Any( task::DocumentPasswordRequest( OUString(), uno::Reference< uno::XInterface >(), task::InteractionClassification_QUERY, @@ -127,7 +127,7 @@ private: virtual ~UnsupportedEncryptionFormatRequest() override {} virtual uno::Any SAL_CALL getRequest() override { -return uno::makeAny( +return uno::Any( task::ErrorCodeRequest( OUString(), uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_IO_WRONGVERSION))); diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index 891839f6b977..62eeea5c5376 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -717,9 +717,9 @@ uno::Sequence LineParser::readImageImpl() uno::UNO_QUERY_THROW ); uno::Sequence aSequence( comphelper::InitPropertySequence({ -{ "URL", uno::makeAny(aFileName) }, -{ "InputStream", uno::makeAny( xDataStream ) }, -{ "InputSequence", uno::makeAny(aDataSequence) } +{ "URL", uno::Any(aFileName) }, +{ "InputStream", uno::Any( xDataStream ) }, +{ "InputSequence", uno::Any(aDataSequence) } })); return aSequence;
[Libreoffice-commits] core.git: sdext/source sd/inc sd/IwyuFilter_sd.yaml sd/qa sd/source
sd/IwyuFilter_sd.yaml | 13 + sd/inc/family.hrc |1 + sd/inc/helpids.h |2 ++ sd/inc/pageformatpanel.hrc|2 ++ sd/inc/sdcommands.h |2 ++ sd/inc/strings.hxx|2 ++ sd/qa/unit/PNGExportTests.cxx |4 sd/qa/unit/export-tests-ooxml2.cxx|4 ++-- sd/qa/unit/export-tests-ooxml3.cxx|3 +-- sd/qa/unit/export-tests.cxx |1 - sd/qa/unit/import-tests.cxx |2 -- sd/qa/unit/misc-tests.cxx |2 -- sd/qa/unit/tiledrendering/CallbackRecorder.hxx|4 sd/qa/unit/tiledrendering/tiledrendering.cxx |4 sd/qa/unit/uiimpress.cxx |1 - sd/source/core/CustomAnimationEffect.cxx |2 -- sd/source/core/CustomAnimationPreset.cxx |3 --- sd/source/core/TransitionPreset.cxx |1 - sd/source/filter/eppt/eppt.cxx|2 +- sd/source/filter/eppt/epptso.cxx |2 +- sd/source/filter/eppt/pptx-epptooxml.cxx |1 - sd/source/filter/xml/sdxmlwrp.cxx |1 - sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx |1 - sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx |1 - sd/source/ui/animations/CustomAnimationList.cxx |1 - sd/source/ui/animations/CustomAnimationPane.cxx |3 --- sd/source/ui/animations/SlideTransitionPane.cxx |2 -- sd/source/ui/annotations/annotationmanager.cxx|4 sd/source/ui/annotations/annotationmanagerimpl.hxx|1 + sd/source/ui/annotations/annotationtag.hxx|2 ++ sd/source/ui/annotations/annotationwindow.hxx |1 - sd/source/ui/app/scalectrl.cxx|2 +- sd/source/ui/app/sdmod.cxx|1 - sd/source/ui/controller/slidelayoutcontroller.cxx |1 - sd/source/ui/dlg/PhotoAlbumDialog.cxx |1 - sd/source/ui/dlg/tpaction.cxx |1 - sd/source/ui/framework/factories/ViewShellWrapper.cxx |1 - sd/source/ui/func/fubullet.cxx|1 - sd/source/ui/func/fucon3d.cxx |1 - sd/source/ui/func/fuinsert.cxx|3 --- sd/source/ui/func/fuline.cxx |1 - sd/source/ui/func/fumorph.cxx |1 - sd/source/ui/inc/framework/ModuleController.hxx |1 - sd/source/ui/inc/tpaction.hxx |1 + sd/source/ui/inc/unokywds.hxx |1 + sd/source/ui/presenter/PresenterTextView.cxx |1 - sd/source/ui/remotecontrol/BluetoothServer.cxx|1 - sd/source/ui/remotecontrol/Communicator.cxx |1 - sd/source/ui/remotecontrol/DiscoveryService.cxx |2 -- sd/source/ui/remotecontrol/ImagePreparer.cxx |1 - sd/source/ui/sidebar/DocumentHelper.hxx |4 +++- sd/source/ui/sidebar/LayoutMenu.cxx |2 -- sd/source/ui/sidebar/MasterPagesSelector.cxx |2 -- sd/source/ui/sidebar/NavigatorWrapper.hxx |1 - sd/source/ui/sidebar/SlideBackground.hxx |2 ++ sd/source/ui/slideshow/slideshowimpl.cxx |4 sd/source/ui/slideshow/slideshowviewimpl.cxx |1 - sd/source/ui/slidesorter/controller/SlsClipboard.cxx |1 - sd/source/ui/slidesorter/controller/SlsSlotManager.cxx|1 - sd/source/ui/tools/GraphicSizeCheck.cxx |2 +- sd/source/ui/unoidl/SdUnoDrawView.cxx |1 - sd/source/ui/unoidl/unolayer.cxx |4 +++- sd/source/ui/unoidl/unomodel.cxx |1 - sd/source/ui/unoidl/unoobj.cxx|1 - sd/source/ui/view/MediaObjectBar.cxx |1 - sd/source/ui/view/drviews1.cxx|1 - sd/source/ui/view/drviews3.cxx|1 - sd/source/ui/view/drviews7.cxx|2 -- sd/source/ui/view/drviews8.cxx|1 - sd/source/ui/view/drviews9.cxx|1 - sd/source/ui/view/drviewsd.cxx|1 - sd/source/ui/view/sdview.cxx |4 +++- sd/source/ui/view/sdview4.cxx
[Libreoffice-commits] core.git: sdext/source
sdext/source/presenter/PresenterSpritePane.hxx |5 + 1 file changed, 1 insertion(+), 4 deletions(-) New commits: commit 6aec296589f9e1fb35443fc1cdbe5e8ea50d100b Author: Deep17 AuthorDate: Sat Feb 19 22:30:10 2022 -0500 Commit: Ilmari Lauhakangas CommitDate: Mon Feb 21 07:28:54 2022 +0100 tdf#143148 Use pragma once instead of include guards Change-Id: I8f2dd2049a70dde809a1b1afb1f67d5feaf60d8b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130222 Tested-by: Jenkins Reviewed-by: Ilmari Lauhakangas diff --git a/sdext/source/presenter/PresenterSpritePane.hxx b/sdext/source/presenter/PresenterSpritePane.hxx index 377d5fa7898e..1c2c923b942a 100644 --- a/sdext/source/presenter/PresenterSpritePane.hxx +++ b/sdext/source/presenter/PresenterSpritePane.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERSPRITEPANE_HXX -#define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERSPRITEPANE_HXX +#pragma once #include "PresenterPaneBase.hxx" #include "PresenterSprite.hxx" @@ -77,6 +76,4 @@ private: } // end of namespace ::sd::presenter -#endif - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/tree/imagecontainer.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 59ac648a1482d9422b8f279bcb284a214032f5cf Author: Stephan Bergmann AuthorDate: Thu Feb 17 12:07:48 2022 +0100 Commit: Stephan Bergmann CommitDate: Thu Feb 17 13:23:56 2022 +0100 Parameter should apparently be of type sal_Int32 It was like this ever since 969aac0edf437ec0cad0baadfde46188c4822161 "INTEGRATION: CWS pdf25", but the single caller of encodeBase64 passes a sal_Int32 value, and all use of i_nBufferLength in encodeBase64 are in sal_Int32-based computations. Change-Id: I2963a05bf5a83aaee25cdd71c11d28481b28061a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130067 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/sdext/source/pdfimport/tree/imagecontainer.cxx b/sdext/source/pdfimport/tree/imagecontainer.cxx index bedbcd73b020..9754e9134a50 100644 --- a/sdext/source/pdfimport/tree/imagecontainer.cxx +++ b/sdext/source/pdfimport/tree/imagecontainer.cxx @@ -43,7 +43,7 @@ const char aBase64EncodeTable[] = 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; -OUString encodeBase64( const sal_Int8* i_pBuffer, const sal_uInt32 i_nBufferLength ) +OUString encodeBase64( const sal_Int8* i_pBuffer, const sal_Int32 i_nBufferLength ) { OUStringBuffer aBuf( (i_nBufferLength+1) * 4 / 3 ); const sal_Int32 nRemain(i_nBufferLength%3);
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/inc/wrapper.hxx | 12 sdext/source/pdfimport/wrapper/wrapper.cxx | 26 +- 2 files changed, 37 insertions(+), 1 deletion(-) New commits: commit bcf10015c5d12d363d0be9f6da25092c83112692 Author: Kevin Suo AuthorDate: Sat Jan 29 21:44:36 2022 +0800 Commit: Noel Grandin CommitDate: Fri Feb 4 07:44:18 2022 +0100 sdext.pdfimport tdf#137128: Recognize more font name and weight... ...values from the embeded 'PS' font names. Change-Id: I8465a6b1d845ce626848112f0a735a9ee3696e5c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129136 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/inc/wrapper.hxx b/sdext/source/pdfimport/inc/wrapper.hxx index 9f25e1b7290b..94cc2b24327d 100644 --- a/sdext/source/pdfimport/inc/wrapper.hxx +++ b/sdext/source/pdfimport/inc/wrapper.hxx @@ -58,16 +58,28 @@ namespace pdfi // and they are checked from the suffix, thus the order matters. // e.g. for "TimesNewRomanPS-BoldItalic", to get "TimesNewRoman", you should // first have "Italic", and then "Bold", then "-", and then "PS". +"-VKana", "MT", "PS", "PSMT", "Regular", +"Normal", +"Book", +"Medium", +"ExtraBold", +"UltraBold", +"ExtraLight", +"UltraLight", "Bold", +"Heavy", +"Black", "Italic", "Oblique", "Bold", //BoldItalic, BoldOblique "Light", +"Thin", "Semibold", +"-Roman", "Reg", "VKana", "-", diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index 0560826d5727..cfa256f0acfa 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -492,7 +492,15 @@ void LineParser::parseFontFamilyName( FontAttributes& rResult ) { rResult.familyName = rResult.familyName.replaceAll(fontAttributesSuffix, ""); SAL_INFO("sdext.pdfimport", rResult.familyName); -if (fontAttributesSuffix == u"Bold") +if (fontAttributesSuffix == u"Heavy" || fontAttributesSuffix == u"Black") +{ +rResult.fontWeight = u"900"; +} +else if (fontAttributesSuffix == u"ExtraBold" || fontAttributesSuffix == u"UltraBold") +{ +rResult.fontWeight = u"800"; +} +else if (fontAttributesSuffix == u"Bold") { rResult.fontWeight = u"bold"; } @@ -500,10 +508,26 @@ void LineParser::parseFontFamilyName( FontAttributes& rResult ) { rResult.fontWeight = u"600"; } +else if (fontAttributesSuffix == u"Medium") +{ +rResult.fontWeight = u"500"; +} +else if (fontAttributesSuffix == u"Normal" || fontAttributesSuffix == u"Regular" || fontAttributesSuffix == u"Book") +{ +rResult.fontWeight = u"400"; +} else if (fontAttributesSuffix == u"Light") { rResult.fontWeight = u"300"; } +else if (fontAttributesSuffix == u"ExtraLight" || fontAttributesSuffix == u"UltraLight") +{ +rResult.fontWeight = u"200"; +} +else if (fontAttributesSuffix == u"Thin") +{ +rResult.fontWeight = u"100"; +} if ( (fontAttributesSuffix == "Italic") or (fontAttributesSuffix == "Oblique") ) {
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/tree/genericelements.cxx |8 1 file changed, 4 insertions(+), 4 deletions(-) New commits: commit 2f605009907166d509ccd1dcb6385e5cd456e3e4 Author: Kevin Suo AuthorDate: Mon Jul 12 09:11:15 2021 +0800 Commit: Noel Grandin CommitDate: Fri Feb 4 07:43:42 2022 +0100 sdext.pdfimport: these SAL_WARN should be SAL_INFO SAL_WARN should be some message which showns where the program runs abnormally. Normal debugging output code should be SAL_INFO, and if you have set it to SAL_WARN for easy debugging you should set it back to SAL_INFO or delete those lines when submit. Otherwise our dbgutil terminal will be flood with unrelated messages Change-Id: I0767bfbeb7a21f208be12208009ccda8b6c72bab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118763 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/tree/genericelements.cxx b/sdext/source/pdfimport/tree/genericelements.cxx index b02e2c0a727d..2c394c973bf0 100644 --- a/sdext/source/pdfimport/tree/genericelements.cxx +++ b/sdext/source/pdfimport/tree/genericelements.cxx @@ -156,8 +156,8 @@ void PolyPolyElement::visitedBy( ElementTreeVisitor& rV #if OSL_DEBUG_LEVEL > 0 void PolyPolyElement::emitStructure( int nLevel) { -SAL_WARN( "sdext", std::string(nLevel, ' ') << "<" << typeid( *this ).name() << " " << this << ">" ); -SAL_WARN( "sdext", "path=" ); +SAL_INFO( "sdext", std::string(nLevel, ' ') << "<" << typeid( *this ).name() << " " << this << ">" ); +SAL_INFO( "sdext", "path=" ); int nPoly = PolyPoly.count(); for( int i = 0; i < nPoly; i++ ) { @@ -169,11 +169,11 @@ void PolyPolyElement::emitStructure( int nLevel) basegfx::B2DPoint aPoint = aPoly.getB2DPoint( n ); buff.append( " (" + OUString::number(aPoint.getX()) + "," + OUString::number(aPoint.getY()) + ")"); } -SAL_WARN( "sdext", "" << buff.makeStringAndClear() ); +SAL_INFO( "sdext", "" << buff.makeStringAndClear() ); } for (auto const& child : Children) child->emitStructure( nLevel+1 ); -SAL_WARN( "sdext", std::string(nLevel, ' ') << ""); +SAL_INFO( "sdext", std::string(nLevel, ' ') << ""); } #endif
[Libreoffice-commits] core.git: sdext/source
sdext/source/minimizer/impoptimizer.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 1aa57f44c0d37ef23551943a64211dea17903873 Author: Caolán McNamara AuthorDate: Thu Dec 9 11:31:18 2021 + Commit: Caolán McNamara CommitDate: Thu Dec 9 14:50:12 2021 +0100 change use of wrong slot id to name of correct command slot was introduced with commit 27452a082237065ac4cf475c8398241907164b2c Date: Wed Oct 10 14:32:04 2007 + INTEGRATION: CWS pppopt02 (1.24.74); FILE MERGED 2007/09/28 14:52:06 sj 1.24.74.1: added slot to be able to clear the undomanager as 27115, but got renumbered to 27118 with commit 35fe915b7cf508356a88897d520b89fc986407fb Date: Wed Jun 10 15:47:52 2015 +0200 Fix sd ID conflicts and duplicates using its name is verified to call the expected handler for it Change-Id: I656d91937612b0807353455930328aa37d5eecb7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126581 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/sdext/source/minimizer/impoptimizer.cxx b/sdext/source/minimizer/impoptimizer.cxx index cf8b875ebe21..7de159177979 100644 --- a/sdext/source/minimizer/impoptimizer.cxx +++ b/sdext/source/minimizer/impoptimizer.cxx @@ -658,7 +658,7 @@ void ImpOptimizer::Optimize( const Sequence< PropertyValue >& rArguments ) Reference< XFrame > xFrame( xSelf.is() ? xSelf : mxInformationDialog ); if ( xFrame.is() ) { -DispatchURL( mxContext, "slot:27115", xFrame ); +DispatchURL(mxContext, ".uno:ClearUndoStack", xFrame); } }
[Libreoffice-commits] core.git: sdext/source
sdext/source/presenter/PresenterCanvasHelper.cxx |7 +++ sdext/source/presenter/PresenterWindowManager.cxx |6 ++ 2 files changed, 5 insertions(+), 8 deletions(-) New commits: commit 86430b76d5833d85f54ccfdbf933162b59a261d9 Author: Julien Nabet AuthorDate: Fri Oct 22 18:16:43 2021 +0200 Commit: Julien Nabet CommitDate: Fri Oct 22 19:17:50 2021 +0200 Revert part of "Simplify vector initialization in sdext" since it needs 2 allocations instead of one This partially reverts commit d64a6e2245169e5e4a3f8bc5388b4fff4984e5f4 . Change-Id: Iadd8193a02bd922105c082fe3bbcc6f8e9f96b22 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124069 Tested-by: Jenkins Reviewed-by: Julien Nabet diff --git a/sdext/source/presenter/PresenterCanvasHelper.cxx b/sdext/source/presenter/PresenterCanvasHelper.cxx index 697a84d0a8ec..8381f8d5aabd 100644 --- a/sdext/source/presenter/PresenterCanvasHelper.cxx +++ b/sdext/source/presenter/PresenterCanvasHelper.cxx @@ -71,11 +71,10 @@ void PresenterCanvasHelper::PaintRectangle ( return; // Create a clip polypolygon that has the content box as hole. -::std::vector aRectangles -{ -PresenterGeometryHelper::Intersection(rRepaintBox, rOuterBoundingBox) -}; +::std::vector aRectangles; aRectangles.reserve(2); +aRectangles.push_back( +PresenterGeometryHelper::Intersection(rRepaintBox, rOuterBoundingBox)); if (rContentBoundingBox.Width > 0 && rContentBoundingBox.Height > 0) aRectangles.push_back( PresenterGeometryHelper::Intersection(rRepaintBox, rContentBoundingBox)); diff --git a/sdext/source/presenter/PresenterWindowManager.cxx b/sdext/source/presenter/PresenterWindowManager.cxx index 9a541842286d..24115fa52523 100644 --- a/sdext/source/presenter/PresenterWindowManager.cxx +++ b/sdext/source/presenter/PresenterWindowManager.cxx @@ -989,11 +989,9 @@ Reference PresenterWindowManager::CreateClipPolyPolyg // Create a clip polygon that includes the whole update area but has the // content windows as holes. const sal_Int32 nPaneCount (mpPaneContainer->maPanes.size()); -::std::vector aRectangles -{ -mxParentWindow->getPosSize() -}; +::std::vector aRectangles; aRectangles.reserve(1+nPaneCount); +aRectangles.push_back(mxParentWindow->getPosSize()); for (const auto& pDescriptor : mpPaneContainer->maPanes) { if ( ! pDescriptor->mbIsActive)
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/tree/drawtreevisiting.cxx | 28 ++--- sdext/source/pdfimport/tree/style.cxx |8 +++--- sdext/source/pdfimport/tree/style.hxx |6 ++-- sdext/source/pdfimport/tree/writertreevisiting.cxx | 28 ++--- 4 files changed, 35 insertions(+), 35 deletions(-) New commits: commit 2c596b694a641de1b18afb1e9a5b843df638af24 Author: Noel Grandin AuthorDate: Mon Oct 11 18:52:02 2021 +0200 Commit: Noel Grandin CommitDate: Tue Oct 12 08:30:14 2021 +0200 loplugin:moveparam in sdext Change-Id: I46e0f73f67cffb11ab5f1cf2453450a3066eb1fe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123425 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx index 436f9f532c20..ffc27c65f56c 100644 --- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx +++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx @@ -767,7 +767,7 @@ void DrawXmlFinalizer::visit( PolyPolyElement& elem, const std::list< std::uniqu { PropertyMap props; FillDashStyleProps(props, rGC.DashArray, scale); -StyleContainer::Style style("draw:stroke-dash", props); +StyleContainer::Style style("draw:stroke-dash", std::move(props)); aGCProps[ "draw:stroke" ] = "dash"; aGCProps[ "draw:stroke-dash" ] = @@ -800,8 +800,8 @@ void DrawXmlFinalizer::visit( PolyPolyElement& elem, const std::list< std::uniqu aGCProps[ "draw:fill" ] = "none"; } -StyleContainer::Style aStyle( "style:style", aProps ); -StyleContainer::Style aSubStyle( "style:graphic-properties", aGCProps ); +StyleContainer::Style aStyle( "style:style", std::move(aProps) ); +StyleContainer::Style aSubStyle( "style:graphic-properties", std::move(aGCProps) ); aStyle.SubStyles.push_back( ); elem.StyleId = m_rStyleContainer.getStyleId( aStyle ); @@ -877,8 +877,8 @@ void DrawXmlFinalizer::visit( TextElement& elem, const std::list< std::unique_pt aFontProps[ "style:text-scale" ] = getPercentString(textScale); } -StyleContainer::Style aStyle( "style:style", aProps ); -StyleContainer::Style aSubStyle( "style:text-properties", aFontProps ); +StyleContainer::Style aStyle( "style:style", std::move(aProps) ); +StyleContainer::Style aSubStyle( "style:text-properties", std::move(aFontProps) ); aStyle.SubStyles.push_back( ); elem.StyleId = m_rStyleContainer.getStyleId( aStyle ); } @@ -899,8 +899,8 @@ void DrawXmlFinalizer::visit( ParagraphElement& elem, const std::list< std::uniq else aParProps[ "style:writing-mode"]= "lr-tb"; -StyleContainer::Style aStyle( "style:style", aProps ); -StyleContainer::Style aSubStyle( "style:paragraph-properties", aParProps ); +StyleContainer::Style aStyle( "style:style", std::move(aProps) ); +StyleContainer::Style aSubStyle( "style:paragraph-properties", std::move(aParProps) ); aStyle.SubStyles.push_back( ); elem.StyleId = m_rStyleContainer.getStyleId( aStyle ); @@ -931,8 +931,8 @@ void DrawXmlFinalizer::visit( FrameElement& elem, const std::list< std::unique_p aGCProps[ "fo:padding-right" ] = "0cm"; aGCProps[ "fo:padding-bottom" ] = "0cm"; -StyleContainer::Style style1( "style:style", props1 ); -StyleContainer::Style subStyle1( "style:graphic-properties", aGCProps ); +StyleContainer::Style style1( "style:style", std::move(props1) ); +StyleContainer::Style subStyle1( "style:graphic-properties", std::move(aGCProps) ); style1.SubStyles.push_back(); elem.StyleId = m_rStyleContainer.getStyleId(style1); @@ -945,8 +945,8 @@ void DrawXmlFinalizer::visit( FrameElement& elem, const std::list< std::unique_p PropertyMap textProps; SetFontsizeProperties(textProps, elem.FontSize); -StyleContainer::Style style2("style:style", props2); -StyleContainer::Style subStyle2("style:text-properties", textProps); +StyleContainer::Style style2("style:style", std::move(props2)); +StyleContainer::Style subStyle2("style:text-properties", std::move(textProps)); style2.SubStyles.push_back(); elem.TextStyleId = m_rStyleContainer.getStyleId(style2); } @@ -1039,8 +1039,8 @@ void DrawXmlFinalizer::visit( PageElement& elem, const std::list< std::unique_pt aPageLayoutProps[ "style:print-orientation" ]= elem.w < elem.h ? std::u16string_view(u"portrait") : std::u16string_view(u"landscape"); aPageLayoutProps[ "style:writing-mode" ]= "lr-tb"; -StyleContainer::Style aStyle( "style:page-layout", aPageProps); -StyleContainer::Style aSubStyle( "style:page-layout-properties", aPageLayoutProps); +StyleContainer::Style aStyle( "style:page-layout", std::move(aPageProps)); +StyleContainer::Style
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/wrapper/wrapper.cxx | 16 1 file changed, 8 insertions(+), 8 deletions(-) New commits: commit 57ffa96d413df2712b15355f49294e564bd0d996 Author: Stephan Bergmann AuthorDate: Mon Oct 11 12:11:40 2021 +0200 Commit: Stephan Bergmann CommitDate: Mon Oct 11 13:38:25 2021 +0200 Fix font weight comparisons ...after 2d486bac81e06c64d13c647f35d3f4affbeb183e "tdf#143959 sdext.pdfimport: call vcl::Font::identifyFont directly" changed the left-hand sides from aFontDescriptor.Weight of type float to aFontReadResult.GetWeight() of type FontWeight from include/tools/fontenum.hxx. (Diagnosed as > sdext/source/pdfimport/wrapper/wrapper.cxx:624:45: error: comparison of enumeration type 'FontWeight' with floating-point type 'float' is deprecated [-Werror,-Wdeprecated-enum-float-conversion] > if (aFontReadResult.GetWeight() == com::sun::star::awt::FontWeight::THIN) > ~~~ ^ ~ in a --with-latest-c++ build.) Change-Id: I0c661fc27eefa478808f796ffb9a7586e1e671c3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123375 Reviewed-by: Kevin Suo Reviewed-by: Stephan Bergmann Tested-by: Jenkins diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index 4d1f328d6f34..3553a588802c 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -621,22 +621,22 @@ void LineParser::readFont() } // Font weight -if (aFontReadResult.GetWeight() == com::sun::star::awt::FontWeight::THIN) +if (aFontReadResult.GetWeight() == WEIGHT_THIN) aResult.fontWeight = u"100"; -else if (aFontReadResult.GetWeight() == com::sun::star::awt::FontWeight::ULTRALIGHT) +else if (aFontReadResult.GetWeight() == WEIGHT_ULTRALIGHT) aResult.fontWeight = u"200"; -else if (aFontReadResult.GetWeight() == com::sun::star::awt::FontWeight::LIGHT) +else if (aFontReadResult.GetWeight() == WEIGHT_LIGHT) aResult.fontWeight = u"300"; -else if (aFontReadResult.GetWeight() == com::sun::star::awt::FontWeight::SEMILIGHT) +else if (aFontReadResult.GetWeight() == WEIGHT_SEMILIGHT) aResult.fontWeight = u"350"; // no need to check "normal" here as this is default in nFontWeight above -else if (aFontReadResult.GetWeight() == com::sun::star::awt::FontWeight::SEMIBOLD) +else if (aFontReadResult.GetWeight() == WEIGHT_SEMIBOLD) aResult.fontWeight = u"600"; -else if (aFontReadResult.GetWeight() == com::sun::star::awt::FontWeight::BOLD) +else if (aFontReadResult.GetWeight() == WEIGHT_BOLD) aResult.fontWeight = u"bold"; -else if (aFontReadResult.GetWeight() == com::sun::star::awt::FontWeight::ULTRABOLD) +else if (aFontReadResult.GetWeight() == WEIGHT_ULTRABOLD) aResult.fontWeight = u"800"; -else if (aFontReadResult.GetWeight() == com::sun::star::awt::FontWeight::BLACK) +else if (aFontReadResult.GetWeight() == WEIGHT_BLACK) aResult.fontWeight = u"900"; SAL_INFO("sdext.pdfimport", aResult.fontWeight);
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/wrapper/wrapper.cxx | 113 +++-- 1 file changed, 46 insertions(+), 67 deletions(-) New commits: commit 2d486bac81e06c64d13c647f35d3f4affbeb183e Author: Kevin Suo AuthorDate: Mon Oct 11 12:29:00 2021 +0800 Commit: Noel Grandin CommitDate: Mon Oct 11 09:08:37 2021 +0200 tdf#143959 sdext.pdfimport: call vcl::Font::identifyFont directly Previously the unittest testTdf143959_nameFromFontFile did not fail even if the fixing code in wrapper.cxx is removed. That was because the "if (xHolder.is())" condition is always false in the unittest run, which suggests that the calling of com.sun.star.awt.FontIdentificator through the uno did not work in some circumstances. See comments in: https://gerrit.libreoffice.org/c/core/+/120815 In this patch, we call the vcl::Font::identifyFont directly rather than through the uno calling. This is proven to work in both the manual and unittest running. Change-Id: I6334bca2defaa27cf6ac72af3d621fbb59e57980 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123358 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index 4de5a8516297..4d1f328d6f34 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -484,14 +484,14 @@ e.g., TimesNewRoman -> Times New Roman */ void LineParser::parseFontFamilyName( FontAttributes& rResult ) { -SAL_WARN("sdext.pdfimport", "Processing " << rResult.familyName << " ---"); +SAL_INFO("sdext.pdfimport", "Processing " << rResult.familyName << " ---"); rResult.familyName = rResult.familyName.trim(); for (const OUString& fontAttributesSuffix: fontAttributesSuffixes) { if ( rResult.familyName.endsWith(fontAttributesSuffix) ) { rResult.familyName = rResult.familyName.replaceAll(fontAttributesSuffix, ""); -SAL_WARN("sdext.pdfimport", rResult.familyName); +SAL_INFO("sdext.pdfimport", rResult.familyName); if (fontAttributesSuffix == u"Bold") { rResult.fontWeight = u"bold"; @@ -579,7 +579,7 @@ void LineParser::readFont() sFontWeight = u"800"; else if (nFontWeight == 9) // W900, Black sFontWeight = u"900"; -SAL_WARN("sdext.pdfimport", "Font weight passed from xpdfimport is: " << sFontWeight); +SAL_INFO("sdext.pdfimport", "Font weight passed from xpdfimport is: " << sFontWeight); FontAttributes aResult( OStringToOUString( aFontName, RTL_TEXTENCODING_UTF8 ), sFontWeight, @@ -602,79 +602,58 @@ void LineParser::readFont() uno::Sequence aFontFile(nFileLen); readBinaryData(aFontFile); // Read fontFile. -uno::Sequence aArgs(1); -awt::FontDescriptor aFontDescriptor; -aArgs[0] <<= aFontFile; +vcl::Font aFontReadResult = vcl::Font::identifyFont(aFontFile.getArray(), nFileLen); +SAL_INFO("sdext.pdfimport", "familyName: " << aFontReadResult.GetFamilyName()); -try +if (!aFontReadResult.GetFamilyName().isEmpty()) // font detection successful { -uno::Reference xHolder( - m_parser.m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( -"com.sun.star.awt.FontIdentificator", aArgs, m_parser.m_xContext), -uno::UNO_QUERY); -if (xHolder.is()) -{ -uno::Any aFontReadResult(xHolder->getMaterial()); -aFontReadResult >>= aFontDescriptor; -if (!aFontDescriptor.Name.isEmpty()) -{ -// Family name -aResult.familyName = aFontDescriptor.Name; -SAL_INFO("sdext.pdfimport", aResult.familyName); -// tdf#143959: there are cases when the family name returned by font descriptor -// is like "AA+TimesNewRoman,Bold". In this case, use the font name -// determined by parseFontFamilyName instead, but still determine the font -// attributes (bold italic etc) from the font descriptor. -if (aResult.familyName.getLength() > 7 and aResult.familyName.indexOf(u"+", 6) == 6) -{ -aResult.familyName = aResult.familyName.copy(7, aResult.familyName.getLength() - 7); -parseFontFamilyName(aResult); -} - -// Font weight -if (aFontDescriptor.Weight == com::sun::star::awt::FontWeight::THIN) -aResult.fontWeight = u"100"; -else if (aFontDescriptor.Weight == com::sun::star::awt::FontWeight::ULTRALIGHT) -aResult.fontWeight =
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/inc/contentsink.hxx | 12 - sdext/source/pdfimport/inc/pdfihelper.hxx | 2 sdext/source/pdfimport/inc/wrapper.hxx | 1 sdext/source/pdfimport/test/testdocs/tdf78427-MyraidPro-Semibold-Light.pdf |binary sdext/source/pdfimport/test/tests.cxx | 65 +-- sdext/source/pdfimport/tree/drawtreevisiting.cxx | 9 - sdext/source/pdfimport/tree/pdfiprocessor.cxx | 4 sdext/source/pdfimport/tree/writertreevisiting.cxx | 20 +- sdext/source/pdfimport/wrapper/wrapper.cxx | 88 -- sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx | 4 sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx | 12 - 11 files changed, 158 insertions(+), 59 deletions(-) New commits: commit 4eef83dc4a8879f21ee6c98226510ac728bc317a Author: Kevin Suo AuthorDate: Sun Oct 10 21:25:58 2021 +0800 Commit: Noel Grandin CommitDate: Mon Oct 11 09:07:59 2021 +0200 sdext.pdfimport tdf#78427: Add support for more Font Weight features ...e.g. Thin, Extra-Light, Light, Semi-Bold, Bold, Extra-Bold and Black. Previously the xpdfimport code passes the isBold value which is bool value. sdext.pdfimport accepted this value from the xpdfimport output and check whether a font is bold or not. However, there are many other FontWeight features more than a "bold". This patch changes the isBold to the GfxFont::Weight type, and changed the sdext.pdfimport isBold bool type (in FontAttributes) to an OUString fontWeight. The value for the fontWeight is set according to the GfxFont::Weight passed by xpdfimport, and then this fontWeight is passed to the ODF xml generation stage and used there directly. Now the Semibold and Light (as shown in the unittest file) can be currectly handled. However, for other weights the parseFontFamilyName still need to be updated, but before doing that I plan to refector this function as the current logic is very difficult for maintennance. Change-Id: If2ce5f0f41c83843d8a6aeb30134b3faf99ba877 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123339 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/inc/contentsink.hxx b/sdext/source/pdfimport/inc/contentsink.hxx index dbe1b0e08808..9d016a7e2a3e 100644 --- a/sdext/source/pdfimport/inc/contentsink.hxx +++ b/sdext/source/pdfimport/inc/contentsink.hxx @@ -48,14 +48,14 @@ namespace pdfi { struct FontAttributes { -FontAttributes( const OUString& familyName_, -bool isBold_, +FontAttributes( const OUString& familyName_, +const OUString& sFontWeight, bool isItalic_, bool isUnderline_, double size_, double ascent_) : familyName(familyName_), -isBold(isBold_), +fontWeight(sFontWeight), isItalic(isItalic_), isUnderline(isUnderline_), isOutline(false), @@ -65,7 +65,7 @@ namespace pdfi FontAttributes() : familyName(), -isBold(false), +fontWeight(u"normal"), isItalic(false), isUnderline(false), isOutline(false), @@ -74,7 +74,7 @@ namespace pdfi {} OUStringfamilyName; -boolisBold; +OUStringfontWeight; boolisItalic; boolisUnderline; boolisOutline; @@ -84,7 +84,7 @@ namespace pdfi bool operator==(const FontAttributes& rFont) const { return familyName == rFont.familyName && -!isBold == !rFont.isBold && +fontWeight == rFont.fontWeight && !isItalic == !rFont.isItalic && !isUnderline == !rFont.isUnderline && !isOutline == !rFont.isOutline && diff --git a/sdext/source/pdfimport/inc/pdfihelper.hxx b/sdext/source/pdfimport/inc/pdfihelper.hxx index aa3a22bd2b67..6b663b203e62 100644 --- a/sdext/source/pdfimport/inc/pdfihelper.hxx +++ b/sdext/source/pdfimport/inc/pdfihelper.hxx @@ -82,7 +82,7 @@ namespace pdfi { std::size_t seed = 0; o3tl::hash_combine(seed, rFont.familyName.hashCode()); -o3tl::hash_combine(seed, rFont.isBold); +o3tl::hash_combine(seed, rFont.fontWeight); o3tl::hash_combine(seed, rFont.isItalic); o3tl::hash_combine(seed,
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx |5 + 1 file changed, 5 insertions(+) New commits: commit bc1b7491436146c3c4b2b69a46bd0cd37bbbecce Author: Rico Tzschichholz AuthorDate: Sat Sep 11 12:09:40 2021 +0200 Commit: Caolán McNamara CommitDate: Sun Sep 12 12:50:18 2021 +0200 allow build with poppler <= 0.71 Change-Id: I359c8259ae402f9f22be392c4ab4a23d31a17b4d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121937 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index 9cd2c55cee21..5d6ce90bc44c 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -435,7 +435,12 @@ int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, const GfxState* st #if POPPLER_CHECK_VERSION(20, 12, 0) std::string familyName = gfxFont->getNameWithoutSubsetTag(); #else +#if POPPLER_CHECK_VERSION(0, 71, 0) // GooString::toStr() std::string familyName = gfxFont->getName()->toStr(); +#else +const GooString* gooString = gfxFont->getName(); +std::string familyName = std::string(gooString->getCString(), gooString->getLength()); +#endif if (familyName.length() > 7 && familyName.at(6) == '+') { familyName = familyName.substr(7);
[Libreoffice-commits] core.git: sdext/source sd/source
sd/source/core/cusshow.cxx | 4 - sd/source/filter/eppt/pptx-epptooxml.cxx| 1 sd/source/filter/eppt/pptx-text.cxx | 11 --- sd/source/filter/html/htmlex.cxx| 1 sd/source/ui/accessibility/AccessibleSlideSorterView.cxx| 1 sd/source/ui/animations/CustomAnimationList.cxx | 1 sd/source/ui/animations/CustomAnimationPane.cxx | 1 sd/source/ui/animations/SlideTransitionPane.cxx | 4 - sd/source/ui/animations/motionpathtag.cxx | 5 - sd/source/ui/app/sdmod1.cxx | 3 sd/source/ui/app/sdxfer.cxx | 1 sd/source/ui/dlg/PaneShells.cxx | 2 sd/source/ui/dlg/TemplateScanner.cxx| 8 -- sd/source/ui/framework/configuration/ChangeRequestQueueProcessor.cxx| 5 - sd/source/ui/framework/configuration/ConfigurationClassifier.cxx| 4 - sd/source/ui/framework/configuration/ConfigurationController.cxx| 2 sd/source/ui/framework/configuration/ConfigurationControllerBroadcaster.cxx | 3 sd/source/ui/framework/configuration/ConfigurationUpdater.cxx | 5 - sd/source/ui/framework/configuration/ResourceFactoryManager.cxx | 6 - sd/source/ui/framework/configuration/ResourceId.cxx | 20 + sd/source/ui/framework/factories/BasicPaneFactory.cxx | 1 sd/source/ui/framework/factories/BasicToolBarFactory.cxx| 4 - sd/source/ui/framework/factories/BasicViewFactory.cxx | 1 sd/source/ui/framework/module/CenterViewFocusModule.cxx | 1 sd/source/ui/framework/module/ModuleController.cxx | 1 sd/source/ui/framework/module/ShellStackGuard.cxx | 2 sd/source/ui/framework/module/SlideSorterModule.cxx | 2 sd/source/ui/framework/module/ToolBarModule.cxx | 2 sd/source/ui/framework/module/ViewTabBarModule.cxx | 1 sd/source/ui/framework/tools/FrameworkHelper.cxx| 6 - sd/source/ui/presenter/PresenterCanvas.cxx | 1 sd/source/ui/presenter/PresenterPreviewCache.cxx| 7 -- sd/source/ui/presenter/PresenterTextView.cxx| 8 -- sd/source/ui/presenter/SlideRenderer.cxx| 3 sd/source/ui/remotecontrol/BufferedStreamSocket.cxx | 3 sd/source/ui/remotecontrol/Server.cxx | 4 - sd/source/ui/remotecontrol/Transmitter.cxx | 6 - sd/source/ui/sidebar/MasterPageContainer.cxx| 14 sd/source/ui/sidebar/MasterPageContainerFiller.cxx | 1 sd/source/ui/sidebar/MasterPageContainerProviders.cxx | 3 sd/source/ui/sidebar/MasterPageContainerQueue.cxx | 1 sd/source/ui/sidebar/MasterPageDescriptor.cxx | 2 sd/source/ui/sidebar/MasterPagesSelector.cxx| 4 - sd/source/ui/sidebar/RecentlyUsedMasterPages.cxx| 4 - sd/source/ui/sidebar/SlideBackground.cxx| 6 - sd/source/ui/slideshow/slideshowviewimpl.cxx| 1 sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx | 9 -- sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx | 4 - sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx| 5 - sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx | 3 sd/source/ui/slidesorter/controller/SlideSorterController.cxx | 10 -- sd/source/ui/slidesorter/controller/SlsAnimationFunction.cxx| 1 sd/source/ui/slidesorter/controller/SlsAnimator.cxx | 3 sd/source/ui/slidesorter/controller/SlsClipboard.cxx| 3 sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx | 4 - sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx| 2 sd/source/ui/slidesorter/controller/SlsListener.cxx | 5 - sd/source/ui/slidesorter/controller/SlsPageSelector.cxx
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/test/testdocs/testTdf143959.pdf |binary sdext/source/pdfimport/test/tests.cxx | 34 + sdext/source/pdfimport/wrapper/wrapper.cxx |9 3 files changed, 43 insertions(+) New commits: commit a1759769804a7f3b9895b481229d497a9eb4c70a Author: Kevin Suo AuthorDate: Sat Aug 21 17:37:52 2021 +0800 Commit: Noel Grandin CommitDate: Sun Aug 22 10:29:50 2021 +0200 tdf#143959 sdext.pdfimport: fix font name with subtag as returned by the font descriptor when reading the font file. Change-Id: I376b887e6356e765f669b41c43776f78f94c3623 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120815 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/test/testdocs/testTdf143959.pdf b/sdext/source/pdfimport/test/testdocs/testTdf143959.pdf new file mode 100644 index ..594e734a5629 Binary files /dev/null and b/sdext/source/pdfimport/test/testdocs/testTdf143959.pdf differ diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx index cb8416d71b21..f47fa459a03c 100644 --- a/sdext/source/pdfimport/test/tests.cxx +++ b/sdext/source/pdfimport/test/tests.cxx @@ -710,6 +710,39 @@ namespace assertXPath(pXmlDoc, xpath, "text-outline", "true"); } +void testTdf143959_nameFromFontFile() +{ +rtl::Reference xAdaptor(new pdfi::PDFIRawAdaptor(OUString(), getComponentContext())); +xAdaptor->setTreeVisitorFactory(createDrawTreeVisitorFactory()); + +OString aOutput; +CPPUNIT_ASSERT_MESSAGE("Converting PDF to ODF XML", + xAdaptor->odfConvert( m_directories.getURLFromSrc(u"/sdext/source/pdfimport/test/testdocs/testTdf143959.pdf"), +new OutputWrapString(aOutput), +nullptr )); + +//std::cout << aOutput << std::endl; +xmlDocUniquePtr pXmlDoc(xmlParseDoc(reinterpret_cast(aOutput.getStr(; + +/* Test for the 1st text paragraph */ +OUString styleName = getXPath(pXmlDoc, "//draw:frame[2]//text:span[1]", "style-name"); +OString xpath = "//office:automatic-styles/style:style[@style:name=\"" + +OUStringToOString(styleName, RTL_TEXTENCODING_UTF8) + +"\"]/style:text-properties"; +CPPUNIT_ASSERT_EQUAL(OUString("TimesNewRoman"), + getXPath(pXmlDoc, xpath, "font-family").replaceAll(u" ", u"")); + +/* Test for the "TOTAL ESTA HOJA USD" paragraph" */ +styleName = getXPath(pXmlDoc, "//draw:frame[last()-1]//text:span[1]", "style-name"); +xpath = "//office:automatic-styles/style:style[@style:name=\"" + +OUStringToOString(styleName, RTL_TEXTENCODING_UTF8) + +"\"]/style:text-properties"; +CPPUNIT_ASSERT_EQUAL(OUString("TimesNewRoman"), + getXPath(pXmlDoc, xpath, "font-family").replaceAll(u" ", u"")); +CPPUNIT_ASSERT_EQUAL(OUString("bold"), + getXPath(pXmlDoc, xpath, "font-weight")); +} + CPPUNIT_TEST_SUITE(PDFITest); CPPUNIT_TEST(testXPDFParser); CPPUNIT_TEST(testOdfWriterExport); @@ -719,6 +752,7 @@ namespace CPPUNIT_TEST(testTdf105536); CPPUNIT_TEST(testTdf141709); CPPUNIT_TEST(testFontFeatures); +CPPUNIT_TEST(testTdf143959_nameFromFontFile); CPPUNIT_TEST_SUITE_END(); }; diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index 7cf30241c5ee..2efdab6f8553 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -584,6 +584,15 @@ void LineParser::readFont() if (!aFontDescriptor.Name.isEmpty()) { aResult.familyName = aFontDescriptor.Name; +// tdf#143959: there are cases when the family name returned by font descriptor +// is like "AA+TimesNewRoman,Bold". In this case, use the font name +// determined by parseFontFamilyName instead, but still determine the font +// attributes (bold italic etc) from the font descriptor. +if (aResult.familyName.getLength() > 7 and aResult.familyName.indexOf(u"+", 6) == 6) +{ +aResult.familyName = aResult.familyName.copy(7, aResult.familyName.getLength() - 7); +parseFontFamilyName(aResult); +} aResult.isBold = (aFontDescriptor.Weight > 100.0); aResult.isItalic = (aFontDescriptor.Slant == awt::FontSlant_OBLIQUE ||
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx |4 1 file changed, 4 insertions(+) New commits: commit fc7fbbd8ba089570c93917eedf1de0512cc0ba3b Author: Caolán McNamara AuthorDate: Fri Aug 20 08:47:23 2021 +0100 Commit: Caolán McNamara CommitDate: Fri Aug 20 11:11:57 2021 +0200 allow build with poppler <= 0.82 Change-Id: Ia062a788fec9c67c18382c2ff5f4b4df35bd17d7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120771 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index 54caf6728133..74740233d467 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -458,7 +458,11 @@ int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, const GfxState* st aNewFont.isBold= gfxFont->isBold(); aNewFont.isItalic = gfxFont->isItalic(); +#if POPPLER_CHECK_VERSION(0, 83, 0) // const added to getTransformedFontSize aNewFont.size = state->getTransformedFontSize(); +#else +aNewFont.size = const_cast(state)->getTransformedFontSize(); +#endif aNewFont.isUnderline = false; if( gfxFont->getType() == fontTrueType || gfxFont->getType() == fontType1 )
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/filterdet.hxx |5 + 1 file changed, 1 insertion(+), 4 deletions(-) New commits: commit ab0bb71280999ef7c11c341f5269ea98019fe4c3 Author: Yildiray AuthorDate: Tue Aug 10 18:32:25 2021 +0300 Commit: Ilmari Lauhakangas CommitDate: Tue Aug 10 22:05:40 2021 +0200 tdf#143148 Use pragma once in sdext Change-Id: I0ba29599509b875494f4021948192d2d447b9e6b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120277 Tested-by: Ilmari Lauhakangas Reviewed-by: Ilmari Lauhakangas diff --git a/sdext/source/pdfimport/filterdet.hxx b/sdext/source/pdfimport/filterdet.hxx index 6ed195d3bb03..6c7d58ca048c 100644 --- a/sdext/source/pdfimport/filterdet.hxx +++ b/sdext/source/pdfimport/filterdet.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_SDEXT_SOURCE_PDFIMPORT_FILTERDET_HXX -#define INCLUDED_SDEXT_SOURCE_PDFIMPORT_FILTERDET_HXX +#pragma once #include #include @@ -100,6 +99,4 @@ bool checkDocChecksum( const OUString& rInPDFFileURL, } -#endif - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/wrapper/wrapper.cxx |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit dd43ed8610f2d3e4c90d4bfd8a6ab3c736e5b4b8 Author: Andrea Gelmini AuthorDate: Mon Jul 26 17:56:32 2021 +0200 Commit: Julien Nabet CommitDate: Mon Jul 26 18:04:41 2021 +0200 Fix typos Change-Id: If0c2b0df62d2f307ceaef0ea961a0ff221ba5e65 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119520 Tested-by: Julien Nabet Reviewed-by: Julien Nabet diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index ffa29b1f7b7b..7cf30241c5ee 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -556,11 +556,11 @@ void LineParser::readFont() /* The above font attributes (fontName, bold, italic) are based on xpdf line output and may not be reliable. To get correct attributes, we do the following: -1. Read the embeded font file and determine the attributes based on the +1. Read the embedded font file and determine the attributes based on the font file. 2. If we failed to read the font file, or empty result is returned, then determine the font attributes from the font name. -3. If all these attemps have failed, then use a fallback font. +3. If all these attempts have failed, then use a fallback font. */ if (nFileLen > 0) { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/wrapper/wrapper.cxx| 97 +++--- sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx |5 2 files changed, 89 insertions(+), 13 deletions(-) New commits: commit 2ee3d4076481262c1e3014dc9341cdf3d1922ff7 Author: Kevin Suo AuthorDate: Sat Jul 17 14:25:45 2021 +0800 Commit: Noel Grandin CommitDate: Mon Jul 26 08:28:20 2021 +0200 sdext.pdfimport: Restore to read font file for the determination... of font attributes, as suggested by Mike Kaganski in https://gerrit.libreoffice.org/c/core/+/118977. This partially reverts da59686672fd2bc98f8cb28d5f04dc978b50ac13 but did some modification of the previous code with some explanationary comments. Change-Id: I224d9e717bf374a90f4834cbd9e11bf1138b41ff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119090 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index e22fe0aeca72..ffa29b1f7b7b 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -503,25 +504,36 @@ void LineParser::parseFontFamilyName( FontAttributes& rResult ) void LineParser::readFont() { -OString aFontName; +/* +xpdf line is like (separated by space): +updateFont +updateFont 14 100 0 1200.00 23068TimesNewRomanPSMT + +If nEmbedSize > 0, then a fontFile is followed as a stream. +*/ + +OStringaFontName; sal_Int64 nFontID; sal_Int32 nIsEmbedded, nIsBold, nIsItalic, nIsUnderline, nFileLen; double nSize; -readInt64(nFontID); -readInt32(nIsEmbedded); -readInt32(nIsBold); -readInt32(nIsItalic); -readInt32(nIsUnderline); -readDouble(nSize); -readInt32(nFileLen); +readInt64(nFontID); // read FontID +readInt32(nIsEmbedded); // read isEmbedded +readInt32(nIsBold); // read isBold +readInt32(nIsItalic); // read isItalic +readInt32(nIsUnderline);// read isUnderline +readDouble(nSize); // read TransformedFontSize +readInt32(nFileLen);// read nEmbedSize nSize = nSize < 0.0 ? -nSize : nSize; -aFontName = lcl_unescapeLineFeeds( m_aLine.subView( m_nCharIndex ) ); +// Read FontName. From the current position to the end (any white spaces will be included). +aFontName = lcl_unescapeLineFeeds(m_aLine.subView(m_nCharIndex)); // name gobbles up rest of line m_nCharIndex = std::string_view::npos; +// Check if this font is already in our font map list. +// If yes, update the font size and skip. Parser::FontMapType::const_iterator pFont( m_parser.m_aFontMap.find(nFontID) ); if( pFont != m_parser.m_aFontMap.end() ) { @@ -534,16 +546,75 @@ void LineParser::readFont() } // yet unknown font - get info and add to map -FontAttributes aResult( OStringToOUString( aFontName, -RTL_TEXTENCODING_UTF8 ), +FontAttributes aResult( OStringToOUString( aFontName, RTL_TEXTENCODING_UTF8 ), nIsBold != 0, nIsItalic != 0, nIsUnderline != 0, nSize, 1.0); -// extract textual attributes (bold, italic in the name, etc.) -parseFontFamilyName(aResult); +/* The above font attributes (fontName, bold, italic) are based on + xpdf line output and may not be reliable. To get correct attributes, + we do the following: +1. Read the embeded font file and determine the attributes based on the + font file. +2. If we failed to read the font file, or empty result is returned, then + determine the font attributes from the font name. +3. If all these attemps have failed, then use a fallback font. +*/ +if (nFileLen > 0) +{ +uno::Sequence aFontFile(nFileLen); +readBinaryData(aFontFile); // Read fontFile. + +uno::Sequence aArgs(1); +awt::FontDescriptor aFontDescriptor; +aArgs[0] <<= aFontFile; + +try +{ +uno::Reference xHolder( + m_parser.m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( +"com.sun.star.awt.FontIdentificator", aArgs, m_parser.m_xContext), +uno::UNO_QUERY); +if (xHolder.is()) +{ +uno::Any aFontReadResult(xHolder->getMaterial()); +aFontReadResult >>= aFontDescriptor; +if (!aFontDescriptor.Name.isEmpty()) +{ +aResult.familyName = aFontDescriptor.Name; +aResult.isBold =
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx |4 1 file changed, 4 insertions(+) New commits: commit c85557c924ee83f9a29c07520c83d308ff5a4c79 Author: Caolán McNamara AuthorDate: Sun Jul 18 14:35:58 2021 +0100 Commit: Caolán McNamara CommitDate: Sun Jul 18 16:47:29 2021 +0200 poppler 0.73 doesn't have GooString::append(const std::string&) don't know what version is appeared in Change-Id: Ia1fff05aa58990e631d63a2e694be47a4b74e24c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119126 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index bc313f76ecc4..9ffece584347 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -444,7 +444,11 @@ int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, GfxState* state ) if( familyName != "" ) { aNewFont.familyName.clear(); +#if POPPLER_CHECK_VERSION(0, 74, 0) // at least 0.73 doesn't have GooString::append(const std::string&) aNewFont.familyName.append( familyName ); +#else +aNewFont.familyName.append( familyName.c_str() ); +#endif } else { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sdext/source sd/qa sw/qa sw/source
sd/qa/unit/export-tests-ooxml3.cxx |2 +- sdext/source/pdfimport/inc/wrapper.hxx |2 +- sw/qa/extras/rtfexport/rtfexport.cxx|2 +- sw/qa/uitest/writer_tests7/tdf134452.py |2 +- sw/source/core/doc/DocumentContentOperationsManager.cxx |2 +- 5 files changed, 5 insertions(+), 5 deletions(-) New commits: commit 1ae182f2503199f86ed9ec5690ca41e4b7213a91 Author: Andrea Gelmini AuthorDate: Fri Jul 16 15:47:24 2021 +0200 Commit: Julien Nabet CommitDate: Fri Jul 16 19:11:58 2021 +0200 Fix typos Change-Id: Iae3eec214849676be51ded133c1ffd9cf2e56ef0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119074 Tested-by: Jenkins Reviewed-by: Julien Nabet diff --git a/sd/qa/unit/export-tests-ooxml3.cxx b/sd/qa/unit/export-tests-ooxml3.cxx index 597783d85a70..359b5215860b 100644 --- a/sd/qa/unit/export-tests-ooxml3.cxx +++ b/sd/qa/unit/export-tests-ooxml3.cxx @@ -1787,7 +1787,7 @@ void SdOOXMLExportTest3::testTdf143315() xmlDocUniquePtr pXml = parseExport(tmpfile, "ppt/slides/slide1.xml"); -// Without the fix in place, whis would have failed with +// Without the fix in place, this would have failed with // - Expected: // - Actual : 216000 // - In , XPath '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:pPr' unexpected 'marL' attribute diff --git a/sdext/source/pdfimport/inc/wrapper.hxx b/sdext/source/pdfimport/inc/wrapper.hxx index 12476a01aa1c..f8682299600c 100644 --- a/sdext/source/pdfimport/inc/wrapper.hxx +++ b/sdext/source/pdfimport/inc/wrapper.hxx @@ -65,7 +65,7 @@ namespace pdfi "Bold", "Italic", "Oblique", -"Bold", //BoldItalic, BoldObique +"Bold", //BoldItalic, BoldOblique "Light", "Reg", "VKana", diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index 326c63a3cbae..0676e524376b 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -1224,7 +1224,7 @@ DECLARE_RTFEXPORT_TEST(testPgndec, "pgndec.rtf") style::NumberingType::ARABIC, getProperty(xPageStyles->getByName(pageStyleName), "NumberingType")); -// tdf#82111 ensure a pargraph exists before a section break. +// tdf#82111 ensure a paragraph exists before a section break. // This was only two paragraphs, and both page number fields were in one para on page 2 ("11"). getParagraph(2, "1"); CPPUNIT_ASSERT_EQUAL(3, getParagraphs()); diff --git a/sw/qa/uitest/writer_tests7/tdf134452.py b/sw/qa/uitest/writer_tests7/tdf134452.py index ce13e8db2270..bffb6f3bba14 100644 --- a/sw/qa/uitest/writer_tests7/tdf134452.py +++ b/sw/qa/uitest/writer_tests7/tdf134452.py @@ -34,7 +34,7 @@ class tdf134452(UITestCase): self.assertEqual("true", get_state_as_dict(xpagestyle)["Selected"]) #applying table style on the table -#without the fix, break and pageDesc properties would be overriden and lost +#without the fix, break and pageDesc properties would be overridden and lost document = self.ui_test.get_component() tables = document.getTextTables() tables[0].setPropertyValue("TableTemplateName", "Box List Red") diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index ef0c4c1f3648..f7e88c891ee8 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -2208,7 +2208,7 @@ bool DocumentContentOperationsManager::MoveRange( SwPaM& rPaM, SwPosition& rPos, SwTextNode* pSrcNd = rPaM.GetPoint()->nNode.GetNode().GetTextNode(); bool bCorrSavePam = pSrcNd && pStt->nNode != pEnd->nNode; -// If one ore more TextNodes are moved, SwNodes::Move will do a SplitNode. +// If one or more TextNodes are moved, SwNodes::Move will do a SplitNode. // However, this does not update the cursor. So we create a TextNode to keep // updating the indices. After the Move the Node is optionally deleted. SwTextNode * pTNd = rPos.nNode.GetNode().GetTextNode(); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) New commits: commit 07087041610ca8351d764c838ae07fa58f3bdf9e Author: Kevin Suo AuthorDate: Thu Jul 15 12:56:43 2021 +0200 Commit: Noel Grandin CommitDate: Fri Jul 16 09:06:47 2021 +0200 restore compatibility with older popplers with poppler 20.09: /home/rene/LibreOffice/git/libreoffice-7-2/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx: In member function 'int pdfi::PDFOutDev::parseFont(long long int, GfxFont*, GfxState*) const': /home/rene/LibreOffice/git/libreoffice-7-2/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx:438:39: error: 'class GfxFont' has no member named 'getNameWithoutSubsetTag' https://www.google.com/search?q=getNameWithoutSubsetTag=getNameWithoutSubsetTag=chrome..69i57.784j0j7=chrome=UTF-8 suggests it was added in 20.12 Change-Id: I4eacd2d740cb689ff9b3c6cab59376e01b1ba162 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118977 Tested-by: René Engelhard Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index d8b73f621a09..bc313f76ecc4 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -432,10 +432,15 @@ int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, GfxState* state ) FontAttributes aNewFont; int nSize = 0; -#if POPPLER_CHECK_VERSION(0, 64, 0) -const -#endif +#if POPPLER_CHECK_VERSION(20, 12, 0) std::string familyName = gfxFont->getNameWithoutSubsetTag(); +#else +std::string familyName = gfxFont->getName()->toStr(); +if (familyName.length() > 7 && familyName.at(6) == '+') +{ +familyName = familyName.substr(7); +} +#endif if( familyName != "" ) { aNewFont.familyName.clear(); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/tree/drawtreevisiting.cxx |1 + 1 file changed, 1 insertion(+) New commits: commit b1ca6d3aae3b75ec3e5c1ef17d582bcec01fc7eb Author: Kevin Suo AuthorDate: Wed Jul 14 09:44:30 2021 +0800 Commit: Noel Grandin CommitDate: Wed Jul 14 18:53:44 2021 +0200 sdext.pdfimport: and don't have "text:style-name" attribute Per OpenDocument specs: * The element only has a "text:c" attribute. * The element only has a text:tab-ref attribute. seen in the SAL_WARN message: warn:xmloff:221658:221658:xmloff/source/text/txtparai.cxx:137: unknown attribute urn:oasis:names:tc:opendocument:xmlns:text:1.0 text:style-name value=text13 ... Change-Id: I02a29ac2c9f9db026caec19238cd97111ce587c9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118946 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx index 69f70001f6d6..d5ce02ad89bf 100644 --- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx +++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx @@ -126,6 +126,7 @@ void DrawXmlEmitter::visit( TextElement& elem, const std::list< std::unique_ptr< m_rEmitContext.rEmitter.beginTag( "text:span", aProps ); +aProps = {}; for(int i=0; i< elem.Text.getLength(); i++) { OUString strToken= str.copy(i,1) ; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/inc/wrapper.hxx |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) New commits: commit 6a1de4f74e2510029313771d2751b6cd59141acf Author: Kevin Suo AuthorDate: Tue Jul 13 15:13:45 2021 +0800 Commit: Noel Grandin CommitDate: Wed Jul 14 18:22:20 2021 +0200 tdf#78427 sdext.pdfimport: more bold/italic/Oblique fixes e.g. the PDF in tdf#107812. Also added notes to the fontAttributesSuffixes list. Change-Id: I4a4dcba2d9369c6b09168a18784d2f6e7d08793d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118832 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/inc/wrapper.hxx b/sdext/source/pdfimport/inc/wrapper.hxx index 918f976ee817..12476a01aa1c 100644 --- a/sdext/source/pdfimport/inc/wrapper.hxx +++ b/sdext/source/pdfimport/inc/wrapper.hxx @@ -54,21 +54,25 @@ namespace pdfi const OUString&rFilterOptions ); const OUString fontAttributesSuffixes[] = { +// Note: for performance consideration, each one listed here is evaluated once, +// and they are checked from the suffix, thus the order matters. +// e.g. for "TimesNewRomanPS-BoldItalic", to get "TimesNewRoman", you should +// first have "Italic", and then "Bold", then "-", and then "PS". "MT", "PS", "PSMT", "Regular", "Bold", "Italic", -"Bold", "Oblique", +"Bold", //BoldItalic, BoldObique "Light", "Reg", "VKana", "-", ",", ";", -"PS", +"PS", // e.g. TimesNewRomanPS-BoldMT }; } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/tree/drawtreevisiting.cxx | 15 ++- sdext/source/pdfimport/tree/pdfiprocessor.cxx | 15 ++- sdext/source/pdfimport/tree/writertreevisiting.cxx | 28 + 3 files changed, 41 insertions(+), 17 deletions(-) New commits: commit fe28633ee6edc5986220c934dfb04aa7b0d065ad Author: Kevin Suo AuthorDate: Wed Jun 30 18:17:36 2021 +0800 Commit: Noel Grandin CommitDate: Wed Jul 14 09:07:09 2021 +0200 tdf81484 Draw and Writer pdf import: SimSun bold font is shown as "outline" Case 1: As discussed in the bug report, SimSun does not have a "bold" font. In PDF it uses fill+stroke rendering mode (i.e., Text Render Mode is 2), see CoreTextStyle::CoreTextStyle, as a faux bold (fake bold) feature. For faux bold, the text render fill color is the same as the stroke color. Case 2: Also, it is noted that if you apply real "outline" characters in Writer and export to PDF, on Draw PDF import the text render mode is also 2, but the text render fill color is different than the stroke color. However, I would argue that for this case on PDF export Writer should set the render mode as 1, not 2, per PDF specs, which is another issue to be improved. The old code treated all these two cases as "outline". This patch: 1) treats render mode 2 as faux bold if the stroke color is the same as the fill color; and 2) still treat it as outline if the fill color and stroke color are different. This way, the real outline remains as outline characters while the faux bold (fake bold) becomes bold again on pdf import. This patch Also fixed some incorrect use of attributes per OpenDocument specification. This patch depends on change-ID I50a510ab9e5483f859ea2a767ea977ea3f065a2e which guesses the bold/italic if the font indentifaction had failed for whatever reason. Change-Id: Idabb22ea9b01ba53733c3acbd9de843790ebe8ca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118156 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx index ebce9efc896b..69f70001f6d6 100644 --- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx +++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx @@ -16,8 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - - +#include #include #include #include @@ -828,23 +827,28 @@ void DrawXmlFinalizer::visit( TextElement& elem, const std::list< std::unique_pt PropertyMap aFontProps; // family name +// TODO: tdf#143095: use system font name rather than PSName +SAL_INFO("sdext.pdfimport", "The font used in xml is: " << rFont.familyName); aFontProps[ "fo:font-family" ] = rFont.familyName; +aFontProps[ "style:font-family-asia" ] = rFont.familyName; aFontProps[ "style:font-family-complex" ] = rFont.familyName; // bold if( rFont.isBold ) { aFontProps[ "fo:font-weight" ] = "bold"; -aFontProps[ "fo:font-weight-asian" ] = "bold"; +aFontProps[ "style:font-weight-asian" ] = "bold"; aFontProps[ "style:font-weight-complex" ] = "bold"; } + // italic if( rFont.isItalic ) { aFontProps[ "fo:font-style" ] = "italic"; -aFontProps[ "fo:font-style-asian" ] = "italic"; +aFontProps[ "style:font-style-asian" ] = "italic"; aFontProps[ "style:font-style-complex" ] = "italic"; } + // underline if( rFont.isUnderline ) { @@ -852,11 +856,10 @@ void DrawXmlFinalizer::visit( TextElement& elem, const std::list< std::unique_pt aFontProps[ "style:text-underline-width" ] = "auto"; aFontProps[ "style:text-underline-color" ] = "font-color"; } + // outline if( rFont.isOutline ) -{ aFontProps[ "style:text-outline" ] = "true"; -} // size SetFontsizeProperties(aFontProps, rFont.size); diff --git a/sdext/source/pdfimport/tree/pdfiprocessor.cxx b/sdext/source/pdfimport/tree/pdfiprocessor.cxx index ed2eaf6510b9..d63ab04e97fd 100644 --- a/sdext/source/pdfimport/tree/pdfiprocessor.cxx +++ b/sdext/source/pdfimport/tree/pdfiprocessor.cxx @@ -147,7 +147,20 @@ void PDFIProcessor::setFont( const FontAttributes& i_rFont ) FontAttributes aChangedFont( i_rFont ); GraphicsContext& rGC=getCurrentContext(); // for text render modes, please see PDF reference manual -aChangedFont.isOutline = ( (rGC.TextRenderMode == 1) || (rGC. TextRenderMode == 2) ); +if (rGC.TextRenderMode == 1) +{ +aChangedFont.isOutline = true; +} +else if (rGC.TextRenderMode == 2) +{ +// tdf#81484: faux bold is represented as "stroke+fill" (while using the
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/inc/wrapper.hxx | 18 +++ sdext/source/pdfimport/wrapper/wrapper.cxx | 147 + 2 files changed, 46 insertions(+), 119 deletions(-) New commits: commit cffd97193f7468f770368559d5a5c58bd0bb2327 Author: Kevin Suo AuthorDate: Sun Jul 11 14:49:54 2021 +0800 Commit: Noel Grandin CommitDate: Mon Jul 12 20:21:49 2021 +0200 tdf#78427 sdext.pdfimport: refactor the conversion of font family names Simplify the code and hopefully improves performance. The previous code used a long for loop within which it used many duplicated parseFontRemoveSuffix. That for loop was simply intended to remove the font family name suffixes. However, the rResult.familyName is a OUString and this type already has the function of removing suffixes which is more efficient. Also, defined a list of suffixes to be removed in the header file. New suffixes can be easily added to this list. Change-Id: Idfa11cfe60e2e34a1f7456d29562a89eb3de7662 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118734 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/inc/wrapper.hxx b/sdext/source/pdfimport/inc/wrapper.hxx index 68e383de6a1a..918f976ee817 100644 --- a/sdext/source/pdfimport/inc/wrapper.hxx +++ b/sdext/source/pdfimport/inc/wrapper.hxx @@ -52,6 +52,24 @@ namespace pdfi const css::uno::Reference< css::uno::XComponentContext >& xContext, const OUString&rFilterOptions ); + +const OUString fontAttributesSuffixes[] = { +"MT", +"PS", +"PSMT", +"Regular", +"Bold", +"Italic", +"Bold", +"Oblique", +"Light", +"Reg", +"VKana", +"-", +",", +";", +"PS", +}; } #endif // INCLUDED_SDEXT_SOURCE_PDFIMPORT_INC_WRAPPER_HXX diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index ae4903526c65..e22fe0aeca72 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -165,20 +165,14 @@ public: }; class LineParser { -Parser & m_parser; -OString m_aLine; +Parser & m_parser; +OString m_aLine; -static sal_Int32 parseFontCheckForString(const sal_Unicode* pCopy, sal_Int32 nCopyLen, - const char* pAttrib, sal_Int32 nAttribLen, - FontAttributes& rResult, bool bItalic, bool bBold); -static sal_Int32 parseFontRemoveSuffix(const sal_Unicode* pCopy, sal_Int32 nCopyLen, - const char* pAttrib, sal_Int32 nAttribLen); -static void parseFontFamilyName( FontAttributes& aResult ); - -void readInt32( sal_Int32& o_Value ); -void readInt64( sal_Int64& o_Value ); -void readDouble( double& o_Value ); -void readBinaryData( uno::Sequence& rBuf ); +static void parseFontFamilyName( FontAttributes& aResult ); +voidreadInt32( sal_Int32& o_Value ); +voidreadInt64( sal_Int64& o_Value ); +voidreadDouble( double& o_Value ); +voidreadBinaryData( uno::Sequence& rBuf ); uno::Sequence readImageImpl(); @@ -477,119 +471,34 @@ rendering::ARGBColor LineParser::readColor() return aRes; } -sal_Int32 LineParser::parseFontCheckForString( -const sal_Unicode* pCopy, sal_Int32 nCopyLen, -const char* pAttrib, sal_Int32 nAttribLen, -FontAttributes& rResult, bool bItalic, bool bBold) -{ -if (nCopyLen < nAttribLen) -return 0; -for (sal_Int32 i = 0; i < nAttribLen; ++i) -{ -sal_uInt32 nCode = pAttrib[i]; -if (rtl::toAsciiLowerCase(pCopy[i]) != nCode -&& rtl::toAsciiUpperCase(pCopy[i]) != nCode) -return 0; -} -rResult.isItalic |= bItalic; -rResult.isBold |= bBold; -return nAttribLen; -} - -sal_Int32 LineParser::parseFontRemoveSuffix( -const sal_Unicode* pCopy, sal_Int32 nCopyLen, -const char* pAttrib, sal_Int32 nAttribLen) -{ -if (nCopyLen < nAttribLen) -return 0; -for (sal_Int32 i = 0; i < nAttribLen; ++i) -if ( pCopy[nCopyLen - nAttribLen + i] != pAttrib[i] ) -return 0; -return nAttribLen; -} +/* Parse and convert the font family name (passed from xpdfimport) to correct font names +e.g. TimesNewRomanPSMT-> TimesNewRoman + TimesNewRomanPS-BoldMT -> TimesNewRoman + TimesNewRomanPS-BoldItalicMT -> TimesNewRoman +During the conversion, also apply the font features (bold italic etc) to the result. +TODO: Further convert the font names to real font names in the system rather than the PS names. +e.g., TimesNewRoman -> Times New Roman +*/ void LineParser::parseFontFamilyName(
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/wrapper/wrapper.cxx| 52 -- sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx |9 +-- 2 files changed, 3 insertions(+), 58 deletions(-) New commits: commit da59686672fd2bc98f8cb28d5f04dc978b50ac13 Author: Kevin Suo AuthorDate: Sat Jul 10 11:47:39 2021 +0800 Commit: Noel Grandin CommitDate: Mon Jul 12 10:57:27 2021 +0200 tdf#78427 sdext.pdfimport: No need to read a font file for the purpose of... ...determining the bold/italic/underline etc. The purpose for reading a font file is that in case the font attributes determined by the xpdfimport process is not enough, then we use the lo core font classes which read in the font file and then determine whether it is bold, italic etc. However, while this works in some cases, it does not work in many cases when the font file was actually a subset and a toUnicode map is followed in the PDF, see tdf#78427. In addition, in case the information collected from the xpdfimport process is enough, there is no need to read the font file. This commit removes the read of font file part. Also, this commit uses gfxFont->getNameWithoutSubsetTag() to get the font name with the subset tags removed, thus simplified the code in wrapper.cxx while also improves performace as the remove of subset tags is only run when the font is a subset (the previous code did this for all the font names). Change-Id: I94c1ad8e743abfab81cf0a46da178d4d8b212427 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118733 Reviewed-by: Noel Grandin Tested-by: Jenkins diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index 2221f1ebe33f..ae4903526c65 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -514,12 +514,6 @@ void LineParser::parseFontFamilyName( FontAttributes& rResult ) const sal_Unicode* pCopy = rResult.familyName.getStr(); sal_Int32 nLen = rResult.familyName.getLength(); -// parse out truetype subsets (e.g. BA+Thorndale) -if( nLen > 8 && pCopy[6] == '+' ) -{ -pCopy += 7; -nLen -= 7; -} // TODO: Looks like this block needs to be refactored while( nLen ) @@ -641,52 +635,6 @@ void LineParser::readFont() // extract textual attributes (bold, italic in the name, etc.) parseFontFamilyName(aResult); -// need to read font file? -if( nFileLen ) -{ -uno::Sequence aFontFile(nFileLen); -readBinaryData( aFontFile ); - -awt::FontDescriptor aFD; -uno::Sequence< uno::Any > aArgs(1); -aArgs[0] <<= aFontFile; - -try -{ -uno::Reference< beans::XMaterialHolder > xMat( - m_parser.m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( -"com.sun.star.awt.FontIdentificator", aArgs, m_parser.m_xContext ), -uno::UNO_QUERY ); -if( xMat.is() ) -{ -uno::Any aRes( xMat->getMaterial() ); -if( aRes >>= aFD ) -{ -if (!aFD.Name.isEmpty()) -{ -aResult.familyName = aFD.Name; -parseFontFamilyName(aResult); -} -aResult.isBold = (aFD.Weight > 100.0); -aResult.isItalic= (aFD.Slant == awt::FontSlant_OBLIQUE || - aFD.Slant == awt::FontSlant_ITALIC ); -aResult.isUnderline = false; -aResult.size= 0; -} -} -} -catch( uno::Exception& ) -{ -} - -if( aResult.familyName.isEmpty() ) -{ -// last fallback -aResult.familyName = "Arial"; -aResult.isUnderline = false; -} - -} if (!m_parser.m_xDev) m_parser.m_xDev.disposeAndReset(VclPtr::Create()); diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index 16ad04bf660a..d8b73f621a09 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -435,11 +435,11 @@ int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, GfxState* state ) #if POPPLER_CHECK_VERSION(0, 64, 0) const #endif -GooString* pFamily = gfxFont->getName(); -if( pFamily ) +std::string familyName = gfxFont->getNameWithoutSubsetTag(); +if( familyName != "" ) { aNewFont.familyName.clear(); -aNewFont.familyName.append( gfxFont->getName() ); +aNewFont.familyName.append( familyName ); } else { @@ -786,9 +786,6 @@ void PDFOutDev::updateFont(GfxState *state) aEsc.data() ); } printf(
[Libreoffice-commits] core.git: sdext/source
sdext/source/presenter/PresenterGeometryHelper.cxx | 44 - sdext/source/presenter/PresenterSlideShowView.cxx | 27 ++-- sdext/source/presenter/PresenterWindowManager.cxx | 27 ++-- 3 files changed, 55 insertions(+), 43 deletions(-) New commits: commit da44de883f205736fffeacc148c32dcfd638ad66 Author: Julien Nabet AuthorDate: Wed Jun 9 19:02:52 2021 +0200 Commit: Julien Nabet CommitDate: Wed Jun 9 21:27:29 2021 +0200 Simplify Sequences initializations (sdext) Change-Id: Ide9a3ddd4f6915f45b02353293236988bff51eba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116935 Tested-by: Jenkins Reviewed-by: Julien Nabet diff --git a/sdext/source/presenter/PresenterGeometryHelper.cxx b/sdext/source/presenter/PresenterGeometryHelper.cxx index 3d59f259ea7b..67a81d63c766 100644 --- a/sdext/source/presenter/PresenterGeometryHelper.cxx +++ b/sdext/source/presenter/PresenterGeometryHelper.cxx @@ -21,6 +21,8 @@ #include #include +#include + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -183,12 +185,15 @@ Reference PresenterGeometryHelper::CreatePolygon( if ( ! rxDevice.is()) return nullptr; -Sequence > aPoints(1); -aPoints[0] = Sequence(4); -aPoints[0][0] = geometry::RealPoint2D(rBox.X, rBox.Y); -aPoints[0][1] = geometry::RealPoint2D(rBox.X, rBox.Y+rBox.Height); -aPoints[0][2] = geometry::RealPoint2D(rBox.X+rBox.Width, rBox.Y+rBox.Height); -aPoints[0][3] = geometry::RealPoint2D(rBox.X+rBox.Width, rBox.Y); +Sequence > aPoints +{ +{ +{ o3tl::narrowing(rBox.X), o3tl::narrowing(rBox.Y) }, +{ o3tl::narrowing(rBox.X), o3tl::narrowing(rBox.Y+rBox.Height) }, +{ o3tl::narrowing(rBox.X+rBox.Width), o3tl::narrowing(rBox.Y+rBox.Height) }, +{ o3tl::narrowing(rBox.X+rBox.Width), o3tl::narrowing(rBox.Y) } +} +}; Reference xPolygon ( rxDevice->createCompatibleLinePolyPolygon(aPoints)); if (xPolygon.is()) @@ -204,12 +209,15 @@ Reference PresenterGeometryHelper::CreatePolygon( if ( ! rxDevice.is()) return nullptr; -Sequence > aPoints(1); -aPoints[0] = Sequence(4); -aPoints[0][0] = geometry::RealPoint2D(rBox.X1, rBox.Y1); -aPoints[0][1] = geometry::RealPoint2D(rBox.X1, rBox.Y2); -aPoints[0][2] = geometry::RealPoint2D(rBox.X2, rBox.Y2); -aPoints[0][3] = geometry::RealPoint2D(rBox.X2, rBox.Y1); +Sequence > aPoints +{ +{ +{ rBox.X1, rBox.Y1 }, +{ rBox.X1, rBox.Y2 }, +{ rBox.X2, rBox.Y2 }, +{ rBox.X2, rBox.Y1 } +} +}; Reference xPolygon ( rxDevice->createCompatibleLinePolyPolygon(aPoints)); if (xPolygon.is()) @@ -230,11 +238,13 @@ Reference PresenterGeometryHelper::CreatePolygon( for (sal_Int32 nIndex=0; nIndex(4); -aPoints[nIndex][0] = geometry::RealPoint2D(rBox.X, rBox.Y); -aPoints[nIndex][1] = geometry::RealPoint2D(rBox.X, rBox.Y+rBox.Height); -aPoints[nIndex][2] = geometry::RealPoint2D(rBox.X+rBox.Width, rBox.Y+rBox.Height); -aPoints[nIndex][3] = geometry::RealPoint2D(rBox.X+rBox.Width, rBox.Y); +aPoints[nIndex] = Sequence +{ +{ o3tl::narrowing(rBox.X), o3tl::narrowing(rBox.Y) }, +{ o3tl::narrowing(rBox.X), o3tl::narrowing(rBox.Y+rBox.Height) }, +{ o3tl::narrowing(rBox.X+rBox.Width), o3tl::narrowing(rBox.Y+rBox.Height) }, +{ o3tl::narrowing(rBox.X+rBox.Width), o3tl::narrowing(rBox.Y) } +}; } Reference xPolygon ( diff --git a/sdext/source/presenter/PresenterSlideShowView.cxx b/sdext/source/presenter/PresenterSlideShowView.cxx index 7ad4bc207645..26239c0b2642 100644 --- a/sdext/source/presenter/PresenterSlideShowView.cxx +++ b/sdext/source/presenter/PresenterSlideShowView.cxx @@ -666,20 +666,21 @@ void PresenterSlideShowView::PaintOuterWindow (const awt::Rectangle& rRepaintBox Reference xBackgroundBitmap (mpBackground->GetNormalBitmap()); if (xBackgroundBitmap.is()) { -Sequence aTextures (1); const geometry::IntegerSize2D aBitmapSize(xBackgroundBitmap->getSize()); -aTextures[0] = rendering::Texture ( -geometry::AffineMatrix2D( -aBitmapSize.Width,0,0, -0,aBitmapSize.Height,0), -1, -0, -xBackgroundBitmap, -nullptr, -nullptr, -rendering::StrokeAttributes(), -rendering::TexturingMode::REPEAT, -rendering::TexturingMode::REPEAT); +Sequence aTextures +{ +{ +geometry::AffineMatrix2D( aBitmapSize.Width,0,0, 0,aBitmapSize.Height,0), +1, +0, +xBackgroundBitmap, +nullptr, +nullptr, +rendering::StrokeAttributes(), +
[Libreoffice-commits] core.git: sdext/source
sdext/source/minimizer/pppoptimizertoken.cxx |9 + sdext/source/pdfimport/misc/pwdinteract.cxx | 11 ++- 2 files changed, 11 insertions(+), 9 deletions(-) New commits: commit d220fc00c2c3d7a2a24fd762599d1bfcc27f34d5 Author: Arnaud Versini AuthorDate: Sun May 30 19:32:41 2021 +0200 Commit: Noel Grandin CommitDate: Mon May 31 15:21:39 2021 +0200 sdext : use std::mutex when possible Change-Id: Ia610c0c46e017452db71945f6f53fedbcb6d1198 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116415 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/minimizer/pppoptimizertoken.cxx b/sdext/source/minimizer/pppoptimizertoken.cxx index 9a5c2eac9a62..9130621ff762 100644 --- a/sdext/source/minimizer/pppoptimizertoken.cxx +++ b/sdext/source/minimizer/pppoptimizertoken.cxx @@ -19,16 +19,17 @@ #include "pppoptimizertoken.hxx" -#include + #include #include #include +#include typedef std::unordered_map< const char*, PPPOptimizerTokenEnum, rtl::CStringHash, rtl::CStringEqual> TypeNameHashMap; static TypeNameHashMap* pHashMap = nullptr; -static ::osl::Mutex& getHashMapMutex() +static std::mutex& getHashMapMutex() { -static osl::Mutex s_aHashMapProtection; +static std::mutex s_aHashMapProtection; return s_aHashMapProtection; } @@ -166,7 +167,7 @@ PPPOptimizerTokenEnum TKGet( const OUString& rToken ) { if ( !pHashMap ) { // init hash map -::osl::MutexGuard aGuard( getHashMapMutex() ); +std::lock_guard aGuard( getHashMapMutex() ); if ( !pHashMap ) { TypeNameHashMap* pH = new TypeNameHashMap; diff --git a/sdext/source/pdfimport/misc/pwdinteract.cxx b/sdext/source/pdfimport/misc/pwdinteract.cxx index 4179795cc073..9885a6606a54 100644 --- a/sdext/source/pdfimport/misc/pwdinteract.cxx +++ b/sdext/source/pdfimport/misc/pwdinteract.cxx @@ -20,6 +20,7 @@ #include #include +#include #include @@ -44,7 +45,7 @@ class PDFPasswordRequest: task::XInteractionRequest, task::XInteractionPassword > { private: -mutable osl::Mutexm_aMutex; +mutable std::mutexm_aMutex; uno::Any m_aRequest; OUString m_aPassword; bool m_bSelected; @@ -65,7 +66,7 @@ public: // XInteractionContinuation virtual void SAL_CALL select() override; -bool isSelected() const { osl::MutexGuard const guard( m_aMutex ); return m_bSelected; } +bool isSelected() const { std::scoped_lock const guard( m_aMutex ); return m_bSelected; } private: virtual ~PDFPasswordRequest() override {} @@ -98,21 +99,21 @@ uno::Sequence< uno::Reference< task::XInteractionContinuation > > PDFPasswordReq void PDFPasswordRequest::setPassword( const OUString& rPwd ) { -osl::MutexGuard const guard( m_aMutex ); +std::scoped_lock const guard( m_aMutex ); m_aPassword = rPwd; } OUString PDFPasswordRequest::getPassword() { -osl::MutexGuard const guard( m_aMutex ); +std::scoped_lock const guard( m_aMutex ); return m_aPassword; } void PDFPasswordRequest::select() { -osl::MutexGuard const guard( m_aMutex ); +std::scoped_lock const guard( m_aMutex ); m_bSelected = true; } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/wrapper/wrapper.cxx |5 - 1 file changed, 4 insertions(+), 1 deletion(-) New commits: commit 12362fc496102b344dedef0a6ba130ba80b94149 Author: Stephan Bergmann AuthorDate: Fri May 21 13:38:32 2021 +0200 Commit: Stephan Bergmann CommitDate: Fri May 21 14:50:14 2021 +0200 LineParser::readNextToken gets called with m_nCharIndex==npos after all eca89ece45ede76605a6102c94b3b67e1f8ff5aa "Replace rtl_string_getTokenView with o3tl::getToken" had erroneously assumed (from a succeeding `make check`) that the only problematic call to o3tl::getToken with position==npos would be the one in LineParser::readPath (and which had been addressed in that commit). But e.g. loading ooo29794-4.pdf from the crash test corpus would also run into that situation via LineParser::readNextToken, > warn:legacy.osl:3090875:3090875:sdext/source/pdfimport/wrapper/wrapper.cxx:259: insufficient input > soffice.bin: include/o3tl/string_view.hxx:34: std::string_view o3tl::getToken(std::string_view, char, std::size_t &): Assertion `position <= sv.size()' failed. > #3 0x77a67a16 in __GI___assert_fail (assertion=0x7fffb39ea58c "position <= sv.size()", file=0x7fffb39f2a7f "include/o3tl/string_view.hxx", line=34, function=0x7fffb39ef3a9 "std::string_view o3tl::getToken(std::string_view, char, std::size_t &)") > #4 0x7fffb3b60131 in o3tl::getToken(std::basic_string_view >, char, unsigned long&) (sv="eoClipPath", delimiter=32 ' ', position=@0x7fff29e0: 18446744073709551615) at include/o3tl/string_view.hxx:34 > #5 0x7fffb3b5aa9f in pdfi::(anonymous namespace)::LineParser::readNextToken() (this=0x7fff29d0) at sdext/source/pdfimport/wrapper/wrapper.cxx:260 > #6 0x7fffb3b5b2fa in pdfi::(anonymous namespace)::LineParser::readPath() (this=0x7fff29d0) at sdext/source/pdfimport/wrapper/wrapper.cxx:323 > #7 0x7fffb3b59eb3 in pdfi::(anonymous namespace)::Parser::parseLine(rtl::OString const&) (this=0x7fff2d28, rLine="eoClipPath") at sdext/source/pdfimport/wrapper/wrapper.cxx:859 [...] so better guard there. Change-Id: Ibfd53fd9d3be0a3548d60cb26d59bb5966c5bc2c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115916 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index 78fb9cd0b331..2221f1ebe33f 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -256,7 +256,10 @@ OString lcl_unescapeLineFeeds(std::string_view i_rStr) std::string_view LineParser::readNextToken() { -OSL_PRECOND(m_nCharIndex!=std::string_view::npos,"insufficient input"); +if (m_nCharIndex == std::string_view::npos) { +SAL_WARN("sdext.pdfimport", "insufficient input"); +return {}; +} return o3tl::getToken(m_aLine,' ',m_nCharIndex); } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/wrapper/wrapper.cxx | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) New commits: commit 66b4852551aa1838009fac72dc6453bf94de2dd8 Author: Stephan Bergmann AuthorDate: Tue May 18 10:23:06 2021 +0200 Commit: Stephan Bergmann CommitDate: Tue May 18 13:38:21 2021 +0200 Use some more std::string_view Change-Id: I7d4039e87fda447b1d2087b2430a3544e9a1eb14 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115732 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index f2439a5bb83c..9bd803d0348f 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -210,10 +210,10 @@ public: characters are encoded as pairs of characters: '\\' 'n', resp. '\\' 'r'. This function converts them back to '\n', resp. '\r'. */ -OString lcl_unescapeLineFeeds(const OString& i_rStr) +OString lcl_unescapeLineFeeds(std::string_view i_rStr) { -const size_t nOrigLen(sal::static_int_cast(i_rStr.getLength())); -const char* const pOrig(i_rStr.getStr()); +const size_t nOrigLen(i_rStr.size()); +const char* const pOrig(i_rStr.data()); std::unique_ptr pBuffer(new char[nOrigLen + 1]); const char* pRead(pOrig); @@ -316,7 +316,7 @@ void LineParser::readBinaryData( uno::Sequence& rBuf ) uno::Reference LineParser::readPath() { -const OString aSubPathMarker( "subpath" ); +static const std::string_view aSubPathMarker( "subpath" ); if( readNextToken() != aSubPathMarker ) OSL_PRECOND(false, "broken path"); @@ -332,7 +332,7 @@ uno::Reference LineParser::readPath() sal_Int32 nContiguousControlPoints(0); sal_Int32 nDummy=m_nCharIndex; -OString aCurrToken( m_aLine.getToken(0,' ',nDummy) ); +std::string_view aCurrToken( m_aLine.getTokenView(0,' ',nDummy) ); while( m_nCharIndex != -1 && aCurrToken != aSubPathMarker ) { @@ -366,7 +366,7 @@ uno::Reference LineParser::readPath() // one token look-ahead (new subpath or more points? nDummy=m_nCharIndex; -aCurrToken = m_aLine.getToken(0,' ',nDummy); +aCurrToken = m_aLine.getTokenView(0,' ',nDummy); } aResult.append( aSubPath ); @@ -397,7 +397,7 @@ void LineParser::readChar() OString aChars; if (m_nCharIndex != -1) -aChars = lcl_unescapeLineFeeds( m_aLine.copy( m_nCharIndex ) ); +aChars = lcl_unescapeLineFeeds( m_aLine.subView( m_nCharIndex ) ); // chars gobble up rest of line m_nCharIndex = -1; @@ -610,7 +610,7 @@ void LineParser::readFont() readInt32(nFileLen); nSize = nSize < 0.0 ? -nSize : nSize; -aFontName = lcl_unescapeLineFeeds( m_aLine.copy( m_nCharIndex ) ); +aFontName = lcl_unescapeLineFeeds( m_aLine.subView( m_nCharIndex ) ); // name gobbles up rest of line m_nCharIndex = -1; @@ -790,7 +790,7 @@ void LineParser::readLink() m_parser.m_pSink->hyperLink( aBounds, OStringToOUString( lcl_unescapeLineFeeds( -m_aLine.copy(m_nCharIndex) ), +m_aLine.subView(m_nCharIndex) ), RTL_TEXTENCODING_UTF8 ) ); // name gobbles up rest of line m_nCharIndex = -1; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/wrapper/wrapper.cxx | 226 +++-- 1 file changed, 117 insertions(+), 109 deletions(-) New commits: commit f80c4bfab668f9f72495526fa438f33b11ccaa7a Author: Stephan Bergmann AuthorDate: Tue May 18 09:11:18 2021 +0200 Commit: Stephan Bergmann CommitDate: Tue May 18 12:30:16 2021 +0200 Move per-Parser::parseLine state into its own LineParser class (together with the member functions that operate on that state). That reveals that Parser::m_nNextToken was always 0 when used, so can be removed. Change-Id: Iaf27d0503efcc8c7628f2f5f99f6e380c91a3893 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115725 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index 953d437ab5e2..5672249c3e15 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -138,6 +138,8 @@ enum parseKey { class Parser { +friend class LineParser; + typedef std::unordered_map< sal_Int64, FontAttributes > FontMapType; @@ -145,20 +147,48 @@ class Parser const uno::Reference m_xContext; const ContentSinkSharedPtr m_pSink; const oslFileHandle m_pErr; -OString m_aLine; FontMapType m_aFontMap; -sal_Int32m_nNextToken; -sal_Int32m_nCharIndex; +public: +Parser( const ContentSinkSharedPtr& rSink, +oslFileHandle pErr, +const uno::Reference& xContext ) : +m_xContext(xContext), +m_pSink(rSink), +m_pErr(pErr), +m_aFontMap(101) +{} + +void parseLine( const OString& rLine ); +}; + +class LineParser { +Parser & m_parser; +OString m_aLine; + +static sal_Int32 parseFontCheckForString(const sal_Unicode* pCopy, sal_Int32 nCopyLen, + const char* pAttrib, sal_Int32 nAttribLen, + FontAttributes& rResult, bool bItalic, bool bBold); +static sal_Int32 parseFontRemoveSuffix(const sal_Unicode* pCopy, sal_Int32 nCopyLen, + const char* pAttrib, sal_Int32 nAttribLen); +static void parseFontFamilyName( FontAttributes& aResult ); -std::string_view readNextToken(); void readInt32( sal_Int32& o_Value ); -sal_Int32 readInt32(); void readInt64( sal_Int64& o_Value ); void readDouble( double& o_Value ); -double readDouble(); void readBinaryData( uno::Sequence& rBuf ); +uno::Sequence readImageImpl(); + +public: +sal_Int32m_nCharIndex = 0; + +LineParser(Parser & parser, OString const & line): m_parser(parser), m_aLine(line) {} + +std::string_view readNextToken(); +sal_Int32 readInt32(); +double readDouble(); + uno::Reference readPath(); void readChar(); @@ -167,35 +197,13 @@ class Parser void readLineJoin(); void readTransformation(); rendering::ARGBColor readColor(); -static void parseFontFamilyName( FontAttributes& aResult ); void readFont(); -uno::Sequence readImageImpl(); void readImage(); void readMask(); void readLink(); void readMaskedImage(); void readSoftMaskedImage(); -static sal_Int32 parseFontCheckForString(const sal_Unicode* pCopy, sal_Int32 nCopyLen, - const char* pAttrib, sal_Int32 nAttribLen, - FontAttributes& rResult, bool bItalic, bool bBold); -static sal_Int32 parseFontRemoveSuffix(const sal_Unicode* pCopy, sal_Int32 nCopyLen, - const char* pAttrib, sal_Int32 nAttribLen); - -public: -Parser( const ContentSinkSharedPtr& rSink, -oslFileHandle pErr, -const uno::Reference& xContext ) : -m_xContext(xContext), -m_pSink(rSink), -m_pErr(pErr), -m_aLine(), -m_aFontMap(101), -m_nNextToken(-1), -m_nCharIndex(-1) -{} - -void parseLine( const OString& rLine ); }; /** Unescapes line-ending characters in input string. These @@ -244,45 +252,45 @@ OString lcl_unescapeLineFeeds(const OString& i_rStr) return aResult; } -std::string_view Parser::readNextToken() +std::string_view LineParser::readNextToken() { OSL_PRECOND(m_nCharIndex!=-1,"insufficient input"); -
[Libreoffice-commits] core.git: sdext/source
sdext/source/presenter/PresenterTimer.cxx | 29 +++-- 1 file changed, 15 insertions(+), 14 deletions(-) New commits: commit b30170661fb3a87d6b0491d748b8eb0d8f3dc99e Author: Arnaud Versini AuthorDate: Mon Apr 19 10:50:06 2021 +0200 Commit: Arnaud Versini CommitDate: Fri May 7 15:52:16 2021 +0200 presenter : use std::mutex Change-Id: I53e081fd6c52fc040b29fad18dc3a758310f943a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114259 Tested-by: Jenkins Reviewed-by: Arnaud Versini diff --git a/sdext/source/presenter/PresenterTimer.cxx b/sdext/source/presenter/PresenterTimer.cxx index 196feeba62ef..f46fcd288ee0 100644 --- a/sdext/source/presenter/PresenterTimer.cxx +++ b/sdext/source/presenter/PresenterTimer.cxx @@ -28,6 +28,7 @@ #include #include +#include #include using namespace ::com::sun::star; @@ -99,14 +100,14 @@ public: private: static std::shared_ptr mpInstance; -static ::osl::Mutex maInstanceMutex; +static std::mutex maInstanceMutex; std::shared_ptr mpLateDestroy; // for clean exit static sal_Int32 mnTaskId; -::osl::Mutex maTaskContainerMutex; +std::mutex maTaskContainerMutex; typedef ::std::set TaskContainer; TaskContainer maScheduledTasks; -::osl::Mutex maCurrentTaskMutex; +std::mutex maCurrentTaskMutex; SharedTimerTask mpCurrentTask; ::osl::Condition m_Shutdown; @@ -177,13 +178,13 @@ void PresenterTimer::CancelTask (const sal_Int32 nTaskId) //= TimerScheduler std::shared_ptr TimerScheduler::mpInstance; -::osl::Mutex TimerScheduler::maInstanceMutex; +std::mutex TimerScheduler::maInstanceMutex; sal_Int32 TimerScheduler::mnTaskId = PresenterTimer::NotAValidTaskId; std::shared_ptr TimerScheduler::Instance( uno::Reference const& xContext) { -::osl::MutexGuard aGuard (maInstanceMutex); +std::lock_guard aGuard (maInstanceMutex); if (mpInstance == nullptr) { if (!xContext.is()) @@ -225,7 +226,7 @@ void TimerScheduler::ScheduleTask (const SharedTimerTask& rpTask) return; { -osl::MutexGuard aTaskGuard (maTaskContainerMutex); +std::lock_guard aTaskGuard (maTaskContainerMutex); maScheduledTasks.insert(rpTask); } } @@ -236,7 +237,7 @@ void TimerScheduler::CancelTask (const sal_Int32 nTaskId) // task ids. Therefore we have to do a linear search for the task to // cancel. { -::osl::MutexGuard aGuard (maTaskContainerMutex); +std::lock_guard aGuard (maTaskContainerMutex); auto iTask = std::find_if(maScheduledTasks.begin(), maScheduledTasks.end(), [nTaskId](const SharedTimerTask& rxTask) { return rxTask->mnTaskId == nTaskId; }); if (iTask != maScheduledTasks.end()) @@ -247,7 +248,7 @@ void TimerScheduler::CancelTask (const sal_Int32 nTaskId) // processed. Mark it with a flag that a) prevents a repeating task // from being scheduled again and b) tries to prevent its execution. { -::osl::MutexGuard aGuard (maCurrentTaskMutex); +std::lock_guard aGuard (maCurrentTaskMutex); if (mpCurrentTask && mpCurrentTask->mnTaskId == nTaskId) mpCurrentTask->mbIsCanceled = true; @@ -265,12 +266,12 @@ void TimerScheduler::NotifyTermination() } { -::osl::MutexGuard aGuard(pInstance->maTaskContainerMutex); +std::lock_guard aGuard(pInstance->maTaskContainerMutex); pInstance->maScheduledTasks.clear(); } { -::osl::MutexGuard aGuard(pInstance->maCurrentTaskMutex); +std::lock_guard aGuard(pInstance->maCurrentTaskMutex); if (pInstance->mpCurrentTask) { pInstance->mpCurrentTask->mbIsCanceled = true; @@ -302,7 +303,7 @@ void SAL_CALL TimerScheduler::run() SharedTimerTask pTask; sal_Int64 nDifference = 0; { -::osl::MutexGuard aGuard (maTaskContainerMutex); +std::lock_guard aGuard (maTaskContainerMutex); // There are no more scheduled task. Leave this loop, function and // live of the TimerScheduler. @@ -321,7 +322,7 @@ void SAL_CALL TimerScheduler::run() // Acquire a reference to the current task. { -::osl::MutexGuard aGuard (maCurrentTaskMutex); +std::lock_guard aGuard (maCurrentTaskMutex); mpCurrentTask = pTask; } @@ -355,13 +356,13 @@ void SAL_CALL TimerScheduler::run() // Release reference to the current task. { -::osl::MutexGuard aGuard (maCurrentTaskMutex); +std::lock_guard aGuard (maCurrentTaskMutex); mpCurrentTask.reset(); } } // While holding maInstanceMutex -osl::Guard< osl::Mutex > aInstance( maInstanceMutex ); +std::lock_guard aInstance( maInstanceMutex ); mpLateDestroy = mpInstance;
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/pdfparse/pdfentries.cxx |1 + sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx |1 + 2 files changed, 2 insertions(+) New commits: commit 23316f2ef210960f22cba225be3d74e29b3182f4 Author: Caolán McNamara AuthorDate: Sun Mar 21 15:07:22 2021 + Commit: Caolán McNamara CommitDate: Sun Mar 21 20:48:56 2021 +0100 cid#1474243 Uninitialized scalar variable and cid#1473901 Uninitialized scalar variable Change-Id: I6a1d0784865c1a77eacbe25497b97ea63cf3705c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112849 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/sdext/source/pdfimport/pdfparse/pdfentries.cxx b/sdext/source/pdfimport/pdfparse/pdfentries.cxx index 0789268372e4..1e4c861df8dc 100644 --- a/sdext/source/pdfimport/pdfparse/pdfentries.cxx +++ b/sdext/source/pdfimport/pdfparse/pdfentries.cxx @@ -727,6 +727,7 @@ static void unzipToBuffer( char* pBegin, unsigned int nLen, z_stream aZStr; aZStr.next_in = reinterpret_cast(pBegin); aZStr.avail_in = nLen; +aZStr.total_out = aZStr.total_in = 0; aZStr.zalloc= nullptr; aZStr.zfree = nullptr; aZStr.opaque= nullptr; diff --git a/sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx b/sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx index 39a1df6f4a76..a6390f0157e9 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx @@ -82,6 +82,7 @@ sal_uInt32 PngHelper::deflateBuffer( const Output_t* i_pBuf, size_t i_nLen, Outp aStream.zalloc = Z_NULL; aStream.zfree = Z_NULL; aStream.opaque = Z_NULL; +aStream.total_out = aStream.total_in = 0; if (Z_OK != deflateInit(, Z_BEST_COMPRESSION)) return 0; aStream.avail_in = uInt(i_nLen); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) New commits: commit 55a96efaacd2e932c7616f6a6072f794266f5948 Author: Caolán McNamara AuthorDate: Fri Mar 19 15:54:31 2021 + Commit: Caolán McNamara CommitDate: Sat Mar 20 13:45:01 2021 +0100 cid#1474176 Unchecked return value from library Change-Id: Iaba514e372ff9892bb2901b967cfd4a5a71e6fbf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112779 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara diff --git a/sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx b/sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx index 5131838a996b..39a1df6f4a76 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx @@ -82,7 +82,8 @@ sal_uInt32 PngHelper::deflateBuffer( const Output_t* i_pBuf, size_t i_nLen, Outp aStream.zalloc = Z_NULL; aStream.zfree = Z_NULL; aStream.opaque = Z_NULL; -deflateInit( , Z_BEST_COMPRESSION ); +if (Z_OK != deflateInit(, Z_BEST_COMPRESSION)) +return 0; aStream.avail_in = uInt(i_nLen); aStream.next_in = const_cast(i_pBuf); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sdext/source sd/source
sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx |2 sd/source/ui/accessibility/AccessibleSlideSorterView.cxx|2 sd/source/ui/framework/configuration/Configuration.cxx |4 - sd/source/ui/slidesorter/controller/SlsClipboard.cxx|8 +-- sd/source/ui/slidesorter/controller/SlsTransferableData.cxx |4 - sd/source/ui/slidesorter/inc/controller/SlsTransferableData.hxx |2 sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx |6 -- sd/source/ui/unoidl/unopage.cxx | 16 +++--- sd/source/ui/unoidl/unosrch.cxx |2 sd/source/ui/view/drviews5.cxx |6 -- sd/source/ui/view/outlnvsh.cxx |6 -- sd/source/ui/view/sdview2.cxx | 23 -- sdext/source/pdfimport/pdfiadaptor.cxx | 13 +++-- 13 files changed, 41 insertions(+), 53 deletions(-) New commits: commit 8f231fc5df201c45d16bce0b4b17f727842b2121 Author: Noel AuthorDate: Sun Feb 21 12:32:12 2021 +0200 Commit: Noel Grandin CommitDate: Sun Feb 21 16:13:06 2021 +0100 loplugin:refcounting in sd Change-Id: Ic95aa7a3c1fdab1baef744ec85ffc9c98dee5f1e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111272 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx b/sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx index a8c81225130b..fde0cd953677 100644 --- a/sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx +++ b/sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx @@ -188,7 +188,7 @@ Reference SAL_CALL { ThrowIfDisposed(); const SolarMutexGuard aSolarGuard; -::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper(); +rtl::Reference<::utl::AccessibleStateSetHelper> pStateSet = new ::utl::AccessibleStateSetHelper(); if (mxParent.is()) { diff --git a/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx b/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx index ee663f2fbb1a..3ce13b899ef9 100644 --- a/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx +++ b/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx @@ -285,7 +285,7 @@ Reference SAL_CALL { ThrowIfDisposed(); const SolarMutexGuard aSolarGuard; -::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper(); +rtl::Reference<::utl::AccessibleStateSetHelper> pStateSet = new ::utl::AccessibleStateSetHelper(); pStateSet->AddState(AccessibleStateType::FOCUSABLE); pStateSet->AddState(AccessibleStateType::SELECTABLE); diff --git a/sd/source/ui/framework/configuration/Configuration.cxx b/sd/source/ui/framework/configuration/Configuration.cxx index 53bbaa339316..f155e0992e68 100644 --- a/sd/source/ui/framework/configuration/Configuration.cxx +++ b/sd/source/ui/framework/configuration/Configuration.cxx @@ -182,12 +182,10 @@ Reference SAL_CALL Configuration::createClone() ::osl::MutexGuard aGuard (maMutex); ThrowIfDisposed(); -Configuration* pConfiguration = new Configuration( +return new Configuration( mxBroadcaster, mbBroadcastRequestEvents, *mpResourceContainer); - -return Reference(pConfiguration); } //- XNamed diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx index 25e2aaea7b56..c7f333a5f0b9 100644 --- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx +++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx @@ -429,17 +429,17 @@ void Clipboard::CreateSlideTransferable ( return; mrSlideSorter.GetView().BrkAction(); -SdTransferable* pTransferable = TransferableData::CreateTransferable ( +rtl::Reference pTransferable = TransferableData::CreateTransferable ( pDocument, dynamic_cast(mrSlideSorter.GetViewShell()), aRepresentatives); if (bDrag) -SD_MOD()->pTransferDrag = pTransferable; +SD_MOD()->pTransferDrag = pTransferable.get(); else -SD_MOD()->pTransferClip = pTransferable; +SD_MOD()->pTransferClip = pTransferable.get(); -pDocument->CreatingDataObj (pTransferable); +pDocument->CreatingDataObj (pTransferable.get()); pTransferable->SetWorkDocument(pDocument->AllocSdDrawDocument()); std::unique_ptr pObjDesc(new TransferableObjectDescriptor); pTransferable->GetWorkDocument()->GetDocSh() diff --git a/sd/source/ui/slidesorter/controller/SlsTransferableData.cxx b/sd/source/ui/slidesorter/controller/SlsTransferableData.cxx index b340642553cc..2aac76fe0600 100644 --- a/sd/source/ui/slidesorter/controller/SlsTransferableData.cxx +++
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/misc/pwdinteract.cxx |2 +- sdext/source/presenter/PresenterAccessibility.cxx |8 sdext/source/presenter/PresenterProtocolHandler.cxx |2 +- sdext/source/presenter/PresenterToolBar.cxx |6 +++--- sdext/source/presenter/PresenterViewFactory.cxx |2 +- 5 files changed, 10 insertions(+), 10 deletions(-) New commits: commit 6cb2365511e23abd22f76cda76981222b81efdc4 Author: Noel AuthorDate: Wed Feb 17 18:23:31 2021 +0200 Commit: Noel Grandin CommitDate: Thu Feb 18 09:13:48 2021 +0100 loplugin:referencecasting in sdext Change-Id: I24514eefb96d04576eed45608c259b2f8dbeda7b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111078 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/pdfimport/misc/pwdinteract.cxx b/sdext/source/pdfimport/misc/pwdinteract.cxx index 4eb7e7d96281..4179795cc073 100644 --- a/sdext/source/pdfimport/misc/pwdinteract.cxx +++ b/sdext/source/pdfimport/misc/pwdinteract.cxx @@ -161,7 +161,7 @@ bool getPassword( const uno::Reference< task::XInteractionHandler >& xHandler, new PDFPasswordRequest( bFirstTry, rDocName ) ); try { -xHandler->handle( xReq.get() ); +xHandler->handle( xReq ); } catch( uno::Exception& ) { diff --git a/sdext/source/presenter/PresenterAccessibility.cxx b/sdext/source/presenter/PresenterAccessibility.cxx index 936c75df35f7..768f4717a48d 100644 --- a/sdext/source/presenter/PresenterAccessibility.cxx +++ b/sdext/source/presenter/PresenterAccessibility.cxx @@ -617,7 +617,7 @@ void PresenterAccessible::UpdateAccessibilityHierarchy ( mxNotesContentWindow, mxNotesBorderWindow, rpNotesTextView); -mpAccessibleConsole->AddChild(mpAccessibleNotes.get()); +mpAccessibleConsole->AddChild(mpAccessibleNotes); } } @@ -809,7 +809,7 @@ Reference SAL_CALL if (nIndex<0 || nIndex>=sal_Int32(maChildren.size())) throw lang::IndexOutOfBoundsException("invalid child index", static_cast(this)); -return Reference(maChildren[nIndex].get()); +return maChildren[nIndex]; } Reference SAL_CALL @@ -1367,7 +1367,7 @@ Reference SAL_CALL } } -return Reference(pSet.get()); +return pSet; } //- XAccessibleText --- @@ -1684,7 +1684,7 @@ rtl::Reference AccessibleNotes::Create ( pObject->UpdateStateSet(); pObject->SetWindow(rxContentWindow, rxBorderWindow); -return rtl::Reference(pObject.get()); +return pObject; } void AccessibleNotes::SetTextView ( diff --git a/sdext/source/presenter/PresenterProtocolHandler.cxx b/sdext/source/presenter/PresenterProtocolHandler.cxx index ff2cf4f251c5..0ee967ffe063 100644 --- a/sdext/source/presenter/PresenterProtocolHandler.cxx +++ b/sdext/source/presenter/PresenterProtocolHandler.cxx @@ -340,7 +340,7 @@ Reference PresenterProtocolHandler::Dispatch::Create ( { ::rtl::Reference pDispatch (new Dispatch (rsURLPath, rpPresenterController)); if (pDispatch->mpCommand != nullptr) -return Reference(pDispatch.get()); +return pDispatch; else return nullptr; } diff --git a/sdext/source/presenter/PresenterToolBar.cxx b/sdext/source/presenter/PresenterToolBar.cxx index db679d94d4ee..1c70661879df 100644 --- a/sdext/source/presenter/PresenterToolBar.cxx +++ b/sdext/source/presenter/PresenterToolBar.cxx @@ -1403,7 +1403,7 @@ namespace { { ::rtl::Reference pElement (new Button(rpToolBar)); pElement->Initialize(); -return ::rtl::Reference(pElement.get()); +return pElement; } Button::Button ( @@ -1765,7 +1765,7 @@ void TimeLabel::ConnectToTimer() { ::rtl::Reference pElement(new CurrentTimeLabel(rpToolBar)); pElement->ConnectToTimer(); -return ::rtl::Reference(pElement.get()); +return pElement; } CurrentTimeLabel::~CurrentTimeLabel() @@ -1802,7 +1802,7 @@ void CurrentTimeLabel::SetModes ( { ::rtl::Reference pElement(new PresentationTimeLabel(rpToolBar)); pElement->ConnectToTimer(); -return ::rtl::Reference(pElement.get()); +return pElement; } PresentationTimeLabel::~PresentationTimeLabel() diff --git a/sdext/source/presenter/PresenterViewFactory.cxx b/sdext/source/presenter/PresenterViewFactory.cxx index 6a59a32935d7..01b40d6e2ab8 100644 --- a/sdext/source/presenter/PresenterViewFactory.cxx +++ b/sdext/source/presenter/PresenterViewFactory.cxx @@ -355,7 +355,7 @@ Reference PresenterViewFactory::CreateSlideShowView( Reference(mxControllerWeak), mpPresenterController)); pShowView->LateInit(); -xView.set(pShowView.get()); +xView = pShowView; } catch (RuntimeException&) { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org
[Libreoffice-commits] core.git: sdext/source
sdext/source/presenter/PresenterSlideSorter.cxx |4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) New commits: commit 4e55bf7553fd90639769184e7027f275d31ca0b1 Author: Dr. David Alan Gilbert AuthorDate: Sun Jan 24 02:57:52 2021 + Commit: Samuel Mehrbrodt CommitDate: Mon Jan 25 07:54:37 2021 +0100 PresenterSlideSorter::mouseMoved: Merge identical if cppchecker spotted a pair of neighbouring if's with identical conditions; merge them. Change-Id: I29e13eb5eeca157d06f98c94587167c1a2ddec12 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109850 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt diff --git a/sdext/source/presenter/PresenterSlideSorter.cxx b/sdext/source/presenter/PresenterSlideSorter.cxx index e87cb442df25..1f8adc555693 100644 --- a/sdext/source/presenter/PresenterSlideSorter.cxx +++ b/sdext/source/presenter/PresenterSlideSorter.cxx @@ -541,11 +541,9 @@ void SAL_CALL PresenterSlideSorter::mouseMoved (const css::awt::MouseEvent& rEve const geometry::RealPoint2D aPosition(rTemp.X, rEvent.Y); sal_Int32 nSlideIndex (mpLayout->GetSlideIndexForPosition(aPosition)); -if (nSlideIndex < 0) -mnSlideIndexMousePressed = -1; - if (nSlideIndex < 0) { +mnSlideIndexMousePressed = -1; mpMouseOverManager->SetSlide(nSlideIndex, awt::Rectangle(0,0,0,0)); } else ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/pdfparse/pdfparse.cxx |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) New commits: commit 58a61c0b85d8e1f08922a3ccedfa6101f4bf587a Author: Stephan Bergmann AuthorDate: Wed Jan 13 14:32:24 2021 +0100 Commit: Stephan Bergmann CommitDate: Wed Jan 13 17:53:38 2021 +0100 Silence Boost bind deprecation warning > In file included from sdext/source/pdfimport/pdfparse/pdfparse.cxx:35: > In file included from external/boost/include/boost/bind.hpp:30: > workdir/UnpackedTarball/boost/boost/bind.hpp:36:1: warning: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior. [-W#pragma-messages] > BOOST_PRAGMA_MESSAGE( > ^ since e0f1b5bd94550835c639efda4e4c9a801c78dbe9 "Upgrade external/boost to latest Boost 1.75.0". boost/bind/bind.hpp and boost::placeholders appear to date back to before our Boost 1.66 baseline. Change-Id: I766be46fca02693fe0114c7c5855e6d94f7860a4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109228 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/sdext/source/pdfimport/pdfparse/pdfparse.cxx b/sdext/source/pdfimport/pdfparse/pdfparse.cxx index e61d900885ea..ef0bfaea65f4 100644 --- a/sdext/source/pdfimport/pdfparse/pdfparse.cxx +++ b/sdext/source/pdfimport/pdfparse/pdfparse.cxx @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include @@ -143,6 +143,8 @@ public: { explicit definition( const PDFGrammar& rSelf ) { +using namespace boost::placeholders; + PDFGrammar* pSelf = const_cast< PDFGrammar* >( ); // workaround workshop compiler: comment_p doesn't work ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sdext/source solenv/clang-format
sdext/source/minimizer/pppoptimizer.cxx|9 - sdext/source/minimizer/pppoptimizer.hxx|3 +-- sdext/source/minimizer/pppoptimizertoken.hxx |4 ++-- sdext/source/presenter/PresenterHelper.hxx | 22 +++--- sdext/source/presenter/PresenterPane.hxx | 24 +++- sdext/source/presenter/PresenterSprite.hxx | 12 +--- sdext/source/presenter/PresenterSpritePane.hxx | 21 ++--- sdext/source/presenter/PresenterUIPainter.hxx | 15 ++- solenv/clang-format/excludelist|8 9 files changed, 50 insertions(+), 68 deletions(-) New commits: commit a9bce41c64bda648be2609a0dc4aea728fa8ec77 Author: Philipp Hofer AuthorDate: Thu Nov 12 13:14:32 2020 +0100 Commit: Christian Lohmaier CommitDate: Sun Nov 22 01:56:27 2020 +0100 tdf#123936 Formatting files in module sdext with clang-format Change-Id: Ibfed67a0f772ea0c02bf0e7267e9ed46517e2018 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105704 Reviewed-by: Christian Lohmaier Tested-by: Jenkins diff --git a/sdext/source/minimizer/pppoptimizer.cxx b/sdext/source/minimizer/pppoptimizer.cxx index 4d21ca3aabc9..c869f72187f6 100644 --- a/sdext/source/minimizer/pppoptimizer.cxx +++ b/sdext/source/minimizer/pppoptimizer.cxx @@ -17,19 +17,18 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - #include "pppoptimizer.hxx" #include // returning filesize, on error zero is returned -sal_Int64 PPPOptimizer::GetFileSize( const OUString& rURL ) +sal_Int64 PPPOptimizer::GetFileSize(const OUString& rURL) { sal_Int64 nFileSize = 0; osl::DirectoryItem aItem; -if ( osl::DirectoryItem::get( rURL, aItem ) == osl::FileBase::E_None ) +if (osl::DirectoryItem::get(rURL, aItem) == osl::FileBase::E_None) { -osl::FileStatus aStatus( osl_FileStatus_Mask_FileSize ); -if ( aItem.getFileStatus( aStatus ) == osl::FileBase::E_None ) +osl::FileStatus aStatus(osl_FileStatus_Mask_FileSize); +if (aItem.getFileStatus(aStatus) == osl::FileBase::E_None) { nFileSize = aStatus.getFileSize(); } diff --git a/sdext/source/minimizer/pppoptimizer.hxx b/sdext/source/minimizer/pppoptimizer.hxx index cf1e5e0f244b..60b191a7bd07 100644 --- a/sdext/source/minimizer/pppoptimizer.hxx +++ b/sdext/source/minimizer/pppoptimizer.hxx @@ -22,10 +22,9 @@ #include - struct PPPOptimizer { -static sal_Int64 GetFileSize( const OUString& rURL ); +static sal_Int64 GetFileSize(const OUString& rURL); }; #endif // INCLUDED_SDEXT_SOURCE_MINIMIZER_PPPOPTIMIZER_HXX diff --git a/sdext/source/minimizer/pppoptimizertoken.hxx b/sdext/source/minimizer/pppoptimizertoken.hxx index 8f83e8dd8f8e..d0ae65ed74ab 100644 --- a/sdext/source/minimizer/pppoptimizertoken.hxx +++ b/sdext/source/minimizer/pppoptimizertoken.hxx @@ -140,8 +140,8 @@ enum PPPOptimizerTokenEnum TK_NotFound }; -PPPOptimizerTokenEnum TKGet( const OUString& ); -OUString TKGet( const PPPOptimizerTokenEnum ); +PPPOptimizerTokenEnum TKGet(const OUString&); +OUString TKGet(const PPPOptimizerTokenEnum); #endif diff --git a/sdext/source/presenter/PresenterHelper.hxx b/sdext/source/presenter/PresenterHelper.hxx index 6704844d730c..7f4387c163bd 100644 --- a/sdext/source/presenter/PresenterHelper.hxx +++ b/sdext/source/presenter/PresenterHelper.hxx @@ -23,23 +23,23 @@ #include #include -namespace sdext::presenter { - +namespace sdext::presenter +{ /** Collection of helper functions that do not fit in anywhere else. Provide access to frequently used strings of the drawing framework. */ namespace PresenterHelper { -extern const OUString msCenterPaneURL; -extern const OUString msFullScreenPaneURL; +extern const OUString msCenterPaneURL; +extern const OUString msFullScreenPaneURL; -/** Return the slide show controller of a running presentation that has -the same document as the given framework controller. -@return -When no presentation is running this method returns an empty reference. -*/ -css::uno::Reference GetSlideShowController ( -const css::uno::Reference& rxController); +/** Return the slide show controller of a running presentation that has +the same document as the given framework controller. +@return +When no presentation is running this method returns an empty reference. +*/ +css::uno::Reference +GetSlideShowController(const css::uno::Reference& rxController); } } // end of namespace presenter diff --git a/sdext/source/presenter/PresenterPane.hxx b/sdext/source/presenter/PresenterPane.hxx index 62b1941695d6..2a057229f802 100644 --- a/sdext/source/presenter/PresenterPane.hxx +++ b/sdext/source/presenter/PresenterPane.hxx @@ -25,8 +25,8 @@ #include #include -namespace sdext::presenter { - +namespace sdext::presenter +{ /** Pane used by the presenter
[Libreoffice-commits] core.git: sdext/source
sdext/source/presenter/PresenterAccessibility.cxx | 15 +-- 1 file changed, 13 insertions(+), 2 deletions(-) New commits: commit 2cb54449b4fc9e908aae0a44f808d82b8e83acfc Author: Michael Stahl AuthorDate: Mon Oct 12 12:19:55 2020 +0200 Commit: Michael Stahl CommitDate: Tue Oct 13 10:46:46 2020 +0200 sdext: fix use-after-free on global AccessibleFocusManager The problem is that the destructor of the vector maFocusableObjects ends up dispose()-ing every element, which calls back into AccessibleFocusManager to remove the element from the vector, which invokes its destructor a 2nd time. Move it to the stack so it doesn't double-free itself. ERROR: AddressSanitizer: heap-use-after-free on address 0x612001571c00 at pc 0x7fc5e723ca72 bp 0x7fffbaa8d6d0 sp 0x7fffbaa8d6c8 READ of size 1 at 0x612001571c00 thread T0 #0 0x7fc5e723ca71 in cppu::WeakComponentImplHelperBase::release() cppuhelper/source/implbase.cxx:84:9 #1 0x7fc595211b27 in cppu::PartialWeakComponentImplHelper::release() include/cppuhelper/compbase.hxx:86:36 #2 0x7fc5952093e4 in rtl::Reference::~Reference() include/rtl/ref.hxx:113:22 #3 0x7fc59522acd4 in void std::_Destroy >(rtl::Reference*) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/stl_construct.h:140:19 0x612001571c00 is located 64 bytes inside of 312-byte region [0x612001571bc0,0x612001571cf8) freed by thread T0 here: #0 0x4be997 in free (instdir/program/soffice.bin+0x4be997) #1 0x7fc5ea2a5104 in rtl_freeMemory sal/rtl/alloc_global.cxx:51:5 #2 0x7fc5952097f4 in cppu::WeakComponentImplHelperBase::operator delete(void*) include/cppuhelper/compbase_ex.hxx:66:11 #3 0x7fc595211e07 in sdext::presenter::PresenterAccessible::AccessibleObject::~AccessibleObject() sdext/source/presenter/PresenterAccessibility.cxx:67:28 #4 0x7fc5e74a11b4 in cppu::OWeakObject::release() cppuhelper/source/weak.cxx:233:9 #5 0x7fc5e723cb05 in cppu::WeakComponentImplHelperBase::release() cppuhelper/source/implbase.cxx:86:18 #6 0x7fc595211b27 in cppu::PartialWeakComponentImplHelper::release() include/cppuhelper/compbase.hxx:86:36 #7 0x7fc5e7194115 in com::sun::star::uno::Reference::~Reference() include/com/sun/star/uno/Reference.hxx:110:22 #8 0x7fc5e71f3944 in com::sun::star::lang::EventObject::~EventObject() workdir/UnoApiHeadersTarget/udkapi/comprehensive/com/sun/star/lang/EventObject.hdl:18:27 #9 0x7fc5e723d395 in cppu::WeakComponentImplHelperBase::dispose() cppuhelper/source/implbase.cxx:118:5 #10 0x7fc595211e27 in cppu::PartialWeakComponentImplHelper::dispose() include/cppuhelper/compbase.hxx:90:36 #11 0x7fc5e723c6e9 in cppu::WeakComponentImplHelperBase::release() cppuhelper/source/implbase.cxx:79:13 #12 0x7fc595211b27 in cppu::PartialWeakComponentImplHelper::release() include/cppuhelper/compbase.hxx:86:36 #13 0x7fc5952093e4 in rtl::Reference::~Reference() include/rtl/ref.hxx:113:22 #14 0x7fc59522acd4 in void std::_Destroy >(rtl::Reference*) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/stl_construct.h:140:19 Change-Id: I95151807e9182ed5f43b63792fba86f83ee0bad8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104208 Tested-by: Jenkins Reviewed-by: Michael Stahl diff --git a/sdext/source/presenter/PresenterAccessibility.cxx b/sdext/source/presenter/PresenterAccessibility.cxx index 951a18c5fca5..936c75df35f7 100644 --- a/sdext/source/presenter/PresenterAccessibility.cxx +++ b/sdext/source/presenter/PresenterAccessibility.cxx @@ -451,9 +451,12 @@ public: void FocusObject (const ::rtl::Reference& rpObject); +~AccessibleFocusManager(); + private: static std::shared_ptr mpInstance; ::std::vector > maFocusableObjects; +bool m_isInDtor = false; AccessibleFocusManager(); }; @@ -1810,10 +1813,18 @@ std::shared_ptr const & AccessibleFocusManager::Instance } AccessibleFocusManager::AccessibleFocusManager() -: maFocusableObjects() { } +AccessibleFocusManager::~AccessibleFocusManager() +{ +// copy member to stack, then drop it - otherwise will get use-after-free +// from AccessibleObject::disposing(), it will call ~Reference *twice* +auto const temp(std::move(maFocusableObjects)); +(void) temp; +m_isInDtor = true; +} + void AccessibleFocusManager::AddFocusableObject ( const ::rtl::Reference& rpObject) { @@ -1833,7 +1844,7 @@ void AccessibleFocusManager::RemoveFocusableObject ( maFocusableObjects.erase(iObject); else { -OSL_ASSERT(iObject!=maFocusableObjects.end()); +OSL_ASSERT(m_isInDtor); // in dtor, was removed already } } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org
[Libreoffice-commits] core.git: sdext/source
sdext/source/presenter/PresenterButton.cxx |6 +++--- sdext/source/presenter/PresenterButton.hxx |2 +- 2 files changed, 4 insertions(+), 4 deletions(-) New commits: commit 19588a1f947c5b3bb3f3fc6d5f4f34e4aee5998f Author: Andrea Gelmini AuthorDate: Fri Aug 28 13:02:21 2020 +0200 Commit: Noel Grandin CommitDate: Sat Aug 29 11:33:26 2020 +0200 Fix typo in code It passed "make check" on Linux Change-Id: I8d393bf42be181fad18829a46393714a95f32000 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101607 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/presenter/PresenterButton.cxx b/sdext/source/presenter/PresenterButton.cxx index 2f1a7767a57d..329ff8399064 100644 --- a/sdext/source/presenter/PresenterButton.cxx +++ b/sdext/source/presenter/PresenterButton.cxx @@ -419,7 +419,7 @@ void PresenterButton::SetupButtonBitmaps() Reference PresenterButton::GetConfigurationProperties ( const css::uno::Reference& rxComponentContext, -const OUString& rsConfgurationName) +const OUString& rsConfigurationName) { PresenterConfigurationAccess aConfiguration ( rxComponentContext, @@ -430,10 +430,10 @@ Reference PresenterButton::GetConfigurationProperties ( Reference( aConfiguration.GetConfigurationNode("PresenterScreenSettings/Buttons"), UNO_QUERY), -[](OUString const&, uno::Reference const& xProps) -> bool +[](OUString const&, uno::Reference const& xProps) -> bool { return PresenterConfigurationAccess::IsStringPropertyEqual( -rsConfgurationName, "Name", xProps); +rsConfigurationName, "Name", xProps); }), UNO_QUERY); } diff --git a/sdext/source/presenter/PresenterButton.hxx b/sdext/source/presenter/PresenterButton.hxx index 07125f71ee73..f722e7da1c52 100644 --- a/sdext/source/presenter/PresenterButton.hxx +++ b/sdext/source/presenter/PresenterButton.hxx @@ -125,7 +125,7 @@ private: void SetupButtonBitmaps(); static css::uno::Reference GetConfigurationProperties ( const css::uno::Reference& rxComponentContext, -const OUString& rsConfgurationName); +const OUString& rsConfigurationName); /// @throws css::lang::DisposedException void ThrowIfDisposed() const; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sdext/source
sdext/source/minimizer/informationdialog.cxx |2 +- sdext/source/minimizer/optimizerdialogcontrols.cxx |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) New commits: commit d784e711c102f204552c3c816636da01b1085f61 Author: Stephan Bergmann AuthorDate: Thu Aug 27 19:22:54 2020 +0200 Commit: Stephan Bergmann CommitDate: Sat Aug 29 09:27:47 2020 +0200 Directly use OUStringBuffer::indexOf Change-Id: I455a7857294a136a515bb68cc8321ede0e5d1c85 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101575 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/sdext/source/minimizer/informationdialog.cxx b/sdext/source/minimizer/informationdialog.cxx index d4a489c56079..8ab6ddfbd8cf 100644 --- a/sdext/source/minimizer/informationdialog.cxx +++ b/sdext/source/minimizer/informationdialog.cxx @@ -191,7 +191,7 @@ static OUString ImpValueOfInMB( sal_Int64 rVal ) fVal /= ( 1 << 20 ); fVal += 0.05; OUStringBuffer aVal( OUString::number( fVal ) ); -sal_Int32 nX( OUString( aVal.getStr() ).indexOf( '.' ) ); +sal_Int32 nX( aVal.indexOf( '.' ) ); if ( nX > 0 ) aVal.setLength( nX + 2 ); return aVal.makeStringAndClear(); diff --git a/sdext/source/minimizer/optimizerdialogcontrols.cxx b/sdext/source/minimizer/optimizerdialogcontrols.cxx index a7e139c33f24..13fe926dd36e 100644 --- a/sdext/source/minimizer/optimizerdialogcontrols.cxx +++ b/sdext/source/minimizer/optimizerdialogcontrols.cxx @@ -581,7 +581,7 @@ static OUString ImpValueOfInMB( sal_Int64 rVal, sal_Unicode nSeparator ) fVal /= ( 1 << 20 ); fVal += 0.05; OUStringBuffer aVal( OUString::number( fVal ) ); -sal_Int32 nX( OUString( aVal.getStr() ).indexOf( '.' ) ); +sal_Int32 nX( aVal.indexOf( '.' ) ); if ( nX >= 0 ) { aVal.setLength( nX + 2 ); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sdext/source
sdext/source/pdfimport/tree/drawtreevisiting.cxx |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) New commits: commit 8029d316d89a6a4ca612e136697532d0accc22fb Author: Stephan Bergmann AuthorDate: Thu Aug 27 19:05:52 2020 +0200 Commit: Stephan Bergmann CommitDate: Sat Aug 29 08:13:33 2020 +0200 Simplify OUStringBuffer to OUString conversion Change-Id: I9bd7722ebe7e29a1b68037c80e8d1c2c49d7984c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101572 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx index 305470101cec..387da6947c68 100644 --- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx +++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx @@ -102,7 +102,7 @@ void DrawXmlEmitter::visit( TextElement& elem, const std::list< std::unique_ptr< m_rEmitContext.rStyles.getStyleName( elem.StyleId ); } -OUString str(elem.Text.getStr()); +OUString str(elem.Text.toString()); // Check for RTL bool isRTL = false; @@ -676,7 +676,7 @@ void DrawXmlOptimizer::optimizeTextElements(Element& rParent) { TextElement* pNext = dynamic_cast(next->get()); bool isComplex = false; -OUString str(pCur->Text.getStr()); +OUString str(pCur->Text.toString()); for(int i=0; i< str.getLength(); i++) { sal_Int16 nType = GetBreakIterator()->getScriptType( str, i ); @@ -708,7 +708,7 @@ void DrawXmlOptimizer::optimizeTextElements(Element& rParent) // append text to current element pCur->Text.append( pNext->Text ); -str = pCur->Text.getStr(); +str = pCur->Text.toString(); for(int i=0; i< str.getLength(); i++) { sal_Int16 nType = GetBreakIterator()->getScriptType( str, i ); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sdext/source
sdext/source/presenter/PresenterPaneContainer.hxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit d0d87244eefc19e6ea6762a029b6ced036faec90 Author: Andrea Gelmini AuthorDate: Thu Aug 20 13:12:51 2020 +0200 Commit: Julien Nabet CommitDate: Fri Aug 21 18:18:12 2020 +0200 Fix typo in code Change-Id: I0ebb5799289e35481ca9dbf288b450c50953a268 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101113 Tested-by: Jenkins Reviewed-by: Julien Nabet diff --git a/sdext/source/presenter/PresenterPaneContainer.hxx b/sdext/source/presenter/PresenterPaneContainer.hxx index 65c6bddb7e0b..136c25690b16 100644 --- a/sdext/source/presenter/PresenterPaneContainer.hxx +++ b/sdext/source/presenter/PresenterPaneContainer.hxx @@ -100,7 +100,7 @@ public: const OUString& rsTitle, const OUString& rsAccessibleTitle, const bool bIsOpaque, -const ViewInitializationFunction& rViewIntialization); +const ViewInitializationFunction& rViewInitialization); SharedPaneDescriptor StorePane ( const rtl::Reference& rxPane); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sdext/source
sdext/source/minimizer/optimizerdialogcontrols.cxx | 45 - 1 file changed, 10 insertions(+), 35 deletions(-) New commits: commit 73f9d308337ce54d724f46e96e6505c45f445f26 Author: Noel Grandin AuthorDate: Tue Aug 18 16:01:19 2020 +0200 Commit: Noel Grandin CommitDate: Tue Aug 18 18:17:35 2020 +0200 remove dead code since commit e22c431e24b4a83ddc928f7703b13a9a109c1b8e Date: Fri May 11 13:01:25 2007 + initial version found by loplugin:unusedvarsglobal Change-Id: I7ae07c25fadc4cac4c176c763fe886c0df02a235 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100926 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sdext/source/minimizer/optimizerdialogcontrols.cxx b/sdext/source/minimizer/optimizerdialogcontrols.cxx index 5c6ad0dd4cb4..a7e139c33f24 100644 --- a/sdext/source/minimizer/optimizerdialogcontrols.cxx +++ b/sdext/source/minimizer/optimizerdialogcontrols.cxx @@ -638,7 +638,6 @@ void OptimizerDialog::UpdateControlStatesPage4() // taking care of deleted slides sal_Int32 nDeletedSlides = 0; -OUString aCustomShowName; if ( getControlProperty( "CheckBox3Pg3", "State" ) >>= nInt16 ) { if ( nInt16 ) @@ -661,44 +660,20 @@ void OptimizerDialog::UpdateControlStatesPage4() } } } -if ( !aCustomShowName.isEmpty() ) -{ -std::vector< Reference< XDrawPage > > vNonUsedPageList; -PageCollector::CollectNonCustomShowPages( mxController->getModel(), aCustomShowName, vNonUsedPageList ); -nDeletedSlides += vNonUsedPageList.size(); -} if ( GetConfigProperty( TK_DeleteHiddenSlides, false ) ) { -if ( !aCustomShowName.isEmpty() ) -{ -std::vector< Reference< XDrawPage > > vUsedPageList; -PageCollector::CollectCustomShowPages( mxController->getModel(), aCustomShowName, vUsedPageList ); -for( const auto& rxPage : vUsedPageList ) -{ -Reference< XPropertySet > xPropSet( rxPage, UNO_QUERY_THROW ); -bool bVisible = true; -if ( xPropSet->getPropertyValue( "Visible" ) >>= bVisible ) -{ -if (!bVisible ) -nDeletedSlides++; -} -} -} -else +Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxController->getModel(), UNO_QUERY_THROW ); +Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_SET_THROW ); +for( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ ) { -Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxController->getModel(), UNO_QUERY_THROW ); -Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_SET_THROW ); -for( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ ) -{ -Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW ); -Reference< XPropertySet > xPropSet( xDrawPage, UNO_QUERY_THROW ); +Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW ); +Reference< XPropertySet > xPropSet( xDrawPage, UNO_QUERY_THROW ); -bool bVisible = true; -if ( xPropSet->getPropertyValue( "Visible" ) >>= bVisible ) -{ -if (!bVisible ) -nDeletedSlides++; -} +bool bVisible = true; +if ( xPropSet->getPropertyValue( "Visible" ) >>= bVisible ) +{ +if (!bVisible ) +nDeletedSlides++; } } } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sdext/source
sdext/source/minimizer/fileopendialog.cxx |8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) New commits: commit 99c6c89deed41457d35c382fc7d6a4cd5191f7d7 Author: Mike Kaganski AuthorDate: Sun Aug 16 18:58:48 2020 +0300 Commit: Mike Kaganski CommitDate: Sun Aug 16 20:08:15 2020 +0200 tdf#135342: filter list must include extensions Regression after commit a0dcc8f78061d22d925f31ef8d03ca751ad6dc19. The commit had added extensions to the filter names sent to file dialog, but kept internal list of filter names aFilterEntryList without extensions. Then dialog returned the chosen filter's name in the form it was sent there, i.e. with extension; and that name couldn't be found in aFilterEntryList. So let's keep aFilterEntryList synchronized with the UI names in the dialog. Change-Id: Ic21d19d1a8d0b7f64ccfb517a7d0ee8ab36fc6a8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100821 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/sdext/source/minimizer/fileopendialog.cxx b/sdext/source/minimizer/fileopendialog.cxx index 68f25f77900a..aab29c03907b 100644 --- a/sdext/source/minimizer/fileopendialog.cxx +++ b/sdext/source/minimizer/fileopendialog.cxx @@ -106,7 +106,7 @@ FileOpenDialog::FileOpenDialog( const Reference< XComponentContext >& rxContext Reference< XNameAccess > xTypes( rxContext->getServiceManager()->createInstanceWithContext( "com.sun.star.document.TypeDetection", rxContext ), UNO_QUERY_THROW ); -for( const auto& rFilterEntry : aFilterEntryList ) +for (auto& rFilterEntry : aFilterEntryList) { Sequence< PropertyValue > aTypeProperties; try @@ -120,10 +120,12 @@ FileOpenDialog::FileOpenDialog( const Reference< XComponentContext >& rxContext pProp->Value >>= aExtensions; if ( aExtensions.hasElements() ) { -// The filter title must be formed in the same way it is -// currently done in the internal implementation: +// The filter title must be formed in the same way it is currently done in the +// internal implementation (see sfx2::appendFiltersForSave). And we will look +// for the same string returned from the dialog, so save it to maUIName: OUString aTitle( rFilterEntry.maUIName + " (." + aExtensions[0] + ")"); +rFilterEntry.maUIName = aTitle; OUString aFilter("*." + aExtensions[0]); mxFilePicker->appendFilter(aTitle, aFilter); if ( rFilterEntry.maFlags & 0x100 ) ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits