desktop/qa/desktop_lib/test_desktop_lib.cxx | 2 - desktop/source/lib/init.cxx | 51 +++++++++++++++++++++------- 2 files changed, 41 insertions(+), 12 deletions(-)
New commits: commit 0b3fbf8299c51767689b4e7656bbf4c331450b98 Author: Andrzej Hunt <andr...@ahunt.org> Date: Thu Nov 12 14:48:55 2015 +0100 sw lok: filter out defalt styles to avoid duplicates Change-Id: Iff84c2f16844a507d30f30c1fd4b23d807ded466 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index b4992cc..bc25f3e 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1263,7 +1263,10 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) "Heading 3" }; - // static const std::vector<OUString> aList = { "aaaa", "bbb" }; + // We need to keep a list of the default style names + // in order to filter these out later when processing + // the full list of styles. + std::set<OUString> aDefaultStyleNames; boost::property_tree::ptree aValues; for (sal_Int32 nStyleFam = 0; nStyleFam < aStyleFamilies.getLength(); ++nStyleFam) @@ -1286,6 +1289,8 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) xStyle->getPropertyValue("DisplayName") >>= sName; if( !sName.isEmpty() ) { + aDefaultStyleNames.insert( sName ); + boost::property_tree::ptree aChild; aChild.put("", sName.toUtf8()); aChildren.push_back(std::make_pair("", aChild)); @@ -1296,9 +1301,14 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) uno::Sequence<OUString> aStyles = xStyleFamily->getElementNames(); for ( OUString aStyle: aStyles ) { - boost::property_tree::ptree aChild; - aChild.put("", aStyles[nInd]); - aChildren.push_back(std::make_pair("", aChild)); + // Filter out the default styles - they are already at the top + // of the list + if (aDefaultStyleNames.find(aStyle) == aDefaultStyleNames.end()) + { + boost::property_tree::ptree aChild; + aChild.put("", aStyle); + aChildren.push_back(std::make_pair("", aChild)); + } } aValues.add_child(sStyleFam.toUtf8().getStr(), aChildren); } commit 6e6ae9803796b120e95f6e89575e03c5fd0ed3c2 Author: Andrzej Hunt <andr...@ahunt.org> Date: Thu Nov 12 14:41:02 2015 +0100 More range based for Change-Id: I9cdcd8dca413981389cd4db3059a420131e5f839 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index b205cf0..b4992cc 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1294,7 +1294,7 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) } uno::Sequence<OUString> aStyles = xStyleFamily->getElementNames(); - for (sal_Int32 nInd = 0; nInd < aStyles.getLength(); ++nInd) + for ( OUString aStyle: aStyles ) { boost::property_tree::ptree aChild; aChild.put("", aStyles[nInd]); commit d5545979fb27e317cce4d374a5a913790d8a2adf Author: Andrzej Hunt <andr...@ahunt.org> Date: Thu Nov 12 14:30:40 2015 +0100 Use std::vector instead of an array of strings This makes the code much more readable / sane. Change-Id: I1d60f4102b6c619fa2fefac4a3644b7f04c0b9c0 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 048215e..b205cf0 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1252,7 +1252,7 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY); uno::Sequence<OUString> aStyleFamilies = xStyleFamilies->getElementNames(); - static const sal_Char* aWriterStyles[] = + static const std::vector<OUString> aWriterStyles = { "Text body", "Quotations", @@ -1263,6 +1263,8 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) "Heading 3" }; + // static const std::vector<OUString> aList = { "aaaa", "bbb" }; + boost::property_tree::ptree aValues; for (sal_Int32 nStyleFam = 0; nStyleFam < aStyleFamilies.getLength(); ++nStyleFam) { @@ -1276,10 +1278,10 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) if (sStyleFam == "ParagraphStyles" && doc_getDocumentType(pThis) == LOK_DOCTYPE_TEXT) { - for( sal_uInt32 nStyle = 0; nStyle < sizeof( aWriterStyles ) / sizeof( sal_Char*); ++nStyle ) + for( OUString aStyle: aWriterStyles ) { uno::Reference< beans::XPropertySet > xStyle; - xStyleFamily->getByName( OUString::createFromAscii( aWriterStyles[nStyle] )) >>= xStyle; + xStyleFamily->getByName( aStyle ) >>= xStyle; OUString sName; xStyle->getPropertyValue("DisplayName") >>= sName; if( !sName.isEmpty() ) commit fbc3965dc117967d2b5f51aa3902823da7c69d12 Author: Andrzej Hunt <andr...@ahunt.org> Date: Thu Nov 12 13:50:52 2015 +0100 lok: send list of commands instead of ClearStyles We currently send just one command, but this could be expanded server side in future. Change-Id: Id8f14196158f3a7fe9c54595d094603efd5e2ce3 diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 2351c7b..21e177a 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -192,7 +192,7 @@ void DesktopLOKTest::testGetStyles() rPair.first != "NumberingStyles" && rPair.first != "CellStyles" && rPair.first != "ShapeStyles" && - rPair.first != "ClearStyle") + rPair.first != "Commands") { CPPUNIT_FAIL("Unknown style family: " + rPair.first); } diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 4b76082..048215e 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1301,10 +1301,27 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) aValues.add_child(sStyleFam.toUtf8().getStr(), aChildren); } - boost::property_tree::ptree aChildClearFormat; - OUString sClearFormat = SVX_RESSTR( RID_SVXSTR_CLEARFORM ); - aChildClearFormat.put("", sClearFormat.toUtf8()); - aValues.add_child("ClearStyle", aChildClearFormat); + { + boost::property_tree::ptree aCommandList; + + { + boost::property_tree::ptree aChild; + + OUString sClearFormat = SVX_RESSTR( RID_SVXSTR_CLEARFORM ); + + boost::property_tree::ptree aName; + aName.put("", sClearFormat.toUtf8()); + aChild.push_back(std::make_pair("text", aName)); + + boost::property_tree::ptree aCommand; + aCommand.put("", ".uno:ResetAttributes"); + aChild.push_back(std::make_pair("id", aCommand)); + + aCommandList.push_back(std::make_pair("", aChild)); + } + + aValues.add_child("Commands", aCommandList); + } aTree.add_child("commandValues", aValues); std::stringstream aStream; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits