GSoC Writer Table Styles; Table Styles Panel

Table styles panel:
+ Added simple table style panel tab icon.
    icon-themes/galaxy/sw/imglst/sf06.png
+ Listing table styles (hierarchical, same order as in container)
+ Listing all table styles (sorted by name).
+ Listing applied table styles.
+ Listing custom styles.
+ Listing hidden styles.
+ Hide/show style.
+ Applying style by double clicking.
+ Highlight current table style.
Everything else yet to be done.

Table styles (SwTableAutoFormat):
+ "hidden" property.
+ "userDefined" property. "Default style" is not user defined. Styles loaded
from tblauto.fmt are also not user defined. Styles loaded from .odt are user
defined. Styles created manually (before binary load/save roundtrip) are user
defined.

Change-Id: I739a48ae1d7ae66f4f8c08076871437ca491bd4e
Reviewed-on: https://gerrit.libreoffice.org/27638
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
This commit is contained in:
Jakub Trzebiatowski 2016-07-28 15:33:17 +02:00 committed by Miklos Vajna
parent d1ffaf5315
commit e7ea91f283
19 changed files with 169 additions and 7 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 B

View File

@ -313,6 +313,7 @@
#define SID_STYLE_FAMILY3 (SID_STYLE_FAMILY_START + 2)
#define SID_STYLE_FAMILY4 (SID_STYLE_FAMILY_START + 3)
#define SID_STYLE_FAMILY5 (SID_STYLE_FAMILY_START + 4)
#define SID_STYLE_FAMILY6 (SID_STYLE_FAMILY_START + 5)
#define SID_STYLE_NEW (SID_SFX_START + 549)
#define SID_STYLE_EDIT (SID_SFX_START + 550)

View File

@ -1151,6 +1151,7 @@ RscTop * RscTypCont::InitClassSfxStyleFamilyItem( RscTop * pSuper,
SETCONST( pSfxStyleFamily, "SfxStyleFamily::Frame",SfxStyleFamily::Frame);
SETCONST( pSfxStyleFamily, "SfxStyleFamily::Page", SfxStyleFamily::Page );
SETCONST( pSfxStyleFamily, "SfxStyleFamily::Pseudo", SfxStyleFamily::Pseudo );
SETCONST( pSfxStyleFamily, "SfxStyleFamily::Table", SfxStyleFamily::Table );
aBaseLst.push_back( pSfxStyleFamily );
nId = aNmTb.Put( "StyleFamily", VARNAME );

View File

@ -4459,6 +4459,23 @@ SfxTemplateItem ListStyle SID_STYLE_FAMILY5
GroupId = GID_DOCUMENT;
]
SfxTemplateItem TableStyle SID_STYLE_FAMILY6
[
AutoUpdate = FALSE,
FastCall = FALSE,
ReadOnlyDoc = TRUE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
RecordPerSet;
AccelConfig = FALSE,
MenuConfig = FALSE,
ToolBoxConfig = FALSE,
GroupId = GID_DOCUMENT;
]
SfxBoolItem TipsDialog SID_TIPWINDOW

View File

@ -754,6 +754,8 @@ void SfxCommonTemplateDialog_Impl::ReadResource()
nSlot = SID_STYLE_FAMILY4; break;
case SfxStyleFamily::Pseudo:
nSlot = SID_STYLE_FAMILY5; break;
case SfxStyleFamily::Table:
nSlot = SID_STYLE_FAMILY6; break;
default: OSL_FAIL("unknown StyleFamily"); break;
}
pBoundItems[i] =
@ -896,6 +898,7 @@ namespace SfxTemplate
case SfxStyleFamily::Frame: return 3;
case SfxStyleFamily::Page: return 4;
case SfxStyleFamily::Pseudo: return 5;
case SfxStyleFamily::Table: return 6;
default: return 0;
}
}
@ -909,6 +912,7 @@ namespace SfxTemplate
case 3: return SfxStyleFamily::Frame;
case 4: return SfxStyleFamily::Page;
case 5: return SfxStyleFamily::Pseudo;
case 6: return SfxStyleFamily::Table;
default: return SfxStyleFamily::All;
}
}
@ -2291,6 +2295,7 @@ void SfxTemplateDialog_Impl::InsertFamilyItem(sal_uInt16 nId,const SfxStyleFamil
case SfxStyleFamily::Frame: sHelpId = ".uno:FrameStyle"; break;
case SfxStyleFamily::Page: sHelpId = ".uno:PageStyle"; break;
case SfxStyleFamily::Pseudo: sHelpId = ".uno:ListStyle"; break;
case SfxStyleFamily::Table: sHelpId = ".uno:TableStyle"; break;
default: OSL_FAIL("unknown StyleFamily"); break;
}
m_aActionTbL->InsertItem( nId, pItem->GetImage(), pItem->GetText(), ToolBoxItemBits::NONE, 0);

