include/oox/export/drawingml.hxx | 2 lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx | 100 +++++------------- oox/inc/drawingml/textspacing.hxx | 14 +- oox/source/drawingml/textspacingcontext.cxx | 1 oox/source/export/drawingml.cxx | 4 sd/qa/unit/data/odp/tdf112647.odp |binary sd/qa/unit/export-tests-ooxml2.cxx | 20 +++ 7 files changed, 65 insertions(+), 76 deletions(-)
New commits: commit d46ae90809193172dca7484adb52520a5779f502 Author: Mike Kaganski <[email protected]> Date: Tue Sep 26 09:55:24 2017 +0300 Unify hyphenator loading and ensure Unicode paths on Windows Change-Id: I2f910194c541cb0b882c69d03b02749ef9b93d29 Reviewed-on: https://gerrit.libreoffice.org/42777 Tested-by: Jenkins <[email protected]> Reviewed-by: Mike Kaganski <[email protected]> diff --git a/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx b/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx index 45fbf3dc5dc0..f4b1f86545f3 100644 --- a/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx +++ b/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx @@ -17,11 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#if defined(_WIN32) -#include <prewin.h> -#include <postwin.h> -#endif - #include <com/sun/star/uno/Reference.h> #include <cppuhelper/factory.hxx> @@ -247,6 +242,34 @@ sal_Bool SAL_CALL Hyphenator::hasLocale(const Locale& rLocale) return bRes; } +namespace { +bool LoadDictionary(HDInfo& rDict) +{ + OUString DictFN = rDict.aName + ".dic"; + OUString dictpath; + + osl::FileBase::getSystemPathFromFileURL(DictFN, dictpath); + +#if defined(_WIN32) + // hnj_hyphen_load expects UTF-8 encoded paths with \\?\ long path prefix. + OString sTmp = Win_AddLongPathPrefix(OUStringToOString(dictpath, RTL_TEXTENCODING_UTF8)); +#else + OString sTmp(OU2ENC(dictpath, osl_getThreadTextEncoding())); +#endif + HyphenDict *dict = nullptr; + if ((dict = hnj_hyphen_load(sTmp.getStr())) == nullptr) + { + SAL_WARN( + "lingucomponent", + "Couldn't find file " << OU2ENC(dictpath, osl_getThreadTextEncoding())); + return false; + } + rDict.aPtr = dict; + rDict.eEnc = getTextEncodingFromCharset(dict->cset); + return true; +} +} + Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWord, const css::lang::Locale& aLocale, sal_Int16 nMaxLeading, @@ -282,25 +305,8 @@ Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWo // if this dictionary has not been loaded yet do that if (!aDicts[k].aPtr) { - OUString DictFN = aDicts[k].aName + ".dic"; - OUString dictpath; - - osl::FileBase::getSystemPathFromFileURL( DictFN, dictpath ); - -#if defined(_WIN32) - // Hyphen waits UTF-8 encoded paths with \\?\ long path prefix. - OString sTmp = Win_AddLongPathPrefix(OUStringToOString(dictpath, RTL_TEXTENCODING_UTF8)); -#else - OString sTmp( OU2ENC( dictpath, osl_getThreadTextEncoding() ) ); -#endif - - if ( ( dict = hnj_hyphen_load ( sTmp.getStr()) ) == nullptr ) - { - fprintf(stderr, "Couldn't find file %s\n", OU2ENC(dictpath, osl_getThreadTextEncoding()) ); - return nullptr; - } - aDicts[k].aPtr = dict; - aDicts[k].eEnc = getTextEncodingFromCharset(dict->cset); + if (!LoadDictionary(aDicts[k])) + return nullptr; } // other wise hyphenate the word with that dictionary @@ -507,29 +513,6 @@ Reference < XHyphenatedWord > SAL_CALL Hyphenator::queryAlternativeSpelling( return nullptr; } -#if defined(_WIN32) -static OString Win_GetShortPathName( const OUString &rLongPathName ) -{ - OString aRes; - - sal_Unicode aShortBuffer[1024] = {0}; - sal_Int32 nShortBufSize = SAL_N_ELEMENTS( aShortBuffer ); - - // use the version of 'GetShortPathName' that can deal with Unicode... - sal_Int32 nShortLen = GetShortPathNameW( - reinterpret_cast<LPCWSTR>( rLongPathName.getStr() ), - reinterpret_cast<LPWSTR>( aShortBuffer ), - nShortBufSize ); - - if (nShortLen < nShortBufSize) // conversion successful? - aRes = OString( OU2ENC( OUString( aShortBuffer, nShortLen ), osl_getThreadTextEncoding()) ); - else - OSL_FAIL( "Win_GetShortPathName: buffer to short" ); - - return aRes; -} -#endif //defined(WNT) - Reference< XPossibleHyphens > SAL_CALL Hyphenator::createPossibleHyphens( const OUString& aWord, const css::lang::Locale& aLocale, const css::beans::PropertyValues& aProperties ) @@ -561,27 +544,8 @@ Reference< XPossibleHyphens > SAL_CALL Hyphenator::createPossibleHyphens( const // if this dictionary has not been loaded yet do that if (!aDicts[k].aPtr) { - OUString DictFN = aDicts[k].aName + ".dic"; - OUString dictpath; - - osl::FileBase::getSystemPathFromFileURL( DictFN, dictpath ); - OString sTmp( OU2ENC( dictpath, osl_getThreadTextEncoding() ) ); - -#if defined(_WIN32) - // workaround for Windows specific problem that the - // path length in calls to 'fopen' is limited to somewhat - // about 120+ characters which will usually be exceed when - // using dictionaries as extensions. - sTmp = Win_GetShortPathName( dictpath ); -#endif - - if ( ( dict = hnj_hyphen_load ( sTmp.getStr()) ) == nullptr ) - { - fprintf(stderr, "Couldn't find file %s and %s\n", sTmp.getStr(), OU2ENC(dictpath, osl_getThreadTextEncoding()) ); - return nullptr; - } - aDicts[k].aPtr = dict; - aDicts[k].eEnc = getTextEncodingFromCharset(dict->cset); + if (!LoadDictionary(aDicts[k])) + return nullptr; } // other wise hyphenate the word with that dictionary commit ef2e9b19a52e04ae0ed45900bcf64bf375a910ef Author: Tamás Zolnai <[email protected]> Date: Mon Sep 25 21:42:57 2017 +0200 tdf#112647: Fixed line spacing is saved incorrectly to PPTX The values were not converted to the right unit. Also the spcPts attribute means an exact value not a minimum one. Change-Id: Ia49683e66153611e96a830f821e3a2487adec505 Reviewed-on: https://gerrit.libreoffice.org/42763 Tested-by: Jenkins <[email protected]> Reviewed-by: Tamás Zolnai <[email protected]> diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index ded3f4e488aa..627bcc983706 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -190,7 +190,7 @@ public: void WriteSrcRect( const css::uno::Reference< css::beans::XPropertySet >&, const OUString& ); void WriteOutline( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet ); void WriteStretch( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, const OUString& rURL ); - void WriteLinespacing( css::style::LineSpacing& rLineSpacing ); + void WriteLinespacing( const css::style::LineSpacing& rLineSpacing ); OUString WriteBlip( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, const OUString& rURL, bool bRelPathToMedia = false , const Graphic *pGraphic=nullptr ); diff --git a/oox/inc/drawingml/textspacing.hxx b/oox/inc/drawingml/textspacing.hxx index d1ed9a988169..ed5f9b3be8d0 100644 --- a/oox/inc/drawingml/textspacing.hxx +++ b/oox/inc/drawingml/textspacing.hxx @@ -38,16 +38,19 @@ namespace oox { namespace drawingml { Percent }; TextSpacing() - : nUnit( Unit::Points ), nValue( 0 ), bHasValue( false ) + : nUnit( Unit::Points ), nValue( 0 ), bHasValue( false ), bExactValue( false ) { } - TextSpacing( sal_Int32 nPoints ) : nUnit( Unit::Points ), nValue( nPoints ), bHasValue( true ){}; + TextSpacing( sal_Int32 nPoints ) : nUnit( Unit::Points ), nValue( nPoints ), bHasValue( true ), bExactValue ( false ){}; css::style::LineSpacing toLineSpacing() const { css::style::LineSpacing aSpacing; - aSpacing.Mode = ( nUnit == Unit::Percent - ? css::style::LineSpacingMode::PROP - : css::style::LineSpacingMode::MINIMUM ); + if (nUnit == Unit::Percent) + aSpacing.Mode = css::style::LineSpacingMode::PROP; + else if (bExactValue) + aSpacing.Mode = css::style::LineSpacingMode::FIX; + else + aSpacing.Mode = css::style::LineSpacingMode::MINIMUM; aSpacing.Height = static_cast< sal_Int16 >( nUnit == Unit::Percent ? nValue / 1000 : nValue ); return aSpacing; } @@ -61,6 +64,7 @@ namespace oox { namespace drawingml { Unit nUnit; sal_Int32 nValue; bool bHasValue; + bool bExactValue; }; } } diff --git a/oox/source/drawingml/textspacingcontext.cxx b/oox/source/drawingml/textspacingcontext.cxx index 97c8162f70b8..133e110e83c3 100644 --- a/oox/source/drawingml/textspacingcontext.cxx +++ b/oox/source/drawingml/textspacingcontext.cxx @@ -49,6 +49,7 @@ namespace oox { namespace drawingml { case A_TOKEN( spcPts ): maSpacing.nUnit = TextSpacing::Unit::Points; maSpacing.nValue = GetTextSpacingPoint( rAttribs.getString( XML_val ).get() ); + maSpacing.bExactValue = true; break; default: break; diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 198ac917bb92..312da7938d05 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -2056,7 +2056,7 @@ const char* DrawingML::GetAlignment( style::ParagraphAdjust nAlignment ) return sAlignment; } -void DrawingML::WriteLinespacing( LineSpacing& rSpacing ) +void DrawingML::WriteLinespacing( const LineSpacing& rSpacing ) { if( rSpacing.Mode == LineSpacingMode::PROP ) { @@ -2067,7 +2067,7 @@ void DrawingML::WriteLinespacing( LineSpacing& rSpacing ) else { mpFS->singleElementNS( XML_a, XML_spcPts, - XML_val, I32S( rSpacing.Height ), + XML_val, I32S( std::lround(rSpacing.Height / 25.4 * 72) ), FSEND ); } } diff --git a/sd/qa/unit/data/odp/tdf112647.odp b/sd/qa/unit/data/odp/tdf112647.odp new file mode 100755 index 000000000000..72a6621b8e86 Binary files /dev/null and b/sd/qa/unit/data/odp/tdf112647.odp differ diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 2a12eb021cc6..9707407efb61 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -62,6 +62,8 @@ #include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> +#include <com/sun/star/style/LineSpacing.hpp> +#include <com/sun/star/style/LineSpacingMode.hpp> #include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/table/XTable.hpp> #include <com/sun/star/table/XMergeableCell.hpp> @@ -114,6 +116,7 @@ public: void testTdf112334(); void testTdf112089(); void testTdf112086(); + void testTdf112647(); CPPUNIT_TEST_SUITE(SdOOXMLExportTest2); @@ -155,6 +158,7 @@ public: CPPUNIT_TEST(testTdf112334); CPPUNIT_TEST(testTdf112089); CPPUNIT_TEST(testTdf112086); + CPPUNIT_TEST(testTdf112647); CPPUNIT_TEST_SUITE_END(); @@ -1182,6 +1186,22 @@ void SdOOXMLExportTest2::testTdf112086() sAttributeName = getXPathContent(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:anim[2]/p:cBhvr/p:attrNameLst/p:attrName"); CPPUNIT_ASSERT_EQUAL(OUString("ppt_h"), sAttributeName); + xDocShRef->DoClose(); +} + +void SdOOXMLExportTest2::testTdf112647() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/odp/tdf112647.odp"), ODP); + xDocShRef = saveAndReload( xDocShRef.get(), PPTX ); + uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) ); + uno::Reference<text::XTextRange> xParagraph( getParagraphFromShape( 0, xShape ) ); + uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW ); + + css::style::LineSpacing aLineSpacing; + xPropSet->getPropertyValue("ParaLineSpacing") >>= aLineSpacing; + CPPUNIT_ASSERT_EQUAL(sal_Int16(css::style::LineSpacingMode::FIX), aLineSpacing.Mode); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2117), aLineSpacing.Height); + xDocShRef->DoClose(); } CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
_______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
