diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-09-27 09:11:25 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-09-27 11:00:42 +0200 |
commit | d378cd2f766eeb1fd1c98f62c9ae6b5b59fd00f1 (patch) | |
tree | f5a131942180636d8c6b801cdf6d238140c9dd89 | |
parent | bae1e2aa636f144fe01cb8d9721e54525fed8b2c (diff) |
tdf#87914 sw: add an initial .uno:SmallCaps command
- handle it in SwTextShell (for normal Writer text)
- simple icon in the galaxy theme
Change-Id: Ib8f11dbca28b19a2fc0411c92d9f0b4b052277bb
-rw-r--r-- | icon-themes/galaxy/cmd/lc_smallcaps.png | bin | 0 -> 672 bytes | |||
-rw-r--r-- | icon-themes/galaxy/cmd/sc_smallcaps.png | bin | 0 -> 551 bytes | |||
-rw-r--r-- | officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu | 8 | ||||
-rw-r--r-- | sw/inc/cmdid.h | 1 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 20 | ||||
-rw-r--r-- | sw/sdi/_textsh.sdi | 6 | ||||
-rw-r--r-- | sw/sdi/swriter.sdi | 18 | ||||
-rw-r--r-- | sw/source/uibase/shells/txtattr.cxx | 37 | ||||
-rw-r--r-- | sw/uiconfig/swriter/toolbar/textobjectbar.xml | 1 |
9 files changed, 91 insertions, 0 deletions
diff --git a/icon-themes/galaxy/cmd/lc_smallcaps.png b/icon-themes/galaxy/cmd/lc_smallcaps.png Binary files differnew file mode 100644 index 000000000000..7ef20cedf7a1 --- /dev/null +++ b/icon-themes/galaxy/cmd/lc_smallcaps.png diff --git a/icon-themes/galaxy/cmd/sc_smallcaps.png b/icon-themes/galaxy/cmd/sc_smallcaps.png Binary files differnew file mode 100644 index 000000000000..eaf41017cde8 --- /dev/null +++ b/icon-themes/galaxy/cmd/sc_smallcaps.png diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index eecbb0aea356..6ec914148730 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -3871,6 +3871,14 @@ <value>9</value> </prop> </node> + <node oor:name=".uno:SmallCaps" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Small capitals</value> + </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>9</value> + </prop> + </node> <node oor:name=".uno:DistributeSelection" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">~Distribution...</value> diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 7223028fc858..284bcfb95dcb 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -311,6 +311,7 @@ #define FN_AUTOFORMAT_REDLINE_APPLY (FN_FORMAT + 6 ) /* apply autoformat with Redlining */ #define FN_SET_SUPER_SCRIPT (FN_FORMAT + 11) /* superscript */ #define FN_SET_SUB_SCRIPT (FN_FORMAT + 12) /* subscript */ +#define FN_SET_SMALL_CAPS (FN_FORMAT + 13) /* small caps */ #define FN_FORMAT_PAGE_SETTING_DLG (FN_FORMAT + 42) /* */ #define FN_NUM_FORMAT_TABLE_DLG (FN_FORMAT + 45) /* number format in table */ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index d6deb9d231b9..6792919e0591 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -11,6 +11,7 @@ #include <com/sun/star/drawing/GraphicExportFilter.hpp> #include <com/sun/star/i18n/TextConversionOption.hpp> #include <com/sun/star/frame/DispatchHelper.hpp> +#include <com/sun/star/style/CaseMap.hpp> #include <tools/errcode.hxx> #include <swmodeltestbase.hxx> #include <ndtxt.hxx> @@ -199,6 +200,7 @@ public: void testTdf88453(); void testTdf88453Table(); void testClassificationPaste(); + void testSmallCaps(); void testTdf98987(); void testTdf99004(); void testTdf84695(); @@ -307,6 +309,7 @@ public: CPPUNIT_TEST(testTdf88453); CPPUNIT_TEST(testTdf88453Table); CPPUNIT_TEST(testClassificationPaste); + CPPUNIT_TEST(testSmallCaps); CPPUNIT_TEST(testTdf98987); CPPUNIT_TEST(testTdf99004); CPPUNIT_TEST(testTdf84695); @@ -3710,6 +3713,23 @@ void SwUiWriterTest::testClassificationPaste() xSourceComponent->dispose(); } +void SwUiWriterTest::testSmallCaps() +{ + // Create a document, add some characters and select them. + createDoc(); + SwDoc* pDoc = createDoc(); + SwDocShell* pDocShell = pDoc->GetDocShell(); + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + pWrtShell->Insert("text"); + pWrtShell->SelAll(); + + // Dispatch the command to make them formatted small capitals. + lcl_dispatchCommand(mxComponent, ".uno:SmallCaps", {}); + + // This was css::style::CaseMap::NONE as the shell didn't handle the command. + CPPUNIT_ASSERT_EQUAL(css::style::CaseMap::SMALLCAPS, getProperty<sal_Int16>(getRun(getParagraph(1), 1), "CharCaseMap")); +} + void SwUiWriterTest::testTdf98987() { createDoc("tdf98987.docx"); diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi index a6991e8ab8d1..88a1f9cf2eba 100644 --- a/sw/sdi/_textsh.sdi +++ b/sw/sdi/_textsh.sdi @@ -1442,6 +1442,12 @@ interface BaseText StateMethod = GetAttrState ; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] + FN_SET_SMALL_CAPS + [ + ExecMethod = ExecCharAttr ; + StateMethod = GetAttrState ; + DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; + ] SID_ATTR_CHAR_CASEMAP // status(final|play) [ ExecMethod = ExecTextCtrl; diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index c5c65688c47a..93c18fae6b15 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -5737,6 +5737,24 @@ SfxBoolItem SuperScript FN_SET_SUPER_SCRIPT GroupId = GID_FORMAT; ] +SfxBoolItem SmallCaps FN_SET_SMALL_CAPS + +[ + AutoUpdate = TRUE, + FastCall = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + + AccelConfig = TRUE, + MenuConfig = TRUE, + ToolBoxConfig = TRUE, + GroupId = GID_FORMAT; +] + SfxVoidItem SwBrwInsert FN_SBA_BRW_INSERT () [ diff --git a/sw/source/uibase/shells/txtattr.cxx b/sw/source/uibase/shells/txtattr.cxx index 64d6370f4751..17b3df9a6fca 100644 --- a/sw/source/uibase/shells/txtattr.cxx +++ b/sw/source/uibase/shells/txtattr.cxx @@ -37,6 +37,7 @@ #include <sfx2/htmlmode.hxx> #include <editeng/scripttypeitem.hxx> #include <editeng/frmdiritem.hxx> +#include <editeng/cmapitem.hxx> #include "paratr.hxx" #include <fmtinfmt.hxx> @@ -130,6 +131,32 @@ void SwTextShell::ExecCharAttr(SfxRequest &rReq) } break; + case FN_SET_SMALL_CAPS: + { + SvxCaseMap eCaseMap = SVX_CASEMAP_KAPITAELCHEN; + switch (eState) + { + case STATE_TOGGLE: + { + SvxCaseMap eTmpCaseMap = static_cast<const SvxCaseMapItem&>(aSet.Get(RES_CHRATR_CASEMAP)).GetCaseMap(); + if (eTmpCaseMap == SVX_CASEMAP_KAPITAELCHEN) + eCaseMap = SVX_CASEMAP_NOT_MAPPED; + } + break; + case STATE_ON: + // Nothing to do, already set. + break; + case STATE_OFF: + eCaseMap = SVX_CASEMAP_NOT_MAPPED; + break; + } + SvxCaseMapItem aCaseMap(eCaseMap, RES_CHRATR_CASEMAP); + rSh.SetAttrItem(aCaseMap); + rReq.AppendItem(aCaseMap); + rReq.Done(); + } + break; + case FN_UPDATE_STYLE_BY_EXAMPLE: rSh.QuickUpdateStyle(); rReq.Done(); @@ -550,6 +577,13 @@ void SwTextShell::GetAttrState(SfxItemSet &rSet) nLineSpace = static_cast<const SvxLineSpacingItem* >(pItem)->GetPropLineSpace(); } + SvxCaseMap eCaseMap = SVX_CASEMAP_NOT_MAPPED; + eState = aCoreSet.GetItemState(RES_CHRATR_CASEMAP, false, &pItem); + if (eState == SfxItemState::DEFAULT) + pItem = &rPool.GetDefaultItem(RES_CHRATR_CASEMAP); + if (eState >= SfxItemState::DEFAULT) + eCaseMap = static_cast<const SvxCaseMapItem*>(pItem)->GetCaseMap(); + while (nSlot) { switch(nSlot) @@ -560,6 +594,9 @@ void SwTextShell::GetAttrState(SfxItemSet &rSet) case FN_SET_SUB_SCRIPT: bFlag = 0 > nEsc; break; + case FN_SET_SMALL_CAPS: + bFlag = eCaseMap == SVX_CASEMAP_KAPITAELCHEN; + break; case SID_ATTR_PARA_ADJUST_LEFT: if (eAdjust == -1) { diff --git a/sw/uiconfig/swriter/toolbar/textobjectbar.xml b/sw/uiconfig/swriter/toolbar/textobjectbar.xml index 8a8a58bf2dcb..43e80fd433f5 100644 --- a/sw/uiconfig/swriter/toolbar/textobjectbar.xml +++ b/sw/uiconfig/swriter/toolbar/textobjectbar.xml @@ -46,6 +46,7 @@ <toolbar:toolbarseparator/> <toolbar:toolbaritem xlink:href=".uno:ChangeCaseToLower" toolbar:visible="false"/> <toolbar:toolbaritem xlink:href=".uno:ChangeCaseToUpper" toolbar:visible="false"/> + <toolbar:toolbaritem xlink:href=".uno:SmallCaps" toolbar:visible="false"/> <toolbar:toolbarseparator/> <toolbar:toolbaritem xlink:href=".uno:FontColor"/> <toolbar:toolbaritem xlink:href=".uno:BackColor"/> |