View File

@ -63,6 +63,7 @@ void SfxTemplateControllerItem::StateChanged( sal_uInt16 nSID, SfxItemState eSta
case SID_STYLE_FAMILY3:
case SID_STYLE_FAMILY4:
case SID_STYLE_FAMILY5:
case SID_STYLE_FAMILY6:
{
bool bAvailable = SfxItemState::DEFAULT == eState;
if ( !bAvailable )
@ -87,6 +88,8 @@ void SfxTemplateControllerItem::StateChanged( sal_uInt16 nSID, SfxItemState eSta
nFamily = 4; break;
case SID_STYLE_FAMILY5:
nFamily = 5; break;
case SID_STYLE_FAMILY6:
nFamily = 6; break;
default: OSL_FAIL("unknown StyleFamily"); break;
}

View File

@ -162,8 +162,8 @@ private:
DeletionWatcher* impl_setDeletionWatcher(DeletionWatcher* pNewWatcher);
protected:
#define MAX_FAMILIES 5
#define COUNT_BOUND_FUNC 13
#define MAX_FAMILIES 6
#define COUNT_BOUND_FUNC 14
friend class DropListBox_Impl;
friend class SfxTemplateControllerItem;

View File

@ -890,6 +890,8 @@ public:
// Query if style (paragraph- / character- / frame- / page-) is used.
bool IsUsed( const SwModify& ) const;
/// Query if table style is used.
bool IsUsed( const SwTableAutoFormat& ) const;
static bool IsUsed( const SwNumRule& );
// Set name of newly loaded document template.

View File

@ -725,6 +725,7 @@ public:
bool IsAdjustCellWidthAllowed( bool bBalance = false ) const;
/// Set table style of the current table.
bool SetTableStyle(const OUString& rStyleName);
bool SetTableStyle(const SwTableAutoFormat& rNew);
/// Update the direct formatting according to the current table style.

View File

@ -266,6 +266,8 @@ class SW_DLLPUBLIC SwTableAutoFormat
bool m_bCollapsingBorders;
SvxShadowItem m_aShadow;
bool m_bHidden;
bool m_bUserDefined;
public:
SwTableAutoFormat( const OUString& rName );
SwTableAutoFormat( const SwTableAutoFormat& rNew );
@ -296,6 +298,11 @@ public:
bool IsBackground() const { return bInclBackground; }
bool IsValueFormat() const { return bInclValueFormat; }
/// Check if style is hidden.
bool IsHidden() const { return m_bHidden; }
/// Check if style is defined by user.
bool IsUserDefined() const { return m_bUserDefined; }
void SetFont( const bool bNew ) { bInclFont = bNew; }
void SetJustify( const bool bNew ) { bInclJustify = bNew; }
void SetFrame( const bool bNew ) { bInclFrame = bNew; }
@ -303,6 +310,11 @@ public:
void SetValueFormat( const bool bNew ) { bInclValueFormat = bNew; }
void SetWidthHeight( const bool bNew ) { bInclWidthHeight = bNew; }
/// Set if style is hidden.
void SetHidden(bool bHidden) { m_bHidden = bHidden; }
/// Set if style is user defined.
void SetUserDefined(bool bUserDefined) { m_bUserDefined = bUserDefined; }
/// These methods returns what style (row or column) is applied first on given Cell
bool FirstRowEndColumnIsRow();
bool FirstRowStartColumnIsRow();

View File

@ -361,6 +361,11 @@ interface BaseTextSelection
StateMethod = StateStyle ;
]
SID_STYLE_FAMILY6 // status(fina|play)
[
StateMethod = StateStyle ;
]
SID_CLASSIFICATION_APPLY
[
ExecMethod = Execute ;

View File

@ -109,6 +109,12 @@ interface BaseTextDocument
StateMethod = StateStyleSheet ;
]
SID_STYLE_FAMILY6
[
Export = FALSE ;
StateMethod = StateStyleSheet ;
]
SID_ATTR_YEAR2000
[
ExecMethod = Execute ;

View File

@ -303,6 +303,11 @@ interface Annotation : _Annotation
StateMethod = StateDisableItems ;
]
SID_STYLE_FAMILY6
[
StateMethod = StateDisableItems ;
]
SID_STYLE_WATERCAN // status()
[
StateMethod = StateDisableItems ;

View File

@ -65,6 +65,8 @@
#include <poolfmt.hrc>
#include <GetMetricVal.hxx>
#include <numrule.hxx>
#include <swtable.hxx>
#include <tblafmt.hxx>
#include <svx/xdef.hxx>
//UUUU
@ -133,6 +135,20 @@ bool SwDoc::IsUsed( const SwModify& rModify ) const
return !rModify.GetInfo( aGetHt );
}
// See if Table style is in use
bool SwDoc::IsUsed( const SwTableAutoFormat& rTableAutoFormat) const
{
size_t nTableCount = GetTableFrameFormatCount(true);
for (size_t i=0; i < nTableCount; ++i)
{
SwFrameFormat* pFrameFormat = &GetTableFrameFormat(i, true);
SwTable* pTable = SwTable::FindTable(pFrameFormat);
if (pTable->GetTableStyleName() == rTableAutoFormat.GetName())
return true;
}
return false;
}
// See if the NumRule is used
bool SwDoc::IsUsed( const SwNumRule& rRule )
{

View File

@ -600,6 +600,8 @@ SwTableAutoFormat::SwTableAutoFormat( const OUString& rName )
, m_bRowSplit( true )
, m_bCollapsingBorders(true)
, m_aShadow( RES_SHADOW )
, m_bHidden( false )
, m_bUserDefined( true )
{
bInclFont = true;
bInclJustify = true;
@ -655,6 +657,8 @@ SwTableAutoFormat& SwTableAutoFormat::operator=( const SwTableAutoFormat& rNew )
m_bRowSplit = rNew.m_bRowSplit;
m_bCollapsingBorders = rNew.m_bCollapsingBorders;
m_aShadow = rNew.m_aShadow;
m_bHidden = rNew.m_bHidden;
m_bUserDefined = rNew.m_bUserDefined;
return *this;
}
@ -1018,6 +1022,7 @@ bool SwTableAutoFormat::Load( SvStream& rStream, const SwAfVersions& rVersions )
}
}
}
m_bUserDefined = false;
return bRet;
}
@ -1259,6 +1264,7 @@ SwTableAutoFormatTable::SwTableAutoFormatTable()
const_cast<SwBoxAutoFormat&>(pNew->GetBoxFormat( i )).SetBox( aBox );
}
pNew->SetUserDefined(false);
m_pImpl->m_AutoFormats.push_back(std::move(pNew));
}

