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
This commit is contained in:
Miklos Vajna
2016-09-27 09:11:25 +02:00
parent bae1e2aa63
commit d378cd2f76
9 changed files with 91 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 672 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

View File

@@ -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>

View File

@@ -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 */

View File

@@ -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");

View File

@@ -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;

View File

@@ -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
()
[

View File

@@ -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)
{

View File

@@ -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"/>