View File

@ -1175,6 +1175,21 @@ bool SwFEShell::IsAdjustCellWidthAllowed( bool bBalance ) const
return false;
}
bool SwFEShell::SetTableStyle(const OUString& rStyleName)
{
// make sure SwDoc has the style
SwTableAutoFormat *pTableFormat = GetDoc()->GetTableStyles().FindAutoFormat(rStyleName);
if (!pTableFormat)
return false;
SwTableNode *pTableNode = const_cast<SwTableNode*>(IsCursorInTable());
if (!pTableNode)
return false;
// set the name & update
return UpdateTableStyleFormatting(pTableNode, false, &rStyleName);
}
// AutoFormat for the table/table selection
bool SwFEShell::SetTableStyle(const SwTableAutoFormat& rStyle)
{

View File

@ -74,9 +74,9 @@ ImageList RID_DEFAULTIMAGELIST_LC
MaskColor = IMAGE_MASK_COLOR ; \
IdList = \
{ \
1; 2; 3; 4; 5; \
1; 2; 3; 4; 5; 6;\
}; \
IdCount = 5;
IdCount = 6;
SfxStyleFamilies DLG_STYLE_DESIGNER
{
@ -150,6 +150,18 @@ SfxStyleFamilies DLG_STYLE_DESIGNER
};
Text [ en-US ] = "List Styles" ;
};
SfxStyleFamilyItem
{
Text [ en-US ] = "Table Styles" ;
StyleFamily = SfxStyleFamily::Table ;
FilterList [ en-US ] =
{
< "All" ; SFXSTYLEBIT_ALL_VISIBLE ; > ;
< "Hidden Styles" ; SFXSTYLEBIT_HIDDEN ; > ;
< "Applied Styles" ; SFXSTYLEBIT_USED ; > ;
< "Custom Styles" ; SFXSTYLEBIT_USERDEF ; > ;
};
};
};
ImageList 1 // == BMP_COLOR_NORMAL + 1

View File

@ -227,6 +227,15 @@ void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh)
rSet.Put(SfxTemplateItem(nWhich, aName));
}
break;
case SID_STYLE_FAMILY6:
{
const SwTableNode *pTableNd = pShell->IsCursorInTable();
if( pTableNd )
aName = pTableNd->GetTable().GetTableStyleName();
rSet.Put(SfxTemplateItem(nWhich, aName));
}
break;
case SID_STYLE_WATERCAN:
{
@ -410,6 +419,9 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq )
else
if(aFamily == "NumberingStyles")
nFamily = SfxStyleFamily::Pseudo;
else
if(aFamily == "TableStyles")
nFamily = SfxStyleFamily::Table;
}
if( SfxItemState::SET == pArgs->GetItemState(SID_STYLE_MASK,
@ -960,6 +972,11 @@ SfxStyleFamily SwDocShell::ApplyStyles(const OUString &rName, SfxStyleFamily nFa
pSh->SetCurNumRule( *pNumRule, false, sListIdForStyle, true );
break;
}
case SfxStyleFamily::Table:
{
pSh->SetTableStyle(pStyle->GetName());
break;
}
default:
OSL_FAIL("Unknown family");
}

View File

@ -649,6 +649,17 @@ void SwDocStyleSheet::SetHidden( bool bValue )
}
break;
case SfxStyleFamily::Table:
{
SwTableAutoFormat* pTableAutoFormat = rDoc.GetTableStyles().FindAutoFormat( aName );
if ( pTableAutoFormat )
{
pTableAutoFormat->SetHidden( bValue );
bChg = true;
}
}
break;
default:
break;
}
@ -698,6 +709,12 @@ bool SwDocStyleSheet::IsHidden( ) const
bRet = pRule && pRule->IsHidden( );
}
break;
case SfxStyleFamily::Table:
{
SwTableAutoFormat* pTableAutoFormat = rDoc.GetTableStyles().FindAutoFormat( aName );
bRet = pTableAutoFormat && pTableAutoFormat->IsHidden( );
}
break;
default:
break;
}
@ -1263,9 +1280,9 @@ std::unique_ptr<SfxItemSet> lcl_SwFormatToFlatItemSet(SwFormat *const pFormat)
std::unique_ptr<SfxItemSet> SwDocStyleSheet::GetItemSetForPreview()
{
if (SfxStyleFamily::Page == nFamily || SfxStyleFamily::Pseudo == nFamily)
if (SfxStyleFamily::Page == nFamily || SfxStyleFamily::Pseudo == nFamily || SfxStyleFamily::Table == nFamily)
{
SAL_WARN("sw.ui", "GetItemSetForPreview not implemented for page or number style");
SAL_WARN("sw.ui", "GetItemSetForPreview not implemented for page or number or table style");
return std::unique_ptr<SfxItemSet>();
}
if (!bPhysical)
@ -1988,6 +2005,7 @@ bool SwDocStyleSheet::FillStyleSheet(
case SfxStyleFamily::Table:
pTableFormat = lcl_FindTableStyle(rDoc, aName, this);
SetMask((pTableFormat && pTableFormat->IsUserDefined()) ? SFXSTYLEBIT_USERDEF : 0);
bRet = bPhysical = (nullptr != pTableFormat);
break;
@ -2164,6 +2182,7 @@ void SwDocStyleSheet::PresetNameAndFamily(const OUString& rName)
case cFRAME: nFamily = SfxStyleFamily::Frame; break;
case cPAGE: nFamily = SfxStyleFamily::Page; break;
case cNUMRULE: nFamily = SfxStyleFamily::Pseudo; break;
case cTABSTYLE: nFamily = SfxStyleFamily::Table; break;
default: nFamily = SfxStyleFamily::Char; break;
}
aName = rName.copy(1);
@ -2212,6 +2231,9 @@ bool SwDocStyleSheet::IsUsed() const
case SfxStyleFamily::Pseudo:
return pNumRule && SwDoc::IsUsed( *pNumRule );
case SfxStyleFamily::Table:
return pTableFormat && rDoc.IsUsed( *pTableFormat );
default:
OSL_ENSURE(false, "unknown style family");
return false;
@ -2980,7 +3002,23 @@ SfxStyleSheetBase* SwStyleSheetIterator::First()
const SwTableAutoFormatTable& rTableStyles = rDoc.GetTableStyles();
for(size_t i = 0; i < rTableStyles.size(); ++i)
{
aLst.Append( cTABSTYLE, rTableStyles[i].GetName() );
const SwTableAutoFormat& rTableStyle = rTableStyles[i];
bool bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(rTableStyle));
if(!bUsed)
{
if(nSrchMask == SFXSTYLEBIT_HIDDEN && !rTableStyle.IsHidden())
continue;
if( (!bSearchHidden && rTableStyle.IsHidden() ) ||
( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
? !rTableStyle.IsUserDefined()
// searched for used and found none
: bIsSearchUsed ) )
continue;
}
aLst.Append( cTABSTYLE, rTableStyle.GetName() );
}
}